Subversion Repositories Scribus

Rev

Rev 15661 | Rev 15840 | 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
{
15741 jghali 237
        if (m_doc)
238
        {
239
                disconnect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged()));
240
                disconnect(m_doc             , SIGNAL(docChanged())      , this, SLOT(handleSelectionChanged()));
241
        }
242
 
15600 jghali 243
        m_haveDoc  = false;
244
        m_haveItem = false;
245
        m_doc   = NULL;
246
        m_item  = NULL;
247
 
248
        TpalGroup->setDocument(NULL);
249
        TpalGroup->setCurrentItem(NULL);
250
 
251
        setEnabled(false);
252
}
253
 
254
void PropertiesPalette_Group::unsetItem()
255
{
256
        m_haveItem = false;
257
        m_item     = NULL;
258
        TpalGroup->setCurrentItem(NULL);
259
        handleSelectionChanged();
260
}
261
 
262
void PropertiesPalette_Group::handleSelectionChanged()
263
{
264
        if (!m_haveDoc || !m_ScMW || m_ScMW->scriptIsRunning())
265
                return;
266
 
267
        PageItem* currItem = currentItemFromSelection();
268
        if (m_doc->m_Selection->count() > 1)
269
        {
270
                bool widgetEnabled = false;
271
                if (m_haveItem && m_item)
272
                {
273
                        if ((m_item->isGroupControl) || ((m_item->Groups.count() != 0) && (!m_item->isSingleSel)))
274
                                widgetEnabled = true;
275
                }
276
                setEnabled(widgetEnabled);
277
        }
278
        else
279
        {
280
                int itemType = currItem ? (int) currItem->itemType() : -1;
281
                m_haveItem = (itemType != -1);
282
 
283
                switch (itemType)
284
                {
285
                case -1:
286
                        setEnabled(false);
287
                        break;
288
                case PageItem::ImageFrame:
289
                case PageItem::LatexFrame:
290
                case PageItem::OSGFrame:
291
                        if (currItem->asOSGFrame())
292
                        {
293
                                setEnabled(false);
294
                        }
295
                        break;
296
                case PageItem::TextFrame:
297
                case PageItem::Line:
298
                case PageItem::ItemType1:
299
                case PageItem::ItemType3:
300
                case PageItem::Polygon:
301
                case PageItem::PolyLine:
302
                case PageItem::PathText:
303
                        break;
304
                case PageItem::Symbol:
305
                        setEnabled(true);
306
                        break;
307
                }
308
        }
309
        if (currItem)
310
        {
311
                setCurrentItem(currItem);
312
        }
313
        updateGeometry();
314
        repaint();
315
}
316
 
