Subversion Repositories Scribus

Rev

Rev 16222 | Rev 16805 | 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 *)));
98
        connect(editShape, SIGNAL(clicked())                 , this, SLOT(handleShapeEdit()));
16781 jghali 99
        connect(evenOdd    , SIGNAL(clicked())                 , this, SLOT(handleFillRule()) );
100
        connect(nonZero    , SIGNAL(clicked())                 , this, SLOT(handleFillRule()) );
16077 jghali 101
        connect(transPalWidget , SIGNAL(editGradient())            , this, SLOT(handleGradientEdit()));
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
 
16077 jghali 128
        connect(this->transPalWidget, SIGNAL(gradientChanged()), m_ScMW, SLOT(updtGradMaskGroup()));
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
        int precision = unitGetPrecisionFromIndex(m_unitIndex);
155
        double maxXYWHVal =  16777215 * m_unitRatio;
156
        double minXYVal   = -16777215 * m_unitRatio;
157
 
16077 jghali 158
        transPalWidget->setDocument(m_doc);
159
        transPalWidget->setCurrentItem(NULL);
15600 jghali 160
 
161
        m_haveDoc  = true;
162
        m_haveItem = false;
163
 
16077 jghali 164
        connect(this->transPalWidget, SIGNAL(NewTrans(double))   , this, SLOT(handleGroupTransparency(double)));
165
        connect(this->transPalWidget, SIGNAL(NewBlend(int))      , this, SLOT(handleGroupBlending(int)));
166
        connect(this->transPalWidget, SIGNAL(NewGradient(int))   , this, SLOT(handleGroupGradMask(int)));
167
        connect(this->transPalWidget, SIGNAL(NewPattern(QString)), this, SLOT(handleGroupPatternMask(QString)));
168
        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 169
 
170
        connect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged()));
171
        connect(m_doc             , SIGNAL(docChanged())      , this, SLOT(handleSelectionChanged()));
172
}
173
 
174
void PropertiesPalette_Group::unsetDoc()
175
{
15741 jghali 176
        if (m_doc)
177
        {
178
                disconnect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged()));
179
                disconnect(m_doc             , SIGNAL(docChanged())      , this, SLOT(handleSelectionChanged()));
180
        }
181
 
15600 jghali 182
        m_haveDoc  = false;
183
        m_haveItem = false;
184
        m_doc   = NULL;
185
        m_item  = NULL;
186
 
16077 jghali 187
        transPalWidget->setDocument(NULL);
188
        transPalWidget->setCurrentItem(NULL);
15600 jghali 189
 
190
        setEnabled(false);
191
}
192
 
193
void PropertiesPalette_Group::unsetItem()
194
{
195
        m_haveItem = false;
196
        m_item     = NULL;
16077 jghali 197
        transPalWidget->setCurrentItem(NULL);
15600 jghali 198
        handleSelectionChanged();
199
}
200
 
201
void PropertiesPalette_Group::handleSelectionChanged()
202
{
203
        if (!m_haveDoc || !m_ScMW || m_ScMW->scriptIsRunning())
204
                return;
205
 
206
        PageItem* currItem = currentItemFromSelection();
207
        if (m_doc->m_Selection->count() > 1)
208
        {
209
                bool widgetEnabled = false;
210
                if (m_haveItem && m_item)
211
                {
16173 jghali 212
                        if ((m_item->isGroup()) && (!m_item->isSingleSel))
15600 jghali 213
                                widgetEnabled = true;
214
                }
215
                setEnabled(widgetEnabled);
216
        }
217
        else
218
        {
219
                int itemType = currItem ? (int) currItem->itemType() : -1;
220
                m_haveItem = (itemType != -1);
221
 
222
                switch (itemType)
223
                {
224
                case -1:
225
                        setEnabled(false);
226
                        break;
227
                case PageItem::ImageFrame:
228
                case PageItem::LatexFrame:
229
                case PageItem::OSGFrame:
230
                        if (currItem->asOSGFrame())
231
                        {
232
                                setEnabled(false);
233
                        }
234
                        break;
16222 jghali 235
                case PageItem::Arc:
15600 jghali 236
                case PageItem::TextFrame:
237
                case PageItem::Line:
238
                case PageItem::ItemType1:
239
                case PageItem::ItemType3:
240
                case PageItem::Polygon:
241
                case PageItem::PolyLine:
242
                case PageItem::PathText:
16222 jghali 243
                case PageItem::RegularPolygon:
244
                        setEnabled(false);
15600 jghali 245
                        break;
246
                case PageItem::Symbol:
247
                        setEnabled(true);
248
                        break;
249
                }
250
        }
251
        if (currItem)
252
        {
253
                setCurrentItem(currItem);
254
        }
255
        updateGeometry();
256
        repaint();
257
}
258
 
