Subversion Repositories Scribus

Rev

Rev 24607 | Rev 24611 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
4430 cbradney 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
*/
10859 cbradney 7
 
8
#include <QEvent>
9
 
10862 cbradney 10
#include "nodeeditpalette.h"
16736 jghali 11
#include "pageitem.h"
16729 fschmid 12
#include "scpage.h"
23474 jghali 13
#include "scribusapp.h"
19093 craig 14
#include "scribusdoc.h"
22909 jghali 15
#include "scribusview.h" 
3934 cbradney 16
#include "selection.h"
1518 tsoots 17
#include "undomanager.h"
18
#include "undostate.h"
10862 cbradney 19
#include "units.h"
20185 craig 20
#include "iconmanager.h"
3 paul 21
 
24027 jghali 22
NodePalette::NodePalette( QWidget* parent) : ScrPaletteBase(parent, "nodePalette", false, Qt::WindowFlags())
3 paul 23
{
9441 fschmid 24
        QSize iconSize = QSize(22, 22);
24607 craig 25
        QSize buttonSize = QSize(24,24);
23474 jghali 26
        m_doc = nullptr;
27
        unitRatio = 1.0;
9041 fschmid 28
        vboxLayout = new QVBoxLayout(this);
24607 craig 29
        vboxLayout->setSpacing(6);
30
        vboxLayout->setContentsMargins(9, 9, 9, 9);
31
 
9041 fschmid 32
        MoveNode = new QToolButton(this);
9441 fschmid 33
        MoveNode->setIconSize(iconSize);
24607 craig 34
        MoveNode->setMinimumSize(buttonSize);
35
        MoveNode->setMaximumSize(buttonSize);
9041 fschmid 36
        MoveNode->setCheckable(true);
37
        MoveNode->setChecked(true);
3 paul 38
 
9041 fschmid 39
        AddNode = new QToolButton(this);
9441 fschmid 40
        AddNode->setIconSize(iconSize);
24607 craig 41
        AddNode->setMinimumSize(buttonSize);
42
        AddNode->setMaximumSize(buttonSize);
9041 fschmid 43
        AddNode->setEnabled(true);
44
        AddNode->setCheckable(true);
3 paul 45
 
9041 fschmid 46
        DeleteNode = new QToolButton(this);
9441 fschmid 47
        DeleteNode->setIconSize(iconSize);
24607 craig 48
        DeleteNode->setMinimumSize(buttonSize);
49
        DeleteNode->setMaximumSize(buttonSize);
9041 fschmid 50
        DeleteNode->setEnabled(true);
51
        DeleteNode->setCheckable(true);
3 paul 52
 
9041 fschmid 53
        ResNode = new QToolButton(this);
9441 fschmid 54
        ResNode->setIconSize(iconSize);
24607 craig 55
        ResNode->setMinimumSize(buttonSize);
56
        ResNode->setMaximumSize(buttonSize);
9041 fschmid 57
        ResNode->setEnabled(true);
3 paul 58
 
9041 fschmid 59
        MoveControl = new QToolButton(this);
9441 fschmid 60
        MoveControl->setIconSize(iconSize);
24607 craig 61
        MoveControl->setMinimumSize(buttonSize);
62
        MoveControl->setMaximumSize(buttonSize);
9041 fschmid 63
        MoveControl->setCheckable(true);
64
 
65
        AsymMove = new QToolButton(this);
9441 fschmid 66
        AsymMove->setIconSize(iconSize);
24607 craig 67
        AsymMove->setMinimumSize(buttonSize);
68
        AsymMove->setMaximumSize(buttonSize);
9041 fschmid 69
        AsymMove->setEnabled(false);
70
        AsymMove->setCheckable(true);
71
 
72
        SymMove = new QToolButton(this);
9441 fschmid 73
        SymMove->setIconSize(iconSize);
24607 craig 74
        SymMove->setMinimumSize(buttonSize);
75
        SymMove->setMaximumSize(buttonSize);
9041 fschmid 76
        SymMove->setEnabled(false);
77
        SymMove->setCheckable(true);
78
 
79
        Res1Node = new QToolButton(this);
9441 fschmid 80
        Res1Node->setIconSize(iconSize);
24607 craig 81
        Res1Node->setMinimumSize(buttonSize);
82
        Res1Node->setMaximumSize(buttonSize);
9041 fschmid 83
        Res1Node->setEnabled(false);
84
 
85
        PolySplit = new QToolButton(this);
19606 craig 86
        PolySplit->setEnabled(false);
87
        PolySplit->setCheckable(true);
9441 fschmid 88
        PolySplit->setIconSize(iconSize);
24607 craig 89
        PolySplit->setMinimumSize(buttonSize);
90
        PolySplit->setMaximumSize(buttonSize);
9041 fschmid 91
 
92
        BezierClose = new QToolButton(this);
19606 craig 93
        BezierClose->setEnabled(false);
9441 fschmid 94
        BezierClose->setIconSize(iconSize);
24607 craig 95
        BezierClose->setMinimumSize(buttonSize);
96
        BezierClose->setMaximumSize(buttonSize);
3 paul 97
 
9041 fschmid 98
        PolyMirrorH = new QToolButton(this);
9441 fschmid 99
        PolyMirrorH->setIconSize(iconSize);
24607 craig 100
        PolyMirrorH->setMinimumSize(buttonSize);
101
        PolyMirrorH->setMaximumSize(buttonSize);
3 paul 102
 
9041 fschmid 103
        PolyMirrorV = new QToolButton(this);
9441 fschmid 104
        PolyMirrorV->setIconSize(iconSize);
24607 craig 105
        PolyMirrorV->setMinimumSize(buttonSize);
106
        PolyMirrorV->setMaximumSize(buttonSize);
3 paul 107
 
9041 fschmid 108
        PolyShearL = new QToolButton(this);
9441 fschmid 109
        PolyShearL->setIconSize(iconSize);
24607 craig 110
        PolyShearL->setMinimumSize(buttonSize);
111
        PolyShearL->setMaximumSize(buttonSize);
161 Franz 112
        PolyShearL->setAutoRepeat(true);
9041 fschmid 113
 
114
        PolyShearR = new QToolButton(this);
9441 fschmid 115
        PolyShearR->setIconSize(iconSize);
24607 craig 116
        PolyShearR->setMinimumSize(buttonSize);
117
        PolyShearR->setMaximumSize(buttonSize);
161 Franz 118
        PolyShearR->setAutoRepeat(true);
9041 fschmid 119
 
120
        PolyShearU = new QToolButton(this);
9441 fschmid 121
        PolyShearU->setIconSize(iconSize);
24607 craig 122
        PolyShearU->setMinimumSize(buttonSize);
123
        PolyShearU->setMaximumSize(buttonSize);
161 Franz 124
        PolyShearU->setAutoRepeat(true);
9041 fschmid 125
 
126
        PolyShearD = new QToolButton(this);
9441 fschmid 127
        PolyShearD->setIconSize(iconSize);
24607 craig 128
        PolyShearD->setMinimumSize(buttonSize);
129
        PolyShearD->setMaximumSize(buttonSize);
161 Franz 130
        PolyShearD->setAutoRepeat(true);
13 Franz 131
 
9041 fschmid 132
        RotateCCW = new QToolButton(this);
9441 fschmid 133
        RotateCCW->setIconSize(iconSize);
24607 craig 134
        RotateCCW->setMinimumSize(buttonSize);
135
        RotateCCW->setMaximumSize(buttonSize);
161 Franz 136
        RotateCCW->setAutoRepeat(true);
9041 fschmid 137
 
138
        RotateCW = new QToolButton(this);
9441 fschmid 139
        RotateCW->setIconSize(iconSize);
24607 craig 140
        RotateCW->setMinimumSize(buttonSize);
141
        RotateCW->setMaximumSize(buttonSize);
161 Franz 142
        RotateCW->setAutoRepeat(true);
9041 fschmid 143
 
10495 cbradney 144
        RotVal = new QSpinBox(this);
10427 cbradney 145
        RotVal->setMinimum(1);
146
        RotVal->setMaximum(180);
9041 fschmid 147
        RotVal->setValue(1);
343 Franz 148
        RotVal->setSuffix( QString::fromUtf8(" °"));
149
 
9041 fschmid 150
        Expand = new QToolButton(this);
9441 fschmid 151
        Expand->setIconSize(iconSize);
24607 craig 152
        Expand->setMinimumSize(buttonSize);
153
        Expand->setMaximumSize(buttonSize);
161 Franz 154
        Expand->setAutoRepeat(true);
9041 fschmid 155
 
156
        Shrink = new QToolButton(this);
9441 fschmid 157
        Shrink->setIconSize(iconSize);
24607 craig 158
        Shrink->setMinimumSize(buttonSize);
159
        Shrink->setMaximumSize(buttonSize);
4619 cbradney 160
        Shrink->setAutoRepeat(true);
9041 fschmid 161
 
10495 cbradney 162
        scalePercentage = new QSpinBox(this);
10427 cbradney 163
        scalePercentage->setMinimum(1);
164
        scalePercentage->setMaximum(100);
9041 fschmid 165
        scalePercentage->setValue(10);
166
 
167
        Enlarge = new QToolButton(this);
9441 fschmid 168
        Enlarge->setIconSize(iconSize);
24607 craig 169
        Enlarge->setMinimumSize(buttonSize);
170
        Enlarge->setMaximumSize(buttonSize);
4619 cbradney 171
        Enlarge->setAutoRepeat(true);
9041 fschmid 172
 
173
        Reduce = new QToolButton(this);
9441 fschmid 174
        Reduce->setIconSize(iconSize);
24607 craig 175
        Reduce->setMinimumSize(buttonSize);
176
        Reduce->setMaximumSize(buttonSize);
4619 cbradney 177
        Reduce->setAutoRepeat(true);
9041 fschmid 178
 
13257 jghali 179
        scaleDistance = new ScrSpinBox( 1, 16777215, this, 0);
24607 craig 180
        scaleDistance->setMaximumSize(114, 16777215); // ScrSpinBox is bigger for 4px than expected
13257 jghali 181
        scaleDistance->setValues(-16777215, 16777215, 2, 30);
132 Franz 182
 
24607 craig 183
        gridLayout = new QGridLayout();
184
        gridLayout->setSpacing(6);
185
        gridLayout->setContentsMargins(0, 0, 0, 0);
24609 craig 186
        gridLayout->addWidget(MoveNode,        0, 1, 1, 1);
187
        gridLayout->addWidget(AddNode,         0, 2, 1, 1);
188
        gridLayout->addWidget(DeleteNode,      0, 3, 1, 1);
189
        gridLayout->addWidget(MoveControl,     0, 4, 1, 1);
190
        gridLayout->addWidget(AsymMove,        1, 1, 1, 1);
191
        gridLayout->addWidget(SymMove,         1, 2, 1, 1);
192
        gridLayout->addWidget(ResNode,         1, 3, 1, 1);
193
        gridLayout->addWidget(Res1Node,        1, 4, 1, 1);
194
        gridLayout->addWidget(PolySplit,       2, 1, 1, 1);
195
        gridLayout->addWidget(BezierClose,     2, 2, 1, 1);
196
        gridLayout->addWidget(PolyMirrorH,     2, 3, 1, 1);
197
        gridLayout->addWidget(PolyMirrorV,     2, 4, 1, 1);
198
        gridLayout->addWidget(PolyShearL,      3, 1, 1, 1);
199
        gridLayout->addWidget(PolyShearR,      3, 2, 1, 1);
200
        gridLayout->addWidget(PolyShearU,      3, 3, 1, 1);
201
        gridLayout->addWidget(PolyShearD,      3, 4, 1, 1);
202
        gridLayout->addWidget(RotVal,          4, 0, 1, 4);
203
        gridLayout->addWidget(RotateCCW,       4, 4, 1, 1);
204
        gridLayout->addWidget(RotateCW,        4, 5, 1, 1);
205
        gridLayout->addWidget(scalePercentage, 5, 0, 1, 4);
206
        gridLayout->addWidget(Expand,          5, 4, 1, 1);
207
        gridLayout->addWidget(Shrink,          5, 5, 1, 1);
208
        gridLayout->addWidget(scaleDistance,   6, 0, 1, 4);
209
        gridLayout->addWidget(Enlarge,         6, 4, 1, 1);
210
        gridLayout->addWidget(Reduce,          6, 5, 1, 1);
24607 craig 211
        vboxLayout->addLayout(gridLayout);
212
 
9041 fschmid 213
        gridLayout2 = new QGridLayout();
24607 craig 214
        gridLayout2->setSpacing(6);
24545 craig 215
        gridLayout2->setContentsMargins(0, 0, 0, 0);
13 Franz 216
 
24607 craig 217
        QSpacerItem* spacer = new QSpacerItem( 6, 6, QSizePolicy::Fixed, QSizePolicy::Fixed );
11145 fschmid 218
        vboxLayout->addItem(spacer);
21262 fschmid 219
 
11145 fschmid 220
        AbsMode = new QGroupBox( "&Absolute Coordinates", this );
24607 craig 221
        AbsMode->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Preferred));