317
void PropertiesPalette_Group::setCurrentItem(PageItem *item)
318
{
319
        if (!m_ScMW || m_ScMW->scriptIsRunning())
320
                return;
321
        //CB We shouldnt really need to process this if our item is the same one
322
        //maybe we do if the item has been changed by scripter.. but that should probably
323
        //set some status if so.
324
        //FIXME: This wont work until when a canvas deselect happens, m_item must be NULL.
325
        //if (m_item == i)
326
        //      return;
327
 
328
        if (!m_doc)
329
                setDoc(item->doc());
330
 
331
        m_haveItem = false;
332
        m_item = item;
333
 
334
        bool   mirrorX, mirrorY;
335
        double patternScaleX, patternScaleY, patternOffsetX, patternOffsetY, patternRotation, patternSkewX, patternSkewY;
336
        m_item->patternTransform(patternScaleX, patternScaleY, patternOffsetX, patternOffsetY, patternRotation, patternSkewX, patternSkewY);
337
        m_item->patternFlip(mirrorX, mirrorY);
338
 
339
        TpalGroup->setCurrentItem(m_item);
340
 
341
        if ((m_item->isGroupControl) || ((m_item->Groups.count() != 0) && (!m_item->isSingleSel)))
342
        {
343
                setEnabled(true);
344
                if (m_item->FrameType == 0)
345
                        SCustom2->setIcon(SCustom2->getIconPixmap(0));
346
                if (m_item->FrameType == 1)
347
                        SCustom2->setIcon(SCustom2->getIconPixmap(1));
348
                if (m_item->FrameType > 3)
349
                        SCustom2->setIcon(SCustom2->getIconPixmap(m_item->FrameType-2));
350
                TpalGroup->updateFromItem();
351
                TpalGroup->setActPattern(m_item->patternMask(), patternScaleX, patternScaleY, patternOffsetX, patternOffsetY, patternRotation, patternSkewX, patternSkewY, mirrorX, mirrorY);
352
                SCustom2->setEnabled(true);
353
                EditShape2->setEnabled(true);
354
                SRect2->setEnabled(true);
355
                textFlowDisabled2->setEnabled(true);
356
                textFlowUsesFrameShape2->setEnabled(true);
357
                textFlowUsesBoundingBox2->setEnabled(true);
358
                textFlowUsesContourLine2->setEnabled(true);
359
                textFlowUsesImageClipping2->setEnabled(false);
360
        }
361
        else
362
        {
363
                setEnabled(false);
364
        }
365
 
366
        m_haveItem = true;
367
 
368
        if (m_item->asOSGFrame())
369
        {
370
                setEnabled(false);
371
        }
372
        if (m_item->asSymbolFrame())
373
        {
374
                setEnabled(true);
375
                if (m_item->FrameType == 0)
376
                        SCustom2->setIcon(SCustom2->getIconPixmap(0));
377
                if (m_item->FrameType == 1)
378
                        SCustom2->setIcon(SCustom2->getIconPixmap(1));
379
                if (m_item->FrameType > 3)
380
                        SCustom2->setIcon(SCustom2->getIconPixmap(m_item->FrameType-2));
381
                TpalGroup->updateFromItem();
382
                TpalGroup->setActPattern(m_item->patternMask(), patternScaleX, patternScaleY, patternOffsetX, patternOffsetY, patternRotation, patternSkewX, patternSkewY, mirrorX, mirrorY);
383
                SCustom2->setEnabled(true);
384
                EditShape2->setEnabled(true);
385
                SRect2->setEnabled(true);
386
                textFlowDisabled2->setEnabled(true);
387
                textFlowUsesFrameShape2->setEnabled(true);
388
                textFlowUsesBoundingBox2->setEnabled(true);
389
                textFlowUsesContourLine2->setEnabled(true);
390
                textFlowUsesImageClipping2->setEnabled(false);
391
        }
392
}
393
 
394
void PropertiesPalette_Group::displayTextFlowMode(PageItem::TextFlowMode mode)
395
{
396
        if (!m_ScMW || m_ScMW->scriptIsRunning() || !m_haveItem)
397
                return;
398
        if (m_item->isGroupControl)
399
        {
400
                if (mode == PageItem::TextFlowDisabled)
401
                        textFlowDisabled2->setChecked(true);
402
                else if (mode == PageItem::TextFlowUsesFrameShape)
403
                        textFlowUsesFrameShape2->setChecked(true);
404
                else if (mode == PageItem::TextFlowUsesBoundingBox)
405
                        textFlowUsesBoundingBox2->setChecked(true);
406
                else if (mode == PageItem::TextFlowUsesContourLine)
407
                        textFlowUsesContourLine2->setChecked(true);
408
                else if (mode == PageItem::TextFlowUsesImageClipping)
409
                        textFlowUsesImageClipping2->setChecked(true);
410
                if ((m_item->asImageFrame()) && (m_item->imageClip.size() != 0))
411
                        textFlowUsesImageClipping2->setEnabled(true);
412
                else
413
                        textFlowUsesImageClipping2->setEnabled(false);
414
        }
415
}
416
 
417
const VGradient PropertiesPalette_Group::getMaskGradientGroup()
418
{
419
        return TpalGroup->gradEdit->gradient();
420
}
421
 