16179 jghali 259
void PropertiesPalette_Group::handleUpdateRequest(int updateFlags)
260
{
261
        if (updateFlags & reqColorsUpdate)
262
                updateColorList();
263
}
264
 
15600 jghali 265
void PropertiesPalette_Group::setCurrentItem(PageItem *item)
266
{
267
        if (!m_ScMW || m_ScMW->scriptIsRunning())
268
                return;
269
        //CB We shouldnt really need to process this if our item is the same one
270
        //maybe we do if the item has been changed by scripter.. but that should probably
271
        //set some status if so.
272
        //FIXME: This wont work until when a canvas deselect happens, m_item must be NULL.
273
        //if (m_item == i)
274
        //      return;
275
 
276
        if (!m_doc)
277
                setDoc(item->doc());
278
 
279
        m_haveItem = false;
280
        m_item = item;
281
 
282
        bool   mirrorX, mirrorY;
283
        double patternScaleX, patternScaleY, patternOffsetX, patternOffsetY, patternRotation, patternSkewX, patternSkewY;
284
        m_item->patternTransform(patternScaleX, patternScaleY, patternOffsetX, patternOffsetY, patternRotation, patternSkewX, patternSkewY);
285
        m_item->patternFlip(mirrorX, mirrorY);
286
 
16077 jghali 287
        transPalWidget->setCurrentItem(m_item);
16781 jghali 288
        nonZero->setChecked(!m_item->fillRule);
289
        evenOdd->setChecked(m_item->fillRule);
15600 jghali 290
 
16173 jghali 291
        if ((m_item->isGroup()) && (!m_item->isSingleSel))
15600 jghali 292
        {
293
                setEnabled(true);
294
                if (m_item->FrameType == 0)
16077 jghali 295
                        customShape->setIcon(customShape->getIconPixmap(0));
15600 jghali 296
                if (m_item->FrameType == 1)
16077 jghali 297
                        customShape->setIcon(customShape->getIconPixmap(1));
15600 jghali 298
                if (m_item->FrameType > 3)
16077 jghali 299
                        customShape->setIcon(customShape->getIconPixmap(m_item->FrameType-2));
300
                transPalWidget->updateFromItem();
301
                transPalWidget->setActPattern(m_item->patternMask(), patternScaleX, patternScaleY, patternOffsetX, patternOffsetY, patternRotation, patternSkewX, patternSkewY, mirrorX, mirrorY);
302
                customShape->setEnabled(true);
303
                editShape->setEnabled(true);
304
                shapeGroup->setEnabled(true);
305
                textFlowDisabled->setEnabled(true);
306
                textFlowUsesFrameShape->setEnabled(true);
307
                textFlowUsesBoundingBox->setEnabled(true);
308
                textFlowUsesContourLine->setEnabled(true);
309
                textFlowUsesImageClipping->setEnabled(false);
15600 jghali 310
        }
311
        else
312
        {
313
                setEnabled(false);
314
        }
315
 
316
        m_haveItem = true;
317
 
318
        if (m_item->asOSGFrame())
319
        {
320
                setEnabled(false);
321
        }
322
        if (m_item->asSymbolFrame())
323
        {
324
                setEnabled(true);
325
                if (m_item->FrameType == 0)
16077 jghali 326
                        customShape->setIcon(customShape->getIconPixmap(0));
15600 jghali 327
                if (m_item->FrameType == 1)
16077 jghali 328
                        customShape->setIcon(customShape->getIconPixmap(1));
15600 jghali 329
                if (m_item->FrameType > 3)
16077 jghali 330
                        customShape->setIcon(customShape->getIconPixmap(m_item->FrameType-2));
331
                transPalWidget->updateFromItem();
332
                transPalWidget->setActPattern(m_item->patternMask(), patternScaleX, patternScaleY, patternOffsetX, patternOffsetY, patternRotation, patternSkewX, patternSkewY, mirrorX, mirrorY);
333
                customShape->setEnabled(true);
334
                editShape->setEnabled(true);
335
                shapeGroup->setEnabled(true);
336
                textFlowDisabled->setEnabled(true);
337
                textFlowUsesFrameShape->setEnabled(true);
338
                textFlowUsesBoundingBox->setEnabled(true);
339
                textFlowUsesContourLine->setEnabled(true);
340
                textFlowUsesImageClipping->setEnabled(false);
15600 jghali 341
        }
342
}
343
 
