Subversion Repositories Scribus

Rev

Rev 17101 | 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"
17020 jghali 63
#include "ui/propertiespalette.h"
15600 jghali 64
#include "ui/propertiespalette_utils.h"
17020 jghali 65
#include "ui/propertiespalette_xyz.h"
15600 jghali 66
#include "ui/transparencypalette.h"
67
 
68
PropertiesPalette_Group::PropertiesPalette_Group( QWidget* parent) : QWidget(parent)
69
{
70
        m_ScMW = 0;
71
        m_doc  = 0;
72
        m_haveDoc   = false;
73
        m_haveItem  = false;
74
        m_unitRatio = 1.0;
75
 
76
        m_tmpSelection = new Selection(this, false);
77
        m_tmpSelection->clear();
78
 
16077 jghali 79
        setupUi(this);
17385 jghali 80
        setSizePolicy( QSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum));
15600 jghali 81
 
16077 jghali 82
        textFlowDisabled->setIcon(QIcon(loadIcon("flow-none.png")));
83
        textFlowUsesFrameShape->setIcon(QIcon(loadIcon("flow-frame.png")));
84
        textFlowUsesBoundingBox->setIcon(QIcon(loadIcon("flow-bounding.png")));
85
        textFlowUsesContourLine->setIcon(QIcon(loadIcon("flow-contour.png")));
86
        textFlowUsesImageClipping->setIcon(QIcon(loadIcon("flow-contour.png")));
15600 jghali 87
 
16077 jghali 88
        textFlowDisabled->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));
89
        textFlowUsesFrameShape->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));
90
        textFlowUsesBoundingBox->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));
91
        textFlowUsesContourLine->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));
92
        textFlowUsesImageClipping->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));
15600 jghali 93
 
16077 jghali 94
        transPalWidget->hideSelectionButtons();
15600 jghali 95
 
96
        languageChange();
97
 
16077 jghali 98
        connect(textFlowBtnGroup, SIGNAL(buttonClicked(int)), this, SLOT(handleTextFlow()));
15600 jghali 99
 
16077 jghali 100
        connect(customShape  , SIGNAL(FormSel(int, int, qreal *)), this, SLOT(handleNewShape(int, int, qreal *)));
16805 jghali 101
        connect(editShape    , SIGNAL(clicked())                 , this, SLOT(handleShapeEdit()));
102
        connect(evenOdd      , SIGNAL(clicked())                 , this, SLOT(handleFillRule()) );
103
        connect(nonZero      , SIGNAL(clicked())                 , this, SLOT(handleFillRule()) );
104
        connect(transPalWidget , SIGNAL(editGradient())          , this, SLOT(handleGradientEdit()));
16077 jghali 105
        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 106
}
107
 
108
PageItem* PropertiesPalette_Group::currentItemFromSelection()
109
{
110
        PageItem *currentItem = NULL;
111
 
112
        if (m_doc)
113
        {
114
                if (m_doc->m_Selection->count() > 1)
115
                {
16173 jghali 116
                        currentItem = m_doc->m_Selection->itemAt(0);
15600 jghali 117
                }
118
                else if (m_doc->m_Selection->count() == 1)
119
                {
120
                        currentItem = m_doc->m_Selection->itemAt(0);
121
                }
122
        }
123
 
124
        return currentItem;
125
}
126
 
127
void PropertiesPalette_Group::setMainWindow(ScribusMainWindow *mw)
128
{
129
        m_ScMW = mw;
130
 
16957 jghali 131
        connect(this->transPalWidget, SIGNAL(gradientChanged()), this, SLOT(handleGradientChanged()));
16179 jghali 132
        connect(m_ScMW, SIGNAL(UpdateRequest(int)), this, SLOT(handleUpdateRequest(int)));
15600 jghali 133
}
134
 
135
void PropertiesPalette_Group::setDoc(ScribusDoc *d)
136
{
137
        if((d == (ScribusDoc*) m_doc) || (m_ScMW && m_ScMW->scriptIsRunning()))
138
                return;
139
 
140
        if (m_doc)
141
        {
142
                disconnect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged()));