11145 fschmid 222
        AbsMode->setCheckable(true);
161 Franz 223
        AbsMode->setChecked(false);
11145 fschmid 224
        vboxLayout1 = new QVBoxLayout(AbsMode);
24607 craig 225
        vboxLayout1->setSpacing(6);
226
        vboxLayout1->setContentsMargins(9, 9, 9, 9);
11145 fschmid 227
        absToCanvas = new QRadioButton( tr("to Canvas"), AbsMode);
228
        vboxLayout1->addWidget(absToCanvas);
229
        absToPage = new QRadioButton( tr("to Page"), AbsMode);
230
        vboxLayout1->addWidget(absToPage);
231
        absToCanvas->setChecked(true);
24607 craig 232
        vboxLayout->addWidget(AbsMode);
97 Franz 233
 
24607 craig 234
        gridLayout2 = new QGridLayout();
235
        gridLayout2->setSpacing(6);
236
        gridLayout2->setContentsMargins(0, 0, 0, 0);
237
        gridLayout2->setColumnStretch(0, 0);
238
        gridLayout2->setColumnStretch(1, 1);
239
 
9041 fschmid 240
        TextLabel1 = new QLabel(this);
24607 craig 241
        gridLayout2->addWidget(TextLabel1, 0, 0, 1, 1);
9041 fschmid 242
 
11724 fschmid 243
        XSpin = new ScrSpinBox( 0, 16777215, this, 2 );
24607 craig 244
        XSpin->setSizePolicy(QSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed));
360 Franz 245
        XSpin->setEnabled(false);
24607 craig 246
        gridLayout2->addWidget(XSpin, 0, 1, 1, 1);
9041 fschmid 247
 
248
        TextLabel2 = new QLabel(this);
24607 craig 249
        gridLayout2->addWidget(TextLabel2, 1, 0, 1, 1);
9041 fschmid 250
 
11724 fschmid 251
        YSpin = new ScrSpinBox( 0, 16777215, this, 2 );
24607 craig 252
        YSpin->setSizePolicy(QSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed));
161 Franz 253
        YSpin->setEnabled(false);
24607 craig 254
        gridLayout2->addWidget(YSpin, 1, 1, 1, 1);
255
        vboxLayout->addLayout(gridLayout2);
256
 
9041 fschmid 257
        TextLabel1->setBuddy(XSpin);
258
        TextLabel2->setBuddy(YSpin);
3 paul 259
 
9041 fschmid 260
        EditCont = new QCheckBox(this);
340 Franz 261
        EditCont->setChecked(false);
24607 craig 262
        vboxLayout->addWidget(EditCont);
340 Franz 263
 
21291 fschmid 264
        PreviewMode = new QCheckBox(this);
265
        PreviewMode->setChecked(false);
24607 craig 266
        vboxLayout->addWidget(PreviewMode);
21291 fschmid 267
 
9041 fschmid 268
        ResetCont = new QPushButton(this);
269
        ResetCont->setEnabled(false);
