Subversion Repositories Scribus

Rev

Rev 14159 | Rev 14168 | 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
*/
3 paul 7
/***************************************************************************
8
                          cpalette.cpp  -  description
9
                             -------------------
10
    begin                : Wed Apr 25 2001
11
    copyright            : (C) 2001 by Franz Schmid
12
    email                : Franz.Schmid@altmuehlnet.de
13
 ***************************************************************************/
14
 
15
/***************************************************************************
16
 *                                                                         *
17
 *   This program is free software; you can redistribute it and/or modify  *
18
 *   it under the terms of the GNU General Public License as published by  *
19
 *   the Free Software Foundation; either version 2 of the License, or     *
20
 *   (at your option) any later version.                                   *
21
 *                                                                         *
22
 ***************************************************************************/
23
 
24
#include "cpalette.h"
686 cbradney 25
 
10859 cbradney 26
#include <QAbstractItemView>
27
#include <QEvent>
28
#include <QFont>
29
#include <QFrame>
10003 fschmid 30
#include <QGridLayout>
31
#include <QGroupBox>
10859 cbradney 32
#include <QHBoxLayout>
10003 fschmid 33
#include <QLabel>
34
#include <QListWidget>
35
#include <QListWidgetItem>
36
#include <QPixmap>
37
#include <QRect>
10859 cbradney 38
#include <QSpacerItem>
39
#include <QSpinBox>
40
#include <QStandardItem>
41
#include <QToolButton>
10003 fschmid 42
#include <QToolTip>
10859 cbradney 43
#include <QVBoxLayout>
10916 fschmid 44
#include <QCheckBox>
10003 fschmid 45
 
7747 jghali 46
#include "colorlistbox.h"
3543 avox 47
#include "sccombobox.h"
686 cbradney 48
#include "scribusdoc.h"
8602 cbradney 49
#include "scrspinbox.h"
686 cbradney 50
#include "gradienteditor.h"
793 cbradney 51
#include "units.h"
2714 craig 52
#include "page.h"
7900 fschmid 53
#include "pageitem.h"
10200 cbradney 54
#include "util_icon.h"
4546 subik 55
#include "commonstrings.h"
6479 fschmid 56
#include "linkbutton.h"
7478 jghali 57
#include "sccolorengine.h"
14150 fschmid 58
#include "scpainter.h"
10601 mrdocs 59
#include "scpattern.h"
14150 fschmid 60
#include "util.h"
295 Franz 61
 
12187 fschmid 62
GradientVectorDialog::GradientVectorDialog(QWidget* parent) : ScrPaletteBase( parent, "GradientVectorPalette", false, 0 )
63
{
64
        freeGradientLayout = new QGridLayout(this);
65
        freeGradientLayout->setMargin(5);
66
        freeGradientLayout->setSpacing(5);
67
        GTextX1 = new QLabel("X1:", this );
68
        freeGradientLayout->addWidget( GTextX1, 0, 0 );
69
        GTextY1 = new QLabel("Y1:", this );
70
        freeGradientLayout->addWidget( GTextY1, 1, 0 );
71
        gX1 = new ScrSpinBox( -3000, 3000, this, 0);
72
        freeGradientLayout->addWidget( gX1, 0, 1 );
73
        gY1 = new ScrSpinBox( -3000, 3000, this, 0);
74
        freeGradientLayout->addWidget( gY1, 1, 1 );
75
        GTextX2 = new QLabel("X2:", this );
76
        freeGradientLayout->addWidget( GTextX2, 0, 2 );
77
        GTextY2 = new QLabel("Y2:", this );
78
        freeGradientLayout->addWidget( GTextY2, 1, 2 );
79
        gX2 = new ScrSpinBox( -3000, 3000, this, 0);
80
        freeGradientLayout->addWidget( gX2, 0, 3 );
81
        gY2 = new ScrSpinBox( -3000, 3000, this, 0);
82
        freeGradientLayout->addWidget( gY2, 1, 3 );
83
        connect(gX1, SIGNAL(valueChanged(double)), this, SLOT(changeSpecial()));
84
        connect(gX2, SIGNAL(valueChanged(double)), this, SLOT(changeSpecial()));
85
        connect(gY1, SIGNAL(valueChanged(double)), this, SLOT(changeSpecial()));
86
        connect(gY2, SIGNAL(valueChanged(double)), this, SLOT(changeSpecial()));
87
        languageChange();
88
}
4546 subik 89
 
12187 fschmid 90
void GradientVectorDialog::changeEvent(QEvent *e)
91
{
92
        if (e->type() == QEvent::LanguageChange)
93
        {
94
                languageChange();
95
        }
96
        else
97
                QWidget::changeEvent(e);
98
}
99
 
100
void GradientVectorDialog::languageChange()
101
{
102
        setWindowTitle( tr( "Gradient Vector" ));
103
        resize(minimumSizeHint());
104
}
105
 
106
void GradientVectorDialog::setValues(double x1, double y1, double x2, double y2)
107
{
108
        disconnect(gX1, SIGNAL(valueChanged(double)), this, SLOT(changeSpecial()));
109
        disconnect(gX2, SIGNAL(valueChanged(double)), this, SLOT(changeSpecial()));
110
        disconnect(gY1, SIGNAL(valueChanged(double)), this, SLOT(changeSpecial()));
111
        disconnect(gY2, SIGNAL(valueChanged(double)), this, SLOT(changeSpecial()));
112
        gX1->setValue(x1);
113
        gX2->setValue(x2);
114
        gY1->setValue(y1);
115
        gY2->setValue(y2);
116
        connect(gX1, SIGNAL(valueChanged(double)), this, SLOT(changeSpecial()));
117
        connect(gX2, SIGNAL(valueChanged(double)), this, SLOT(changeSpecial()));
118
        connect(gY1, SIGNAL(valueChanged(double)), this, SLOT(changeSpecial()));
119
        connect(gY2, SIGNAL(valueChanged(double)), this, SLOT(changeSpecial()));
120
}
121
 