422
void PropertiesPalette_Group::updateColorList()
423
{
424
        if (!m_haveDoc || !m_ScMW || m_ScMW->scriptIsRunning())
425
                return;
426
        TpalGroup->SetColors(m_doc->PageColors);
427
        TpalGroup->SetPatterns(&m_doc->docPatterns);
428
        TpalGroup->SetGradients(&m_doc->docGradients);
429
}
430
 
431
void PropertiesPalette_Group::updateColorSpecialGradient()
432
{
433
        if (!m_haveDoc)
434
                return;
435
        if(m_doc->m_Selection->isEmpty())
436
                return;
437
        double ratio = m_doc->unitRatio();
438
        PageItem *currItem = m_doc->m_Selection->itemAt(0);
439
        if (currItem)
440
        {
441
                switch (m_ScMW->view->editStrokeGradient)
442
                {
443
                case 0:
444
                case 1:
445
                case 3:
446
                case 4:
447
                case 5:
448
                case 6:
449
                case 7:
450
                        break;
451
                default:
452
                        if (currItem->isGroupControl)
453
                                TpalGroup->setSpecialGradient(currItem->GrMaskStartX * ratio, currItem->GrMaskStartY * ratio, currItem->GrMaskEndX * ratio, currItem->GrMaskEndY * ratio, currItem->GrMaskFocalX * ratio, currItem->GrMaskFocalY * ratio, currItem->GrMaskScale, currItem->GrMaskSkew);
454
                }
455
        }
456
}
457
 
15614 jghali 458
void PropertiesPalette_Group::handleGroupTransparency(double trans)
459
{
460
        if ((m_haveDoc) && (m_haveItem))
461
        {
462
                m_item->setFillTransparency(trans);
463
                m_item->update();
464
                emit DocChanged();
465
        }
466
}
467
 
468
void PropertiesPalette_Group::handleGroupBlending(int blend)
469
{
470
        if ((m_haveDoc) && (m_haveItem))
471
        {
472
                m_item->setFillBlendmode(blend);
473
                m_item->update();
474
                emit DocChanged();
475
        }
476
}
477
 
478
void PropertiesPalette_Group::handleGroupGradMask(int typ)
479
{
480
        if ((m_haveDoc) && (m_haveItem))
481
        {
482
                m_item->GrMask = typ;
483
                if ((typ > 0) && (typ < 7))
484
                        m_item->updateGradientVectors();
485
                m_item->update();
486
                emit DocChanged();
487
        }
488
}
489
 
490
void PropertiesPalette_Group::handleGroupPatternMask(QString pattern)
491
{
492
        if ((m_haveDoc) && (m_haveItem))
493
        {
494
                m_item->setPatternMask(pattern);
495
                m_item->update();
496
                emit DocChanged();
497
        }
498
}
499
 
500
void PropertiesPalette_Group::handleGroupPatternMaskProps(double imageScaleX, double imageScaleY, double offsetX, double offsetY, double rotation, double skewX, double skewY, bool mirrorX, bool mirrorY)
501
{
502
        if ((m_haveDoc) && (m_haveItem))
503
        {
504
                m_item->setMaskTransform(imageScaleX, imageScaleY, offsetX, offsetY, rotation, skewX, skewY);
505
                m_item->setMaskFlip(mirrorX, mirrorY);
506
                m_item->update();
507
                emit DocChanged();
508
        }
509
}
510
 
15600 jghali 511
void PropertiesPalette_Group::handleNewShape(int frameType, int count, qreal *points)
512
{
513
        if (!m_ScMW || m_ScMW->scriptIsRunning())
514
                return;
515
        if ((m_haveDoc) && (m_haveItem))
516
        {
517
                if ((m_item->itemType() == PageItem::PolyLine) || (m_item->itemType() == PageItem::PathText))
518
                        return;
519
 
520
                m_doc->item_setFrameShape(m_item, frameType, count, points);
521
 
522
                //ScribusDoc::changed() is called in item_setFrameShape()
523
                //Hope this is enough
524
                //emit DocChanged();
525
                emit shapeChanged(frameType);
526
        }
527
}
528
 
