Subversion Repositories Scribus

Rev

Rev 16844 | Rev 17020 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
15600 jghali 1
/*
2
For general Scribus (>=1.3.2) copyright and licensing information please refer
3
to the COPYING file provided with the program. Following this notice may exist
4
a copyright and/or license notice that predates the release of Scribus 1.3.2
5
for which a new license (GPL+exception) is in place.
6
*/
7
 
8
#include "propertiespalette_group.h"
9
 
10
#include <QButtonGroup>
11
#include <QCheckBox>
12
#include <QCloseEvent>
13
#include <QComboBox>
14
#include <QEvent>
15
#include <QFocusEvent>
16
#include <QFrame>
17
#include <QGridLayout>
18
#include <QGroupBox>
19
#include <QHBoxLayout>
20
#include <QImage>
21
#include <QKeyEvent>
22
#include <QLabel>
23
#include <QListView>
24
#include <QTransform>
25
#include <QMenu>
26
#include <QMessageBox>
27
#include <QObject>
28
#include <QPixmap>
29
#include <QPoint>
30
#include <QPushButton>
31
#include <QRadioButton>
32
#include <QRegExp>
33
#include <QSpacerItem>
34
#include <QSpinBox>
35
#include <QStackedWidget>
36
#include <QTimer>
37
#include <QToolBox>
38
#include <QToolTip>
39
#include <QVBoxLayout>
40
#include <QValidator>
41
#include <QWidget>
42
 
43
#if defined(_MSC_VER)
44
#define _USE_MATH_DEFINES
45
#endif
46
#include <cmath>
47
#include "commonstrings.h"
48
#include "sccombobox.h"
49
#include "scribus.h"
50
#include "scribuscore.h"
51
#include "scraction.h"
52
#include "scribusview.h"
53
#include "selection.h"
54
#include "units.h"
55
#include "undomanager.h"
56
#include "util.h"
57
#include "util_icon.h"
58
#include "util_math.h"
59
 
60
#include "text/nlsconfig.h"
61
#include "ui/autoform.h"
15661 jghali 62
#include "ui/nodeeditpalette.h"
15600 jghali 63
#include "ui/propertiespalette_utils.h"
64
#include "ui/transparencypalette.h"
65
 
66
PropertiesPalette_Group::PropertiesPalette_Group( QWidget* parent) : QWidget(parent)
67
{
68
        m_ScMW = 0;
69
        m_doc  = 0;
70
        m_haveDoc   = false;
71
        m_haveItem  = false;
72
        m_unitRatio = 1.0;
73
 
74
        m_tmpSelection = new Selection(this, false);
75
        m_tmpSelection->clear();
76
 
16077 jghali 77
        setupUi(this);
15600 jghali 78
 
16077 jghali 79
        textFlowDisabled->setIcon(QIcon(loadIcon("flow-none.png")));
80
        textFlowUsesFrameShape->setIcon(QIcon(loadIcon("flow-frame.png")));
81
        textFlowUsesBoundingBox->setIcon(QIcon(loadIcon("flow-bounding.png")));
82
        textFlowUsesContourLine->setIcon(QIcon(loadIcon("flow-contour.png")));
83
        textFlowUsesImageClipping->setIcon(QIcon(loadIcon("flow-contour.png")));
15600 jghali 84
 
16077 jghali 85
        textFlowDisabled->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));
86
        textFlowUsesFrameShape->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));
87
        textFlowUsesBoundingBox->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));
88
        textFlowUsesContourLine->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));
89
        textFlowUsesImageClipping->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));
15600 jghali 90
 
16077 jghali 91
        transPalWidget->hideSelectionButtons();
15600 jghali 92
 
93
        languageChange();
94
 
16077 jghali 95
        connect(textFlowBtnGroup, SIGNAL(buttonClicked(int)), this, SLOT(handleTextFlow()));
15600 jghali 96
 
16077 jghali 97
        connect(customShape  , SIGNAL(FormSel(int, int, qreal *)), this, SLOT(handleNewShape(int, int, qreal *)));
16805 jghali 98
        connect(editShape    , SIGNAL(clicked())                 , this, SLOT(handleShapeEdit()));
99
        connect(evenOdd      , SIGNAL(clicked())                 , this, SLOT(handleFillRule()) );
100
        connect(nonZero      , SIGNAL(clicked())                 , this, SLOT(handleFillRule()) );