122
void GradientVectorDialog::changeSpecial()
123
{
124
        emit NewSpecial(gX1->value(), gY1->value(), gX2->value(), gY2->value());
125
}
126
 
127
void GradientVectorDialog::unitChange(int unitIndex)
128
{
129
        disconnect(gX1, SIGNAL(valueChanged(double)), this, SLOT(changeSpecial()));
130
        disconnect(gX2, SIGNAL(valueChanged(double)), this, SLOT(changeSpecial()));
131
        disconnect(gY1, SIGNAL(valueChanged(double)), this, SLOT(changeSpecial()));
132
        disconnect(gY2, SIGNAL(valueChanged(double)), this, SLOT(changeSpecial()));
133
        gX1->setNewUnit(unitIndex);
134
        gY1->setNewUnit(unitIndex);
135
        gX2->setNewUnit(unitIndex);
136
        gY2->setNewUnit(unitIndex);
137
        connect(gX1, SIGNAL(valueChanged(double)), this, SLOT(changeSpecial()));
138
        connect(gX2, SIGNAL(valueChanged(double)), this, SLOT(changeSpecial()));
139
        connect(gY1, SIGNAL(valueChanged(double)), this, SLOT(changeSpecial()));
140
        connect(gY2, SIGNAL(valueChanged(double)), this, SLOT(changeSpecial()));
141
}
142
 
14126 fschmid 143
PatternPropsDialog::PatternPropsDialog(QWidget* parent, int unitIndex) : QDialog( parent )
144
{
145
        setModal(true);
146
        frame3Layout = new QVBoxLayout( this );
147
        frame3Layout->setMargin(0);
148
        frame3Layout->setSpacing(2);
149
 
150
        groupOffset = new QGroupBox( this );
151
        groupOffsetLayout = new QHBoxLayout( groupOffset );
152
        groupOffsetLayout->setSpacing( 2 );
153
        groupOffsetLayout->setMargin( 3 );
154
        groupOffsetLayout->setAlignment( Qt::AlignTop );
155
        textLabel1 = new QLabel( groupOffset );
156
        groupOffsetLayout->addWidget( textLabel1 );
157
        spinXoffset = new ScrSpinBox( -3000, 3000, groupOffset, 0);
158
        groupOffsetLayout->addWidget( spinXoffset );
159
        textLabel2 = new QLabel( groupOffset );
160
        groupOffsetLayout->addWidget( textLabel2 );
161
        spinYoffset = new ScrSpinBox( -3000, 3000, groupOffset, 0);
162
        groupOffsetLayout->addWidget( spinYoffset );
163
        frame3Layout->addWidget( groupOffset );
164
 
165
        groupScale = new QGroupBox( this );
166
        groupScaleLayout = new QGridLayout( groupScale );
167
        groupScaleLayout->setSpacing( 2 );
168
        groupScaleLayout->setMargin( 3 );
169
        groupScaleLayout->setAlignment( Qt::AlignTop );
170
        textLabel5 = new QLabel( groupScale );
171
        groupScaleLayout->addWidget( textLabel5, 0, 0 );
172
        spinXscaling = new ScrSpinBox( 1, 500, groupScale, 0);
173
        spinXscaling->setValue( 100 );
174
        groupScaleLayout->addWidget( spinXscaling, 0, 1 );
175
        textLabel6 = new QLabel( groupScale );
176
        groupScaleLayout->addWidget( textLabel6, 1, 0 );
177
        spinYscaling = new ScrSpinBox( 1, 500, groupScale, 0 );
178
        groupScaleLayout->addWidget( spinYscaling, 1, 1 );
179
        keepScaleRatio = new LinkButton( groupScale );
180
        keepScaleRatio->setCheckable( true );
181
        keepScaleRatio->setAutoRaise( true );
182
        keepScaleRatio->setMaximumSize( QSize( 15, 32767 ) );
183
        groupScaleLayout->addWidget( keepScaleRatio, 0, 2, 2, 1 );
184
        frame3Layout->addWidget( groupScale );
185
        groupRotation = new QGroupBox( this );
186
        groupRotationLayout = new QHBoxLayout( groupRotation );
187
        groupRotationLayout->setSpacing( 2 );
188
        groupRotationLayout->setMargin( 3 );
189
        groupRotationLayout->setAlignment( Qt::AlignTop );
190
        textLabel7 = new QLabel( groupRotation );
191
        groupRotationLayout->addWidget( textLabel7 );
192
        spinAngle = new ScrSpinBox( -180, 180, groupRotation, 6 );
193
        groupRotationLayout->addWidget( spinAngle );
194
        frame3Layout->addWidget( groupRotation );
195
        buttonLayout = new QHBoxLayout;
196
        buttonLayout->setMargin(0);
197
        buttonLayout->setSpacing(5);
198
        QSpacerItem* hspacing = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum);
199
        buttonLayout->addItem(hspacing);
200
        buttonOk = new QPushButton( this );
201
        buttonOk->setAutoDefault( TRUE );
202
        buttonOk->setDefault( TRUE );
203
        buttonLayout->addWidget( buttonOk );
204
        frame3Layout->addLayout( buttonLayout );
205
        spinXoffset->setNewUnit(unitIndex);
206
        spinYoffset->setNewUnit(unitIndex);
207
        languageChange();
208
        connect(spinXoffset, SIGNAL(valueChanged(double)), this, SLOT(changePatternProps()));