344
void PropertiesPalette_Group::displayTextFlowMode(PageItem::TextFlowMode mode)
345
{
346
        if (!m_ScMW || m_ScMW->scriptIsRunning() || !m_haveItem)
347
                return;
16173 jghali 348
        if (m_item->isGroup())
15600 jghali 349
        {
350
                if (mode == PageItem::TextFlowDisabled)
16077 jghali 351
                        textFlowDisabled->setChecked(true);
15600 jghali 352
                else if (mode == PageItem::TextFlowUsesFrameShape)
16077 jghali 353
                        textFlowUsesFrameShape->setChecked(true);
15600 jghali 354
                else if (mode == PageItem::TextFlowUsesBoundingBox)
16077 jghali 355
                        textFlowUsesBoundingBox->setChecked(true);
15600 jghali 356
                else if (mode == PageItem::TextFlowUsesContourLine)
16077 jghali 357
                        textFlowUsesContourLine->setChecked(true);
15600 jghali 358
                else if (mode == PageItem::TextFlowUsesImageClipping)
16077 jghali 359
                        textFlowUsesImageClipping->setChecked(true);
15600 jghali 360
                if ((m_item->asImageFrame()) && (m_item->imageClip.size() != 0))
16077 jghali 361
                        textFlowUsesImageClipping->setEnabled(true);
15600 jghali 362
                else
16077 jghali 363
                        textFlowUsesImageClipping->setEnabled(false);
15600 jghali 364
        }
365
}
366
 
367
const VGradient PropertiesPalette_Group::getMaskGradientGroup()
368
{
16077 jghali 369
        return transPalWidget->gradEdit->gradient();
15600 jghali 370
}
371
 
372
void PropertiesPalette_Group::updateColorList()
373
{
374
        if (!m_haveDoc || !m_ScMW || m_ScMW->scriptIsRunning())
375
                return;
16077 jghali 376
        transPalWidget->setColors(m_doc->PageColors);
377
        transPalWidget->setPatterns(&m_doc->docPatterns);
378
        transPalWidget->setGradients(&m_doc->docGradients);
15600 jghali 379
}
380
 
