Subversion Repositories Scribus

Rev

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

Rev Author Line No. Line
13761 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
*/
7
 
14373 cbradney 8
#include "ui/prefs_itemtools.h"
14385 cbradney 9
#include "ui/arrowchooser.h"
15592 craig 10
#include "ui/linkbutton.h"
14373 cbradney 11
#include "prefsstructs.h"
12
#include "scrspinbox.h"
14385 cbradney 13
#include "scribusdoc.h"
14373 cbradney 14
#include "units.h"
14385 cbradney 15
#include "commonstrings.h"
16
#include "prefsmanager.h"
14390 cbradney 17
#include "sampleitem.h"
13761 cbradney 18
 
15592 craig 19
 
15021 cbradney 20
Prefs_ItemTools::Prefs_ItemTools(QWidget* parent, ScribusDoc* doc)
14385 cbradney 21
        : Prefs_Pane(parent),
14390 cbradney 22
        m_doc(NULL),
23
        showFontPreview(false)
13761 cbradney 24
{
25
        setupUi(this);
14385 cbradney 26
        lineEndArrowComboBox->setStartDirection(false);
27
        shapeLineWidthSpinBox->setNewUnit(0);
15847 fschmid 28
        shapeLineWidthSpinBox->setMaximum(36);
29
        shapeLineWidthSpinBox->setDecimals(1);
14385 cbradney 30
        lineWidthSpinBox->setNewUnit(0);
31
        lineWidthSpinBox->setMaximum(36);
32
        lineWidthSpinBox->setDecimals(1);
15847 fschmid 33
        calPenLineWidthSpinBox->setNewUnit(0);
34
        calPenLineWidthSpinBox->setMaximum(36);
35
        calPenLineWidthSpinBox->setDecimals(1);
36
        calPenWidthSpinBox->setNewUnit(0);
37
        calPenWidthSpinBox->setMaximum(100);
38
        calPenWidthSpinBox->setDecimals(1);
39
        calPenAngleSpinBox->setNewUnit(6);
40
        calPenAngleSpinBox->setMaximum(180);
41
        calPenAngleSpinBox->setMinimum(-180);
42
        calPenAngleSpinBox->setDecimals(0);
14385 cbradney 43
        shapeLineWidthSpinBox->setSpecialValueText( tr("Hairline"));
44
        lineWidthSpinBox->setSpecialValueText( tr("Hairline"));
15847 fschmid 45
        calPenLineWidthSpinBox->setSpecialValueText( tr("Hairline"));
14388 cbradney 46
        textSizeSpinBox->setNewUnit(0);
47
        textSizeSpinBox->setMinimum(0.5);
48
        textSizeSpinBox->setMaximum(2048);
14373 cbradney 49
        languageChange();
13761 cbradney 50
}
51
 
52
Prefs_ItemTools::~Prefs_ItemTools()
53
{
54
}
55
 
14373 cbradney 56
 
57
void Prefs_ItemTools::languageChange()
58
{
14390 cbradney 59
        textPreviewWidget->setText( tr( "Woven silk pyjamas exchanged for blue quartz" ));
15592 craig 60
        scalingLockToolButton->setToolTip( tr( "Keep horizontal and vertical scaling the same" ) );
14373 cbradney 61
}
62
 
63
void Prefs_ItemTools::unitChange(int newIndex)
64
{
14388 cbradney 65
        textColumnGapSpinBox->setNewUnit(newIndex);
66
        textTabWidthSpinBox->setNewUnit(newIndex);
19346 craig 67
        topTextDistanceSpinBox->setNewUnit(newIndex);
68
        bottomTextDistanceSpinBox->setNewUnit(newIndex);
69
        leftTextDistanceSpinBox->setNewUnit(newIndex);
70
        rightTextDistanceSpinBox->setNewUnit(newIndex);
14373 cbradney 71
}
72
 
