Subversion Repositories Scribus

Rev

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