381
void PropertiesPalette_Group::updateColorSpecialGradient()
382
{
383
        if (!m_haveDoc)
384
                return;
385
        if(m_doc->m_Selection->isEmpty())
386
                return;
387
        double ratio = m_doc->unitRatio();
388
        PageItem *currItem = m_doc->m_Selection->itemAt(0);
389
        if (currItem)
390
        {
391
                switch (m_ScMW->view->editStrokeGradient)
392
                {
393
                case 0:
394
                case 1:
395
                case 3:
396
                case 4:
397
                case 5:
398
                case 6:
399
                case 7:
400
                        break;
401
                default:
16173 jghali 402
                        if (currItem->isGroup())
16077 jghali 403
                                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 404
                }
405
        }
406
}
407
 
15614 jghali 408
void PropertiesPalette_Group::handleGroupTransparency(double trans)
409
{
410
        if ((m_haveDoc) && (m_haveItem))
411
        {
412
                m_item->setFillTransparency(trans);
413
                m_item->update();
414
                emit DocChanged();
415
        }
416
}
417
 
418
void PropertiesPalette_Group::handleGroupBlending(int blend)
419
{
420
        if ((m_haveDoc) && (m_haveItem))
421
        {
422
                m_item->setFillBlendmode(blend);
423
                m_item->update();
424
                emit DocChanged();
425
        }
426
}
427
 
428
void PropertiesPalette_Group::handleGroupGradMask(int typ)
429
{
430
        if ((m_haveDoc) && (m_haveItem))
431
        {
432
                m_item->GrMask = typ;
433
                if ((typ > 0) && (typ < 7))
434
                        m_item->updateGradientVectors();
435
                m_item->update();
436
                emit DocChanged();
437
        }
438
}
439
 
440
void PropertiesPalette_Group::handleGroupPatternMask(QString pattern)
441
{
442
        if ((m_haveDoc) && (m_haveItem))
443
        {
444
                m_item->setPatternMask(pattern);
445
                m_item->update();
446
                emit DocChanged();
447
        }
448
}
449
 
450
void PropertiesPalette_Group::handleGroupPatternMaskProps(double imageScaleX, double imageScaleY, double offsetX, double offsetY, double rotation, double skewX, double skewY, bool mirrorX, bool mirrorY)
451
{
452
        if ((m_haveDoc) && (m_haveItem))
453
        {
454
                m_item->setMaskTransform(imageScaleX, imageScaleY, offsetX, offsetY, rotation, skewX, skewY);
455
                m_item->setMaskFlip(mirrorX, mirrorY);
456
                m_item->update();
457
                emit DocChanged();
458
        }
459
}
460
 
15600 jghali 461
void PropertiesPalette_Group::handleNewShape(int frameType, int count, qreal *points)
462
{
463
        if (!m_ScMW || m_ScMW->scriptIsRunning())
464
                return;
465
        if ((m_haveDoc) && (m_haveItem))
466
        {
467
                if ((m_item->itemType() == PageItem::PolyLine) || (m_item->itemType() == PageItem::PathText))
468
                        return;
469
 
470
                m_doc->item_setFrameShape(m_item, frameType, count, points);
471
 
472
                //ScribusDoc::changed() is called in item_setFrameShape()
473
                //Hope this is enough
474
                //emit DocChanged();
475
                emit shapeChanged(frameType);
476
        }
477
}
478
 
479
void PropertiesPalette_Group::handleTextFlow()
480
{
481
        if (!m_ScMW || m_ScMW->scriptIsRunning())
482
                return;
483
        if ((m_haveDoc) && (m_haveItem))
484
        {
485
                PageItem::TextFlowMode mode = PageItem::TextFlowDisabled;
16173 jghali 486
                if (m_item->isGroup())
15600 jghali 487
                {
16077 jghali 488
                        if (textFlowDisabled->isChecked())
15600 jghali 489
                                mode = PageItem::TextFlowDisabled;
16077 jghali 490
                        if (textFlowUsesFrameShape->isChecked())
15600 jghali 491
                                mode = PageItem::TextFlowUsesFrameShape;
16077 jghali 492
                        if (textFlowUsesBoundingBox->isChecked())
15600 jghali 493
                                mode = PageItem::TextFlowUsesBoundingBox;
16077 jghali 494
                        if (textFlowUsesContourLine->isChecked())
15600 jghali 495
                                mode = PageItem::TextFlowUsesContourLine;
16077 jghali 496
                        if (textFlowUsesImageClipping->isChecked())
15600 jghali 497
                                mode = PageItem::TextFlowUsesImageClipping;
498
                }
499
                m_item->setTextFlowMode(mode);
500
                m_ScMW->view->DrawNew();
501
                emit DocChanged();
502
        }
503
}
504
 