24607 craig 270
        vboxLayout->addWidget(ResetCont);
343 Franz 271
 
9041 fschmid 272
        ResetContClip = new QPushButton(this);
273
        ResetContClip->setEnabled(true);
9441 fschmid 274
        ResetContClip->hide();
24607 craig 275
        vboxLayout->addWidget(ResetContClip);
9041 fschmid 276
 
12681 fschmid 277
        ResetShape2Clip = new QPushButton(this);
278
        ResetShape2Clip->setEnabled(true);
279
        ResetShape2Clip->hide();
24607 craig 280
        vboxLayout->addWidget(ResetShape2Clip);
12681 fschmid 281
 
18040 fschmid 282
        resetDefaultButton = new QPushButton(this);
283
        resetDefaultButton->setEnabled(true);
24607 craig 284
        vboxLayout->addWidget(resetDefaultButton);
18040 fschmid 285
 
24607 craig 286
        hboxLayout = new QHBoxLayout(this);
287
        hboxLayout->setSpacing(6);
288
        hboxLayout->setContentsMargins(0, 0, 0, 0);
23054 craig 289
        editEditButton = new QPushButton(IconManager::instance().loadIcon("22/exit.png"), tr("OK"), this);
18040 fschmid 290
        editEditButton->setEnabled(true);
4866 cbradney 291
        editEditButton->setDefault(true);
24607 craig 292
        hboxLayout->addWidget(editEditButton);
18040 fschmid 293
        cancelEditButton = new QPushButton( tr("Cancel"), this);
294
        cancelEditButton->setEnabled(true);
24607 craig 295
        hboxLayout->addWidget(cancelEditButton);
296
        vboxLayout->addLayout(hboxLayout);
18040 fschmid 297
 
9441 fschmid 298
        resize(QSize(170, 380).expandedTo(minimumSizeHint()));
24609 craig 299
        layout()->setSizeConstraint(QLayout::SetFixedSize);
24607 craig 300
        iconSetChange();
2210 cbradney 301
        languageChange();
23474 jghali 302
 
303
        connect(ScQApp, SIGNAL(iconSetChanged()), this, SLOT(iconSetChange()));
6531 cbradney 304
}
305
 
306
void NodePalette::connectSignals()
307
{
218 Franz 308
        // signals and slots connections
4866 cbradney 309
        connect(editEditButton, SIGNAL(clicked()), this, SLOT(EndEdit()));
18040 fschmid 310
        connect(cancelEditButton, SIGNAL(clicked()), this, SLOT(CancelEdit()));
311
        connect(resetDefaultButton, SIGNAL(clicked()), this, SLOT(ResetToEditDefaults()));
218 Franz 312
        connect(DeleteNode, SIGNAL(clicked()), this, SLOT(DelN()));
313
        connect(AddNode, SIGNAL(clicked()), this, SLOT(AddN()));
314
        connect(MoveNode, SIGNAL(clicked()), this, SLOT(MoveN()));
315
        connect(AsymMove, SIGNAL(clicked()), this, SLOT(SetAsym()));
316
        connect(SymMove, SIGNAL(clicked()), this, SLOT(SetSym()));
317
        connect(ResNode, SIGNAL(clicked()), this, SLOT(ResetControl()));
318
        connect(Res1Node, SIGNAL(clicked()), this, SLOT(Reset1Control()));
319
        connect(BezierClose, SIGNAL(clicked()), this, SLOT(CloseBezier()));
320
        connect(PolySplit, SIGNAL(clicked()), this, SLOT(SplitPoly()));
321
        connect(MoveControl, SIGNAL(clicked()), this, SLOT(MoveK()));
8713 fschmid 322
        connect(XSpin, SIGNAL(valueChanged(double)), this, SLOT(MovePoint()));
323
        connect(YSpin, SIGNAL(valueChanged(double)), this, SLOT(MovePoint()));
218 Franz 324
        connect(PolyMirrorH, SIGNAL(clicked()), this, SLOT(MirrorH()));
325
        connect(PolyMirrorV, SIGNAL(clicked()), this, SLOT(MirrorV()));
21309 jghali 326
        connect(PolyShearR, SIGNAL(clicked()), this, SLOT(ShearR()));
327
        connect(PolyShearL, SIGNAL(clicked()), this, SLOT(ShearL()));
218 Franz 328
        connect(PolyShearU, SIGNAL(clicked()), this, SLOT(ShearU()));
329
        connect(PolyShearD, SIGNAL(clicked()), this, SLOT(ShearD()));
330
        connect(RotateCCW, SIGNAL(clicked()), this, SLOT(doRotCCW()));
331
        connect(RotateCW, SIGNAL(clicked()), this, SLOT(doRotCW()));
4619 cbradney 332
        connect(Shrink, SIGNAL(clicked()), this, SLOT(doShrink()));
218 Franz 333
        connect(Expand, SIGNAL(clicked()), this, SLOT(doExpand()));
4619 cbradney 334
        connect(Reduce, SIGNAL(clicked()), this, SLOT(doReduce()));
9041 fschmid 335
        connect(Enlarge, SIGNAL(clicked()), this, SLOT(doEnlarge()));
161 Franz 336
        connect(AbsMode, SIGNAL(clicked()), this, SLOT(ToggleAbsMode()));
11145 fschmid 337
        connect(absToCanvas, SIGNAL(clicked()), this, SLOT(ToggleAbsMode()));
338
        connect(absToPage, SIGNAL(clicked()), this, SLOT(ToggleAbsMode()));
340 Franz 339
        connect(EditCont, SIGNAL(clicked()), this, SLOT(ToggleConMode()));
343 Franz 340
        connect(ResetCont, SIGNAL(clicked()), this, SLOT(ResetContour()));
8445 fschmid 341
        connect(ResetContClip, SIGNAL(clicked()), this, SLOT(ResetContourToImageClip()));
12681 fschmid 342
        connect(ResetShape2Clip, SIGNAL(clicked()), this, SLOT(ResetShapeToImageClip()));
21262 fschmid 343
        connect(PreviewMode, SIGNAL(clicked()), this, SLOT(TogglePreview()));
3 paul 344
}
345
 
6531 cbradney 346
void NodePalette::disconnectSignals()
347
{
348
        // signals and slots disconnetions
349
        disconnect(editEditButton, SIGNAL(clicked()), this, SLOT(EndEdit()));
18040 fschmid 350
        disconnect(cancelEditButton, SIGNAL(clicked()), this, SLOT(CancelEdit()));
351
        disconnect(resetDefaultButton, SIGNAL(clicked()), this, SLOT(ResetToEditDefaults()));
6531 cbradney 352
        disconnect(DeleteNode, SIGNAL(clicked()), this, SLOT(DelN()));
353
        disconnect(AddNode, SIGNAL(clicked()), this, SLOT(AddN()));
354
        disconnect(MoveNode, SIGNAL(clicked()), this, SLOT(MoveN()));
355
        disconnect(AsymMove, SIGNAL(clicked()), this, SLOT(SetAsym()));
356
        disconnect(SymMove, SIGNAL(clicked()), this, SLOT(SetSym()));
357
        disconnect(ResNode, SIGNAL(clicked()), this, SLOT(ResetControl()));
358
        disconnect(Res1Node, SIGNAL(clicked()), this, SLOT(Reset1Control()));
359
        disconnect(BezierClose, SIGNAL(clicked()), this, SLOT(CloseBezier()));
360
        disconnect(PolySplit, SIGNAL(clicked()), this, SLOT(SplitPoly()));
361
        disconnect(MoveControl, SIGNAL(clicked()), this, SLOT(MoveK()));
8713 fschmid 362
        disconnect(XSpin, SIGNAL(valueChanged(double)), this, SLOT(MovePoint()));
363
        disconnect(YSpin, SIGNAL(valueChanged(double)), this, SLOT(MovePoint()));
6531 cbradney 364
        disconnect(PolyMirrorH, SIGNAL(clicked()), this, SLOT(MirrorH()));
365
        disconnect(PolyMirrorV, SIGNAL(clicked()), this, SLOT(MirrorV()));
366
        disconnect(PolyShearR, SIGNAL(clicked()), this, SLOT(ShearR()));
367
        disconnect(PolyShearL, SIGNAL(clicked()), this, SLOT(ShearL()));
368
        disconnect(PolyShearU, SIGNAL(clicked()), this, SLOT(ShearU()));
369
        disconnect(PolyShearD, SIGNAL(clicked()), this, SLOT(ShearD()));
370
        disconnect(RotateCCW, SIGNAL(clicked()), this, SLOT(doRotCCW()));
371
        disconnect(RotateCW, SIGNAL(clicked()), this, SLOT(doRotCW()));
372
        disconnect(Shrink, SIGNAL(clicked()), this, SLOT(doShrink()));
373
        disconnect(Expand, SIGNAL(clicked()), this, SLOT(doExpand()));
374
        disconnect(Reduce, SIGNAL(clicked()), this, SLOT(doReduce()));
9041 fschmid 375
        disconnect(Enlarge, SIGNAL(clicked()), this, SLOT(doEnlarge()));
6531 cbradney 376
        disconnect(ResetCont, SIGNAL(clicked()), this, SLOT(ResetContour()));
8445 fschmid 377
        disconnect(ResetContClip, SIGNAL(clicked()), this, SLOT(ResetContourToImageClip()));
12681 fschmid 378
        disconnect(ResetShape2Clip, SIGNAL(clicked()), this, SLOT(ResetShapeToImageClip()));
21262 fschmid 379
        disconnect(PreviewMode, SIGNAL(clicked()), this, SLOT(TogglePreview()));
6531 cbradney 380
}
381
 
