~ubuntu-branches/ubuntu/maverick/scribus-ng/maverick-backports

« back to all changes in this revision

Viewing changes to scribus/marginWidget.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Oleksandr Moskalenko
  • Date: 2007-08-11 17:41:51 UTC
  • mfrom: (0.1.1 upstream) (4.1.2 feisty)
  • Revision ID: james.westby@ubuntu.com-20070811174151-tmkgjvjuc0mtk8ul
Tags: 1.3.4.dfsg+svn20071115-1
* Upstream svn update (Closes: #447480, #448949).
* debian/NEWS: Added a note for users wanting stable Scribus to switch to
  the "scribus" package (Closes: #427638).
* debian/watch: Updated the watch regex to properly track sourceforge
  releases for this branch (Closes: #449700).

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
#include "useprintermarginsdialog.h"
16
16
 
17
17
 
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"),
 
19
pageType(0)
19
20
{
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;
28
27
 
29
28
        m_docUnitIndex=unitIndex;
30
29
        m_unitRatio = unitGetRatioFromIndex(unitIndex);
31
30
        m_suffix = unitGetSuffixFromIndex(unitIndex);
32
31
        int decimals = unitGetDecimalsFromIndex(unitIndex);
33
32
 
34
 
        presetCombo = new PresetLayout(this, "presetCombo");
35
 
        presetLabel = new QLabel(presetCombo, tr("Preset Layouts:"), this, "presetLabel");
36
 
 
37
 
        leftR = new MSpinBox( 0, 1000, this, decimals );
 
33
        marginPage = new QWidget(this);
 
34
 
 
35
        presetCombo = new PresetLayout(marginPage, "presetCombo");
 
36
        presetLabel = new QLabel(presetCombo, tr("Preset Layouts:"), marginPage, "presetLabel");
 
37
 
 
38
        leftR = new MSpinBox( 0, 1000, marginPage, decimals );
38
39
        leftR->setSuffix( m_suffix );
39
40
        leftR->setValue(RandL * m_unitRatio);
40
41
 
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);
44
45
 
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);
48
49
 
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);
52
53
 
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" );
57
58
 
58
59
        // layout
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 );
71
74
        if (showChangeAll)
72
75
        {
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>" );
79
 
 
 
89
                QToolTip::add( marginsForAllMasterPages, "<qt>" + tr( "Apply the margin changes to all existing master pages in the document" ) + "</qt>" );
80
90
        }
81
91
        else
 
92
        {
 
93
                marginsForPages=NULL;
82
94
                marginsForAllPages=NULL;
 
95
                marginsForAllMasterPages=NULL;
 
96
        }
83
97
 
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()));
90
104
#endif
91
105
 
 
106
        addTab(marginPage, tr("Margin Guides"));
 
107
 
 
108
        if (useBleeds)
 
109
        {
 
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"));
 
160
        }
 
161
 
92
162
        // hints
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>");
97
167
 
98
168
                // signals&slots
99
169
        connect(topR, SIGNAL(valueChanged(int)), this, SLOT(setTop()));
103
173
        connect(presetCombo, SIGNAL(activated(int)), this, SLOT(setPreset()));
104
174
}
105
175
 
106
 
void MarginWidget::setFacingPages(bool facing)
 
176
void MarginWidget::ToggleKette()
 
177
{
 
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())
 
183
        {
 
184
                BleedTop->setValue(BleedLeft->value());
 
185
                BleedBottom->setValue(BleedLeft->value());
 
186
                BleedRight->setValue(BleedLeft->value());
 
187
        }
 
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()));
 
192
}
 
193
 
 
194
void MarginWidget::changeBleeds()
 
195
{
 
196
        if (linkBleeds->isOn())
 
197
        {
 
198
                double val = 0.0;
 
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);
 
209
                setNewBleeds(v);
 
210
        }
 
211
}
 
