15
15
#include "useprintermarginsdialog.h"
18
MarginWidget::MarginWidget( QWidget* parent, QString title, MarginStruct* margs, int unitIndex, bool showChangeAll) : QGroupBox( title, parent, "marginWidget")
18
MarginWidget::MarginWidget( QWidget* parent, QString /*title*/, const MarginStruct* margs, int unitIndex, bool showChangeAll, bool showBleeds) : QTabWidget(parent, "marginWidget"),
20
setColumnLayout(0, Qt::Vertical );
21
layout()->setSpacing( 5 );
22
layout()->setMargin( 10 );
23
21
RandT = margs->Top;
24
22
RandB = margs->Bottom;
25
23
RandR = margs->Right;
26
24
RandL = margs->Left;
27
25
facingPages = false;
26
useBleeds = showBleeds;
29
28
m_docUnitIndex=unitIndex;
30
29
m_unitRatio = unitGetRatioFromIndex(unitIndex);
31
30
m_suffix = unitGetSuffixFromIndex(unitIndex);
32
31
int decimals = unitGetDecimalsFromIndex(unitIndex);
34
presetCombo = new PresetLayout(this, "presetCombo");
35
presetLabel = new QLabel(presetCombo, tr("Preset Layouts:"), this, "presetLabel");
37
leftR = new MSpinBox( 0, 1000, this, decimals );
33
marginPage = new QWidget(this);
35
presetCombo = new PresetLayout(marginPage, "presetCombo");
36
presetLabel = new QLabel(presetCombo, tr("Preset Layouts:"), marginPage, "presetLabel");
38
leftR = new MSpinBox( 0, 1000, marginPage, decimals );
38
39
leftR->setSuffix( m_suffix );
39
40
leftR->setValue(RandL * m_unitRatio);
41
rightR = new MSpinBox( 0, 1000, this, decimals );
42
rightR = new MSpinBox( 0, 1000, marginPage, decimals );
42
43
rightR->setSuffix( m_suffix );
43
44
rightR->setValue(RandR * m_unitRatio);
45
topR = new MSpinBox( 0, 1000, this, decimals );
46
topR = new MSpinBox( 0, 1000, marginPage, decimals );
46
47
topR->setSuffix( m_suffix );
47
48
topR->setValue(RandT * m_unitRatio);
49
bottomR = new MSpinBox( 0, 1000, this, decimals );
50
bottomR = new MSpinBox( 0, 1000, marginPage, decimals );
50
51
bottomR->setSuffix( m_suffix );
51
52
bottomR->setValue(RandB * m_unitRatio);
53
bText = new QLabel( bottomR, tr( "&Bottom:" ), this, "bText" );
54
tText = new QLabel( topR, tr( "&Top:" ), this, "tText" );
55
rText = new QLabel( rightR, tr( "&Right:" ), this, "rText" );
56
lText = new QLabel( leftR, tr( "&Left:" ), this, "lText" );
54
bText = new QLabel( bottomR, tr( "&Bottom:" ), marginPage, "bText" );
55
tText = new QLabel( topR, tr( "&Top:" ), marginPage, "tText" );
56
rText = new QLabel( rightR, tr( "&Right:" ), marginPage, "rText" );
57
lText = new QLabel( leftR, tr( "&Left:" ), marginPage, "lText" );
59
GroupLayout = new QGridLayout( this->layout() );
60
GroupLayout = new QGridLayout( marginPage );
60
61
GroupLayout->setAlignment( Qt::AlignTop );
62
GroupLayout->setSpacing( 5 );
63
GroupLayout->setMargin( 10 );
61
64
GroupLayout->addWidget(presetLabel, 0, 0);
62
65
GroupLayout->addWidget(presetCombo, 0, 1);
63
66
GroupLayout->addWidget( leftR, 1, 1 );
70
73
GroupLayout->addWidget( bText, 4, 0 );
73
marginsForAllPages = new QCheckBox( this, "moveObjects" );
74
marginsForAllPages->setText( tr( "Apply margin settings to all pages" ) );
76
marginsForPagesLayout = new QHBoxLayout( 0, 5, 5, "marginsForPagesLayout");
77
marginsForPages = new QLabel( tr( "Apply settings to:" ), marginPage, "marginsForPages" );
78
marginsForPagesLayout->addWidget(marginsForPages);
79
marginsForAllPages = new QCheckBox( marginPage, "marginsForAllPages" );
80
marginsForAllPages->setText( tr( "All Document Pages" ) );
75
81
marginsForAllPages->setChecked( false );
76
//GroupLayout->addMultiCellWidget( marginsForAllPages, 5, 5, 0, 1);
77
GroupLayout->addWidget( marginsForAllPages, 5, 0 );
82
marginsForPagesLayout->addWidget(marginsForAllPages);
83
marginsForAllMasterPages = new QCheckBox( marginPage, "marginsForAllMasterPages" );
84
marginsForAllMasterPages->setText( tr( "All Master Pages" ) );
85
marginsForAllMasterPages->setChecked( false );
86
marginsForPagesLayout->addWidget(marginsForAllMasterPages);
87
GroupLayout->addMultiCellLayout( marginsForPagesLayout, 6, 6, 0, 1 );
78
88
QToolTip::add( marginsForAllPages, "<qt>" + tr( "Apply the margin changes to all existing pages in the document" ) + "</qt>" );
89
QToolTip::add( marginsForAllMasterPages, "<qt>" + tr( "Apply the margin changes to all existing master pages in the document" ) + "</qt>" );
82
94
marginsForAllPages=NULL;
95
marginsForAllMasterPages=NULL;
84
98
usePrinterMarginsButton=NULL;
85
99
#if defined(HAVE_CUPS) || defined(_WIN32)
86
usePrinterMarginsButton=new QPushButton( tr("Printer Margins..."),this, "usePrinterMarginsButton" );
100
usePrinterMarginsButton=new QPushButton( tr("Printer Margins..."),marginPage, "usePrinterMarginsButton" );
87
101
GroupLayout->addWidget( usePrinterMarginsButton, 5, 1 );
88
102
QToolTip::add( usePrinterMarginsButton, "<qt>" + tr( "Import the margins for the selected page size from the available printers." ) + "</qt>");
89
103
connect(usePrinterMarginsButton, SIGNAL(clicked()), this, SLOT(setMarginsToPrinterMargins()));
106
addTab(marginPage, tr("Margin Guides"));
110
bleedPage = new QWidget(this);
111
BleedGroupLayout = new QGridLayout( bleedPage );
112
BleedGroupLayout->setSpacing( 5 );
113
BleedGroupLayout->setMargin( 10 );
114
BleedGroupLayout->setAlignment( Qt::AlignTop );
115
BleedTxt3 = new QLabel( bleedPage, "BleedTxt3" );
116
BleedGroupLayout->addWidget( BleedTxt3, 0, 0 );
117
BleedLeft = new MSpinBox( bleedPage, decimals );
118
BleedGroupLayout->addWidget( BleedLeft, 0, 1 );
119
BleedTxt4 = new QLabel( bleedPage, "BleedTxt4" );
120
BleedGroupLayout->addWidget( BleedTxt4, 1, 0 );
121
BleedRight = new MSpinBox( bleedPage, decimals );
122
BleedGroupLayout->addWidget( BleedRight, 1, 1 );
123
BleedTxt1 = new QLabel( bleedPage, "BleedTxt1" );
124
BleedTxt1->setText( tr( "Top:" ) );
125
BleedGroupLayout->addWidget( BleedTxt1, 2, 0 );
126
BleedTop = new MSpinBox( bleedPage, decimals );
127
BleedGroupLayout->addWidget( BleedTop, 2, 1 );
128
BleedTxt2 = new QLabel( bleedPage, "BleedTxt2" );
129
BleedTxt2->setText( tr( "Bottom:" ) );
130
BleedGroupLayout->addWidget( BleedTxt2, 3, 0 );
131
BleedBottom = new MSpinBox( bleedPage, decimals );
132
BleedGroupLayout->addWidget( BleedBottom, 3, 1 );
133
linkBleeds = new LinkButton( bleedPage );
134
linkBleeds->setToggleButton( true );
135
linkBleeds->setAutoRaise( true );
136
linkBleeds->setMaximumSize( QSize( 15, 32767 ) );
137
BleedGroupLayout->addMultiCellWidget( linkBleeds, 0, 3, 2, 2 );
138
BleedTop->setSuffix( m_suffix );
139
BleedTop->setMinValue(0);
140
BleedTop->setMaxValue(3000*m_unitRatio);
141
BleedBottom->setSuffix( m_suffix );
142
BleedBottom->setMinValue(0);
143
BleedBottom->setMaxValue(3000*m_unitRatio);
144
BleedRight->setSuffix( m_suffix );
145
BleedRight->setMinValue(0);
146
BleedRight->setMaxValue(3000*m_unitRatio);
147
BleedLeft->setSuffix( m_suffix );
148
BleedLeft->setMinValue(0);
149
BleedLeft->setMaxValue(3000*m_unitRatio);
150
QToolTip::add( BleedTop, "<qt>" + tr( "Distance for bleed from the top of the physical page" ) + "</qt>" );
151
QToolTip::add( BleedBottom, "<qt>" + tr( "Distance for bleed from the bottom of the physical page" ) + "</qt>" );
152
QToolTip::add( BleedLeft, "<qt>" + tr( "Distance for bleed from the left of the physical page" ) + "</qt>" );
153
QToolTip::add( BleedRight, "<qt>" + tr( "Distance for bleed from the right of the physical page" ) + "</qt>");
154
connect(linkBleeds, SIGNAL(clicked()), this, SLOT(ToggleKette()));
155
connect(BleedLeft, SIGNAL(valueChanged(int)), this, SLOT(changeBleeds()));
156
connect(BleedRight, SIGNAL(valueChanged(int)), this, SLOT(changeBleeds()));
157
connect(BleedTop, SIGNAL(valueChanged(int)), this, SLOT(changeBleeds()));
158
connect(BleedBottom, SIGNAL(valueChanged(int)), this, SLOT(changeBleeds()));
159
addTab(bleedPage, tr("Bleeds"));
93
163
QToolTip::add( topR, "<qt>" + tr( "Distance between the top margin guide and the edge of the page" ) + "</qt>");
94
164
QToolTip::add( bottomR, "<qt>" + tr( "Distance between the bottom margin guide and the edge of the page" ) + "</qt>");
95
QToolTip::add( leftR, "<qt>" + tr( "Distance between the left margin guide and the edge of the page. If Facing Pages is selected, this margin space can be used to achieve the correct margins for binding") + "</qt>");
96
QToolTip::add( rightR, "<qt>" + tr( "Distance between the right margin guide and the edge of the page. If Facing Pages is selected, this margin space can be used to achieve the correct margins for binding") + "</qt>");
165
QToolTip::add( leftR, "<qt>" + tr( "Distance between the left margin guide and the edge of the page. If a double-sided, 3 or 4-fold layout is selected, this margin space can be used to achieve the correct margins for binding") + "</qt>");
166
QToolTip::add( rightR, "<qt>" + tr( "Distance between the right margin guide and the edge of the page. If a double-sided, 3 or 4-fold layout is selected, this margin space can be used to achieve the correct margins for binding") + "</qt>");
99
169
connect(topR, SIGNAL(valueChanged(int)), this, SLOT(setTop()));
103
173
connect(presetCombo, SIGNAL(activated(int)), this, SLOT(setPreset()));
106
void MarginWidget::setFacingPages(bool facing)
176
void MarginWidget::ToggleKette()
178
disconnect(BleedLeft, SIGNAL(valueChanged(int)), this, SLOT(changeBleeds()));
179
disconnect(BleedRight, SIGNAL(valueChanged(int)), this, SLOT(changeBleeds()));
180
disconnect(BleedTop, SIGNAL(valueChanged(int)), this, SLOT(changeBleeds()));
181
disconnect(BleedBottom, SIGNAL(valueChanged(int)), this, SLOT(changeBleeds()));
182
if (linkBleeds->isOn())
184
BleedTop->setValue(BleedLeft->value());
185
BleedBottom->setValue(BleedLeft->value());
186
BleedRight->setValue(BleedLeft->value());
188
connect(BleedLeft, SIGNAL(valueChanged(int)), this, SLOT(changeBleeds()));
189
connect(BleedRight, SIGNAL(valueChanged(int)), this, SLOT(changeBleeds()));
190
connect(BleedTop, SIGNAL(valueChanged(int)), this, SLOT(changeBleeds()));
191
connect(BleedBottom, SIGNAL(valueChanged(int)), this, SLOT(changeBleeds()));
194
void MarginWidget::changeBleeds()
196
if (linkBleeds->isOn())
199
if (BleedTop == sender())
200
val = BleedTop->value();
201
else if (BleedBottom == sender())
202
val = BleedBottom->value();
203
else if (BleedLeft == sender())
204
val = BleedLeft->value();
205
else if (BleedRight == sender())
206
val = BleedRight->value();
207
val = val / m_unitRatio;
208
MarginStruct v(val,val,val,val);
213
void MarginWidget::setFacingPages(bool facing, int pagetype)
108
215
facingPages = facing;
109
217
lText->setText(facing == true ? tr( "&Inside:" ) : tr( "&Left:" ));
110
218
rText->setText(facing == true ? tr( "O&utside:" ) : tr( "&Right:" ));
223
BleedTxt3->setText( tr( "Inside:" ) );
224
BleedTxt4->setText( tr( "Outside:" ) );
228
BleedTxt3->setText( tr( "Left:" ) );
229
BleedTxt4->setText( tr( "Right:" ) );
188
309
leftR->setValues(0, oldMax * invUnitConversion, newDecimals, val * invUnitConversion);
189
310
rightR->getValues(&oldMin, &oldMax, &decimalsOld, &val);
190
311
rightR->setValues(0, oldMax * invUnitConversion, newDecimals, val * invUnitConversion);
315
disconnect(BleedLeft, SIGNAL(valueChanged(int)), this, SLOT(changeBleeds()));
316
disconnect(BleedRight, SIGNAL(valueChanged(int)), this, SLOT(changeBleeds()));
317
disconnect(BleedTop, SIGNAL(valueChanged(int)), this, SLOT(changeBleeds()));
318
disconnect(BleedBottom, SIGNAL(valueChanged(int)), this, SLOT(changeBleeds()));
319
BleedBottom->setSuffix(newSuffix);
320
BleedTop->setSuffix(newSuffix);
321
BleedRight->setSuffix(newSuffix);
322
BleedLeft->setSuffix(newSuffix);
323
BleedBottom->getValues(&oldMin, &oldMax, &decimalsOld, &val);
324
BleedBottom->setValues(0, oldMax * invUnitConversion, newDecimals, val * invUnitConversion);
325
BleedTop->getValues(&oldMin, &oldMax, &decimalsOld, &val);
326
BleedTop->setValues(0, oldMax * invUnitConversion, newDecimals, val * invUnitConversion);
327
BleedRight->getValues(&oldMin, &oldMax, &decimalsOld, &val);
328
BleedRight->setValues(0, oldMax * invUnitConversion, newDecimals, val * invUnitConversion);
329
BleedLeft->getValues(&oldMin, &oldMax, &decimalsOld, &val);
330
BleedLeft->setValues(0, oldMax * invUnitConversion, newDecimals, val * invUnitConversion);
331
connect(BleedLeft, SIGNAL(valueChanged(int)), this, SLOT(changeBleeds()));
332
connect(BleedRight, SIGNAL(valueChanged(int)), this, SLOT(changeBleeds()));
333
connect(BleedTop, SIGNAL(valueChanged(int)), this, SLOT(changeBleeds()));
334
connect(BleedBottom, SIGNAL(valueChanged(int)), this, SLOT(changeBleeds()));
191
336
m_unitRatio = newUnit;
192
337
m_suffix=newSuffix;
193
338
connect(topR, SIGNAL(valueChanged(int)), this, SLOT(setTop()));
292
void MarginWidget::setNewMargins(double t, double b, double l, double r)
439
void MarginWidget::setNewMargins(MarginStruct &m)
294
topR->setValue(t * m_unitRatio);
295
//RandT = val; // it's called by signal emitted by setValue()
296
bottomR->setValue(b * m_unitRatio);
298
leftR->setValue(l * m_unitRatio);
300
rightR->setValue(r * m_unitRatio);
441
disconnect(topR, SIGNAL(valueChanged(int)), this, SLOT(setTop()));
442
disconnect(bottomR, SIGNAL(valueChanged(int)), this, SLOT(setBottom()));
443
disconnect(leftR, SIGNAL(valueChanged(int)), this, SLOT(setLeft()));
444
disconnect(rightR, SIGNAL(valueChanged(int)), this, SLOT(setRight()));
445
topR->setValue(m.Top * m_unitRatio);
447
bottomR->setValue(m.Bottom * m_unitRatio);
449
leftR->setValue(m.Left * m_unitRatio);
451
rightR->setValue(m.Right * m_unitRatio);
453
connect(topR, SIGNAL(valueChanged(int)), this, SLOT(setTop()));
454
connect(bottomR, SIGNAL(valueChanged(int)), this, SLOT(setBottom()));
455
connect(leftR, SIGNAL(valueChanged(int)), this, SLOT(setLeft()));
456
connect(rightR, SIGNAL(valueChanged(int)), this, SLOT(setRight()));
304
459
bool MarginWidget::getMarginsForAllPages()
306
461
return marginsForAllPages->isChecked();
464
bool MarginWidget::getMarginsForAllMasterPages()
466
return marginsForAllMasterPages->isChecked();
469
void MarginWidget::setNewBleeds(MarginStruct& b)
471
disconnect(BleedLeft, SIGNAL(valueChanged(int)), this, SLOT(changeBleeds()));
472
disconnect(BleedRight, SIGNAL(valueChanged(int)), this, SLOT(changeBleeds()));
473
disconnect(BleedTop, SIGNAL(valueChanged(int)), this, SLOT(changeBleeds()));
474
disconnect(BleedBottom, SIGNAL(valueChanged(int)), this, SLOT(changeBleeds()));
475
BleedTop->setValue(b.Top * m_unitRatio);
476
BleedBottom->setValue(b.Bottom * m_unitRatio);
477
BleedLeft->setValue(b.Left * m_unitRatio);
478
BleedRight->setValue(b.Right * m_unitRatio);
479
connect(BleedLeft, SIGNAL(valueChanged(int)), this, SLOT(changeBleeds()));
480
connect(BleedRight, SIGNAL(valueChanged(int)), this, SLOT(changeBleeds()));
481
connect(BleedTop, SIGNAL(valueChanged(int)), this, SLOT(changeBleeds()));
482
connect(BleedBottom, SIGNAL(valueChanged(int)), this, SLOT(changeBleeds()));
485
double MarginWidget::topBleed()
487
return BleedTop->value() / m_unitRatio;
490
double MarginWidget::bottomBleed()
492
return BleedBottom->value() / m_unitRatio;
495
double MarginWidget::leftBleed()
497
return BleedLeft->value() / m_unitRatio;
500
double MarginWidget::rightBleed()
502
return BleedRight->value() / m_unitRatio;