456 fschmid 382
void NodePalette::setDoc(ScribusDoc *dc, ScribusView *vi)
3 paul 383
{
18330 jghali 384
        m_doc = dc;
385
        m_view = vi;
6531 cbradney 386
 
4619 cbradney 387
        unitChange();
341 Franz 388
        disconnect(EditCont, SIGNAL(clicked()), this, SLOT(ToggleConMode()));
97 Franz 389
        disconnect(AbsMode, SIGNAL(clicked()), this, SLOT(ToggleAbsMode()));
22603 craig 390
        if (m_doc!=nullptr)
6531 cbradney 391
        {
18330 jghali 392
                YSpin->setNewUnit(m_doc->unitIndex());
393
                XSpin->setNewUnit(m_doc->unitIndex());
6531 cbradney 394
        }
97 Franz 395
        AbsMode->setChecked(false);
341 Franz 396
        EditCont->setChecked(false);
22790 jghali 397
        if (m_doc == nullptr)
6531 cbradney 398
                disconnectSignals();
399
        else
400
                connectSignals();
3 paul 401
}
402
 
403
void NodePalette::SplitPoly()
404
{
22790 jghali 405
        if (m_doc == nullptr)
6531 cbradney 406
                return;
3 paul 407
        MoveN();
19946 craig 408
        m_doc->nodeEdit.setSubMode(NodeEditContext::SPLIT_PATH);
9041 fschmid 409
        PolySplit->setChecked(true);
3 paul 410
}
411
 
412
void NodePalette::IsOpen()
413
{
22790 jghali 414
        if (m_doc == nullptr)
6531 cbradney 415
                return;
9041 fschmid 416
        PolySplit->setChecked(false);
3 paul 417
        BezierClose->setEnabled(true);
418
        PolySplit->setEnabled(true);
340 Franz 419
        EditCont->setEnabled(false);
3 paul 420
}
421
 
422
void NodePalette::PolyStatus(int typ, uint size)
423
{
22790 jghali 424
        if (m_doc == nullptr)
6531 cbradney 425
                return;
80 Franz 426
        bool setter;
3 paul 427
        switch (typ)
161 Franz 428
        {
16105 fschmid 429
                case PageItem::Polygon:
430
                        PolySplit->setEnabled(true);
431
                        BezierClose->setEnabled(false);
432
                        break;
433
                case PageItem::PolyLine:
22639 craig 434
                        setter = size > 7;
16105 fschmid 435
                        BezierClose->setEnabled(setter);
436
                        PolySplit->setEnabled(setter);
437
                        break;
438
                default:
439
                        BezierClose->setEnabled(false);
440
                        PolySplit->setEnabled(false);
441
                        break;
161 Franz 442
        }
3 paul 443
}
444
 
445
void NodePalette::CloseBezier()
446
{
22790 jghali 447
        if (m_doc == nullptr)
6531 cbradney 448
                return;
3 paul 449
        MoveN();
18330 jghali 450
        PageItem *currItem = m_doc->m_Selection->itemAt(0);
451
        PageItem* newItem = m_doc->convertItemTo(currItem, PageItem::Polygon);
452
        m_doc->m_Selection->clear();
453
        m_doc->m_Selection->addItem(newItem);
11089 fschmid 454
        newItem->update();
3 paul 455
        BezierClose->setEnabled(false);
456
        PolySplit->setEnabled(true);
340 Franz 457
        EditCont->setEnabled(true);
3 paul 458
}
459
 
132 Franz 460
void NodePalette::doRotCCW()
461
{
22790 jghali 462
        if (m_doc == nullptr)
463
                return;
464
        m_view->TransformPoly(0, RotVal->value());
132 Franz 465
}
466
 
467
void NodePalette::doRotCW()
468
{
22790 jghali 469
        if (m_doc == nullptr)
470
                return;
471
        m_view->TransformPoly(1, RotVal->value());
132 Franz 472
}
473
 
4619 cbradney 474
void NodePalette::doShrink()
132 Franz 475
{
22790 jghali 476
        if (m_doc == nullptr)
477
                return;
478
        m_view->TransformPoly(2, 1, scalePercentage->value());
132 Franz 479
}
480
 
481
void NodePalette::doExpand()
482
{
22790 jghali 483
        if (m_doc == nullptr)
484
                return;
485
        m_view->TransformPoly(3, 1, scalePercentage->value());
132 Franz 486
}
487
 
4619 cbradney 488
void NodePalette::doReduce()
489
{
22790 jghali 490
        if (m_doc == nullptr)
491
                return;
492
        m_view->TransformPoly(8, 1, value2pts(scaleDistance->value(),m_doc->unitIndex()));
4619 cbradney 493
}
494
 
495
void NodePalette::doEnlarge()
496
{
22790 jghali 497
        if (m_doc == nullptr)
498
                return;
499
        m_view->TransformPoly(9, 1, value2pts(scaleDistance->value(),m_doc->unitIndex()));
4619 cbradney 500
}
501
 
13 Franz 502
void NodePalette::ShearR()
503
{
22790 jghali 504
        if (m_doc == nullptr)
505
                return;
506
        m_view->TransformPoly(4);
13 Franz 507
}
508
 
509
void NodePalette::ShearL()
510
{
22790 jghali 511
        if (m_doc == nullptr)
512
                return;
513
        m_view->TransformPoly(5);
13 Franz 514
}
515
 
516
void NodePalette::ShearU()
517
{
22790 jghali 518
        if (m_doc == nullptr)
519
                return;
520
        m_view->TransformPoly(6);
13 Franz 521
}
522
 
523
void NodePalette::ShearD()
524
{
22790 jghali 525
        if (m_doc == nullptr)
526
                return;
527
        m_view->TransformPoly(7);
13 Franz 528
}
529
 
3 paul 530
void NodePalette::MirrorH()
531
{
22790 jghali 532
        if (m_doc == nullptr)
533
                return;
534
        m_doc->MirrorPolyH(m_doc->m_Selection->itemAt(0));
3 paul 535
}
536
 
537
void NodePalette::MirrorV()
538
{
22790 jghali 539
        if (m_doc == nullptr)
540
                return;
541
        m_doc->MirrorPolyV(m_doc->m_Selection->itemAt(0));
3 paul 542
}
543
 
544
void NodePalette::ResetControl()
545
{
22790 jghali 546
        if (m_doc == nullptr)
547
                return;
548
        m_doc->nodeEdit.resetControl(m_doc->m_Selection->itemAt(0));
3 paul 549
}
550
 