101
        connect(transPalWidget , SIGNAL(editGradient())          , this, SLOT(handleGradientEdit()));
16077 jghali 102
        connect(transPalWidget , SIGNAL(NewSpecial(double, double, double, double, double, double, double, double, double, double)), this, SLOT(handleSpecialGradient(double, double, double, double, double, double, double, double )));
15600 jghali 103
}
104
 
105
PageItem* PropertiesPalette_Group::currentItemFromSelection()
106
{
107
        PageItem *currentItem = NULL;
108
 
109
        if (m_doc)
110
        {
111
                if (m_doc->m_Selection->count() > 1)
112
                {
16173 jghali 113
                        currentItem = m_doc->m_Selection->itemAt(0);
15600 jghali 114
                }
115
                else if (m_doc->m_Selection->count() == 1)
116
                {
117
                        currentItem = m_doc->m_Selection->itemAt(0);
118
                }
119
        }
120
 
121
        return currentItem;
122
}
123
 
124
void PropertiesPalette_Group::setMainWindow(ScribusMainWindow *mw)
125
{
126
        m_ScMW = mw;
127
 
16957 jghali 128
        connect(this->transPalWidget, SIGNAL(gradientChanged()), this, SLOT(handleGradientChanged()));
16179 jghali 129
        connect(this                , SIGNAL(DocChanged())     , m_ScMW, SLOT(slotDocCh()));
130
        connect(m_ScMW, SIGNAL(UpdateRequest(int)), this, SLOT(handleUpdateRequest(int)));
15600 jghali 131
}
132
 
133
void PropertiesPalette_Group::setDoc(ScribusDoc *d)
134
{
135
        if((d == (ScribusDoc*) m_doc) || (m_ScMW && m_ScMW->scriptIsRunning()))
136
                return;
137
 
138
        if (m_doc)
139
        {
140
                disconnect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged()));
141
                disconnect(m_doc             , SIGNAL(docChanged())      , this, SLOT(handleSelectionChanged()));
142
        }
143
 
16077 jghali 144
        disconnect(this->transPalWidget, SIGNAL(NewTrans(double)), 0, 0);
145
        disconnect(this->transPalWidget, SIGNAL(NewBlend(int)), 0, 0);
146
        disconnect(this->transPalWidget, SIGNAL(NewGradient(int)), 0, 0);
147
        disconnect(this->transPalWidget, SIGNAL(NewPattern(QString)), 0, 0);
148
        disconnect(this->transPalWidget, SIGNAL(NewPatternProps(double, double, double, double, double, double, double, bool, bool)), 0, 0);
15600 jghali 149
 
150
        m_doc  = d;
151
        m_item = NULL;
152
        m_unitRatio   = m_doc->unitRatio();
153
        m_unitIndex   = m_doc->unitIndex();
154
 
16077 jghali 155
        transPalWidget->setDocument(m_doc);
156
        transPalWidget->setCurrentItem(NULL);
15600 jghali 157
 
158
        m_haveDoc  = true;
159
        m_haveItem = false;
160
 
16077 jghali 161
        connect(this->transPalWidget, SIGNAL(NewTrans(double))   , this, SLOT(handleGroupTransparency(double)));
162
        connect(this->transPalWidget, SIGNAL(NewBlend(int))      , this, SLOT(handleGroupBlending(int)));
163
        connect(this->transPalWidget, SIGNAL(NewGradient(int))   , this, SLOT(handleGroupGradMask(int)));
164
        connect(this->transPalWidget, SIGNAL(NewPattern(QString)), this, SLOT(handleGroupPatternMask(QString)));
165
        connect(this->transPalWidget, SIGNAL(NewPatternProps(double, double, double, double, double, double, double, bool, bool)), this, SLOT(handleGroupPatternMaskProps(double, double, double, double, double, double, double, bool, bool)));
15600 jghali 166
 
167
        connect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged()));
168
        connect(m_doc             , SIGNAL(docChanged())      , this, SLOT(handleSelectionChanged()));
169
}
170
 
171
void PropertiesPalette_Group::unsetDoc()
172
{
15741 jghali 173
        if (m_doc)
174
        {
175
                disconnect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged()));
176
                disconnect(m_doc             , SIGNAL(docChanged())      , this, SLOT(handleSelectionChanged()));
177
        }
178
 
15600 jghali 179
        m_haveDoc  = false;
180
        m_haveItem = false;
