Subversion Repositories Scribus

Rev

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