Subversion Repositories Scribus

Rev

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