Subversion Repositories Scribus

Rev

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