143
                disconnect(m_doc             , SIGNAL(docChanged())      , this, SLOT(handleSelectionChanged()));
144
        }
145
 
16077 jghali 146
        disconnect(this->transPalWidget, SIGNAL(NewTrans(double)), 0, 0);
147
        disconnect(this->transPalWidget, SIGNAL(NewBlend(int)), 0, 0);
148
        disconnect(this->transPalWidget, SIGNAL(NewGradient(int)), 0, 0);
149
        disconnect(this->transPalWidget, SIGNAL(NewPattern(QString)), 0, 0);
150
        disconnect(this->transPalWidget, SIGNAL(NewPatternProps(double, double, double, double, double, double, double, bool, bool)), 0, 0);
15600 jghali 151
 
152
        m_doc  = d;
153
        m_item = NULL;
154
        m_unitRatio   = m_doc->unitRatio();
155
        m_unitIndex   = m_doc->unitIndex();
156
 
16077 jghali 157
        transPalWidget->setDocument(m_doc);
158
        transPalWidget->setCurrentItem(NULL);
15600 jghali 159
 
160
        m_haveDoc  = true;
161
        m_haveItem = false;
162
 
16077 jghali 163
        connect(this->transPalWidget, SIGNAL(NewTrans(double))   , this, SLOT(handleGroupTransparency(double)));
164
        connect(this->transPalWidget, SIGNAL(NewBlend(int))      , this, SLOT(handleGroupBlending(int)));
165
        connect(this->transPalWidget, SIGNAL(NewGradient(int))   , this, SLOT(handleGroupGradMask(int)));
166
        connect(this->transPalWidget, SIGNAL(NewPattern(QString)), this, SLOT(handleGroupPatternMask(QString)));
167
        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 168
 
169
        connect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged()));
170
        connect(m_doc             , SIGNAL(docChanged())      , this, SLOT(handleSelectionChanged()));
171
}
172
 
173
void PropertiesPalette_Group::unsetDoc()
174
{
15741 jghali 175
        if (m_doc)
176
        {
177
                disconnect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged()));
178
                disconnect(m_doc             , SIGNAL(docChanged())      , this, SLOT(handleSelectionChanged()));
179
        }
180
 
15600 jghali 181
        m_haveDoc  = false;
182
        m_haveItem = false;
183
        m_doc   = NULL;
184
        m_item  = NULL;
185
 
16077 jghali 186
        transPalWidget->setDocument(NULL);
187
        transPalWidget->setCurrentItem(NULL);
15600 jghali 188
 
189
        setEnabled(false);
190
}
191
 
192
void PropertiesPalette_Group::unsetItem()
193
{
194
        m_haveItem = false;
195
        m_item     = NULL;
16077 jghali 196
        transPalWidget->setCurrentItem(NULL);
15600 jghali 197
        handleSelectionChanged();
198
}
199
 