73
void Prefs_ItemTools::restoreDefaults(struct ApplicationPrefs *prefsData)
74
{
14385 cbradney 75
        enableSignals(false);
14373 cbradney 76
        int docUnitIndex = prefsData->docSetupPrefs.docUnitIndex;
14388 cbradney 77
        double unitRatio = unitGetRatioFromIndex(docUnitIndex);
14373 cbradney 78
        unitChange(docUnitIndex);
14385 cbradney 79
 
80
        PrefsManager* prefsManager=PrefsManager::instance();
14390 cbradney 81
        ColorList* colorList = (m_doc != NULL) ? (&m_doc->PageColors) : prefsManager->colorSetPtr();
14385 cbradney 82
 
14388 cbradney 83
        //Text Tool
14390 cbradney 84
        for (int i=0; i<textFontComboBox->count(); ++i)
14388 cbradney 85
        {
14390 cbradney 86
                if (textFontComboBox->itemText(i) == prefsData->itemToolPrefs.textFont)
14388 cbradney 87
                {
14390 cbradney 88
                        textFontComboBox->setCurrentIndex(i);
14388 cbradney 89
                        break;
90
                }
91
        }
92
        textSizeSpinBox->setValue(prefsData->itemToolPrefs.textSize / 10);
14389 cbradney 93
        textColorComboBox->initColorList(colorList, m_doc, prefsData->itemToolPrefs.textColor);
14388 cbradney 94
        textColorShadingSpinBox->setValue(prefsData->itemToolPrefs.textShade);
14389 cbradney 95
        textStrokeColorComboBox->initColorList(colorList, m_doc, prefsData->itemToolPrefs.textStrokeColor);
14388 cbradney 96
        textStrokeShadingSpinBox->setValue(prefsData->itemToolPrefs.textStrokeShade);
14389 cbradney 97
        textFrameFillColorComboBox->initColorList(colorList, m_doc, prefsData->itemToolPrefs.textFillColor);
14388 cbradney 98
        textFrameFillShadingSpinBox->setValue(prefsData->itemToolPrefs.textFillColorShade);
14389 cbradney 99
        textFrameLineColorComboBox->initColorList(colorList, m_doc, prefsData->itemToolPrefs.textLineColor);
14388 cbradney 100
        textFrameLineShadingSpinBox->setValue(prefsData->itemToolPrefs.textLineColorShade);
101
        textTabFillCharComboBox->clear();
102
        textTabFillCharComboBox->addItem( tr("None", "tab fill" ));
103
        textTabFillCharComboBox->addItem( tr("Dot"));
104
        textTabFillCharComboBox->addItem( tr("Hyphen"));
105
        textTabFillCharComboBox->addItem( tr("Underscore"));
106
        textTabFillCharComboBox->addItem( tr("Custom"));
107
        if (prefsData->itemToolPrefs.textTabFillChar.isEmpty())
108
        {
109
                textTabFillCharComboBox->setCurrentIndex(0);
110
        }
111
        else if (prefsData->itemToolPrefs.textTabFillChar == ".")
112
        {
113
                textTabFillCharComboBox->setCurrentIndex(1);
114
        }
115
        else if (prefsData->itemToolPrefs.textTabFillChar == "-")
116
        {
117
                textTabFillCharComboBox->setCurrentIndex(2);
118
        }
119
        else if (prefsData->itemToolPrefs.textTabFillChar == "_")
120
        {
121
                textTabFillCharComboBox->setCurrentIndex(3);
122
        }
123
        else
124
        {
125
                textTabFillCharComboBox->setCurrentIndex(4);
126
                textTabFillCharComboBox->setEditable(true);
127
                textTabFillCharComboBox->setItemText(textTabFillCharComboBox->currentIndex(), CommonStrings::trCustomTabFill + prefsData->itemToolPrefs.textTabFillChar);
128
        }
129
        textTabWidthSpinBox->setValue(prefsData->itemToolPrefs.textTabWidth * unitRatio);
130
        textColumnsSpinBox->setValue(prefsData->itemToolPrefs.textColumns);
131
        textColumnGapSpinBox->setValue(prefsData->itemToolPrefs.textColumnGap * unitRatio);
15138 cbradney 132
        topTextDistanceSpinBox->setValue(prefsData->itemToolPrefs.textDistances.Top * unitRatio);
133
        bottomTextDistanceSpinBox->setValue(prefsData->itemToolPrefs.textDistances.Bottom * unitRatio);
134
        leftTextDistanceSpinBox->setValue(prefsData->itemToolPrefs.textDistances.Left * unitRatio);
135
        rightTextDistanceSpinBox->setValue(prefsData->itemToolPrefs.textDistances.Right * unitRatio);
14388 cbradney 136
 
137
        //Image Tool
138
        imageFreeScalingRadioButton->setChecked( prefsData->itemToolPrefs.imageScaleType );
139
        imageFrameScalingRadioButton->setChecked( !prefsData->itemToolPrefs.imageScaleType );
140
        imageHorizontalScalingSpinBox->setValue(qRound(prefsData->itemToolPrefs.imageScaleX * 100));
141
        imageVerticalScalingSpinBox->setValue(qRound(prefsData->itemToolPrefs.imageScaleY * 100));
142
        imageKeepAspectRatioCheckBox->setChecked(prefsData->itemToolPrefs.imageAspectRatio);
17747 craig 143
        scalingLockToolButton->setChecked(prefsData->itemToolPrefs.imageAspectRatio);
14389 cbradney 144
        imageFrameFillColorComboBox->initColorList(colorList, m_doc, prefsData->itemToolPrefs.imageFillColor);
14388 cbradney 145
        imageFrameFillShadingSpinBox->setValue(prefsData->itemToolPrefs.imageFillColorShade );
17054 fschmid 146
        imageFrameLineColorComboBox->initColorList(colorList, m_doc, prefsData->itemToolPrefs.imageStrokeColor);
147
        imageFrameLineShadingSpinBox->setValue(prefsData->itemToolPrefs.imageStrokeColorShade );
14388 cbradney 148
        imageUseEmbeddedClippingPathCheckBox->setChecked(prefsData->itemToolPrefs.imageUseEmbeddedPath);
149
        switch (prefsData->itemToolPrefs.imageLowResType)
150
        {
151
                case 0:
152
                        onscreenResolutionFullRadioButton->setChecked(true);
153
                        break;
154
                case 1:
155
                        onscreenResolutionNormalRadioButton->setChecked(true);
156
                        break;
157
                case 2:
158
                        onscreenResolutionLowRadioButton->setChecked(true);
159
                        break;
160
        }
14385 cbradney 161
 
14388 cbradney 162
        //Shape Tool
14389 cbradney 163
        shapeFrameLineColorComboBox->initColorList(colorList, m_doc, prefsData->itemToolPrefs.shapeLineColor);
14385 cbradney 164
        shapeFrameLineShadingSpinBox->setValue(prefsData->itemToolPrefs.shapeLineColorShade);
14389 cbradney 165
        shapeFrameFillColorComboBox->initColorList(colorList, m_doc, prefsData->itemToolPrefs.shapeFillColor);
14385 cbradney 166
        shapeFrameFillShadingSpinBox->setValue(prefsData->itemToolPrefs.shapeFillColorShade);
167
        shapeFrameLineStyleComboBox->setCurrentIndex(static_cast<int>(prefsData->itemToolPrefs.shapeLineStyle) - 1);
168
        shapeLineWidthSpinBox->setValue(prefsData->itemToolPrefs.shapeLineWidth);
169
 
170
        //Polygon Tool
14436 cbradney 171
        polygonWidget->restoreDefaults(&prefsData->itemToolPrefs);
14385 cbradney 172
 
173
        //Line Tool
14389 cbradney 174
        lineFillColorComboBox->initColorList(colorList, m_doc, prefsData->itemToolPrefs.lineColor);
175
 
14385 cbradney 176
        lineFillColorShadingSpinBox->setValue(prefsData->itemToolPrefs.lineColorShade);
177
        lineStyleComboBox->setCurrentIndex(static_cast<int>(prefsData->itemToolPrefs.lineStyle) - 1);
178
        if (m_doc != 0)
179
        {
14969 cbradney 180
                lineStartArrowComboBox->rebuildList(&m_doc->arrowStyles());
181
                lineEndArrowComboBox->rebuildList(&m_doc->arrowStyles());
14385 cbradney 182
        }
183
        else
184
        {
185
                lineStartArrowComboBox->rebuildList(&prefsData->arrowStyles);
186
                lineEndArrowComboBox->rebuildList(&prefsData->arrowStyles);
187
        }
188
        lineStartArrowComboBox->setCurrentIndex(prefsData->itemToolPrefs.lineStartArrow);
189
        lineEndArrowComboBox->setCurrentIndex(prefsData->itemToolPrefs.lineEndArrow);
190
        lineWidthSpinBox->setValue(prefsData->itemToolPrefs.lineWidth);
191
        //
15847 fschmid 192
        //Calligraphic Pen Tool
19378 craig 193
        calPenFillColorComboBox->initColorList(colorList, m_doc, prefsData->itemToolPrefs.calligraphicPenFillColor);
194
        calPenFillShadingSpinBox->setValue(prefsData->itemToolPrefs.calligraphicPenFillColorShade);
195
        calPenColorComboBox->initColorList(colorList, m_doc, prefsData->itemToolPrefs.calligraphicPenLineColor);
196
        calPenLineShadingSpinBox->setValue(prefsData->itemToolPrefs.calligraphicPenLineColorShade);
197
        calPenStyleComboBox->setCurrentIndex(static_cast<int>(prefsData->itemToolPrefs.calligraphicPenStyle) - 1);
198
        calPenLineWidthSpinBox->setValue(prefsData->itemToolPrefs.calligraphicPenLineWidth);
199
        calPenAngleSpinBox->setValue(prefsData->itemToolPrefs.calligraphicPenAngle);
200
        calPenWidthSpinBox->setValue(prefsData->itemToolPrefs.calligraphicPenWidth);
14385 cbradney 201
 
16316 fschmid 202
        // Arc Tool
203
        arcDisplay->restoreDefaults(&prefsData->itemToolPrefs);
16317 fschmid 204
        // Spiral Tool
205
        spiralDisplay->restoreDefaults(&prefsData->itemToolPrefs);
16316 fschmid 206
 
14385 cbradney 207
        enableSignals(true);
14373 cbradney 208
}
209
 