209
        connect(spinYoffset, SIGNAL(valueChanged(double)), this, SLOT(changePatternProps()));
210
        connect(spinXscaling, SIGNAL(valueChanged(double)), this, SLOT(HChange()));
211
        connect(spinYscaling, SIGNAL(valueChanged(double)), this, SLOT(VChange()));
212
        connect(keepScaleRatio, SIGNAL(clicked()), this, SLOT(ToggleKette()));
213
        connect(spinAngle, SIGNAL(valueChanged(double)), this, SLOT(changePatternProps()));
214
        connect(buttonOk, SIGNAL(clicked()), this, SLOT(accept()));
215
}
216
 
217
void PatternPropsDialog::changeEvent(QEvent *e)
218
{
219
        if (e->type() == QEvent::LanguageChange)
220
        {
221
                languageChange();
222
        }
223
        else
224
                QWidget::changeEvent(e);
225
}
226
 
227
void PatternPropsDialog::languageChange()
228
{
229
        setWindowTitle( tr( "Pattern Properties" ));
230
        QString ptSuffix=tr(" pt");
231
        QString pctSuffix=tr(" %");
232
        groupOffset->setTitle( tr( "Offsets" ) );
233
        textLabel1->setText( tr( "X:" ) );
234
        spinXoffset->setSuffix( ptSuffix );
235
        textLabel2->setText( tr( "Y:" ) );
236
        spinYoffset->setSuffix( ptSuffix );
237
        groupScale->setTitle( tr( "Scaling" ) );
238
        textLabel5->setText( tr( "X-Scale:" ) );
239
        spinXscaling->setSuffix( pctSuffix );
240
        textLabel6->setText( tr( "Y-Scale:" ) );
241
        spinYscaling->setSuffix( pctSuffix );
242
        groupRotation->setTitle( tr( "Rotation" ) );
243
        textLabel7->setText( tr( "Angle" ) );
244
        buttonOk->setText( tr("Close"));
245
        resize(minimumSizeHint());
246
}
247
 
248
void PatternPropsDialog::changePatternProps()
249
{
250
        emit NewPatternProps(spinXscaling->value(), spinYscaling->value(), spinXoffset->value(), spinYoffset->value(), spinAngle->value());
251
}
252
 
253
void PatternPropsDialog::ToggleKette()
254
{
255
        disconnect(spinXscaling, SIGNAL(valueChanged(double)), this, SLOT(HChange()));
256
        disconnect(spinYscaling, SIGNAL(valueChanged(double)), this, SLOT(VChange()));
257
        if (keepScaleRatio->isChecked())
258
        {
259
                spinYscaling->setValue(spinXscaling->value());
260
                changePatternProps();
261
                keepScaleRatio->setChecked(true);
262
        }
263
        else
264
                keepScaleRatio->setChecked(false);
265
        connect(spinXscaling, SIGNAL(valueChanged(double)), this, SLOT(HChange()));
266
        connect(spinYscaling, SIGNAL(valueChanged(double)), this, SLOT(VChange()));
267
}
268
 
269
void PatternPropsDialog::HChange()
270
{
271
        disconnect(spinXscaling, SIGNAL(valueChanged(double)), this, SLOT(HChange()));
272
        disconnect(spinYscaling, SIGNAL(valueChanged(double)), this, SLOT(VChange()));
273
        if (keepScaleRatio->isChecked())
274
                spinYscaling->setValue(spinXscaling->value());
275
        changePatternProps();
276
        connect(spinXscaling, SIGNAL(valueChanged(double)), this, SLOT(HChange()));
277
        connect(spinYscaling, SIGNAL(valueChanged(double)), this, SLOT(VChange()));
278
}
279
 
280
void PatternPropsDialog::VChange()
281
{
282
        disconnect(spinXscaling, SIGNAL(valueChanged(double)), this, SLOT(HChange()));
283
        disconnect(spinYscaling, SIGNAL(valueChanged(double)), this, SLOT(VChange()));
284
        if (keepScaleRatio->isChecked())
285
                spinXscaling->setValue(spinYscaling->value());
286
        changePatternProps();
287
        connect(spinXscaling, SIGNAL(valueChanged(double)), this, SLOT(HChange()));
288
        connect(spinYscaling, SIGNAL(valueChanged(double)), this, SLOT(VChange()));
289
}
290
 
10497 fschmid 291
Cpalette::Cpalette(QWidget* parent) : QWidget(parent)
3 paul 292
{
11630 jghali 293
        currentItem = NULL;
294
        patternList = NULL;
12187 fschmid 295
        CGradDia = NULL;
296
        CGradDia = new GradientVectorDialog(this->parentWidget());
297
        CGradDia->hide();
14126 fschmid 298
        setupUi(this);
299
        editLineColorSelector->setIcon(QIcon(loadIcon("16/color-stroke.png")));
300
        editFillColorSelector->setIcon(QIcon(loadIcon("16/color-fill.png")));
301
        connect(editLineColorSelector, SIGNAL(clicked()), this, SLOT(editLineColorSelectorButton()));
302
        connect(editFillColorSelector, SIGNAL(clicked()), this, SLOT(editFillColorSelectorButton()));
303
        connect(strokeOpacity, SIGNAL(valueChanged(int)), this, SLOT(slotTransS(int)));
304
        connect(fillOpacity, SIGNAL(valueChanged(int)), this, SLOT(slotTransF(int)));
305
        connect(blendModeFill, SIGNAL(activated(int)), this, SIGNAL(NewBlend(int)));
306
        connect(blendModeStroke, SIGNAL(activated(int)), this, SIGNAL(NewBlendS(int)));
307
        connect(patternBox, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(selectPattern(QListWidgetItem*)));
14138 fschmid 308
        connect(fillShade, SIGNAL(valueChanged(int)), this, SIGNAL(NewBrushShade(int)));
309
        connect(strokeShade, SIGNAL(valueChanged(int)), this, SIGNAL(NewPenShade(int)));
14126 fschmid 310
        connect(colorListStroke, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), this, SLOT(selectColorS(QListWidgetItem*)));
