Subversion Repositories Scribus

Rev

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

Rev Author Line No. Line
879 fschmid 1
#include "tabguides.h"
2
#include "tabguides.moc"
3
#include <qlayout.h>
4
#include <qgroupbox.h>
1187 fschmid 5
#include <qbuttongroup.h>
6
#include <qradiobutton.h>
879 fschmid 7
#include <qlabel.h>
8
#include <qtooltip.h>
9
#include <qspinbox.h>
10
#include <qcolor.h>
11
#include <qcolordialog.h>
12
#include <qcheckbox.h>
13
#include <qpushbutton.h>
14
#include <qpixmap.h>
15
#include "mspinbox.h"
16
#include "scribusstructs.h"
1790 cbradney 17
#include "units.h"
879 fschmid 18
 
1790 cbradney 19
TabGuides::TabGuides( QWidget* parent, struct guidesPrefs *prefsData, struct typoPrefs *prefsData2, int unitIndex) : QWidget( parent, "tabguide", 0 )
879 fschmid 20
{
1790 cbradney 21
        unit = unitGetSuffixFromIndex(unitIndex);
22
        precision = unitGetPrecisionFromIndex(unitIndex);
23
        unitRatio = unitGetRatioFromIndex(unitIndex);
24
 
879 fschmid 25
        tabGuidesLayout = new QVBoxLayout( this, 10, 5, "tabViewLayout");
1195 fschmid 26
 
27
        commonBox = new QGroupBox( this, "commonBox" );
28
        commonBox->setTitle( tr( "Common Settings" ) );
29
        commonBox->setColumnLayout(0, Qt::Vertical );
30
        commonBox->layout()->setSpacing( 5 );
31
        commonBox->layout()->setMargin( 10 );
32
        commonBoxLayout = new QHBoxLayout( commonBox->layout() );
33
 
34
        buttonGroup1 = new QButtonGroup( commonBox, "buttonGroup1" );
35
        buttonGroup1->setExclusive( true );
36
        buttonGroup1->setColumnLayout(0, Qt::Horizontal );
37
        buttonGroup1->layout()->setSpacing( 5 );
38
        buttonGroup1->layout()->setMargin( 10 );
39
        buttonGroup1->setTitle( tr( "Placing in Documents" ) );
40
        buttonGroup1Layout = new QVBoxLayout( buttonGroup1->layout() );
41
        buttonGroup1Layout->setAlignment( Qt::AlignTop );
42
        inBackground = new QRadioButton( buttonGroup1, "inBackground" );
43
        inBackground->setText( tr( "In the Background" ) );
44
        buttonGroup1Layout->addWidget( inBackground );
45
        inForeground = new QRadioButton( buttonGroup1, "inForeground" );
46
        inForeground->setText( tr( "In the Foreground" ) );
47
        buttonGroup1Layout->addWidget( inForeground );
48
        inBackground->setChecked( prefsData->before );
49
        inForeground->setChecked( !prefsData->before );
50
        commonBoxLayout->addWidget( buttonGroup1 );
51
 
52
        snapBox = new QGroupBox( commonBox, "snapBox" );
53
        snapBox->setTitle( tr( "Snapping" ) );
54
        snapBox->setColumnLayout(0, Qt::Vertical );
55
        snapBox->layout()->setSpacing( 5 );
56
        snapBox->layout()->setMargin( 10 );
57
        snapBoxLayout = new QGridLayout( snapBox->layout() );
58
        textLabel8 = new QLabel( snapBox, "textLabel8" );
59
        textLabel8->setText( tr( "Snap Distance:" ) );
60
        snapBoxLayout->addWidget( textLabel8, 0, 0 );
1790 cbradney 61
        snapDistance = new MSpinBox( unitRatio, 1000 * unitRatio, snapBox, precision );
62
        snapDistance->setValue( prefsData->guideRad * unitRatio );
1195 fschmid 63
        snapDistance->setSuffix( unit );
64
        snapBoxLayout->addWidget( snapDistance, 0, 1 );
65
        textLabel82 = new QLabel( snapBox, "textLabel8" );
66
        textLabel82->setText( tr( "Grab Radius:" ) );
67
        snapBoxLayout->addWidget( textLabel82, 1, 0 );
68
        grabDistance = new QSpinBox( snapBox, "grabDistance" );
69
        grabDistance->setMaxValue( 1000 );
70
        grabDistance->setMinValue( 1 );
71
        grabDistance->setLineStep( 1 );
72
        grabDistance->setValue( prefsData->grabRad );
73
        grabDistance->setSuffix( tr( " px" ) );
74
        snapBoxLayout->addWidget( grabDistance, 1, 1 );
75
        commonBoxLayout->addWidget( snapBox );
76
        tabGuidesLayout->addWidget( commonBox );
77
        layout9 = new QHBoxLayout( 0, 0, 5, "layout9");
78
        guideBox = new QGroupBox( this, "guideBox" );
79
        guideBox->setTitle( tr( "Guides" ) );
80
        guideBox->setColumnLayout(0, Qt::Vertical );
81
        guideBox->layout()->setSpacing( 5 );
82
        guideBox->layout()->setMargin( 10 );
83
        guideBoxLayout = new QHBoxLayout( guideBox->layout() );
84
        checkGuides = new QCheckBox( guideBox, "checkGuides" );
85
        checkGuides->setText( tr( "Show Guides" ) );
86
        checkGuides->setChecked(prefsData->guidesShown);
87
        guideBoxLayout->addWidget( checkGuides );
88
        guideColor = new QPushButton( guideBox, "guideColor" );
89
        guideColor->setMinimumSize( QSize( 60, 20 ) );
90
        guideColor->setMaximumSize( QSize( 60, 20 ) );
91
        guideColor->setFlat( false );
92
        guideColor->setAutoDefault( false );
93
        QPixmap pm3 = QPixmap(54, 14);
94
        pm3.fill(prefsData->guideColor);
95
        colorGuides = prefsData->guideColor;
96
        guideColor->setPixmap(pm3);
97
        guideColor->setText( QString::null );
98
        guideBoxLayout->addWidget( guideColor );
99
        layout9->addWidget( guideBox );
100
        marginBox = new QGroupBox( this, "guideBox" );
101
        marginBox->setTitle( tr( "Margins" ) );
102
        marginBox->setColumnLayout(0, Qt::Vertical );
103
        marginBox->layout()->setSpacing( 5 );
104
        marginBox->layout()->setMargin( 10 );
105
        marginBoxLayout = new QHBoxLayout( marginBox->layout() );
106
        checkMargin = new QCheckBox( marginBox, "checkMargin" );
107
        checkMargin->setText( tr( "Show Margins" ) );
108
        checkMargin->setChecked(prefsData->marginsShown);
109
        marginBoxLayout->addWidget( checkMargin );
110
        marginColor = new QPushButton( marginBox, "marginColor" );
111
        marginColor->setMinimumSize( QSize( 60, 20 ) );
112
        marginColor->setMaximumSize( QSize( 60, 20 ) );
113
        marginColor->setAutoDefault( false );
114
        QPixmap pm6 = QPixmap(54, 14);
115
        pm6.fill(prefsData->margColor);
116
        colorMargin = prefsData->margColor;
117
        marginColor->setPixmap(pm6);
118
        marginColor->setFlat( false );
119
        marginColor->setText( QString::null );
120
        marginBoxLayout->addWidget( marginColor );
121
        layout9->addWidget( marginBox );
122
        tabGuidesLayout->addLayout( layout9 );
123
 
879 fschmid 124
        checkGrid = new QGroupBox( this, "checkGrid" );
1195 fschmid 125
        checkGrid->setTitle( tr( "Show Page Grid" ) );
879 fschmid 126
        checkGrid->setCheckable( true );
127
        checkGrid->setChecked(prefsData->gridShown);
128
        checkGrid->setColumnLayout(0, Qt::Vertical );
129
        checkGrid->layout()->setSpacing( 5 );
130
        checkGrid->layout()->setMargin( 10 );
131
        checkGridLayout = new QGridLayout( checkGrid->layout() );
132
        checkGridLayout->setAlignment( Qt::AlignTop );
133
        groupBox1 = new QGroupBox( checkGrid, "groupBox1" );
134
        groupBox1->setColumnLayout(0, Qt::Vertical );
135
        groupBox1->layout()->setSpacing( 5 );
136
        groupBox1->layout()->setMargin( 10 );
137
        groupBox1->setTitle( tr( "Major Grid" ) );
138
        groupBox1Layout = new QGridLayout( groupBox1->layout() );
139
        groupBox1Layout->setAlignment( Qt::AlignTop );
140
        majorGridColor = new QPushButton( groupBox1, "majorGridColor" );
141
        majorGridColor->setMinimumSize( QSize( 60, 20 ) );
142
        majorGridColor->setMaximumSize( QSize( 60, 20 ) );
143
        majorGridColor->setFlat( false );
144
        majorGridColor->setAutoDefault( false );
145
        QPixmap pm1 = QPixmap(54, 14);
146
        pm1.fill(prefsData->majorColor);
147
        colorMajorGrid = prefsData->majorColor;
148
        majorGridColor->setPixmap(pm1);
149
        majorGridColor->setText( QString::null );
150
        groupBox1Layout->addWidget( majorGridColor, 1, 1 );
151
        textLabel4 = new QLabel( groupBox1, "textLabel4" );
152
        textLabel4->setText( tr( "Color:" ) );
153
        groupBox1Layout->addWidget( textLabel4, 1, 0 );
154
        textLabel6 = new QLabel( groupBox1, "textLabel6" );
155
        textLabel6->setText( tr( "Spacing:" ) );
156
        groupBox1Layout->addWidget( textLabel6, 0, 0 );
1790 cbradney 157
        majorSpace = new MSpinBox( 10 * unitRatio, 1000 * unitRatio, groupBox1, precision );
158
        majorSpace->setValue( prefsData->majorGrid * unitRatio );
879 fschmid 159
        majorSpace->setSuffix( unit );
160
        groupBox1Layout->addWidget( majorSpace, 0, 1 );
161
        checkGridLayout->addWidget( groupBox1, 0, 0 );
162
        groupBox2 = new QGroupBox( checkGrid, "groupBox2" );
163
        groupBox2->setColumnLayout(0, Qt::Vertical );
164
        groupBox2->layout()->setSpacing( 5 );
165
        groupBox2->layout()->setMargin( 10 );
166
        groupBox2->setTitle( tr( "Minor Grid" ) );
167
        groupBox2Layout = new QGridLayout( groupBox2->layout() );
168
        groupBox2Layout->setAlignment( Qt::AlignTop );
169
        textLabel5 = new QLabel( groupBox2, "textLabel5" );
170
        textLabel5->setText( tr( "Color:" ) );
171
        groupBox2Layout->addWidget( textLabel5, 1, 0 );
172
        minorGridColor = new QPushButton( groupBox2, "minorGridColor" );
173
        minorGridColor->setMinimumSize( QSize( 60, 20 ) );
174
        minorGridColor->setMaximumSize( QSize( 60, 20 ) );
175
        minorGridColor->setFlat( false );
176
        minorGridColor->setAutoDefault( false );
177
        QPixmap pm = QPixmap(54, 14);
178
        pm.fill(prefsData->minorColor);
179
        colorMinorGrid = prefsData->minorColor;
180
        minorGridColor->setPixmap(pm);
181
        minorGridColor->setText( QString::null );
182
        groupBox2Layout->addWidget( minorGridColor, 1, 1 );
183
        textLabel7 = new QLabel( groupBox2, "textLabel7" );
184
        textLabel7->setText( tr( "Spacing:" ) );
185
        groupBox2Layout->addWidget( textLabel7, 0, 0 );
1790 cbradney 186
        minorSpace = new MSpinBox( unitRatio, 1000 * unitRatio, groupBox2, precision );
187
        minorSpace->setValue( prefsData->minorGrid  * unitRatio);
879 fschmid 188
        minorSpace->setSuffix( unit );
189
        groupBox2Layout->addWidget( minorSpace, 0, 1 );
190
        checkGridLayout->addWidget( groupBox2, 0, 1 );
191
        tabGuidesLayout->addWidget( checkGrid );
192
 
1195 fschmid 193
        baselineBox = new QGroupBox( this, "baselineBox" );
194
        baselineBox->setTitle( tr( "Baseline Grid" ) );
195
        baselineBox->setColumnLayout(0, Qt::Vertical );
196
        baselineBox->layout()->setSpacing( 5 );
197
        baselineBox->layout()->setMargin( 10 );
198
        baselineBoxLayout = new QGridLayout( baselineBox->layout() );
199
        baselineBoxLayout->setAlignment( Qt::AlignTop );
200
        checkBaseline = new QCheckBox( baselineBox, "checkBaseline" );
879 fschmid 201
        checkBaseline->setText( tr( "Show Baseline Grid" ) );
202
        checkBaseline->setChecked(prefsData->baseShown);
1195 fschmid 203
        baselineBoxLayout->addWidget( checkBaseline, 0, 0 );
204
        baselineColor = new QPushButton( baselineBox, "baselineColor" );
879 fschmid 205
        baselineColor->setMinimumSize( QSize( 60, 20 ) );
206
        baselineColor->setMaximumSize( QSize( 60, 20 ) );
207
        baselineColor->setFlat( false );
208
        baselineColor->setAutoDefault( false );
209
        QPixmap pm4 = QPixmap(54, 14);
210
        pm4.fill(prefsData->baseColor);
211
        colorBaselineGrid = prefsData->baseColor;
212
        baselineColor->setPixmap(pm4);
213
        baselineColor->setText( QString::null );
1195 fschmid 214
        baselineBoxLayout->addWidget( baselineColor, 0, 1 );
215
        autoLine = new QSpinBox( baselineBox, "autoLine" );
216
        autoLine->setMaxValue( 100 );
217
        autoLine->setMinValue( 1 );
218
        autoLine->setValue( prefsData2->autoLineSpacing );
219
        autoLine->setSuffix( tr( " %" ) );
220
        baselineBoxLayout->addWidget( autoLine, 1, 1 );
221
        textLabel8a = new QLabel( autoLine, tr( "Automatic &Line Spacing:" ), baselineBox, "textLabel8a" );
222
        baselineBoxLayout->addWidget( textLabel8a, 1, 0 );
1790 cbradney 223
        baseGrid = new MSpinBox( 1, 1000, baselineBox, precision );
1195 fschmid 224
        baseGrid->setSuffix( unit );
1790 cbradney 225
        baseGrid->setValue(prefsData2->valueBaseGrid * unitRatio);
1195 fschmid 226
        baselineBoxLayout->addWidget( baseGrid, 0, 3 );
227
        textLabel6a = new QLabel(baseGrid, tr( "Baseline &Grid:" ), baselineBox, "textLabel6a" );
228
        baselineBoxLayout->addWidget( textLabel6a, 0, 2 );
1790 cbradney 229
        baseOffset = new MSpinBox( 0, 1000, baselineBox, precision );
1195 fschmid 230
        baseOffset->setSuffix( unit );
1790 cbradney 231
        baseOffset->setValue(prefsData2->offsetBaseGrid * unitRatio);
1195 fschmid 232
        baselineBoxLayout->addWidget( baseOffset, 1, 3 );
233
        textLabel7a = new QLabel(baseOffset, tr( "Baseline &Offset:" ), baselineBox, "textLabel7a" );
234
        baselineBoxLayout->addWidget( textLabel7a, 1, 2 );
235
        tabGuidesLayout->addWidget( baselineBox );
236
 
879 fschmid 237
        connect(majorGridColor, SIGNAL(clicked()), this, SLOT(changeMajorColor()));
238
        connect(minorGridColor, SIGNAL(clicked()), this, SLOT(changeMinorColor()));
239
        connect(baselineColor, SIGNAL(clicked()), this, SLOT(changeBaselineColor()));
240
        connect(guideColor, SIGNAL(clicked()), this, SLOT(changeGuideColor()));
241
        connect(marginColor, SIGNAL(clicked()), this, SLOT(changeMarginColor()));
242
        QToolTip::add( minorSpace, tr( "Distance between the minor grid lines" ) );
243
        QToolTip::add( majorSpace, tr( "Distance between the major grid lines" ) );
244
        QToolTip::add( snapDistance, tr( "Distance within which an object will snap to your placed guides" ) );
245
        QToolTip::add( grabDistance, tr( "Radius of the area where Scribus will allow you to grab an objects handles" ) );
246
        QToolTip::add( minorGridColor, tr( "Color of the minor grid lines" ) );
247
        QToolTip::add( majorGridColor, tr( "Color of the major grid lines" ) );
248
        QToolTip::add( guideColor, tr( "Color of the guide lines you insert" ) );
249
        QToolTip::add( marginColor, tr( "Color for the margin lines" ) );
250
        QToolTip::add( baselineColor, tr( "Color for the basegrid lines" ) );
251
        QToolTip::add( checkBaseline, tr("Turns the basegrid on or off"));
252
        QToolTip::add( checkGrid, tr("Turns the gridlines on or off"));
253
        QToolTip::add( checkGuides, tr("Turns the guides on or off"));
254
        QToolTip::add( checkMargin, tr("Turns the margins on or off"));
1195 fschmid 255
        QToolTip::add( autoLine, tr( "Percentage increase over the font size for the line spacing" ) );
879 fschmid 256
}
257
 