181
        m_doc   = NULL;
182
        m_item  = NULL;
183
 
16077 jghali 184
        transPalWidget->setDocument(NULL);
185
        transPalWidget->setCurrentItem(NULL);
15600 jghali 186
 
187
        setEnabled(false);
188
}
189
 
190
void PropertiesPalette_Group::unsetItem()
191
{
192
        m_haveItem = false;
193
        m_item     = NULL;
16077 jghali 194
        transPalWidget->setCurrentItem(NULL);
15600 jghali 195
        handleSelectionChanged();
196
}
197
 
198
void PropertiesPalette_Group::handleSelectionChanged()
199
{
200
        if (!m_haveDoc || !m_ScMW || m_ScMW->scriptIsRunning())
201
                return;
202
 
203
        PageItem* currItem = currentItemFromSelection();
204
        if (m_doc->m_Selection->count() > 1)
205
        {
206
                bool widgetEnabled = false;
207
                if (m_haveItem && m_item)
208
                {
16173 jghali 209
                        if ((m_item->isGroup()) && (!m_item->isSingleSel))
15600 jghali 210
                                widgetEnabled = true;
211
                }
212
                setEnabled(widgetEnabled);
213
        }
214
        else
215
        {
216
                int itemType = currItem ? (int) currItem->itemType() : -1;
217
                m_haveItem = (itemType != -1);
218
 
219
                switch (itemType)
220
                {
221
                case -1:
222
                        setEnabled(false);
223
                        break;
224
                case PageItem::ImageFrame:
225
                case PageItem::LatexFrame:
226
                case PageItem::OSGFrame:
227
                        if (currItem->asOSGFrame())
228
                        {
229
                                setEnabled(false);
230
                        }
231
                        break;
16222 jghali 232
                case PageItem::Arc:
15600 jghali 233
                case PageItem::TextFrame:
234
                case PageItem::Line:
235
                case PageItem::ItemType1:
236
                case PageItem::ItemType3:
237
                case PageItem::Polygon:
238
                case PageItem::PolyLine:
239
                case PageItem::PathText:
16222 jghali 240
                case PageItem::RegularPolygon:
241
                        setEnabled(false);
15600 jghali 242
                        break;
243
                case PageItem::Symbol:
244
                        setEnabled(true);
245
                        break;
246
                }
247
        }
248
        if (currItem)
249
        {
250
                setCurrentItem(currItem);
251
        }
252
        updateGeometry();
253
        repaint();
254
}
255
 
16179 jghali 256
void PropertiesPalette_Group::handleUpdateRequest(int updateFlags)
257
{
258
        if (updateFlags & reqColorsUpdate)
259
                updateColorList();
260
}
261
 