200
void PropertiesPalette_Group::handleSelectionChanged()
201
{
202
        if (!m_haveDoc || !m_ScMW || m_ScMW->scriptIsRunning())
203
                return;
204
 
205
        PageItem* currItem = currentItemFromSelection();
206
        if (m_doc->m_Selection->count() > 1)
207
        {
208
                bool widgetEnabled = false;
209
                if (m_haveItem && m_item)
210
                {
16173 jghali 211
                        if ((m_item->isGroup()) && (!m_item->isSingleSel))
15600 jghali 212
                                widgetEnabled = true;
213
                }
214
                setEnabled(widgetEnabled);
215
        }
216
        else
217
        {
218
                int itemType = currItem ? (int) currItem->itemType() : -1;
219
                m_haveItem = (itemType != -1);
220
 
221
                switch (itemType)
222
                {
223
                case -1:
224
                        setEnabled(false);
225
                        break;
226
                case PageItem::ImageFrame:
227
                case PageItem::LatexFrame:
228
                case PageItem::OSGFrame:
229
                        if (currItem->asOSGFrame())
230
                        {
231
                                setEnabled(false);
232
                        }
233
                        break;
16222 jghali 234
                case PageItem::Arc:
15600 jghali 235
                case PageItem::TextFrame:
236
                case PageItem::Line:
237
                case PageItem::ItemType1:
238
                case PageItem::ItemType3:
239
                case PageItem::Polygon:
240
                case PageItem::PolyLine:
241
                case PageItem::PathText:
16222 jghali 242
                case PageItem::RegularPolygon:
243
                        setEnabled(false);
15600 jghali 244
                        break;
245
                case PageItem::Symbol:
246
                        setEnabled(true);
247
                        break;
248
                }
249
        }
250
        if (currItem)
251
        {
252
                setCurrentItem(currItem);
253
        }
254
        updateGeometry();
255
        repaint();
256
}
257
 
16179 jghali 258
void PropertiesPalette_Group::handleUpdateRequest(int updateFlags)
259
{
260
        if (updateFlags & reqColorsUpdate)
261
                updateColorList();
262
}
263
 