311
        connect(colorListFill, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), this, SLOT(selectColorF(QListWidgetItem*)));
312
        connect(gradEditButton, SIGNAL(clicked()), this, SLOT(editGradientVector()));
313
        connect(displayAllColors, SIGNAL(clicked()), this, SLOT(ToggleColorDisplay()));
314
        connect(tabWidget, SIGNAL(currentChanged(int)), this, SLOT(slotGrad(int)));
315
        connect(CGradDia, SIGNAL(NewSpecial(double, double, double, double)), this, SIGNAL(NewSpecial(double, double, double, double)));
316
        connect(CGradDia, SIGNAL(paletteShown(bool)), this, SLOT(setActiveGradDia(bool)));
317
        connect(gradientType, SIGNAL(activated(int)), this, SLOT(slotGradType(int)));
318
        connect(gradEdit, SIGNAL(gradientChanged()), this, SIGNAL(gradientChanged()));
319
        connect(editPatternProps, SIGNAL(clicked()), this, SLOT(changePatternProps()));
14150 fschmid 320
        connect(namedGradient, SIGNAL(activated(const QString &)), this, SLOT(setNamedGradient(const QString &)));
14159 fschmid 321
        connect(overPrintCombo, SIGNAL(activated(int)), this, SIGNAL(NewOverprint(int)));
14126 fschmid 322
        editFillColorSelector->setChecked(true);
323
        editFillColorSelectorButton();
3 paul 324
}
325
 
7900 fschmid 326
void Cpalette::setCurrentItem(PageItem* item)
327
{
328
        currentItem = item;
329
}
330
 
9575 fschmid 331
void Cpalette::setDocument(ScribusDoc* doc)
332
{
333
        currentDoc = doc;
334
        if (doc == NULL)
14126 fschmid 335
        {
336
                colorListStroke->cList = NULL;
337
                colorListFill->cList = NULL;
338
        }
9575 fschmid 339
        else
14126 fschmid 340
        {
341
                colorListStroke->cList = &doc->PageColors;
342
                colorListFill->cList = &doc->PageColors;
343
                gradEdit->setColors(doc->PageColors);
344
                currentUnit = doc->unitIndex();
345
        }
9575 fschmid 346
}
347
 
7900 fschmid 348
void Cpalette::updateFromItem()
349
{
350
        if (currentItem == NULL)
351
                return;
352
        if (!currentDoc)
353
                return;
14126 fschmid 354
        updateCList();
7900 fschmid 355
        setActTrans(currentItem->fillTransparency(), currentItem->lineTransparency());
356
        setActBlend(currentItem->fillBlendmode(), currentItem->lineBlendmode());
14159 fschmid 357
        if (currentItem->doOverprint)
358
                setActOverprint(1);
359
        else
360
                setActOverprint(0);
14126 fschmid 361
        setActFarben(currentItem->lineColor(), currentItem->fillColor(), currentItem->lineShade(), currentItem->fillShade());
362
        ChooseGrad(currentItem->GrType);
363
        gradEdit->setGradient(currentItem->fill_gradient);
14150 fschmid 364
        disconnect(namedGradient, SIGNAL(activated(const QString &)), this, SLOT(setNamedGradient(const QString &)));
365
        if (!currentItem->gradient().isEmpty())
366
        {
367
                setCurrentComboItem(namedGradient, currentItem->gradient());
368
                gradEdit->setGradientEditable(false);
369
        }
370
        else
371
        {
372
                namedGradient->setCurrentIndex(0);
373
                gradEdit->setGradientEditable(true);
374
        }
14126 fschmid 375
        if (patternList->count() == 0)
376
                tabWidget->setTabEnabled(2, false);
377
        else
378
                tabWidget->setTabEnabled(2, true);
14150 fschmid 379
        connect(namedGradient, SIGNAL(activated(const QString &)), this, SLOT(setNamedGradient(const QString &)));
14126 fschmid 380
}
381
 
382
void Cpalette::updateCList()
383
{
384
        disconnect(colorListStroke, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), this, SLOT(selectColorS(QListWidgetItem*)));
385
        disconnect(colorListFill, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), this, SLOT(selectColorF(QListWidgetItem*)));
386
        colorListStroke->clear();
387
        colorListStroke->addItem(CommonStrings::tr_NoneColor);
388
        colorListFill->clear();
389
        colorListFill->addItem(CommonStrings::tr_NoneColor);
390
        if (displayAllColors->isChecked())
7900 fschmid 391
        {
14126 fschmid 392
                if (currentDoc != NULL)
393
                        currentDoc->getUsedColors(colorList);
7900 fschmid 394
        }
14138 fschmid 395
        gradEdit->setColors(colorList);
14126 fschmid 396
        colorListFill->insertItems(colorList, ColorListBox::fancyPixmap);
397
        colorListStroke->insertItems(colorList, ColorListBox::fancyPixmap);
398
        if (colorListFill->currentItem())
399
                colorListFill->currentItem()->setSelected(false);
400
        if (colorListStroke->currentItem())
401
                colorListStroke->currentItem()->setSelected(false);
402
        connect(colorListStroke, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), this, SLOT(selectColorS(QListWidgetItem*)));
403
        connect(colorListFill, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), this, SLOT(selectColorF(QListWidgetItem*)));
