Subversion Repositories Scribus

Rev

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