212
 
 
213
void MarginWidget::setFacingPages(bool facing, int pagetype)
107
214
{
108
215
        facingPages = facing;
 
216
        pageType = pagetype;
109
217
        lText->setText(facing == true ? tr( "&Inside:" ) : tr( "&Left:" ));
110
218
        rText->setText(facing == true ? tr( "O&utside:" ) : tr( "&Right:" ));
 
219
        if (useBleeds)
 
220
        {
 
221
                if (facing)
 
222
                {
 
223
                        BleedTxt3->setText( tr( "Inside:" ) );
 
224
                        BleedTxt4->setText( tr( "Outside:" ) );
 
225
                }
 
226
                else
 
227
                {
 
228
                        BleedTxt3->setText( tr( "Left:" ) );
 
229
                        BleedTxt4->setText( tr( "Right:" ) );
 
230
                }
 
231
        }
111
232
        setPreset();
112
233
}
113
234
 
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);
 
312
 
 
313
        if (useBleeds)
 
314
        {
 
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()));
 
335
        }
191
336
        m_unitRatio = newUnit;
192
337
        m_suffix=newSuffix;
193
338
        connect(topR, SIGNAL(valueChanged(int)), this, SLOT(setTop()));
229
374
                topR->setEnabled(true);
230
375
                bottomR->setEnabled(true);
231
376
        }
 
377
        if (pageType == 1)
 
378
                rightR->setEnabled(false);
232
379
        connect(topR, SIGNAL(valueChanged(int)), this, SLOT(setTop()));
233
380
        connect(bottomR, SIGNAL(valueChanged(int)), this, SLOT(setBottom()));
234
381
        connect(leftR, SIGNAL(valueChanged(int)), this, SLOT(setLeft()));
289
436
        return RandR;
290
437
}
291
438
 
292
 
void MarginWidget::setNewMargins(double t, double b, double l, double r)
 
439
void MarginWidget::setNewMargins(MarginStruct &m)
293
440
{
294
 
        topR->setValue(t * m_unitRatio);
295
 
        //RandT = val; // it's called by signal emitted by setValue()
296
 
        bottomR->setValue(b * m_unitRatio);
297
 
        //RandB = val;
298
 
        leftR->setValue(l * m_unitRatio);
299
 
        //RandL = val;
300
 
        rightR->setValue(r * m_unitRatio);
301
 
        //RandR = val;
 
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);
 
446
        RandT = m.Top;
 
447
        bottomR->setValue(m.Bottom * m_unitRatio);
 
448
        RandB = m.Bottom;
 
449
        leftR->setValue(m.Left * m_unitRatio);
 
450
        RandL = m.Left;
 
451
        rightR->setValue(m.Right * m_unitRatio);
 
452
        RandR = m.Right;
 
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()));
302
457
}
303
458
 
304
459
bool MarginWidget::getMarginsForAllPages()
306
461
        return marginsForAllPages->isChecked();
307
462
}
308
463
 
 
464
bool MarginWidget::getMarginsForAllMasterPages()
 
465
{
 
466
        return marginsForAllMasterPages->isChecked();
 
467
}
 
468
 
 
469
void MarginWidget::setNewBleeds(MarginStruct& b)
 
470
{
 
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()));
 
483
}
 
484
 
 
485
double MarginWidget::topBleed()
 
486
{
 
487
        return BleedTop->value() / m_unitRatio;
 
488
}
 
489
 
 
490
double MarginWidget::bottomBleed()
 
491
{
 
492
        return BleedBottom->value() / m_unitRatio;
 
493
}
 
494
 
 
495
double MarginWidget::leftBleed()
 
496
{
 
497
        return BleedLeft->value() / m_unitRatio;
 
498
}
 
499
 
 
500
double MarginWidget::rightBleed()
 
501
{
 
502
        return BleedRight->value() / m_unitRatio;
 
503
}
 
504
 
309
505
 
310
506
/*
311
507
 * presets
320
516
        insertItem( tr("Nine Parts"), PresetLayout::nineparts);
321
517
        setCurrentItem(PresetLayout::none);
322
518
 
323
 
        QToolTip::add(this, "<qt>" + tr("You can select predefined page layout here. 'None' leave margins as is, Gutenberg sets margins classically. 'Magazine' sets all margins for same value. Leading is Left/Inside value.") + "</qt>");
 
519
        QToolTip::add(this, "<qt>" + tr("You can select a predefined page layout here. 'None' leave margins as is, Gutenberg sets margins classically. 'Magazine' sets all margins for same value. Leading is Left/Inside value.") + "</qt>");
324
520
}
325
521
 
326
522
MarginStruct PresetLayout::getMargins(int index, double pageWidth, double pageHeight, double leftMargin)