404
}
405
 
406
void Cpalette::ToggleColorDisplay()
407
{
408
        if (currentDoc != NULL)
7900 fschmid 409
        {
14126 fschmid 410
                colorListStroke->cList = &currentDoc->PageColors;
411
                colorListFill->cList = &currentDoc->PageColors;
412
                colorList = currentDoc->PageColors;
413
                updateFromItem();
7900 fschmid 414
        }
14126 fschmid 415
}
416
 
417
void Cpalette::setActTrans(double val, double val2)
418
{
419
        disconnect(strokeOpacity, SIGNAL(valueChanged(int)), this, SLOT(slotTransS(int)));
420
        disconnect(fillOpacity, SIGNAL(valueChanged(int)), this, SLOT(slotTransF(int)));
421
        strokeOpacity->setValue(qRound(100 - (val2 * 100)));
422
        fillOpacity->setValue(qRound(100 - (val * 100)));
423
        connect(strokeOpacity, SIGNAL(valueChanged(int)), this, SLOT(slotTransS(int)));
424
        connect(fillOpacity, SIGNAL(valueChanged(int)), this, SLOT(slotTransF(int)));
425
}
426
 
427
void Cpalette::setActBlend(int val, int val2)
428
{
429
        disconnect(blendModeFill, SIGNAL(activated(int)), this, SIGNAL(NewBlend(int)));
430
        disconnect(blendModeStroke, SIGNAL(activated(int)), this, SIGNAL(NewBlendS(int)));
431
        blendModeFill->setCurrentIndex(val);
14159 fschmid 432
        blendModeStroke->setCurrentIndex(val2);
14126 fschmid 433
        connect(blendModeFill, SIGNAL(activated(int)), this, SIGNAL(NewBlend(int)));
434
        connect(blendModeStroke, SIGNAL(activated(int)), this, SIGNAL(NewBlendS(int)));
435
}
436
 
14159 fschmid 437
void Cpalette::setActOverprint(int val)
438
{
439
        disconnect(overPrintCombo, SIGNAL(activated(int)), this, SIGNAL(NewOverprint(int)));
440
        overPrintCombo->setCurrentIndex(val);
441
        connect(overPrintCombo, SIGNAL(activated(int)), this, SIGNAL(NewOverprint(int)));
442
}
443
 
14126 fschmid 444
void Cpalette::setActFarben(QString p, QString b, int shp, int shb)
445
{
446
        disconnect(fillShade, SIGNAL(valueChanged(int)), this, SIGNAL(NewBrushShade(int)));
447
        disconnect(strokeShade, SIGNAL(valueChanged(int)), this, SIGNAL(NewPenShade(int)));
448
        disconnect(colorListStroke, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), this, SLOT(selectColorS(QListWidgetItem*)));
449
        disconnect(colorListFill, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), this, SLOT(selectColorF(QListWidgetItem*)));
450
        strokeShade->setValue(shp);
451
        fillShade->setValue(shp);
452
        if ((p != CommonStrings::None) && (!p.isEmpty()))
11213 fschmid 453
        {
14126 fschmid 454
                QList<QListWidgetItem *> cCol = colorListStroke->findItems(p, Qt::MatchExactly);
455
                if (cCol.count() != 0)
456
                        colorListStroke->setCurrentItem(cCol[0]);
11213 fschmid 457
        }
458
        else
14126 fschmid 459
                colorListStroke->setCurrentRow(0);
460
        if ((b != CommonStrings::None) && (!b.isEmpty()))
11213 fschmid 461
        {
14126 fschmid 462
                QList<QListWidgetItem *> cCol = colorListFill->findItems(b, Qt::MatchExactly);
463
                if (cCol.count() != 0)
464
                        colorListFill->setCurrentItem(cCol[0]);
11213 fschmid 465
        }
14126 fschmid 466
        else
467
                colorListStroke->setCurrentRow(0);
468
        connect(fillShade, SIGNAL(valueChanged(int)), this, SIGNAL(NewBrushShade(int)));
469
        connect(strokeShade, SIGNAL(valueChanged(int)), this, SIGNAL(NewPenShade(int)));
470
        connect(colorListStroke, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), this, SLOT(selectColorS(QListWidgetItem*)));
471
        connect(colorListFill, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), this, SLOT(selectColorF(QListWidgetItem*)));
7900 fschmid 472
}
473
 
14126 fschmid 474
void Cpalette::selectColorS(QListWidgetItem *item)
475
{
476
        ColorPixmapItem* c = dynamic_cast<ColorPixmapItem*>(item);
477
        if (c != NULL) 
478
                sFarbe = c->colorName();
479
        else if (! item->data(Qt::DisplayRole).toString().isEmpty())
480
                sFarbe = item->data(Qt::DisplayRole).toString();
481
        else
482
                return;
483
        emit NewPen(sFarbe);
484
}
485
 
486
void Cpalette::selectColorF(QListWidgetItem *item)
487
{
488
        ColorPixmapItem* c = dynamic_cast<ColorPixmapItem*>(item);
489
        if (c != NULL) 
490
                sFarbe = c->colorName();
491
        else if (! item->data(Qt::DisplayRole).toString().isEmpty())
492
                sFarbe = item->data(Qt::DisplayRole).toString();
493
        else
494
                return;
495
        emit NewBrush(sFarbe);
496
}
497
 
498
void Cpalette::slotTransS(int val)
499
{
500
        emit NewTransS(static_cast<double>(100 - val) / 100.0);
501
}
502
 
503
void Cpalette::slotTransF(int val)
504
{
505
        emit NewTrans(static_cast<double>(100 - val) / 100.0);
506
}
507
 