210
void Prefs_ItemTools::saveGuiToPrefs(struct ApplicationPrefs *prefsData) const
211
{
14385 cbradney 212
 
14388 cbradney 213
        //Text Tool
214
        prefsData->itemToolPrefs.textFont = textFontComboBox->currentText();
215
        prefsData->itemToolPrefs.textSize = textSizeSpinBox->value() * 10;
216
        prefsData->itemToolPrefs.textFillColor = textFrameFillColorComboBox->currentText();
217
        if (prefsData->itemToolPrefs.textFillColor == CommonStrings::tr_NoneColor)
218
                prefsData->itemToolPrefs.textFillColor = CommonStrings::None;
219
        prefsData->itemToolPrefs.textLineColor = textFrameLineColorComboBox->currentText();
220
        if (prefsData->itemToolPrefs.textLineColor == CommonStrings::tr_NoneColor)
221
                prefsData->itemToolPrefs.textLineColor = CommonStrings::None;
222
        prefsData->itemToolPrefs.textFillColorShade = textFrameFillShadingSpinBox->value();
223
        prefsData->itemToolPrefs.textLineColorShade = textFrameLineShadingSpinBox->value();
224
        prefsData->itemToolPrefs.textShade = textColorShadingSpinBox->value();
225
        prefsData->itemToolPrefs.textStrokeShade = textStrokeShadingSpinBox->value();
226
        prefsData->itemToolPrefs.textColor = textColorComboBox->currentText();
227
        if (prefsData->itemToolPrefs.textColor == CommonStrings::tr_NoneColor)
228
                prefsData->itemToolPrefs.textColor = CommonStrings::None;
229
        prefsData->itemToolPrefs.textStrokeColor = textStrokeColorComboBox->currentText();
230
        if (prefsData->itemToolPrefs.textStrokeColor == CommonStrings::tr_NoneColor)
231
                prefsData->itemToolPrefs.textStrokeColor = CommonStrings::None;
232
        prefsData->itemToolPrefs.textColumns = textColumnsSpinBox->value();
233
        int docUnitIndex = prefsData->docSetupPrefs.docUnitIndex;
234
        double unitRatio = unitGetRatioFromIndex(docUnitIndex);
235
        prefsData->itemToolPrefs.textColumnGap = textColumnGapSpinBox->value() / unitRatio;
236
        prefsData->itemToolPrefs.textTabWidth = textTabWidthSpinBox->value() / unitRatio;
237
 
238
        switch (textTabFillCharComboBox->currentIndex())
239
        {
240
                case 0:
241
                        prefsData->itemToolPrefs.textTabFillChar = "";
242
                        break;
243
                case 1:
244
                        prefsData->itemToolPrefs.textTabFillChar = ".";
245
                        break;
246
                case 2:
247
                        prefsData->itemToolPrefs.textTabFillChar = "-";
248
                        break;
249
                case 3:
250
                        prefsData->itemToolPrefs.textTabFillChar = "_";
251
                        break;
252
                case 4:
253
                        prefsData->itemToolPrefs.textTabFillChar = textTabFillCharComboBox->currentText().right(1);
254
                        break;
255
        }
15138 cbradney 256
        prefsData->itemToolPrefs.textDistances.Top = topTextDistanceSpinBox->value() / unitRatio;
257
        prefsData->itemToolPrefs.textDistances.Bottom = bottomTextDistanceSpinBox->value() / unitRatio;
258
        prefsData->itemToolPrefs.textDistances.Left = leftTextDistanceSpinBox->value() / unitRatio;
259
        prefsData->itemToolPrefs.textDistances.Right = rightTextDistanceSpinBox->value() / unitRatio;
14388 cbradney 260
        prefsData->itemToolPrefs.imageFillColor = imageFrameFillColorComboBox->currentText();
261
        if (prefsData->itemToolPrefs.imageFillColor == CommonStrings::tr_NoneColor)
262
                prefsData->itemToolPrefs.imageFillColor = CommonStrings::None;
263
        prefsData->itemToolPrefs.imageFillColorShade = imageFrameFillShadingSpinBox->value();
17054 fschmid 264
        prefsData->itemToolPrefs.imageStrokeColor = imageFrameLineColorComboBox->currentText();
265
        if (prefsData->itemToolPrefs.imageStrokeColor == CommonStrings::tr_NoneColor)
266
                prefsData->itemToolPrefs.imageStrokeColor = CommonStrings::None;
267
        prefsData->itemToolPrefs.imageStrokeColorShade = imageFrameFillShadingSpinBox->value();
14388 cbradney 268
        prefsData->itemToolPrefs.imageScaleX = static_cast<double>(imageHorizontalScalingSpinBox->value()) / 100.0;
269
        prefsData->itemToolPrefs.imageScaleY = static_cast<double>(imageVerticalScalingSpinBox->value()) / 100.0;
270
        prefsData->itemToolPrefs.imageScaleType = imageFreeScalingRadioButton->isChecked();
271
        prefsData->itemToolPrefs.imageAspectRatio = imageKeepAspectRatioCheckBox->isChecked();
272
        prefsData->itemToolPrefs.imageUseEmbeddedPath = imageUseEmbeddedClippingPathCheckBox->isChecked();
273
        int haRes = 0;
274
        if (onscreenResolutionFullRadioButton->isChecked())
275
                haRes = 0;
276
        if (onscreenResolutionNormalRadioButton->isChecked())
277
                haRes = 1;
278
        if (onscreenResolutionLowRadioButton->isChecked())
279
                haRes = 2;
280
        prefsData->itemToolPrefs.imageLowResType = haRes;
281
 
282
 
14385 cbradney 283
        //Shape tool
284
        prefsData->itemToolPrefs.shapeLineColor = shapeFrameLineColorComboBox->currentText();
285
        if (prefsData->itemToolPrefs.shapeLineColor == CommonStrings::tr_NoneColor)
286
                prefsData->itemToolPrefs.shapeLineColor = CommonStrings::None;
287
        prefsData->itemToolPrefs.shapeFillColor = shapeFrameFillColorComboBox->currentText();
288
        if (prefsData->itemToolPrefs.shapeFillColor == CommonStrings::tr_NoneColor)
289
                prefsData->itemToolPrefs.shapeFillColor = CommonStrings::None;
290
        prefsData->itemToolPrefs.shapeFillColorShade = shapeFrameFillShadingSpinBox->value();
291
        prefsData->itemToolPrefs.shapeLineColorShade = shapeFrameLineShadingSpinBox->value();
292
        prefsData->itemToolPrefs.shapeLineStyle = static_cast<Qt::PenStyle>(shapeFrameLineStyleComboBox->currentIndex()) + 1;
293
        prefsData->itemToolPrefs.shapeLineWidth = shapeLineWidthSpinBox->value();
294
 
295
 
296
 
297
        //Polygon Tool
14436 cbradney 298
        polygonWidget->saveGuiToPrefs(&prefsData->itemToolPrefs);
14385 cbradney 299
 
300
        //Line Tool
301
        prefsData->itemToolPrefs.lineColor = lineFillColorComboBox->currentText();
302
        if (prefsData->itemToolPrefs.lineColor == CommonStrings::tr_NoneColor)
303
                prefsData->itemToolPrefs.lineColor = CommonStrings::None;
304
        prefsData->itemToolPrefs.lineColorShade = lineFillColorShadingSpinBox->value();
305
        prefsData->itemToolPrefs.lineStyle = static_cast<Qt::PenStyle>(lineStyleComboBox->currentIndex()) + 1;
306
        prefsData->itemToolPrefs.lineWidth = lineWidthSpinBox->value();
307
        prefsData->itemToolPrefs.lineStartArrow = lineStartArrowComboBox->currentIndex();
308
        prefsData->itemToolPrefs.lineEndArrow = lineEndArrowComboBox->currentIndex();
15847 fschmid 309
        //Calligraphic Pen Tool
19378 craig 310
        prefsData->itemToolPrefs.calligraphicPenFillColor = calPenFillColorComboBox->currentText();
311
        if (prefsData->itemToolPrefs.calligraphicPenFillColor == CommonStrings::tr_NoneColor)
312
                prefsData->itemToolPrefs.calligraphicPenFillColor = CommonStrings::None;
313
        prefsData->itemToolPrefs.calligraphicPenLineColor = calPenColorComboBox->currentText();
314
        if (prefsData->itemToolPrefs.calligraphicPenLineColor == CommonStrings::tr_NoneColor)
315
                prefsData->itemToolPrefs.calligraphicPenLineColor = CommonStrings::None;
316
        prefsData->itemToolPrefs.calligraphicPenFillColorShade = calPenFillShadingSpinBox->value();
317
        prefsData->itemToolPrefs.calligraphicPenLineColorShade = calPenLineShadingSpinBox->value();
318
        prefsData->itemToolPrefs.calligraphicPenStyle = static_cast<Qt::PenStyle>(calPenStyleComboBox->currentIndex()) + 1;
319
        prefsData->itemToolPrefs.calligraphicPenLineWidth = calPenLineWidthSpinBox->value();
320
        prefsData->itemToolPrefs.calligraphicPenAngle = calPenAngleSpinBox->value();
321
        prefsData->itemToolPrefs.calligraphicPenWidth = calPenWidthSpinBox->value();
16316 fschmid 322
 
323
        //Arc Tool
324
        arcDisplay->saveGuiToPrefs(&prefsData->itemToolPrefs);
16317 fschmid 325
        //Spiral Tool
326
        spiralDisplay->saveGuiToPrefs(&prefsData->itemToolPrefs);
14373 cbradney 327
}
14385 cbradney 328
 