551
void NodePalette::Reset1Control()
552
{
22790 jghali 553
        if (m_doc == nullptr)
554
                return;
555
        m_doc->nodeEdit.reset1Control(m_doc->m_Selection->itemAt(0));
3 paul 556
}
557
 
343 Franz 558
void NodePalette::ResetContour()
559
{
22790 jghali 560
        if (m_doc == nullptr)
561
                return;
562
 
563
        PageItem *currItem = m_doc->m_Selection->itemAt(0);
564
        if (UndoManager::undoEnabled())
343 Franz 565
        {
22790 jghali 566
                ScItemState<FPointArray> *is = new ScItemState<FPointArray>(Um::ResetContourLine, "",Um::IBorder);
567
                is->set("RESET_CONTOUR");
568
                is->setItem(m_doc->m_Selection->itemAt(0)->ContourLine);
569
                UndoManager::instance()->action(currItem, is);
343 Franz 570
        }
22790 jghali 571
        //FIXME make an internal item copy poline to contourline member
572
        currItem->ContourLine = currItem->PoLine.copy();
573
        currItem->ClipEdited = true;
574
        m_doc->regionsChanged()->update(QRectF());
575
        emit DocChanged();
343 Franz 576
}
577
 
8445 fschmid 578
void NodePalette::ResetContourToImageClip()
579
{
22790 jghali 580
        if (m_doc == nullptr)
581
                return;
582
 
583
        PageItem *currItem = m_doc->m_Selection->itemAt(0);
584
        currItem->ContourLine = currItem->imageClip.copy();
585
        currItem->ClipEdited = true;
586
        m_doc->regionsChanged()->update(QRectF());
587
        emit DocChanged();
8445 fschmid 588
}
589
 
12681 fschmid 590
void NodePalette::ResetShapeToImageClip()
591
{
22790 jghali 592
        if (m_doc == nullptr)
593
                return;
594
 
595
        PageItem *currItem = m_doc->m_Selection->itemAt(0);
596
        currItem->PoLine = currItem->imageClip.copy();
597
        currItem->ClipEdited = true;
598
        currItem->FrameType = 3;
599
        m_doc->adjustItemSize(currItem);
600
        if (currItem->itemType() == PageItem::PathText)
601
                currItem->updatePolyClip();
602
        m_doc->regionsChanged()->update(QRectF());
603
        emit DocChanged();
12681 fschmid 604
}
605
 
3 paul 606
void NodePalette::MovePoint()
607
{
22790 jghali 608
        if (m_doc == nullptr)
6531 cbradney 609
                return;
19946 craig 610
        if (m_doc->nodeEdit.submode() == NodeEditContext::MOVE_POINT)
161 Franz 611
        {
18330 jghali 612
                PageItem *currItem = m_doc->m_Selection->itemAt(0);
11145 fschmid 613
                FPoint zp;
18330 jghali 614
                FPoint np(XSpin->value()/m_doc->unitRatio(), YSpin->value()/m_doc->unitRatio());
97 Franz 615
                if (AbsMode->isChecked())
11145 fschmid 616
                {
617
                        if (absToCanvas->isChecked())
12681 fschmid 618
                                zp = FPoint(currItem->xPos(), currItem->yPos());
11145 fschmid 619
                        else
18330 jghali 620
                                zp = FPoint(currItem->xPos() - m_doc->currentPage()->xOffset(), currItem->yPos() - m_doc->currentPage()->yOffset());
97 Franz 621
                        np -= zp;
11145 fschmid 622
                }
18330 jghali 623
                m_doc->nodeEdit.moveClipPoint(currItem, np);
23277 jghali 624
                m_doc->adjustItemSize(currItem, true);
17260 fschmid 625
                if (currItem->itemType() == PageItem::PathText)
626
                        currItem->updatePolyClip();
18330 jghali 627
                m_doc->regionsChanged()->update(QRectF());
4078 fschmid 628
                emit DocChanged();
161 Franz 629
        }
3 paul 630
}
631
 
632
void NodePalette::SetSym()
633
{
22603 craig 634
        if (m_doc != nullptr)
19946 craig 635
                m_doc->nodeEdit.setMoveSym(true);
9041 fschmid 636
        SymMove->setChecked(true);
637
        AsymMove->setChecked(false);
19606 craig 638
        PolySplit->setChecked(false);
3 paul 639
}
640
 
641
void NodePalette::SetAsym()
642
{
22603 craig 643
        if (m_doc != nullptr)
19946 craig 644
                m_doc->nodeEdit.setMoveSym(false);
9041 fschmid 645
        SymMove->setChecked(false);
646
        AsymMove->setChecked(true);
19606 craig 647
        PolySplit->setChecked(false);
3 paul 648
}
649
 
80 Franz 650
void NodePalette::SetXY(double x, double y)
3 paul 651
{
22790 jghali 652
        if (m_doc == nullptr)
6531 cbradney 653
                return;
3934 cbradney 654
        FPoint zp(0.0, 0.0);
8713 fschmid 655
        disconnect(XSpin, SIGNAL(valueChanged(double)), this, SLOT(MovePoint()));
656
        disconnect(YSpin, SIGNAL(valueChanged(double)), this, SLOT(MovePoint()));
97 Franz 657
        if (AbsMode->isChecked())
11145 fschmid 658
        {
659
                if (absToCanvas->isChecked())
18330 jghali 660
                        zp = FPoint(m_doc->m_Selection->itemAt(0)->xPos(), m_doc->m_Selection->itemAt(0)->yPos());
11145 fschmid 661
                else
18330 jghali 662
                        zp = FPoint(m_doc->m_Selection->itemAt(0)->xPos() - m_doc->currentPage()->xOffset(), m_doc->m_Selection->itemAt(0)->yPos() - m_doc->currentPage()->yOffset());
11145 fschmid 663
        }
18330 jghali 664
        XSpin->setValue((x + zp.x()) * m_doc->unitRatio());
665
        YSpin->setValue((y + zp.y()) * m_doc->unitRatio());
8713 fschmid 666
        connect(XSpin, SIGNAL(valueChanged(double)), this, SLOT(MovePoint()));
667
        connect(YSpin, SIGNAL(valueChanged(double)), this, SLOT(MovePoint()));
3 paul 668
}
669
 
97 Franz 670
void NodePalette::ToggleAbsMode()
671
{
22603 craig 672
        if (m_doc == nullptr)
6531 cbradney 673
                return;
11145 fschmid 674
        FPoint zp(0.0, 0.0);
8713 fschmid 675
        disconnect(XSpin, SIGNAL(valueChanged(double)), this, SLOT(MovePoint()));
676
        disconnect(YSpin, SIGNAL(valueChanged(double)), this, SLOT(MovePoint()));
11145 fschmid 677
        FPointArray Clip;
11151 fschmid 678
        FPoint np(0.0, 0.0);
11145 fschmid 679
        if (EditCont->isChecked())
18330 jghali 680
                Clip = m_doc->m_Selection->itemAt(0)->ContourLine;
11145 fschmid 681
        else
18330 jghali 682
                Clip = m_doc->m_Selection->itemAt(0)->PoLine;
22909 jghali 683
        if (m_doc->nodeEdit.selectionCount() != 0)
19946 craig 684
                np = Clip.point(m_doc->nodeEdit.selNode().at(0));
97 Franz 685
        if (AbsMode->isChecked())
11145 fschmid 686
        {
11724 fschmid 687
                XSpin->setMinimum(-16777215);
688
                YSpin->setMinimum(-16777215);
11145 fschmid 689
                if (absToCanvas->isChecked())
18330 jghali 690
                        zp = FPoint(m_doc->m_Selection->itemAt(0)->xPos(), m_doc->m_Selection->itemAt(0)->yPos());
11145 fschmid 691
                else
18330 jghali 692
                        zp = FPoint(m_doc->m_Selection->itemAt(0)->xPos() - m_doc->currentPage()->xOffset(), m_doc->m_Selection->itemAt(0)->yPos() - m_doc->currentPage()->yOffset());
11145 fschmid 693
        }
97 Franz 694
        else
11145 fschmid 695
        {
696
                XSpin->setMinimum(0);
697
                YSpin->setMinimum(0);
698
        }
18330 jghali 699
        XSpin->setValue((np.x() + zp.x()) * m_doc->unitRatio());
700
        YSpin->setValue((np.y() + zp.y()) * m_doc->unitRatio());
8713 fschmid 701
        connect(XSpin, SIGNAL(valueChanged(double)), this, SLOT(MovePoint()));
702
        connect(YSpin, SIGNAL(valueChanged(double)), this, SLOT(MovePoint()));
97 Franz 703
}
704
 