508
void Cpalette::SetColors(ColorList newColorList)
509
{
510
        colorList.clear();
511
        colorList = newColorList;
512
        updateCList();
513
}
514
 
12208 cbradney 515
void Cpalette::editLineColorSelectorButton()
3 paul 516
{
12208 cbradney 517
        if (editLineColorSelector->isChecked())
161 Franz 518
        {
14126 fschmid 519
                stackedWidget->setCurrentIndex(0);
12208 cbradney 520
                editFillColorSelector->setChecked(false);
161 Franz 521
        }
7900 fschmid 522
        updateFromItem();
3 paul 523
}
524
 
12208 cbradney 525
void Cpalette::editFillColorSelectorButton()
3 paul 526
{
12208 cbradney 527
        if (editFillColorSelector->isChecked())
161 Franz 528
        {
14126 fschmid 529
                stackedWidget->setCurrentIndex(1);
12208 cbradney 530
                editLineColorSelector->setChecked(false);
161 Franz 531
        }
7900 fschmid 532
        updateFromItem();
3 paul 533
}
10003 fschmid 534
 
14150 fschmid 535
void Cpalette::updateGradientList()
536
{
537
        disconnect(namedGradient, SIGNAL(activated(const QString &)), this, SLOT(setNamedGradient(const QString &)));
538
        namedGradient->clear();
539
        namedGradient->setIconSize(QSize(48, 12));
540
        namedGradient->addItem( tr("Custom"));
541
        for (QMap<QString, VGradient>::Iterator it = gradientList->begin(); it != gradientList->end(); ++it)
542
        {
543
                QImage pixm(48, 12, QImage::Format_ARGB32);
544
                QPainter pb;
545
                QBrush b(QColor(205,205,205), loadIcon("testfill.png"));
546
                pb.begin(&pixm);
547
                pb.fillRect(0, 0, 48, 12, b);
548
                pb.end();
549
                ScPainter *p = new ScPainter(&pixm, 48, 12);
550
                p->setPen(Qt::black);
551
                p->setLineWidth(1);
552
                p->setFillMode(2);
553
                p->fill_gradient = it.value();
554
                p->setGradient(VGradient::linear, FPoint(0,6), FPoint(48, 6));
555
                p->drawRect(0, 0, 48, 12);
556
                p->end();
557
                delete p;
558
                QPixmap pm;
559
                pm = QPixmap::fromImage(pixm);
560
                namedGradient->addItem(pm, it.key());
561
        }
562
        connect(namedGradient, SIGNAL(activated(const QString &)), this, SLOT(setNamedGradient(const QString &)));
563
}
564
 
565
void Cpalette::SetGradients(QMap<QString, VGradient> *docGradients)
566
{
567
        gradientList = docGradients;
568
        updateGradientList();
569
}
570
 
571
void Cpalette::setNamedGradient(const QString &name)
572
{
573
        if (namedGradient->currentIndex() == 0)
574
        {
575
                gradEdit->setGradient(currentItem->fill_gradient);
576
                currentItem->setGradient("");
577
                gradEdit->setGradientEditable(true);
578
        }
579
        else
580
        {
581
                gradEdit->setGradient(gradientList->value(name));
582
                gradEdit->setGradientEditable(false);
583
                currentItem->setGradient(name);
584
        }
585
}
586
 
6368 fschmid 587
void Cpalette::updatePatternList()
588
{
10003 fschmid 589
        disconnect(patternBox, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(selectPattern(QListWidgetItem*)));
6368 fschmid 590
        patternBox->clear();
10003 fschmid 591
        patternBox->setIconSize(QSize(48, 48));
592
        for (QMap<QString, ScPattern>::Iterator it = patternList->begin(); it != patternList->end(); ++it)
6368 fschmid 593
        {
594
                QPixmap pm;
10427 cbradney 595
                if (it.value().getPattern()->width() >= it.value().getPattern()->height())
596
                        pm=QPixmap::fromImage(it.value().getPattern()->scaledToWidth(48, Qt::SmoothTransformation));
6368 fschmid 597
                else
10427 cbradney 598
                        pm=QPixmap::fromImage(it.value().getPattern()->scaledToHeight(48, Qt::SmoothTransformation));
10003 fschmid 599
                QPixmap pm2(48, 48);
10497 fschmid 600
                pm2.fill(palette().color(QPalette::Base));
10003 fschmid 601
                QPainter p;
602
                p.begin(&pm2);
603
                p.drawPixmap(24 - pm.width() / 2, 24 - pm.height() / 2, pm);
604
                p.end();
605
                QListWidgetItem *item = new QListWidgetItem(pm2, it.key(), patternBox);
606
                item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
6368 fschmid 607
        }
10003 fschmid 608
        patternBox->clearSelection();
609
        connect(patternBox, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(selectPattern(QListWidgetItem*)));
6368 fschmid 610
}
611
 
612
void Cpalette::SetPatterns(QMap<QString, ScPattern> *docPatterns)
613
{
614
        patternList = docPatterns;
615
        updatePatternList();
616
}
617
 
10003 fschmid 618
void Cpalette::selectPattern(QListWidgetItem *c)
6368 fschmid 619
{
620
        if (c == NULL)
621
                return;
622
        emit NewPattern(c->text());
623
}
624
 