329
void Prefs_ItemTools::enableSignals(bool on)
330
{
331
        if (on)
332
        {
14390 cbradney 333
                connect(textFontComboBox, SIGNAL(activated(int)), this, SLOT(updateFontPreview()));
334
                connect(textSizeSpinBox, SIGNAL(valueChanged(double)), this, SLOT(updateFontPreview()));
335
                connect(textColorComboBox, SIGNAL(activated(int)), this, SLOT(updateFontPreview()));
336
                connect(textFrameFillColorComboBox, SIGNAL(activated(int)), this, SLOT(updateFontPreview()));
337
                connect(textFrameFillShadingSpinBox, SIGNAL(valueChanged(int)), this, SLOT(updateFontPreview()));
338
                connect(textColorShadingSpinBox, SIGNAL(valueChanged(int)), this, SLOT(updateFontPreview()));
14385 cbradney 339
//              connect(buttonGroup3, SIGNAL(toggled(bool)), this, SLOT(changeImageScalingFree(bool)));
340
//              connect(buttonGroup5, SIGNAL(toggled(bool)), this, SLOT(changeImageScalingRatio(bool)));
15592 craig 341
                connect(scalingLockToolButton, SIGNAL(clicked()), this, SLOT(toggleImagesScalingChain()));
342
                connect(imageHorizontalScalingSpinBox, SIGNAL(valueChanged(int)), this, SLOT(imageHorizontalScalingChange()));
17747 craig 343
                connect(imageKeepAspectRatioCheckBox, SIGNAL(toggled(bool)), scalingLockToolButton, SLOT(setChecked(bool)));
15592 craig 344
                connect(imageVerticalScalingSpinBox, SIGNAL(valueChanged(int)), this, SLOT(imageVerticalScalingChange()));
14385 cbradney 345
//              connect(tabFillCombo, SIGNAL(activated(int)), this, SLOT(setFillChar(int)));
346
        }
347
        else
348
        {
14390 cbradney 349
                disconnect(textFontComboBox, SIGNAL(activated(int)), this, SLOT(updateFontPreview()));
350
                disconnect(textSizeSpinBox, SIGNAL(valueChanged(double)), this, SLOT(updateFontPreview()));
351
                disconnect(textColorComboBox, SIGNAL(activated(int)), this, SLOT(updateFontPreview()));
352
                disconnect(textFrameFillColorComboBox, SIGNAL(activated(int)), this, SLOT(updateFontPreview()));
353
                disconnect(textFrameFillShadingSpinBox, SIGNAL(valueChanged(int)), this, SLOT(updateFontPreview()));
354
                disconnect(textColorShadingSpinBox, SIGNAL(valueChanged(int)), this, SLOT(updateFontPreview()));
14385 cbradney 355
//              disconnect(buttonGroup3, SIGNAL(toggled(bool)), this, SLOT(changeImageScalingFree(bool)));
356
//              disconnect(buttonGroup5, SIGNAL(toggled(bool)), this, SLOT(changeImageScalingRatio(bool)));
15592 craig 357
                disconnect(scalingLockToolButton, SIGNAL(clicked()), this, SLOT(toggleImagesScalingChain()));
358
                disconnect(imageHorizontalScalingSpinBox, SIGNAL(valueChanged(int)), this, SLOT(imageHorizontalScalingChange()));
359
                disconnect(imageVerticalScalingSpinBox, SIGNAL(valueChanged(int)), this, SLOT(imageVerticalScalingChange()));
14385 cbradney 360
//              disconnect(tabFillCombo, SIGNAL(activated(int)), this, SLOT(setFillChar(int)));
361
        }
362
}
14390 cbradney 363
 