15600 jghali 264
void PropertiesPalette_Group::setCurrentItem(PageItem *item)
265
{
266
        if (!m_ScMW || m_ScMW->scriptIsRunning())
267
                return;
268
        //CB We shouldnt really need to process this if our item is the same one
269
        //maybe we do if the item has been changed by scripter.. but that should probably
270
        //set some status if so.
271
        //FIXME: This wont work until when a canvas deselect happens, m_item must be NULL.
272
        //if (m_item == i)
273
        //      return;
274
 
275
        if (!m_doc)
276
                setDoc(item->doc());
277
 
278
        m_haveItem = false;
279
        m_item = item;
280
 
281
        bool   mirrorX, mirrorY;
282
        double patternScaleX, patternScaleY, patternOffsetX, patternOffsetY, patternRotation, patternSkewX, patternSkewY;
283
        m_item->patternTransform(patternScaleX, patternScaleY, patternOffsetX, patternOffsetY, patternRotation, patternSkewX, patternSkewY);
284
        m_item->patternFlip(mirrorX, mirrorY);
285
 
16077 jghali 286
        transPalWidget->setCurrentItem(m_item);
16781 jghali 287
        nonZero->setChecked(!m_item->fillRule);
288
        evenOdd->setChecked(m_item->fillRule);
15600 jghali 289
 
16173 jghali 290
        if ((m_item->isGroup()) && (!m_item->isSingleSel))
15600 jghali 291
        {
292
                setEnabled(true);
293
                if (m_item->FrameType == 0)
16077 jghali 294
                        customShape->setIcon(customShape->getIconPixmap(0));
15600 jghali 295
                if (m_item->FrameType == 1)
16077 jghali 296
                        customShape->setIcon(customShape->getIconPixmap(1));
15600 jghali 297
                if (m_item->FrameType > 3)
16077 jghali 298
                        customShape->setIcon(customShape->getIconPixmap(m_item->FrameType-2));
299
                transPalWidget->updateFromItem();
300
                transPalWidget->setActPattern(m_item->patternMask(), patternScaleX, patternScaleY, patternOffsetX, patternOffsetY, patternRotation, patternSkewX, patternSkewY, mirrorX, mirrorY);
301
                customShape->setEnabled(true);
302
                editShape->setEnabled(true);
303
                shapeGroup->setEnabled(true);
304
                textFlowDisabled->setEnabled(true);
305
                textFlowUsesFrameShape->setEnabled(true);
306
                textFlowUsesBoundingBox->setEnabled(true);
307
                textFlowUsesContourLine->setEnabled(true);
308
                textFlowUsesImageClipping->setEnabled(false);
15600 jghali 309
        }
310
        else
311
        {
312
                setEnabled(false);
313
        }
314
 
315
        m_haveItem = true;
316
 
317
        if (m_item->asOSGFrame())
318
        {
319
                setEnabled(false);
320
        }
321
        if (m_item->asSymbolFrame())
322
        {
323
                setEnabled(true);
324
                if (m_item->FrameType == 0)
16077 jghali 325
                        customShape->setIcon(customShape->getIconPixmap(0));
15600 jghali 326
                if (m_item->FrameType == 1)
16077 jghali 327
                        customShape->setIcon(customShape->getIconPixmap(1));
15600 jghali 328
                if (m_item->FrameType > 3)
16077 jghali 329
                        customShape->setIcon(customShape->getIconPixmap(m_item->FrameType-2));
330
                transPalWidget->updateFromItem();
331
                transPalWidget->setActPattern(m_item->patternMask(), patternScaleX, patternScaleY, patternOffsetX, patternOffsetY, patternRotation, patternSkewX, patternSkewY, mirrorX, mirrorY);
332
                customShape->setEnabled(true);
333
                editShape->setEnabled(true);
334
                shapeGroup->setEnabled(true);
335
                textFlowDisabled->setEnabled(true);
336
                textFlowUsesFrameShape->setEnabled(true);
337
                textFlowUsesBoundingBox->setEnabled(true);
338
                textFlowUsesContourLine->setEnabled(true);
339
                textFlowUsesImageClipping->setEnabled(false);
15600 jghali 340
        }
17088 jghali 341
        displayTextFlowMode(m_item->textFlowMode());
15600 jghali 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
void PropertiesPalette_Group::updateColorList()
368
{
369
        if (!m_haveDoc || !m_ScMW || m_ScMW->scriptIsRunning())
370
                return;
16077 jghali 371
        transPalWidget->setColors(m_doc->PageColors);
372
        transPalWidget->setPatterns(&m_doc->docPatterns);
373
        transPalWidget->setGradients(&m_doc->docGradients);
15600 jghali 374
}
375
 
376
void PropertiesPalette_Group::updateColorSpecialGradient()
377
{
378
        if (!m_haveDoc)
379
                return;
380
        if(m_doc->m_Selection->isEmpty())
381
                return;
382
        double ratio = m_doc->unitRatio();
383
        PageItem *currItem = m_doc->m_Selection->itemAt(0);
384
        if (currItem)
385
        {
386
                switch (m_ScMW->view->editStrokeGradient)
387
                {
388
                case 0:
389
                case 1:
390
                case 3:
391
                case 4:
392
                case 5:
393
                case 6:
394
                case 7:
395
                        break;
396
                default:
16173 jghali 397
                        if (currItem->isGroup())
16077 jghali 398
                                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 399
                }
400
        }
401
}
402
 
16957 jghali 403
void PropertiesPalette_Group::handleGradientChanged()
404
{
405
        if (m_haveDoc)
406
        {
407
                VGradient vg(transPalWidget->gradEdit->gradient());
408
                m_doc->itemSelection_SetMaskGradient(vg);
409
        }
410
}
411
 
15614 jghali 412
void PropertiesPalette_Group::handleGroupTransparency(double trans)
413
{
414
        if ((m_haveDoc) && (m_haveItem))
415
        {
416
                m_item->setFillTransparency(trans);
417
                m_item->update();
418
        }
419
}
420
 
421
void PropertiesPalette_Group::handleGroupBlending(int blend)
422
{
423
        if ((m_haveDoc) && (m_haveItem))
424
        {
425
                m_item->setFillBlendmode(blend);
426
                m_item->update();
427
        }
428
}
429
 
430
void PropertiesPalette_Group::handleGroupGradMask(int typ)
431
{
432
        if ((m_haveDoc) && (m_haveItem))
433
        {
434
                m_item->GrMask = typ;
435
                if ((typ > 0) && (typ < 7))
436
                        m_item->updateGradientVectors();
437
                m_item->update();
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
        }
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
        }
458
}
459
 