340 Franz 705
void NodePalette::ToggleConMode()
706
{
22790 jghali 707
        if (m_doc == nullptr)
708
                return;
709
 
8713 fschmid 710
        disconnect(XSpin, SIGNAL(valueChanged(double)), this, SLOT(MovePoint()));
711
        disconnect(YSpin, SIGNAL(valueChanged(double)), this, SLOT(MovePoint()));
22790 jghali 712
 
713
        m_doc->nodeEdit.setIsContourLine(EditCont->isChecked());
714
        m_doc->nodeEdit.setSubMode(NodeEditContext::MOVE_POINT);
715
        m_doc->nodeEdit.setClre(-1);
716
        m_doc->nodeEdit.setClre2(-1);
717
        m_doc->nodeEdit.setSegP1(-1);
718
        m_doc->nodeEdit.setSegP2(-1);
719
        if (EditCont->isChecked())
340 Franz 720
        {
22790 jghali 721
                BezierClose->setEnabled(false);
722
                PolySplit->setEnabled(false);
723
                ResetCont->setEnabled(true);
724
                ResetContClip->setEnabled(true);
725
                XSpin->setMinimum(-16777215);
726
                YSpin->setMinimum(-16777215);
727
        }
728
        else
729
        {
730
                BezierClose->setEnabled(false);
731
                PolySplit->setEnabled(true);
732
                ResetCont->setEnabled(false);
733
                ResetContClip->setEnabled(false);
734
                if (AbsMode->isChecked())
340 Franz 735
                {
11724 fschmid 736
                        XSpin->setMinimum(-16777215);
737
                        YSpin->setMinimum(-16777215);
340 Franz 738
                }
739
                else
740
                {
22790 jghali 741
                        XSpin->setMinimum(0);
742
                        YSpin->setMinimum(0);
340 Franz 743
                }
744
        }
22790 jghali 745
        m_view->DrawNew();
746
 
8713 fschmid 747
        connect(XSpin, SIGNAL(valueChanged(double)), this, SLOT(MovePoint()));
748
        connect(YSpin, SIGNAL(valueChanged(double)), this, SLOT(MovePoint()));
340 Franz 749
}
750
 
21262 fschmid 751
void NodePalette::TogglePreview()
752
{
22790 jghali 753
        if (m_doc == nullptr)
754
                return;
755
        m_doc->nodeEdit.setPreviewMode(PreviewMode->isChecked());
756
        m_doc->regionsChanged()->update(QRectF());
21262 fschmid 757
}
758
 
3 paul 759
void NodePalette::HaveNode(bool have, bool mov)
760
{
22790 jghali 761
        if (m_doc == nullptr)
6531 cbradney 762
                return;
22639 craig 763
        bool setter = have;
22909 jghali 764
        if (m_doc->nodeEdit.selectionCount() > 1)
12584 fschmid 765
        {
766
                XSpin->setEnabled(false);
767
                YSpin->setEnabled(false);
768
        }
769
        else
770
        {
771
                XSpin->setEnabled(setter);
772
                YSpin->setEnabled(setter);
773
        }
22639 craig 774
        if (setter)
80 Franz 775
        {
19946 craig 776
                if (m_doc->nodeEdit.edPoints())
218 Franz 777
                        ResNode->setEnabled(setter);
3 paul 778
                else
218 Franz 779
                        Res1Node->setEnabled(setter);
80 Franz 780
        }
3 paul 781
        else
80 Franz 782
        {
218 Franz 783
                ResNode->setEnabled(setter);
784
                Res1Node->setEnabled(setter);
80 Franz 785
        }
19946 craig 786
        if (m_doc->nodeEdit.submode() == NodeEditContext::MOVE_POINT)
3586 fschmid 787
        {
788
                disconnect(AsymMove, SIGNAL(clicked()), this, SLOT(SetAsym()));
789
                disconnect(SymMove, SIGNAL(clicked()), this, SLOT(SetSym()));
790
                if (mov)
9041 fschmid 791
                {
792
                        SymMove->setChecked(true);
793
                        AsymMove->setChecked(false);
794
                }
3586 fschmid 795
                else
9041 fschmid 796
                {
797
                        AsymMove->setChecked(true);
798
                        SymMove->setChecked(false);
799
                }
3586 fschmid 800
                connect(AsymMove, SIGNAL(clicked()), this, SLOT(SetAsym()));
801
                connect(SymMove, SIGNAL(clicked()), this, SLOT(SetSym()));
802
        }
19946 craig 803
        if (m_doc->nodeEdit.submode() == NodeEditContext::DEL_POINT)
3586 fschmid 804
        {
805
                uint cc;
806
                bool leaveEd = false;
18330 jghali 807
                PageItem*currItem=m_doc->m_Selection->itemAt(0);
19946 craig 808
                if (m_doc->nodeEdit.isContourLine())
3934 cbradney 809
                        cc = currItem->ContourLine.size();
3586 fschmid 810
                else
3934 cbradney 811
                        cc = currItem->PoLine.size();
23794 craig 812
                if (currItem->isPolyLine())
3586 fschmid 813
                {
814
                        if (cc < 5)
815
                                leaveEd = true;
816
                }
817
                else
818
                {
819
                        if (cc < 13)
820
                                leaveEd = true;
821
                }
822
                if (leaveEd)
823
                {
824
                        MoveN();
825
                        MoveControl->setEnabled(true);
826
                }
827
        }
3 paul 828
}
829
 
830
void NodePalette::MoveK()
831
{
22790 jghali 832
        if (m_doc == nullptr)
6531 cbradney 833
                return;
19946 craig 834
        m_doc->nodeEdit.setSubMode(NodeEditContext::MOVE_POINT);
835
        m_doc->nodeEdit.setEdPoints(false);
836
        m_doc->nodeEdit.setClre(-1);
837
        m_doc->nodeEdit.setClre2(-1);
838
        m_doc->nodeEdit.setSegP1(-1);
839
        m_doc->nodeEdit.setSegP2(-1);
18330 jghali 840
        if (m_doc->m_Selection->count() > 0)
841
                m_doc->m_Selection->itemAt(0)->update();
161 Franz 842
        SymMove->setEnabled(true);
843
        AsymMove->setEnabled(true);
18844 jghali 844
        Res1Node->setEnabled(false);
161 Franz 845
        ResNode->setEnabled(false);
9041 fschmid 846
        AddNode->setEnabled(false);
847
        DeleteNode->setEnabled(false);
848
        MoveNode->setChecked(false);
849
        MoveControl->setChecked(true);
850
        DeleteNode->setChecked(false);
851
        AddNode->setChecked(false);
19606 craig 852
        PolySplit->setChecked(false);
3 paul 853
}
854
 
855
void NodePalette::MoveN()
856
{
22790 jghali 857
        if (m_doc == nullptr)
6531 cbradney 858
                return;
19946 craig 859
        m_doc->nodeEdit.setSubMode(NodeEditContext::MOVE_POINT);
860
        m_doc->nodeEdit.setEdPoints(true);
861
        m_doc->nodeEdit.setClre(-1);
862
        m_doc->nodeEdit.setClre2(-1);
863
        m_doc->nodeEdit.setSegP1(-1);
864
        m_doc->nodeEdit.setSegP2(-1);
18330 jghali 865
        if (m_doc->m_Selection->count() > 0)
866
                m_doc->m_Selection->itemAt(0)->update();
18847 jghali 867
        ResNode->setEnabled(false);
9041 fschmid 868
        AddNode->setEnabled(true);
869
        DeleteNode->setEnabled(true);
161 Franz 870
        SymMove->setEnabled(false);
871
        AsymMove->setEnabled(false);
872
        Res1Node->setEnabled(false);
9041 fschmid 873
        MoveNode->setChecked(true);
874
        MoveControl->setChecked(false);
875
        DeleteNode->setChecked(false);
876
        AddNode->setChecked(false);
19606 craig 877
        PolySplit->setChecked(false);
3 paul 878
}
879
 
