Subversion Repositories Scribus

Rev

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