364
void Prefs_ItemTools::enableFontPreview(bool showPreview)
365
{
366
        showFontPreview = showPreview;
367
        updateFontPreview();
368
}
369
 
370
void Prefs_ItemTools::updateFontPreview()
371
{
372
        if (!showFontPreview)
373
                return;
374
 
14807 fschmid 375
        SampleItem si;
14390 cbradney 376
        si.setText( tr("Woven silk pyjamas exchanged for blue quartz"));
377
        if (textFrameFillColorComboBox->currentText() != CommonStrings::tr_NoneColor)
378
        {
379
                if (m_doc != 0)
380
                {
381
                        si.setBgColor(m_doc->PageColors[textFrameFillColorComboBox->currentText()].getRawRGBColor());
382
                }
383
                else
384
                {
385
                        PrefsManager* prefsManager=PrefsManager::instance();
386
                        ColorList* colorList=prefsManager->colorSetPtr();
387
                        si.setBgColor((*colorList)[textFrameFillColorComboBox->currentText()].getRawRGBColor());
388
                }
389
                si.setBgShade(textFrameFillShadingSpinBox->value());
390
        }
391
        else
392
                si.setBgColor(palette().color(QPalette::Window));
393
 
394
        if (textColorComboBox->currentText() != CommonStrings::tr_NoneColor)
395
        {
396
                if (m_doc != 0)
397
                {
398
                        si.setTxColor(m_doc->PageColors[textColorComboBox->currentText()].getRawRGBColor());
399
                }
400
                else
401
                {
402
                        PrefsManager* prefsManager=PrefsManager::instance();
403
                        ColorList* colorList=prefsManager->colorSetPtr();
404
                        si.setTxColor((*colorList)[textColorComboBox->currentText()].getRawRGBColor());
405
                }
406
                si.setTxShade(textColorShadingSpinBox->value());
407
        }
408
        else
409
                si.setTxColor(palette().color(QPalette::Window));
410
        si.setFont(textFontComboBox->currentText());
411
        si.setFontSize(textSizeSpinBox->value() * 10, true);
412
        textPreviewWidget->setPixmap(si.getSample(textPreviewWidget->width(), textPreviewWidget->height()));
413
}
414
 
15592 craig 415
void Prefs_ItemTools::toggleImagesScalingChain()
416
{
417
        imageHorizontalScalingChange();
17747 craig 418
        imageKeepAspectRatioCheckBox->setChecked(scalingLockToolButton->isChecked());
15592 craig 419
}
420
 
421
void Prefs_ItemTools::imageHorizontalScalingChange()
422
{
423
        if (scalingLockToolButton->isChecked())
424
                imageVerticalScalingSpinBox->setValue(imageHorizontalScalingSpinBox->value());
425
}
426
 
427
void Prefs_ItemTools::imageVerticalScalingChange()
428
{
429
        if (scalingLockToolButton->isChecked())
430
                imageHorizontalScalingSpinBox->setValue(imageVerticalScalingSpinBox->value());
431
}
432
 
433