880
void NodePalette::AddN()
881
{
22790 jghali 882
        if (m_doc == nullptr)
6531 cbradney 883
                return;
19946 craig 884
        m_doc->nodeEdit.setSubMode(NodeEditContext::ADD_POINT);
885
        m_doc->nodeEdit.setEdPoints(true);
161 Franz 886
        SymMove->setEnabled(false);
887
        AsymMove->setEnabled(false);
888
        ResNode->setEnabled(false);
889
        Res1Node->setEnabled(false);
9041 fschmid 890
        AddNode->setChecked(true);
891
        DeleteNode->setChecked(false);
19606 craig 892
        PolySplit->setChecked(false);
3 paul 893
}
894
 
895
void NodePalette::DelN()
896
{
22790 jghali 897
        if (m_doc == nullptr)
6531 cbradney 898
                return;
19946 craig 899
        m_doc->nodeEdit.setSubMode(NodeEditContext::DEL_POINT);
900
        m_doc->nodeEdit.setEdPoints(true);
161 Franz 901
        SymMove->setEnabled(false);
902
        AsymMove->setEnabled(false);
903
        ResNode->setEnabled(false);
218 Franz 904
        Res1Node->setEnabled(false);
9041 fschmid 905
        AddNode->setChecked(false);
906
        DeleteNode->setChecked(true);
19606 craig 907
        PolySplit->setChecked(false);
3 paul 908
}
909
 
1525 cbradney 910
void NodePalette::closeEvent(QCloseEvent *ce)
3 paul 911
{
22603 craig 912
        if (m_doc != nullptr)
161 Franz 913
        {
3 paul 914
                MoveN();
19946 craig 915
                m_doc->nodeEdit.setClre(-1);
916
                m_doc->nodeEdit.setClre2(-1);
917
                m_doc->nodeEdit.setSegP1(-1);
918
                m_doc->nodeEdit.setSegP2(-1);
919
                m_doc->nodeEdit.selNode().clear();
18330 jghali 920
                PageItem *currItem = m_doc->m_Selection->itemAt(0);
17260 fschmid 921
                if (currItem->itemType() == PageItem::PathText)
922
                        currItem->updatePolyClip();
161 Franz 923
        }
19606 craig 924
        PolySplit->setEnabled(false);
925
        BezierClose->setEnabled(false);
16546 jghali 926
        emit paletteClosed();
1525 cbradney 927
        ScrPaletteBase::closeEvent(ce);
3 paul 928
}
929
 
930
void NodePalette::EndEdit()
931
{
22603 craig 932
        if (m_doc != nullptr)
161 Franz 933
        {
3 paul 934
                MoveN();
19946 craig 935
                m_doc->nodeEdit.setClre(-1);
936
                m_doc->nodeEdit.setClre2(-1);
937
                m_doc->nodeEdit.setSegP1(-1);
938
                m_doc->nodeEdit.setSegP2(-1);
939
                m_doc->nodeEdit.selNode().clear();
21262 fschmid 940
                m_doc->nodeEdit.setPreviewMode(false);
340 Franz 941
                EditCont->setChecked(false);
341 Franz 942
                ToggleConMode();
18330 jghali 943
                PageItem *currItem = m_doc->m_Selection->itemAt(0);
19218 jghali 944
                if (currItem && currItem->itemType() == PageItem::PathText)
17260 fschmid 945
                        currItem->updatePolyClip();
161 Franz 946
        }
19606 craig 947
        PolySplit->setEnabled(false);
948
        BezierClose->setEnabled(false);
340 Franz 949
        EditCont->setChecked(false);
16546 jghali 950
        emit paletteClosed();
3 paul 951
}
2210 cbradney 952
 
18040 fschmid 953
void NodePalette::CancelEdit()
954
{
22603 craig 955
        if (m_doc != nullptr)
18040 fschmid 956
        {
957
                MoveN();
19946 craig 958
                m_doc->nodeEdit.setClre(-1);
959
                m_doc->nodeEdit.setClre2(-1);
960
                m_doc->nodeEdit.setSegP1(-1);
961
                m_doc->nodeEdit.setSegP2(-1);
962
                m_doc->nodeEdit.selNode().clear();
21262 fschmid 963
                m_doc->nodeEdit.setPreviewMode(false);
18040 fschmid 964
                EditCont->setChecked(false);
965
                ToggleConMode();
18330 jghali 966
                PageItem *currItem = m_doc->m_Selection->itemAt(0);
23528 jghali 967
 
968
                // Calculate the difference of the current position and the original
969
                // position in the item's coordinate space (which is rotated and translated,
970
                // but the translation does not matter for the delta)
971
                QTransform m = QTransform().rotate(-currItem->rotation());
972
                QPointF delta = m.map(QPointF(xPos, yPos)) - m.map(QPointF(currItem->xPos(), currItem->yPos()));
973
                // During operation the image offsets and possibly other values are changed.
974
                // To not remember everything we move the clip path to the original position
975
                // relative to the current position (in the item's coordinate space).
976
                // adjustItemSize will then take care of moving the position and changing
977
                // image offsets, etc.
978
                currItem->PoLine = itemPath.copy();
979
                currItem->PoLine.translate(delta.x(), delta.y());
18040 fschmid 980
                currItem->ContourLine = itemContourPath.copy();
20694 craig 981
                m_doc->adjustItemSize(currItem);
18040 fschmid 982
                if (currItem->itemType() == PageItem::PathText)
983
                        currItem->updatePolyClip();
21224 fschmid 984
                m_doc->regionsChanged()->update(QRectF());
18040 fschmid 985
        }
19606 craig 986
        PolySplit->setEnabled(false);
987
        BezierClose->setEnabled(false);
18040 fschmid 988
        EditCont->setChecked(false);
989
        emit paletteClosed();
990
}
991
 
992
void NodePalette::ResetToEditDefaults()
993
{
22790 jghali 994
        if (m_doc == nullptr)
995
                return;
996
 
997
        m_doc->nodeEdit.setClre(-1);
998
        m_doc->nodeEdit.setClre2(-1);
999
        m_doc->nodeEdit.setSegP1(-1);
1000
        m_doc->nodeEdit.setSegP2(-1);
1001
        m_doc->nodeEdit.selNode().clear();
1002
        m_doc->nodeEdit.setPreviewMode(false);
1003
        PageItem *currItem = m_doc->m_Selection->itemAt(0);
23528 jghali 1004
 
1005
        // See comment in NodePalette::CancelEdit
1006
        QTransform m = QTransform().rotate(-currItem->rotation());
1007
        QPointF delta = m.map(QPointF(xPos, yPos)) - m.map(QPointF(currItem->xPos(), currItem->yPos()));
22790 jghali 1008
        if (EditCont->isChecked())
23528 jghali 1009
        {
22790 jghali 1010
                currItem->ContourLine = itemContourPath.copy();
23528 jghali 1011
                currItem->ContourLine.translate(delta.x(), delta.y());
1012
        }
22790 jghali 1013
        else
18040 fschmid 1014
        {
23528 jghali 1015
                // See comment in NodePalette::CancelEdit
1016
                currItem->PoLine = itemPath;
1017
                currItem->PoLine.translate(delta.x(), delta.y());
1018
                currItem->ContourLine = itemContourPath;
22790 jghali 1019
                m_doc->adjustItemSize(currItem);
18040 fschmid 1020
        }
22790 jghali 1021
        if (currItem->itemType() == PageItem::PathText)
1022
                currItem->updatePolyClip();
1023
        currItem->update();
1024
        m_doc->regionsChanged()->update(QRectF());
18040 fschmid 1025
}
1026
 