15600 jghali 262
void PropertiesPalette_Group::setCurrentItem(PageItem *item)
263
{
264
        if (!m_ScMW || m_ScMW->scriptIsRunning())
265
                return;
266
        //CB We shouldnt really need to process this if our item is the same one
267
        //maybe we do if the item has been changed by scripter.. but that should probably
268
        //set some status if so.
269
        //FIXME: This wont work until when a canvas deselect happens, m_item must be NULL.
270
        //if (m_item == i)
271
        //      return;
272
 
273
        if (!m_doc)
274
                setDoc(item->doc());
275
 
276
        m_haveItem = false;
277
        m_item = item;
278
 
279
        bool   mirrorX, mirrorY;
280
        double patternScaleX, patternScaleY, patternOffsetX, patternOffsetY, patternRotation, patternSkewX, patternSkewY;
281
        m_item->patternTransform(patternScaleX, patternScaleY, patternOffsetX, patternOffsetY, patternRotation, patternSkewX, patternSkewY);
282
        m_item->patternFlip(mirrorX, mirrorY);
283
 
16077 jghali 284
        transPalWidget->setCurrentItem(m_item);
16781 jghali 285
        nonZero->setChecked(!m_item->fillRule);
286
        evenOdd->setChecked(m_item->fillRule);
15600 jghali 287
 
16173 jghali 288
        if ((m_item->isGroup()) && (!m_item->isSingleSel))
15600 jghali 289
        {
290
                setEnabled(true);
291
                if (m_item->FrameType == 0)
16077 jghali 292
                        customShape->setIcon(customShape->getIconPixmap(0));
15600 jghali 293
                if (m_item->FrameType == 1)
16077 jghali 294
                        customShape->setIcon(customShape->getIconPixmap(1));
15600 jghali 295
                if (m_item->FrameType > 3)
16077 jghali 296
                        customShape->setIcon(customShape->getIconPixmap(m_item->FrameType-2));
297
                transPalWidget->updateFromItem();
298
                transPalWidget->setActPattern(m_item->patternMask(), patternScaleX, patternScaleY, patternOffsetX, patternOffsetY, patternRotation, patternSkewX, patternSkewY, mirrorX, mirrorY);
299
                customShape->setEnabled(true);
300
                editShape->setEnabled(true);
301
                shapeGroup->setEnabled(true);
302
                textFlowDisabled->setEnabled(true);
303
                textFlowUsesFrameShape->setEnabled(true);
304
                textFlowUsesBoundingBox->setEnabled(true);
305
                textFlowUsesContourLine->setEnabled(true);
306
                textFlowUsesImageClipping->setEnabled(false);
15600 jghali 307
        }
308
        else
309
        {
310
                setEnabled(false);
311
        }
312
 
313
        m_haveItem = true;
314
 
315
        if (m_item->asOSGFrame())
316
        {
317
                setEnabled(false);
318
        }
319
        if (m_item->asSymbolFrame())
320
        {
321
                setEnabled(true);
322
                if (m_item->FrameType == 0)
16077 jghali 323
                        customShape->setIcon(customShape->getIconPixmap(0));
15600 jghali 324
                if (m_item->FrameType == 1)
16077 jghali 325
                        customShape->setIcon(customShape->getIconPixmap(1));
15600 jghali 326
                if (m_item->FrameType > 3)
16077 jghali 327
                        customShape->setIcon(customShape->getIconPixmap(m_item->FrameType-2));
328
                transPalWidget->updateFromItem();
329
                transPalWidget->setActPattern(m_item->patternMask(), patternScaleX, patternScaleY, patternOffsetX, patternOffsetY, patternRotation, patternSkewX, patternSkewY, mirrorX, mirrorY);
330
                customShape->setEnabled(true);
331
                editShape->setEnabled(true);
332
                shapeGroup->setEnabled(true);
333
                textFlowDisabled->setEnabled(true);
334
                textFlowUsesFrameShape->setEnabled(true);
335
                textFlowUsesBoundingBox->setEnabled(true);
336
                textFlowUsesContourLine->setEnabled(true);
337
                textFlowUsesImageClipping->setEnabled(false);
15600 jghali 338
        }
339
}
340
 
341
void PropertiesPalette_Group::displayTextFlowMode(PageItem::TextFlowMode mode)
342
{
343
        if (!m_ScMW || m_ScMW->scriptIsRunning() || !m_haveItem)
344
                return;
16173 jghali 345
        if (m_item->isGroup())
15600 jghali 346
        {
347
                if (mode == PageItem::TextFlowDisabled)
16077 jghali 348
                        textFlowDisabled->setChecked(true);
15600 jghali 349
                else if (mode == PageItem::TextFlowUsesFrameShape)
16077 jghali 350
                        textFlowUsesFrameShape->setChecked(true);
15600 jghali 351
                else if (mode == PageItem::TextFlowUsesBoundingBox)
16077 jghali 352
                        textFlowUsesBoundingBox->setChecked(true);
15600 jghali 353
                else if (mode == PageItem::TextFlowUsesContourLine)
16077 jghali 354
                        textFlowUsesContourLine->setChecked(true);
15600 jghali 355
                else if (mode == PageItem::TextFlowUsesImageClipping)
16077 jghali 356
                        textFlowUsesImageClipping->setChecked(true);
15600 jghali 357
                if ((m_item->asImageFrame()) && (m_item->imageClip.size() != 0))
16077 jghali 358
                        textFlowUsesImageClipping->setEnabled(true);
15600 jghali 359
                else
16077 jghali 360
                        textFlowUsesImageClipping->setEnabled(false);
15600 jghali 361
        }
362
}
363
 
364
void PropertiesPalette_Group::updateColorList()
365
{
366
        if (!m_haveDoc || !m_ScMW || m_ScMW->scriptIsRunning())
367
                return;
16077 jghali 368
        transPalWidget->setColors(m_doc->PageColors);
369
        transPalWidget->setPatterns(&m_doc->docPatterns);
370
        transPalWidget->setGradients(&m_doc->docGradients);
15600 jghali 371
}
372
 