505
void PropertiesPalette_Group::handleGradientEdit()
506
{
507
        if (!m_ScMW || m_ScMW->scriptIsRunning())
508
                return;
509
        if ((m_haveDoc) && (m_haveItem))
510
        {
511
                m_ScMW->view->editStrokeGradient = 2;
16077 jghali 512
                if (transPalWidget->gradEditButton->isChecked())
15600 jghali 513
                        m_ScMW->view->requestMode(modeEditGradientVectors);
514
                else
515
                        m_ScMW->view->requestMode(modeNormal);
516
        }
517
}
518
 
519
void PropertiesPalette_Group::handleSpecialGradient(double x1, double y1, double x2, double y2, double fx, double fy, double sg, double sk)
520
{
521
        if (!m_ScMW || m_ScMW->scriptIsRunning())
522
                return;
523
        if ((m_haveDoc) && (m_haveItem))
524
        {
525
                QRectF upRect;
526
                m_item->GrMaskStartX = x1 / m_unitRatio;
527
                m_item->GrMaskStartY = y1 / m_unitRatio;
528
                m_item->GrMaskEndX = x2 / m_unitRatio;
529
                m_item->GrMaskEndY = y2 / m_unitRatio;
530
                m_item->GrMaskFocalX = fx / m_unitRatio;
531
                m_item->GrMaskFocalY = fy / m_unitRatio;
532
                m_item->GrMaskScale = sg;
533
                m_item->GrMaskSkew = sk;
534
                if ((m_item->GrMask == 1) || (m_item->GrMask == 4))
535
                {
536
                        m_item->GrMaskFocalX = m_item->GrMaskStartX;
537
                        m_item->GrMaskFocalY = m_item->GrMaskStartY;
538
                }
539
                m_item->update();
540
                upRect = QRectF(QPointF(m_item->GrMaskStartX, m_item->GrMaskStartY), QPointF(m_item->GrMaskEndX, m_item->GrMaskEndY));
541
                double radEnd = distance(m_item->GrMaskEndX - m_item->GrMaskStartX, m_item->GrMaskEndY - m_item->GrMaskStartY);
542
                double rotEnd = xy2Deg(m_item->GrMaskEndX - m_item->GrMaskStartX, m_item->GrMaskEndY - m_item->GrMaskStartY);
543
                QTransform m;
544
                m.translate(m_item->GrMaskStartX, m_item->GrMaskStartY);
545
                m.rotate(rotEnd);
546
                m.rotate(-90);
547
                m.rotate(m_item->GrMaskSkew);
548
                m.translate(radEnd * m_item->GrMaskScale, 0);
549
                QPointF shP = m.map(QPointF(0,0));
550
                upRect |= QRectF(shP, QPointF(m_item->GrMaskEndX, m_item->GrMaskEndY)).normalized();
551
                upRect |= QRectF(shP, QPointF(m_item->GrMaskStartX, m_item->GrMaskStartY)).normalized();
552
                upRect |= QRectF(shP, QPointF(0, 0)).normalized();
553
                upRect |= QRectF(shP, QPointF(m_item->width(), m_item->height())).normalized();
554
                upRect.translate(m_item->xPos(), m_item->yPos());
555
                m_doc->regionsChanged()->update(upRect.adjusted(-10.0, -10.0, 10.0, 10.0));
556
                emit DocChanged();
557
        }
558
}
559
 