529
void PropertiesPalette_Group::handleTextFlow()
530
{
531
        if (!m_ScMW || m_ScMW->scriptIsRunning())
532
                return;
533
        if ((m_haveDoc) && (m_haveItem))
534
        {
535
                PageItem::TextFlowMode mode = PageItem::TextFlowDisabled;
536
                if (m_item->isGroupControl)
537
                {
538
                        if (textFlowDisabled2->isChecked())
539
                                mode = PageItem::TextFlowDisabled;
540
                        if (textFlowUsesFrameShape2->isChecked())
541
                                mode = PageItem::TextFlowUsesFrameShape;
542
                        if (textFlowUsesBoundingBox2->isChecked())
543
                                mode = PageItem::TextFlowUsesBoundingBox;
544
                        if (textFlowUsesContourLine2->isChecked())
545
                                mode = PageItem::TextFlowUsesContourLine;
546
                        if (textFlowUsesImageClipping2->isChecked())
547
                                mode = PageItem::TextFlowUsesImageClipping;
548
                }
549
                m_item->setTextFlowMode(mode);
550
                m_ScMW->view->DrawNew();
551
                emit DocChanged();
552
        }
553
}
554
 
555
void PropertiesPalette_Group::handleGradientEdit()
556
{
557
        if (!m_ScMW || m_ScMW->scriptIsRunning())
558
                return;
559
        if ((m_haveDoc) && (m_haveItem))
560
        {
561
                m_ScMW->view->editStrokeGradient = 2;
562
                if (TpalGroup->gradEditButton->isChecked())
563
                        m_ScMW->view->requestMode(modeEditGradientVectors);
564
                else
565
                        m_ScMW->view->requestMode(modeNormal);
566
        }
567
}
568
 
569
void PropertiesPalette_Group::handleSpecialGradient(double x1, double y1, double x2, double y2, double fx, double fy, double sg, double sk)
570
{
571
        if (!m_ScMW || m_ScMW->scriptIsRunning())
572
                return;
573
        if ((m_haveDoc) && (m_haveItem))
574
        {
575
                QRectF upRect;
576
                m_item->GrMaskStartX = x1 / m_unitRatio;
577
                m_item->GrMaskStartY = y1 / m_unitRatio;
578
                m_item->GrMaskEndX = x2 / m_unitRatio;
579
                m_item->GrMaskEndY = y2 / m_unitRatio;
580
                m_item->GrMaskFocalX = fx / m_unitRatio;
581
                m_item->GrMaskFocalY = fy / m_unitRatio;
582
                m_item->GrMaskScale = sg;
583
                m_item->GrMaskSkew = sk;
584
                if ((m_item->GrMask == 1) || (m_item->GrMask == 4))
585
                {
586
                        m_item->GrMaskFocalX = m_item->GrMaskStartX;
587
                        m_item->GrMaskFocalY = m_item->GrMaskStartY;
588
                }
589
                m_item->update();
590
                upRect = QRectF(QPointF(m_item->GrMaskStartX, m_item->GrMaskStartY), QPointF(m_item->GrMaskEndX, m_item->GrMaskEndY));
591
                double radEnd = distance(m_item->GrMaskEndX - m_item->GrMaskStartX, m_item->GrMaskEndY - m_item->GrMaskStartY);
592
                double rotEnd = xy2Deg(m_item->GrMaskEndX - m_item->GrMaskStartX, m_item->GrMaskEndY - m_item->GrMaskStartY);
593
                QTransform m;
594
                m.translate(m_item->GrMaskStartX, m_item->GrMaskStartY);
595
                m.rotate(rotEnd);
596
                m.rotate(-90);
597
                m.rotate(m_item->GrMaskSkew);
598
                m.translate(radEnd * m_item->GrMaskScale, 0);
599
                QPointF shP = m.map(QPointF(0,0));
600
                upRect |= QRectF(shP, QPointF(m_item->GrMaskEndX, m_item->GrMaskEndY)).normalized();
601
                upRect |= QRectF(shP, QPointF(m_item->GrMaskStartX, m_item->GrMaskStartY)).normalized();
602
                upRect |= QRectF(shP, QPointF(0, 0)).normalized();
603
                upRect |= QRectF(shP, QPointF(m_item->width(), m_item->height())).normalized();
604
                upRect.translate(m_item->xPos(), m_item->yPos());
605
                m_doc->regionsChanged()->update(upRect.adjusted(-10.0, -10.0, 10.0, 10.0));
606
                emit DocChanged();
607
        }
608
}
609
 