373
void PropertiesPalette_Group::updateColorSpecialGradient()
374
{
375
        if (!m_haveDoc)
376
                return;
377
        if(m_doc->m_Selection->isEmpty())
378
                return;
379
        double ratio = m_doc->unitRatio();
380
        PageItem *currItem = m_doc->m_Selection->itemAt(0);
381
        if (currItem)
382
        {
383
                switch (m_ScMW->view->editStrokeGradient)
384
                {
385
                case 0:
386
                case 1:
387
                case 3:
388
                case 4:
389
                case 5:
390
                case 6:
391
                case 7:
392
                        break;
393
                default:
16173 jghali 394
                        if (currItem->isGroup())
16077 jghali 395
                                transPalWidget->setSpecialGradient(currItem->GrMaskStartX * ratio, currItem->GrMaskStartY * ratio, currItem->GrMaskEndX * ratio, currItem->GrMaskEndY * ratio, currItem->GrMaskFocalX * ratio, currItem->GrMaskFocalY * ratio, currItem->GrMaskScale, currItem->GrMaskSkew);
15600 jghali 396
                }
397
        }
398
}
399
 
16957 jghali 400
void PropertiesPalette_Group::handleGradientChanged()
401
{
402
        if (m_haveDoc)
403
        {
404
                VGradient vg(transPalWidget->gradEdit->gradient());
405
                m_doc->itemSelection_SetMaskGradient(vg);
406
        }
407
}
408
 
15614 jghali 409
void PropertiesPalette_Group::handleGroupTransparency(double trans)
410
{
411
        if ((m_haveDoc) && (m_haveItem))
412
        {
413
                m_item->setFillTransparency(trans);
414
                m_item->update();
415
                emit DocChanged();
416
        }
417
}
418
 
419
void PropertiesPalette_Group::handleGroupBlending(int blend)
420
{
421
        if ((m_haveDoc) && (m_haveItem))
422
        {
423
                m_item->setFillBlendmode(blend);
424
                m_item->update();
425
                emit DocChanged();
426
        }
427
}
428
 
429
void PropertiesPalette_Group::handleGroupGradMask(int typ)
430
{
431
        if ((m_haveDoc) && (m_haveItem))
432
        {
433
                m_item->GrMask = typ;
434
                if ((typ > 0) && (typ < 7))
435
                        m_item->updateGradientVectors();
436
                m_item->update();
437
                emit DocChanged();
438
        }
439
}
440
 
441
void PropertiesPalette_Group::handleGroupPatternMask(QString pattern)
442
{
443
        if ((m_haveDoc) && (m_haveItem))
444
        {
445
                m_item->setPatternMask(pattern);
446
                m_item->update();
447
                emit DocChanged();
448
        }
449
}
450
 
451
void PropertiesPalette_Group::handleGroupPatternMaskProps(double imageScaleX, double imageScaleY, double offsetX, double offsetY, double rotation, double skewX, double skewY, bool mirrorX, bool mirrorY)
452
{
453
        if ((m_haveDoc) && (m_haveItem))
454
        {
455
                m_item->setMaskTransform(imageScaleX, imageScaleY, offsetX, offsetY, rotation, skewX, skewY);
456
                m_item->setMaskFlip(mirrorX, mirrorY);
457
                m_item->update();
458
                emit DocChanged();
459
        }
460
}
461
 
15600 jghali 462
void PropertiesPalette_Group::handleNewShape(int frameType, int count, qreal *points)
463
{
464
        if (!m_ScMW || m_ScMW->scriptIsRunning())
465
                return;
466
        if ((m_haveDoc) && (m_haveItem))
467
        {
468
                if ((m_item->itemType() == PageItem::PolyLine) || (m_item->itemType() == PageItem::PathText))
469
                        return;
470
 
471
                m_doc->item_setFrameShape(m_item, frameType, count, points);
472
 
473
                //ScribusDoc::changed() is called in item_setFrameShape()
474
                //Hope this is enough
475
                //emit DocChanged();
476
                emit shapeChanged(frameType);
477
        }
478
}
479
 