14126 fschmid 625
void Cpalette::setActPattern(QString pattern, double scaleX, double scaleY, double offsetX, double offsetY, double rotation)
6414 fschmid 626
{
14126 fschmid 627
        disconnect(patternBox, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(selectPattern(QListWidgetItem*)));
628
        QList<QListWidgetItem*> itl = patternBox->findItems(pattern, Qt::MatchExactly);
629
        if (itl.count() != 0)
6479 fschmid 630
        {
14126 fschmid 631
                QListWidgetItem *it = itl[0];
632
                patternBox->setCurrentItem(it);
6479 fschmid 633
        }
634
        else
14126 fschmid 635
                patternBox->clearSelection();
636
        m_Pattern_scaleX = scaleX;
637
        m_Pattern_scaleY = scaleX;
638
        m_Pattern_offsetX = offsetX;
639
        m_Pattern_offsetY = offsetY;
640
        m_Pattern_rotation = rotation;
641
        connect(patternBox, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(selectPattern(QListWidgetItem*)));
6479 fschmid 642
}
643
 
14126 fschmid 644
void Cpalette::ChooseGrad(int number)
6479 fschmid 645
{
14138 fschmid 646
        disconnect(tabWidget, SIGNAL(currentChanged(int)), this, SLOT(slotGrad(int)));
14126 fschmid 647
        if (number==-1)
10916 fschmid 648
        {
14126 fschmid 649
                tabWidget->setCurrentIndex(0);
10916 fschmid 650
        }
14126 fschmid 651
        if (number == 0)
652
                tabWidget->setCurrentIndex(0);
653
        else if ((number > 0) && (number < 8))
10916 fschmid 654
        {
14126 fschmid 655
                if ((number == 5) || (number == 7))
656
                        gradientType->setCurrentIndex(1);
657
                else
658
                        gradientType->setCurrentIndex(0);
659
                tabWidget->setCurrentIndex(1);
10916 fschmid 660
        }
9874 avox 661
        else
280 Franz 662
        {
14126 fschmid 663
                if (patternList->count() == 0)
280 Franz 664
                {
14126 fschmid 665
                        tabWidget->setCurrentIndex(0);
666
                        emit NewGradient(0);
280 Franz 667
                }
14126 fschmid 668
                else
669
                        tabWidget->setCurrentIndex(2);
280 Franz 670
        }
14138 fschmid 671
        connect(tabWidget, SIGNAL(currentChanged(int)), this, SLOT(slotGrad(int)));
80 Franz 672
}
3 paul 673
 
686 cbradney 674
void Cpalette::slotGrad(int number)
3 paul 675
{
14126 fschmid 676
        if (number == 1)
6513 fschmid 677
        {
14163 fschmid 678
                disconnect(namedGradient, SIGNAL(activated(const QString &)), this, SLOT(setNamedGradient(const QString &)));
679
                if (!currentItem->gradient().isEmpty())
680
                {
681
                        setCurrentComboItem(namedGradient, currentItem->gradient());
682
                        gradEdit->setGradient(gradientList->value(currentItem->gradient()));
683
                        gradEdit->setGradientEditable(false);
684
                }
685
                else
686
                {
687
                        namedGradient->setCurrentIndex(0);
688
                        gradEdit->setGradient(currentItem->fill_gradient);
689
                        gradEdit->setGradientEditable(true);
690
                }
14126 fschmid 691
                if (gradientType->currentIndex() == 0)
692
                        emit NewGradient(6);
295 Franz 693
                else
14163 fschmid 694
                        currentItem->GrType = 7;
695
                connect(namedGradient, SIGNAL(activated(const QString &)), this, SLOT(setNamedGradient(const QString &)));
295 Franz 696
        }
14126 fschmid 697
        else if (number == 2)
698
                emit NewGradient(8);
294 Franz 699
        else
14126 fschmid 700
                emit NewGradient(0);
3 paul 701
}
702
 
14126 fschmid 703
void Cpalette::slotGradType(int type)
3 paul 704
{
14126 fschmid 705
        if (type == 0)
706
                emit NewGradient(6);
5746 fschmid 707
        else
14126 fschmid 708
                emit NewGradient(7);
5746 fschmid 709
}
710
 
295 Franz 711
void Cpalette::setActGradient(int typ)
3 paul 712
{
14126 fschmid 713
        ChooseGrad(typ);
3 paul 714
}
715
 
12187 fschmid 716
void Cpalette::editGradientVector()
294 Franz 717
{
12187 fschmid 718
        if (gradEditButton->isChecked())
719
        {
720
                CGradDia->unitChange(currentDoc->unitIndex());
721
                CGradDia->setValues(currentItem->GrStartX, currentItem->GrStartY, currentItem->GrEndX, currentItem->GrEndY);
722
                CGradDia->show();
723
        }
724
        else
725
        {
726
                CGradDia->hide();
727
        }
728
        emit editGradient();
294 Franz 729
}
730
 
12187 fschmid 731
void Cpalette::setActiveGradDia(bool active)
732
{
733
        if (!active)
734
        {
735
                gradEditButton->setChecked(false);
736
                emit editGradient();
737
        }
738
}
739
 
14126 fschmid 740
void Cpalette::setSpecialGradient(double x1, double y1, double x2, double y2)
3 paul 741
{
14126 fschmid 742
        if (CGradDia)
743
                CGradDia->setValues(x1, y1, x2, y2);
3 paul 744
}
294 Franz 745
 
14126 fschmid 746
void Cpalette::changePatternProps()
6368 fschmid 747
{
14126 fschmid 748
        PatternPropsDialog *dia = new PatternPropsDialog(this, currentUnit);
749
        dia->spinXscaling->setValue(m_Pattern_scaleX);
750
        dia->spinYscaling->setValue(m_Pattern_scaleY);
751
        dia->spinXoffset->setValue(m_Pattern_offsetX);
752
        dia->spinYoffset->setValue(m_Pattern_offsetY);
753
        dia->spinAngle->setValue(m_Pattern_rotation);
754
        connect(dia, SIGNAL(NewPatternProps(double, double, double, double, double)), this, SIGNAL(NewPatternProps(double, double, double, double, double)));
755
        dia->exec();
756
        m_Pattern_scaleX = dia->spinXscaling->value();
757
        m_Pattern_scaleY = dia->spinYscaling->value();
758
        m_Pattern_offsetX = dia->spinXoffset->value();
759
        m_Pattern_offsetY = dia->spinYoffset->value();
760
        m_Pattern_rotation = dia->spinAngle->value();
761
        delete dia;
762
        tabWidget->setCurrentIndex(2);
763
        emit NewGradient(8);
6368 fschmid 764
}
765
 