1833 fschmid 258
void TabGuides::restoreDefaults(struct guidesPrefs *prefsData, struct typoPrefs *prefsData2, int unitIndex)
1828 fschmid 259
{
1833 fschmid 260
        unit = unitGetSuffixFromIndex(unitIndex);
261
        precision = unitGetPrecisionFromIndex(unitIndex);
262
        unitRatio = unitGetRatioFromIndex(unitIndex);
263
        QPixmap pm3 = QPixmap(54, 14);
264
        pm3.fill(prefsData->guideColor);
265
        colorGuides = prefsData->guideColor;
266
        guideColor->setPixmap(pm3);
267
        QPixmap pm6 = QPixmap(54, 14);
268
        pm6.fill(prefsData->margColor);
269
        colorMargin = prefsData->margColor;
270
        marginColor->setPixmap(pm6);
271
        QPixmap pm1 = QPixmap(54, 14);
272
        pm1.fill(prefsData->majorColor);
273
        colorMajorGrid = prefsData->majorColor;
274
        majorGridColor->setPixmap(pm1);
275
        QPixmap pm = QPixmap(54, 14);
276
        pm.fill(prefsData->minorColor);
277
        colorMinorGrid = prefsData->minorColor;
278
        minorGridColor->setPixmap(pm);
279
        QPixmap pm4 = QPixmap(54, 14);
280
        pm4.fill(prefsData->baseColor);
281
        colorBaselineGrid = prefsData->baseColor;
282
        baselineColor->setPixmap(pm4);
283
        minorSpace->setValue(prefsData->minorGrid  * unitRatio);
284
        majorSpace->setValue(prefsData->majorGrid * unitRatio);
285
        snapDistance->setValue(prefsData->guideRad * unitRatio);
286
        grabDistance->setValue(prefsData->grabRad);
287
        baseGrid->setValue(prefsData2->valueBaseGrid * unitRatio);
288
        baseOffset->setValue(prefsData2->offsetBaseGrid * unitRatio);
289
        inBackground->setChecked( prefsData->before );
290
        inForeground->setChecked( !prefsData->before );
291
        checkBaseline->setChecked(prefsData->baseShown);
292
        checkGrid->setChecked(prefsData->gridShown);
293
        checkMargin->setChecked(prefsData->marginsShown);
294
        checkGuides->setChecked(prefsData->guidesShown);
1828 fschmid 295
}
296
 