15600 jghali 460
void PropertiesPalette_Group::handleNewShape(int frameType, int count, qreal *points)
461
{
462
        if (!m_ScMW || m_ScMW->scriptIsRunning())
463
                return;
464
        if ((m_haveDoc) && (m_haveItem))
465
        {
466
                if ((m_item->itemType() == PageItem::PolyLine) || (m_item->itemType() == PageItem::PathText))
467
                        return;
468
 
469
                m_doc->item_setFrameShape(m_item, frameType, count, points);
17101 jghali 470
                m_doc->invalidateAll();
471
                m_doc->regionsChanged()->update(QRect());
15600 jghali 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);
17101 jghali 501
                m_doc->changed();
17091 jghali 502
                m_doc->invalidateAll();
17088 jghali 503
                m_doc->regionsChanged()->update(QRect());
15600 jghali 504
        }
505
}
506
 
507
void PropertiesPalette_Group::handleGradientEdit()
508
{
509
        if (!m_ScMW || m_ScMW->scriptIsRunning())
510
                return;
511
        if ((m_haveDoc) && (m_haveItem))
512
        {
513
                m_ScMW->view->editStrokeGradient = 2;
16077 jghali 514
                if (transPalWidget->gradEditButton->isChecked())
15600 jghali 515
                        m_ScMW->view->requestMode(modeEditGradientVectors);
516
                else
517
                        m_ScMW->view->requestMode(modeNormal);
518
        }
519
}
520
 
521
void PropertiesPalette_Group::handleSpecialGradient(double x1, double y1, double x2, double y2, double fx, double fy, double sg, double sk)
522
{
523
        if (!m_ScMW || m_ScMW->scriptIsRunning())
524
                return;
525
        if ((m_haveDoc) && (m_haveItem))
526
        {
527
                QRectF upRect;
528
                m_item->GrMaskStartX = x1 / m_unitRatio;
529
                m_item->GrMaskStartY = y1 / m_unitRatio;
530
                m_item->GrMaskEndX = x2 / m_unitRatio;
531
                m_item->GrMaskEndY = y2 / m_unitRatio;
532
                m_item->GrMaskFocalX = fx / m_unitRatio;
533
                m_item->GrMaskFocalY = fy / m_unitRatio;
534
                m_item->GrMaskScale = sg;
535
                m_item->GrMaskSkew = sk;
536
                if ((m_item->GrMask == 1) || (m_item->GrMask == 4))
537
                {
538
                        m_item->GrMaskFocalX = m_item->GrMaskStartX;
539
                        m_item->GrMaskFocalY = m_item->GrMaskStartY;
540
                }
541
                m_item->update();
542
                upRect = QRectF(QPointF(m_item->GrMaskStartX, m_item->GrMaskStartY), QPointF(m_item->GrMaskEndX, m_item->GrMaskEndY));
543
                double radEnd = distance(m_item->GrMaskEndX - m_item->GrMaskStartX, m_item->GrMaskEndY - m_item->GrMaskStartY);
544
                double rotEnd = xy2Deg(m_item->GrMaskEndX - m_item->GrMaskStartX, m_item->GrMaskEndY - m_item->GrMaskStartY);
545
                QTransform m;
546
                m.translate(m_item->GrMaskStartX, m_item->GrMaskStartY);
547
                m.rotate(rotEnd);
548
                m.rotate(-90);
549
                m.rotate(m_item->GrMaskSkew);
550
                m.translate(radEnd * m_item->GrMaskScale, 0);
551
                QPointF shP = m.map(QPointF(0,0));
552
                upRect |= QRectF(shP, QPointF(m_item->GrMaskEndX, m_item->GrMaskEndY)).normalized();
553
                upRect |= QRectF(shP, QPointF(m_item->GrMaskStartX, m_item->GrMaskStartY)).normalized();
554
                upRect |= QRectF(shP, QPointF(0, 0)).normalized();
555
                upRect |= QRectF(shP, QPointF(m_item->width(), m_item->height())).normalized();
556
                upRect.translate(m_item->xPos(), m_item->yPos());
557
                m_doc->regionsChanged()->update(upRect.adjusted(-10.0, -10.0, 10.0, 10.0));
17101 jghali 558
                m_doc->changed();
15600 jghali 559
        }
560
}
561
 