14126 fschmid 766
void Cpalette::unitChange(double, double, int unitIndex)
294 Franz 767
{
12187 fschmid 768
        if (CGradDia)
769
                CGradDia->unitChange(unitIndex);
14126 fschmid 770
        currentUnit = unitIndex;
294 Franz 771
}
2207 cbradney 772
 
10859 cbradney 773
void Cpalette::changeEvent(QEvent *e)
774
{
775
        if (e->type() == QEvent::LanguageChange)
776
        {
777
                languageChange();
778
        }
10903 cbradney 779
        else
780
                QWidget::changeEvent(e);
10859 cbradney 781
}
782
 
14126 fschmid 783
/*
2207 cbradney 784
void Cpalette::languageChange()
785
{
786
        QString ptSuffix=tr(" pt");
787
        QString pctSuffix=tr(" %");
4546 subik 788
        PM1->setSuffix(pctSuffix);
2207 cbradney 789
        TransSpin->setSuffix(pctSuffix);
6414 fschmid 790
        groupOffset->setTitle( tr( "Offsets" ) );
791
        textLabel1->setText( tr( "X:" ) );
792
        spinXoffset->setSuffix( ptSuffix );
793
        textLabel2->setText( tr( "Y:" ) );
794
        spinYoffset->setSuffix( ptSuffix );
795
        groupScale->setTitle( tr( "Scaling" ) );
6479 fschmid 796
        textLabel5->setText( tr( "X-Scale:" ) );
6414 fschmid 797
        spinXscaling->setSuffix( pctSuffix );
6479 fschmid 798
        textLabel6->setText( tr( "Y-Scale:" ) );
6414 fschmid 799
        spinYscaling->setSuffix( pctSuffix );
800
        groupRotation->setTitle( tr( "Rotation" ) );
801
        textLabel7->setText( tr( "Angle" ) );
4546 subik 802
 
2207 cbradney 803
        ShadeTxt->setText( tr( "Shade:" ) );
804
        TransTxt->setText( tr( "Opacity:" ) );
805
        gradEditButton->setText( tr("Move Vector"));
4546 subik 806
 
10497 fschmid 807
        int oldGradient=gradientQCombo->currentIndex();
2207 cbradney 808
        gradientQCombo->clear();
10497 fschmid 809
        gradientQCombo->addItem( tr("Normal"));
810
        gradientQCombo->addItem( tr("Horizontal Gradient"));
811
        gradientQCombo->addItem( tr("Vertical Gradient"));
812
        gradientQCombo->addItem( tr("Diagonal Gradient"));
813
        gradientQCombo->addItem( tr("Cross Diagonal Gradient"));
814
        gradientQCombo->addItem( tr("Radial Gradient"));
815
        gradientQCombo->addItem( tr("Free linear Gradient"));
816
        gradientQCombo->addItem( tr("Free radial Gradient"));
817
        gradientQCombo->addItem( tr("Pattern"));
818
        gradientQCombo->setCurrentIndex(oldGradient);
5746 fschmid 819
        TransGroup->setTitle( tr( "Transparency Settings" ));
820
        TransTxt2->setText( tr( "Blend Mode:" ) );
821
        blendMode->clear();
10497 fschmid 822
        blendMode->addItem( tr("Normal"));
823
        blendMode->addItem( tr("Darken"));
824
        blendMode->addItem( tr("Lighten"));
825
        blendMode->addItem( tr("Multiply"));
826
        blendMode->addItem( tr("Screen"));
827
        blendMode->addItem( tr("Overlay"));
828
        blendMode->addItem( tr("Hard Light"));
829
        blendMode->addItem( tr("Soft Light"));
830
        blendMode->addItem( tr("Difference"));
831
        blendMode->addItem( tr("Exclusion"));
832
        blendMode->addItem( tr("Color Dodge"));
833
        blendMode->addItem( tr("Color Burn"));
834
        blendMode->addItem( tr("Hue"));
835
        blendMode->addItem( tr("Saturation"));
836
        blendMode->addItem( tr("Color"));
837
        blendMode->addItem( tr("Luminosity"));
10916 fschmid 838
        displayAllColors->setText( tr( "Display only used Colors" ));
2207 cbradney 839
 
12208 cbradney 840
        editLineColorSelector->setToolTip( tr( "Edit Line Color Properties" ) );
841
        editFillColorSelector->setToolTip( tr( "Edit Fill Color Properties" ) );
10397 cbradney 842
        PM1->setToolTip( tr( "Saturation of color" ) );
843
        gradientQCombo->setToolTip( tr( "Normal or gradient fill method" ) );
844
        TransSpin->setToolTip( tr( "Set the transparency for the color selected" ) );
845
        gradEditButton->setToolTip( "<qt>" + tr( "Move the start of the gradient vector with the left mouse button pressed and move the end of the gradient vector with the right mouse button pressed" ) + "</qt>");
12208 cbradney 846
        displayAllColors->setToolTip( "<qt>" + tr( "Display all colors from the document color list, or only the already used colors" ) + "</qt>");
2295 cbradney 847
}
14126 fschmid 848
*/