480
void PropertiesPalette_Group::handleTextFlow()
481
{
482
        if (!m_ScMW || m_ScMW->scriptIsRunning())
483
                return;
484
        if ((m_haveDoc) && (m_haveItem))
485
        {
486
                PageItem::TextFlowMode mode = PageItem::TextFlowDisabled;
16173 jghali 487
                if (m_item->isGroup())
15600 jghali 488
                {
16077 jghali 489
                        if (textFlowDisabled->isChecked())
15600 jghali 490
                                mode = PageItem::TextFlowDisabled;
16077 jghali 491
                        if (textFlowUsesFrameShape->isChecked())
15600 jghali 492
                                mode = PageItem::TextFlowUsesFrameShape;
16077 jghali 493
                        if (textFlowUsesBoundingBox->isChecked())
15600 jghali 494
                                mode = PageItem::TextFlowUsesBoundingBox;
16077 jghali 495
                        if (textFlowUsesContourLine->isChecked())
15600 jghali 496
                                mode = PageItem::TextFlowUsesContourLine;
16077 jghali 497
                        if (textFlowUsesImageClipping->isChecked())
15600 jghali 498
                                mode = PageItem::TextFlowUsesImageClipping;
499
                }
500
                m_item->setTextFlowMode(mode);
501
                m_ScMW->view->DrawNew();
502
                emit DocChanged();
503
        }
504
}
505
 
506
void PropertiesPalette_Group::handleGradientEdit()
507
{
508
        if (!m_ScMW || m_ScMW->scriptIsRunning())
509
                return;
510
        if ((m_haveDoc) && (m_haveItem))
511
        {
512
                m_ScMW->view->editStrokeGradient = 2;
16077 jghali 513
                if (transPalWidget->gradEditButton->isChecked())
15600 jghali 514
                        m_ScMW->view->requestMode(modeEditGradientVectors);
515
                else
516
                        m_ScMW->view->requestMode(modeNormal);
517
        }
518
}
519
 
520
void PropertiesPalette_Group::handleSpecialGradient(double x1, double y1, double x2, double y2, double fx, double fy, double sg, double sk)
521
{
522
        if (!m_ScMW || m_ScMW->scriptIsRunning())
523
                return;
524
        if ((m_haveDoc) && (m_haveItem))
525
        {
526
                QRectF upRect;
527
                m_item->GrMaskStartX = x1 / m_unitRatio;
528
                m_item->GrMaskStartY = y1 / m_unitRatio;
529
                m_item->GrMaskEndX = x2 / m_unitRatio;
530
                m_item->GrMaskEndY = y2 / m_unitRatio;
531
                m_item->GrMaskFocalX = fx / m_unitRatio;
532
                m_item->GrMaskFocalY = fy / m_unitRatio;
533
                m_item->GrMaskScale = sg;
534
                m_item->GrMaskSkew = sk;
535
                if ((m_item->GrMask == 1) || (m_item->GrMask == 4))
536
                {
537
                        m_item->GrMaskFocalX = m_item->GrMaskStartX;
538
                        m_item->GrMaskFocalY = m_item->GrMaskStartY;
539
                }
540
                m_item->update();
541
                upRect = QRectF(QPointF(m_item->GrMaskStartX, m_item->GrMaskStartY), QPointF(m_item->GrMaskEndX, m_item->GrMaskEndY));
542
                double radEnd = distance(m_item->GrMaskEndX - m_item->GrMaskStartX, m_item->GrMaskEndY - m_item->GrMaskStartY);
543
                double rotEnd = xy2Deg(m_item->GrMaskEndX - m_item->GrMaskStartX, m_item->GrMaskEndY - m_item->GrMaskStartY);
544
                QTransform m;
545
                m.translate(m_item->GrMaskStartX, m_item->GrMaskStartY);
546
                m.rotate(rotEnd);
547
                m.rotate(-90);
548
                m.rotate(m_item->GrMaskSkew);
549
                m.translate(radEnd * m_item->GrMaskScale, 0);
550
                QPointF shP = m.map(QPointF(0,0));
551
                upRect |= QRectF(shP, QPointF(m_item->GrMaskEndX, m_item->GrMaskEndY)).normalized();
552
                upRect |= QRectF(shP, QPointF(m_item->GrMaskStartX, m_item->GrMaskStartY)).normalized();
553
                upRect |= QRectF(shP, QPointF(0, 0)).normalized();
554
                upRect |= QRectF(shP, QPointF(m_item->width(), m_item->height())).normalized();
555
                upRect.translate(m_item->xPos(), m_item->yPos());
556
                m_doc->regionsChanged()->update(upRect.adjusted(-10.0, -10.0, 10.0, 10.0));
557
                emit DocChanged();
558
        }
559
}
560
 