16781 jghali 560
void PropertiesPalette_Group::handleFillRule()
561
{
562
        if (!m_haveDoc || !m_haveItem || !m_ScMW || m_ScMW->scriptIsRunning())
563
                return;
564
        m_item->fillRule = evenOdd->isChecked();
565
        m_item->update();
566
        emit DocChanged();
567
}
568
 
15661 jghali 569
void PropertiesPalette_Group::handleShapeEdit()
15600 jghali 570
{
571
        if (!m_ScMW || m_ScMW->scriptIsRunning())
572
                return;
573
        if ((m_haveDoc) && (m_haveItem))
574
        {
575
                m_tmpSelection->clear();
576
                m_tmpSelection->copy(*m_doc->m_Selection, true);
577
                m_doc->m_Selection->clear();
578
                m_doc->m_Selection->addItem(m_item);
579
                m_item->isSingleSel = true;
580
                m_item->update();
581
                m_ScMW->view->requestMode(modeEditClip);
15661 jghali 582
                connect(m_ScMW->nodePalette, SIGNAL(paletteClosed()), this, SLOT(handleShapeEditEnded()));
15600 jghali 583
                emit shapeEditStarted();
584
        }
585
}
586
 
15661 jghali 587
void PropertiesPalette_Group::handleShapeEditEnded()
588
{
589
        disconnect(m_ScMW->nodePalette, SIGNAL(paletteClosed()), this, SLOT(handleShapeEditEnded()));
590
        if ((m_haveDoc) && (m_haveItem))
591
        {
592
                if (m_tmpSelection->count() > 0)
593
                {
594
                        m_doc->m_Selection->copy(*m_tmpSelection, false);
595
                        m_doc->m_Selection->connectItemToGUI();
596
                }
597
                m_tmpSelection->clear();
598
        }
599
}
600
 
15600 jghali 601
void PropertiesPalette_Group::changeEvent(QEvent *e)
602
{
603
        if (e->type() == QEvent::LanguageChange)
604
        {
605
                languageChange();
606
                return;
607
        }
608
        QWidget::changeEvent(e);
609
}
610
 
611
 
612
void PropertiesPalette_Group::languageChange()
613
{
16077 jghali 614
        editShape->setText( tr("&Edit..."));
615
        shapeGroup->setTitle( tr("Shape"));
15600 jghali 616
 
16077 jghali 617
        textFlowGroup->setTitle( tr("Text &Flow Around Frame"));
618
        textFlowDisabled->setText( tr("Disabled"));
619
        textFlowUsesFrameShape->setText( tr("Use Frame &Shape"));
620
        textFlowUsesBoundingBox->setText( tr("Use &Bounding Box"));
621
        textFlowUsesContourLine->setText( tr("&Use Contour Line"));
622
        textFlowUsesImageClipping->setText( tr("Use Image Clip Path"));
15600 jghali 623
 
16077 jghali 624
        textFlowDisabled->setToolTip( tr("Disable text flow from lower frames around object"));
625
        textFlowUsesFrameShape->setToolTip( tr("Use the frame shape for text flow of text frames below the object."));
626
        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>" );
627
        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>" );
628
        textFlowUsesImageClipping->setToolTip(  "<qt>" + tr("Use the clipping path of the image") + "</qt>" );
15600 jghali 629
}
630
 
631
void PropertiesPalette_Group::unitChange()
632
{
633
        if (!m_doc)
634
                return;
635
 
636
        double oldRatio = m_unitRatio;
637
        m_unitRatio = m_doc->unitRatio();
638
        m_unitIndex = m_doc->unitIndex();
639
 
16077 jghali 640
        transPalWidget->blockSignals(true);
641
        transPalWidget->unitChange(oldRatio, m_unitRatio, m_doc->unitIndex());
642
        transPalWidget->blockSignals(false);
16781 jghali 643
}