16781 jghali 562
void PropertiesPalette_Group::handleFillRule()
563
{
564
        if (!m_haveDoc || !m_haveItem || !m_ScMW || m_ScMW->scriptIsRunning())
565
                return;
566
        m_item->fillRule = evenOdd->isChecked();
567
        m_item->update();
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);
17020 jghali 583
                m_ScMW->scrActions["itemUngroup"]->setEnabled(false);
15661 jghali 584
                connect(m_ScMW->nodePalette, SIGNAL(paletteClosed()), this, SLOT(handleShapeEditEnded()));
15600 jghali 585
                emit shapeEditStarted();
586
        }
587
}
588
 
15661 jghali 589
void PropertiesPalette_Group::handleShapeEditEnded()
590
{
591
        disconnect(m_ScMW->nodePalette, SIGNAL(paletteClosed()), this, SLOT(handleShapeEditEnded()));
592
        if ((m_haveDoc) && (m_haveItem))
593
        {
594
                if (m_tmpSelection->count() > 0)
595
                {
596
                        m_doc->m_Selection->copy(*m_tmpSelection, false);
597
                        m_doc->m_Selection->connectItemToGUI();
598
                }
599
                m_tmpSelection->clear();
17020 jghali 600
//              m_ScMW->propertiesPalette->setCurrentItem(m_doc->m_Selection->itemAt(0));
601
//              m_ScMW->scrActions["itemGroup"]->setEnabled(true);
602
//              m_ScMW->propertiesPalette->xyzPal->doUnGroup->setEnabled(true);
15661 jghali 603
        }
604
}
605
 
15600 jghali 606
void PropertiesPalette_Group::changeEvent(QEvent *e)
607
{
608
        if (e->type() == QEvent::LanguageChange)
609
        {
610
                languageChange();
611
                return;
612
        }
613
        QWidget::changeEvent(e);
614
}
615
 
616
 
617
void PropertiesPalette_Group::languageChange()
618
{
16077 jghali 619
        editShape->setText( tr("&Edit..."));
620
        shapeGroup->setTitle( tr("Shape"));
15600 jghali 621
 
16077 jghali 622
        textFlowGroup->setTitle( tr("Text &Flow Around Frame"));
623
        textFlowDisabled->setText( tr("Disabled"));
624
        textFlowUsesFrameShape->setText( tr("Use Frame &Shape"));
625
        textFlowUsesBoundingBox->setText( tr("Use &Bounding Box"));
626
        textFlowUsesContourLine->setText( tr("&Use Contour Line"));
627
        textFlowUsesImageClipping->setText( tr("Use Image Clip Path"));
15600 jghali 628
 
16077 jghali 629
        textFlowDisabled->setToolTip( tr("Disable text flow from lower frames around object"));
630
        textFlowUsesFrameShape->setToolTip( tr("Use the frame shape for text flow of text frames below the object."));
631
        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>" );
632
        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>" );
633
        textFlowUsesImageClipping->setToolTip(  "<qt>" + tr("Use the clipping path of the image") + "</qt>" );
15600 jghali 634
}
635
 
636
void PropertiesPalette_Group::unitChange()
637
{
638
        if (!m_doc)
639
                return;
640
 
641
        double oldRatio = m_unitRatio;
642
        m_unitRatio = m_doc->unitRatio();
643
        m_unitIndex = m_doc->unitIndex();
644
 
16077 jghali 645
        transPalWidget->blockSignals(true);
646
        transPalWidget->unitChange(oldRatio, m_unitRatio, m_doc->unitIndex());
647
        transPalWidget->blockSignals(false);
16781 jghali 648
}