16781 jghali 561
void PropertiesPalette_Group::handleFillRule()
562
{
563
        if (!m_haveDoc || !m_haveItem || !m_ScMW || m_ScMW->scriptIsRunning())
564
                return;
565
        m_item->fillRule = evenOdd->isChecked();
566
        m_item->update();
567
        emit DocChanged();
568
}
569
 
15661 jghali 570
void PropertiesPalette_Group::handleShapeEdit()
15600 jghali 571
{
572
        if (!m_ScMW || m_ScMW->scriptIsRunning())
573
                return;
574
        if ((m_haveDoc) && (m_haveItem))
575
        {
576
                m_tmpSelection->clear();
577
                m_tmpSelection->copy(*m_doc->m_Selection, true);
578
                m_doc->m_Selection->clear();
579
                m_doc->m_Selection->addItem(m_item);
580
                m_item->isSingleSel = true;
581
                m_item->update();
582
                m_ScMW->view->requestMode(modeEditClip);
15661 jghali 583
                connect(m_ScMW->nodePalette, SIGNAL(paletteClosed()), this, SLOT(handleShapeEditEnded()));
15600 jghali 584
                emit shapeEditStarted();
585
        }
586
}
587
 
15661 jghali 588
void PropertiesPalette_Group::handleShapeEditEnded()
589
{
590
        disconnect(m_ScMW->nodePalette, SIGNAL(paletteClosed()), this, SLOT(handleShapeEditEnded()));
591
        if ((m_haveDoc) && (m_haveItem))
592
        {
593
                if (m_tmpSelection->count() > 0)
594
                {
595
                        m_doc->m_Selection->copy(*m_tmpSelection, false);
596
                        m_doc->m_Selection->connectItemToGUI();
597
                }
598
                m_tmpSelection->clear();
599
        }
600
}
601
 
15600 jghali 602
void PropertiesPalette_Group::changeEvent(QEvent *e)
603
{
604
        if (e->type() == QEvent::LanguageChange)
605
        {
606
                languageChange();
607
                return;
608
        }
609
        QWidget::changeEvent(e);
610
}
611
 
612
 
613
void PropertiesPalette_Group::languageChange()
614
{
16077 jghali 615
        editShape->setText( tr("&Edit..."));
616
        shapeGroup->setTitle( tr("Shape"));
15600 jghali 617
 
16077 jghali 618
        textFlowGroup->setTitle( tr("Text &Flow Around Frame"));
619
        textFlowDisabled->setText( tr("Disabled"));
620
        textFlowUsesFrameShape->setText( tr("Use Frame &Shape"));
621
        textFlowUsesBoundingBox->setText( tr("Use &Bounding Box"));
622
        textFlowUsesContourLine->setText( tr("&Use Contour Line"));
623
        textFlowUsesImageClipping->setText( tr("Use Image Clip Path"));
15600 jghali 624
 
16077 jghali 625
        textFlowDisabled->setToolTip( tr("Disable text flow from lower frames around object"));
626
        textFlowUsesFrameShape->setToolTip( tr("Use the frame shape for text flow of text frames below the object."));
627
        textFlowUsesBoundingBox->setToolTip(  "<qt>" + tr("Use the bounding box, which is always rectangular, instead of the frame's shape for text flow of text frames below the object. ") + "</qt>" );
628
        textFlowUsesContourLine->setToolTip(  "<qt>" + tr("When chosen, the contour line can be edited with the Edit Shape Tool on the palette further above. When edited via the shape palette, this becomes a second separate line originally based on the frame's shape for text flow of text frames below the object.") + "</qt>" );
629
        textFlowUsesImageClipping->setToolTip(  "<qt>" + tr("Use the clipping path of the image") + "</qt>" );
15600 jghali 630
}
631
 
632
void PropertiesPalette_Group::unitChange()
633
{
634
        if (!m_doc)
635
                return;
636
 
637
        double oldRatio = m_unitRatio;
638
        m_unitRatio = m_doc->unitRatio();
639
        m_unitIndex = m_doc->unitIndex();
640
 
16077 jghali 641
        transPalWidget->blockSignals(true);
642
        transPalWidget->unitChange(oldRatio, m_unitRatio, m_doc->unitIndex());
643
        transPalWidget->blockSignals(false);
16781 jghali 644
}