879 fschmid 297
void TabGuides::changeMajorColor()
298
{
299
        QColor neu = QColor();
300
        neu = QColorDialog::getColor(colorMajorGrid, this);
301
        if (neu.isValid())
302
        {
303
                QPixmap pm = QPixmap(54, 14);
304
                pm.fill(neu);
305
                colorMajorGrid = neu;
306
                majorGridColor->setPixmap(pm);
307
        }
308
}
309
 
310
void TabGuides::changeMinorColor()
311
{
312
        QColor neu = QColor();
313
        neu = QColorDialog::getColor(colorMinorGrid, this);
314
        if (neu.isValid())
315
        {
316
                QPixmap pm = QPixmap(54, 14);
317
                pm.fill(neu);
318
                colorMinorGrid = neu;
319
                minorGridColor->setPixmap(pm);
320
        }
321
}
322
 
323
void TabGuides::changeBaselineColor()
324
{
325
        QColor neu = QColor();
326
        neu = QColorDialog::getColor(colorBaselineGrid, this);
327
        if (neu.isValid())
328
        {
329
                QPixmap pm = QPixmap(54, 14);
330
                pm.fill(neu);
331
                colorBaselineGrid = neu;
332
                baselineColor->setPixmap(pm);
333
        }
334
}
335
 
336
void TabGuides::changeGuideColor()
337
{
338
        QColor neu = QColor();
339
        neu = QColorDialog::getColor(colorGuides, this);
340
        if (neu.isValid())
341
        {
342
                QPixmap pm = QPixmap(54, 14);
343
                pm.fill(neu);
344
                colorGuides = neu;
345
                guideColor->setPixmap(pm);
346
        }
347
}
348
 
349
void TabGuides::changeMarginColor()
350
{
351
        QColor neu = QColor();
352
        neu = QColorDialog::getColor(colorMargin, this);
353
        if (neu.isValid())
354
        {
355
                QPixmap pm = QPixmap(54, 14);
356
                pm.fill(neu);
357
                colorMargin = neu;
358
                marginColor->setPixmap(pm);
359
        }
360
}