10859 cbradney 1027
void NodePalette::changeEvent(QEvent *e)
1028
{
1029
        if (e->type() == QEvent::LanguageChange)
1030
        {
1031
                languageChange();
1032
        }
10903 cbradney 1033
        else
1034
                QWidget::changeEvent(e);
10859 cbradney 1035
}
1036
 
19388 jghali 1037
void NodePalette::reject()
1038
{
1039
        EndEdit();
1040
        ScrPaletteBase::reject();
1041
}
1042
 
18040 fschmid 1043
void NodePalette::setDefaults(PageItem* currItem)
1044
{
1045
        xPos = currItem->xPos();
1046
        yPos = currItem->yPos();
1047
        itemPath = currItem->PoLine.copy();
1048
        itemContourPath = currItem->ContourLine.copy();
1049
}
1050
 
23474 jghali 1051
void NodePalette::iconSetChange()
1052
{
1053
        IconManager& im = IconManager::instance();
1054
 
1055
        MoveNode->setIcon(im.loadIcon("MoveNode.png"));
1056
        AddNode->setIcon(im.loadIcon("AddNode.png"));
1057
        DeleteNode->setIcon(im.loadIcon("DeleteNode.png"));
1058
        ResNode->setIcon(im.loadIcon("ResetNode.png"));
1059
        MoveControl->setIcon(im.loadIcon("MoveKontrol.png"));
1060
        AsymMove->setIcon(im.loadIcon("MoveAsym.png"));
1061
        SymMove->setIcon(im.loadIcon("MoveSym.png"));
1062
        Res1Node->setIcon(im.loadIcon("Reset1Node.png"));
1063
        PolySplit->setIcon(im.loadIcon("PolyCut.png"));
1064
        BezierClose->setIcon(im.loadIcon("BezierClose.png"));
1065
        PolyMirrorH->setIcon(im.loadIcon("hmirror.png"));
1066
        PolyMirrorV->setIcon(im.loadIcon("vmirror.png"));
1067
        PolyShearL->setIcon(im.loadIcon("22/transform-shear-left.png"));
1068
        PolyShearR->setIcon(im.loadIcon("22/transform-shear-right.png"));
1069
        PolyShearU->setIcon(im.loadIcon("22/transform-shear-up.png"));
1070
        PolyShearD->setIcon(im.loadIcon("22/transform-shear-down.png"));
1071
        RotateCCW->setIcon(im.loadIcon("rotate_ccw.png"));
1072
        RotateCW->setIcon(im.loadIcon("rotate_cw.png"));
1073
        Expand->setIcon(im.loadIcon("expand.png"));
1074
        Shrink->setIcon(im.loadIcon("crop.png"));
1075
        Enlarge->setIcon(im.loadIcon("expand.png"));
1076
        Reduce->setIcon(im.loadIcon("crop.png"));
1077
}
1078
 
2210 cbradney 1079
void NodePalette::languageChange()
1080
{
10495 cbradney 1081
        setWindowTitle( tr( "Nodes" ) );
4619 cbradney 1082
        scalePercentage->setSuffix( tr(" %"));
9041 fschmid 1083
 
11145 fschmid 1084
        AbsMode->setTitle( tr("&Absolute Coordinates"));
1085
        absToCanvas->setText( tr("to Canvas"));
1086
        absToPage->setText( tr("to Page"));
2397 cbradney 1087
        TextLabel1->setText( tr("&X-Pos:"));
1088
        TextLabel2->setText( tr("&Y-Pos:"));
21292 fschmid 1089
        PreviewMode->setText( tr("Hide Nodes"));
2397 cbradney 1090
        EditCont->setText( tr("Edit &Contour Line"));
1091
        ResetCont->setText( tr("&Reset Contour Line"));
8445 fschmid 1092
        ResetContClip->setText( tr("Set Contour to Image Clip"));
12681 fschmid 1093
        ResetShape2Clip->setText( tr("Set Shape to Image Clip"));
18040 fschmid 1094
        editEditButton->setText( tr("OK"));
1095
        cancelEditButton->setText( tr("Cancel"));
1096
        resetDefaultButton->setText( tr("Reset all edits"));
1097
//      editEditButton->setText( tr("&End Editing"));
10397 cbradney 1098
        MoveNode->setToolTip( tr("Move Nodes"));
1099
        MoveControl->setToolTip( tr("Move Control Points"));
1100
        AddNode->setToolTip( tr("Add Nodes"));
1101
        DeleteNode->setToolTip( tr("Delete Nodes"));
1102
        AsymMove->setToolTip( tr("Move Control Points Independently"));
1103
        SymMove->setToolTip( tr("Move Control Points Symmetrical"));
1104
        ResNode->setToolTip( tr("Reset Control Points"));
1105
        Res1Node->setToolTip( tr("Reset this Control Point"));
1106
        PolySplit->setToolTip( tr("Open a Polygon or Cuts a Bezier Curve"));
1107
        BezierClose->setToolTip( tr("Close this Bezier Curve"));
1108
        PolyMirrorH->setToolTip( tr("Mirror the Path Horizontally"));
1109
        PolyMirrorV->setToolTip( tr("Mirror the Path Vertically"));
1110
        PolyShearR->setToolTip( tr("Shear the Path Horizontally to the Right"));
1111
        PolyShearL->setToolTip( tr("Shear the Path Horizontally to the Left"));
1112
        PolyShearU->setToolTip( tr("Shear the Path Vertically Up"));
1113
        PolyShearD->setToolTip( tr("Shear the Path Vertically Down"));
1114
        RotateCCW->setToolTip( tr("Rotate the Path Counter-Clockwise"));
1115
        RotateCW->setToolTip( tr("Rotate the Path Clockwise"));
1116
        Shrink->setToolTip( tr("Shrink the Size of the Path by shown %"));
1117
        Expand->setToolTip( tr("Enlarge the Size of the Path by shown %"));
1118
        Reduce->setToolTip( tr("Reduce the Size of the Path by the shown value"));
1119
        Enlarge->setToolTip( tr("Enlarge the Size of the Path by the shown value"));
1120
        RotVal->setToolTip( tr("Angle of Rotation"));
1121
        scalePercentage->setToolTip( tr("% to Enlarge or Shrink By"));
1122
        scaleDistance->setToolTip( tr("Value to Enlarge or Shrink By"));
1123
        EditCont->setToolTip( tr("Activate Contour Line Editing Mode"));
1124
        ResetCont->setToolTip( tr("Reset the Contour Line to the Original Shape of the Frame"));
1125
        ResetContClip->setToolTip( tr("Reset the Contour Line to the Clipping Path of the Image"));
12681 fschmid 1126
        ResetShape2Clip->setToolTip( tr("Set the Shape to the Clipping Path of the Image"));
20270 craig 1127
        AbsMode->setToolTip(  "<qt>" + tr("When checked use coordinates relative to the page, otherwise coordinates are relative to the Object") + "</qt>");
2210 cbradney 1128
}
3934 cbradney 1129
 
4619 cbradney 1130
void NodePalette::unitChange()
1131
{
22790 jghali 1132
        if (m_doc == nullptr)
4619 cbradney 1133
                return;
18330 jghali 1134
        unitRatio = m_doc->unitRatio();
19622 jghali 1135
 
1136
        bool sigBlocked1 = XSpin->blockSignals(true);
1137
        bool sigBlocked2 = YSpin->blockSignals(true);
1138
        bool sigBlocked3 = scaleDistance->blockSignals(true);
1139
 
1140
        XSpin->setNewUnit(m_doc->unitIndex());
1141
        YSpin->setNewUnit(m_doc->unitIndex());
18330 jghali 1142
        scaleDistance->setNewUnit(m_doc->unitIndex());
19622 jghali 1143
 
1144
        XSpin->blockSignals(sigBlocked1);
1145
        YSpin->blockSignals(sigBlocked2);
1146
        scaleDistance->blockSignals(sigBlocked3);
4619 cbradney 1147
}
6531 cbradney 1148
 
1149
ScribusDoc* NodePalette::currentDocument() const
1150
{
18330 jghali 1151
        return m_doc;
6531 cbradney 1152
}