15661 jghali 610
void PropertiesPalette_Group::handleShapeEdit()
15600 jghali 611
{
612
        if (!m_ScMW || m_ScMW->scriptIsRunning())
613
                return;
614
        if ((m_haveDoc) && (m_haveItem))
615
        {
616
                m_tmpSelection->clear();
617
                m_tmpSelection->copy(*m_doc->m_Selection, true);
618
                m_doc->m_Selection->clear();
619
                m_doc->m_Selection->addItem(m_item);
620
                m_item->isSingleSel = true;
621
                m_item->update();
622
                m_ScMW->view->requestMode(modeEditClip);
15661 jghali 623
                connect(m_ScMW->nodePalette, SIGNAL(paletteClosed()), this, SLOT(handleShapeEditEnded()));
15600 jghali 624
                emit shapeEditStarted();
625
        }
626
}
627
 
15661 jghali 628
void PropertiesPalette_Group::handleShapeEditEnded()
629
{
630
        disconnect(m_ScMW->nodePalette, SIGNAL(paletteClosed()), this, SLOT(handleShapeEditEnded()));
631
        if ((m_haveDoc) && (m_haveItem))
632
        {
633
                if (m_tmpSelection->count() > 0)
634
                {
635
                        m_doc->m_Selection->copy(*m_tmpSelection, false);
636
                        m_doc->m_Selection->connectItemToGUI();
637
                }
638
                m_tmpSelection->clear();
639
        }
640
}
641
 
15600 jghali 642
void PropertiesPalette_Group::changeEvent(QEvent *e)
643
{
644
        if (e->type() == QEvent::LanguageChange)
645
        {
646
                languageChange();
647
                return;
648
        }
649
        QWidget::changeEvent(e);
650
}
651
 
652
 
653
void PropertiesPalette_Group::languageChange()
654
{
655
        EditShape2->setText( tr("&Edit..."));
656
        SRect2->setText( tr("Shape:"));
657
 
658
        textFlowOptions2->setTitle( tr("Text &Flow Around Frame"));
659
        textFlowDisabled2->setText( tr("Disabled"));
660
        textFlowUsesFrameShape2->setText( tr("Use Frame &Shape"));
661
        textFlowUsesBoundingBox2->setText( tr("Use &Bounding Box"));
662
        textFlowUsesContourLine2->setText( tr("&Use Contour Line"));
663
        textFlowUsesImageClipping2->setText( tr("Use Image Clip Path"));
664
 
665
        textFlowDisabled2->setToolTip( tr("Disable text flow from lower frames around object"));
666
        textFlowUsesFrameShape2->setToolTip( tr("Use the frame shape for text flow of text frames below the object."));
667
        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>" );
668
        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>" );
669
        textFlowUsesImageClipping2->setToolTip(  "<qt>" + tr("Use the clipping path of the image") + "</qt>" );
670
}
671
 
672
void PropertiesPalette_Group::unitChange()
673
{
674
        if (!m_doc)
675
                return;
676
 
677
        double oldRatio = m_unitRatio;
678
        m_unitRatio = m_doc->unitRatio();
679
        m_unitIndex = m_doc->unitIndex();
680
 
681
        TpalGroup->blockSignals(true);
682
        TpalGroup->unitChange(oldRatio, m_unitRatio, m_doc->unitIndex());
683
        TpalGroup->blockSignals(false);
684
}