Subversion Repositories Scribus

Rev

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

Rev Author Line No. Line
3 paul 1
#include "reformdoc.h"
2
#include "reformdoc.moc"
249 Franz 3
#include <qtooltip.h>
3 paul 4
extern QPixmap loadIcon(QString nam);
80 Franz 5
extern double UmReFaktor;
3 paul 6
 
534 fschmid 7
ReformDoc::ReformDoc( QWidget* parent, double t, double l, double r, double b, double Pagebr, double Pageho, bool fp, bool fpe, int Einh, int ori, QString pageSize, int PageNr)
249 Franz 8
                : QDialog( parent, "r", true, 0 )
3 paul 9
{
173 Franz 10
        einheit = Einh;
274 Franz 11
        QString units[] = { tr(" pt"), tr(" mm"), tr(" in"), tr(" p")};
12
        QString ein = units[Einh];
13
        int dp[] = {100, 1000, 10000, 100};
14
        int decimals = dp[Einh];
519 cbradney 15
        int i=-1;
173 Franz 16
        Breite = Pagebr * UmReFaktor;
17
        Hoehe = Pageho * UmReFaktor;
249 Franz 18
        setCaption( tr( "Document Setup" ) );
19
        setIcon(loadIcon("AppIcon.png"));
20
        ReformDocLayout = new QVBoxLayout( this );
21
        ReformDocLayout->setSpacing( 6 );
22
        ReformDocLayout->setMargin( 10 );
519 cbradney 23
 
24
        dsGroupBox7 = new QGroupBox( this, "GroupBox7" );
25
        dsGroupBox7->setTitle( tr( "Page Size" ) );
26
        dsGroupBox7->setColumnLayout(0, Qt::Vertical );
27
        dsGroupBox7->layout()->setSpacing( 0 );
28
        dsGroupBox7->layout()->setMargin( 0 );
29
        dsGroupBox7Layout = new QHBoxLayout( dsGroupBox7->layout() );
30
        dsGroupBox7Layout->setAlignment( Qt::AlignTop );
31
        dsGroupBox7Layout->setSpacing( 0 );
32
        dsGroupBox7Layout->setMargin( 10 );
33
        dsLayout4 = new QGridLayout;
34
        dsLayout4->setSpacing( 6 );
35
        dsLayout4->setMargin( 0 );
36
 
37
    sizeQComboBox = new QComboBox( true, dsGroupBox7, "sizeQComboBox" );
38
    sizeQLabel = new QLabel( sizeQComboBox, tr( "&Size:" ), dsGroupBox7, "sizeQLabel" );
39
    QString sizelist[] = {"A0", "A1", "A2", "A3", "A4", "A5", "A6", "A7", "A8", "A9", "B0", "B1", "B2", "B3", "B4",
40
                          "B5", "B6", "B7", "B8", "B9", "B10", "C5E", "Comm10E", "DLE", "Executive", "Folio",
41
                          "Ledger", tr("Legal"), tr("Letter"), tr("Tabloid"), tr("Custom")};
42
    size_t const num_mappings = (sizeof sizelist)/(sizeof *sizelist);
43
    for (uint m = 0; m < num_mappings; ++m) {
44
        sizeQComboBox->insertItem(sizelist[m]);
45
                if (sizelist[m]==pageSize)
46
                        i=m;
47
        }
48
        //set Custom if we dont have one already as old docs wont have this attribute
49
        if (i==-1)
50
                i=num_mappings-1;
51
    sizeQComboBox->setEnabled(false);
52
    sizeQComboBox->setCurrentItem(i);
53
    dsLayout4->addWidget( sizeQLabel, 0, 0 );
54
    dsLayout4->addWidget( sizeQComboBox, 0, 1 );
55
 
56
 
57
    orientationQComboBox = new QComboBox( true, dsGroupBox7, "orientationQComboBox" );
58
    orientationQLabel = new QLabel( orientationQComboBox, tr( "Orie&ntation:" ), dsGroupBox7, "orientationQLabel" );
59
    orientationQComboBox->insertItem( tr( "Portrait" ) );
60
    orientationQComboBox->insertItem( tr( "Landscape" ) );
61
    orientationQComboBox->setEnabled(false);
62
    orientationQComboBox->setCurrentItem(ori);
63
 
64
    dsLayout4->addWidget( orientationQLabel, 0, 2 );
65
        dsLayout4->addWidget( orientationQComboBox, 0, 3 );
66
 
67
    widthMSpinBox = new MSpinBox( 1, 10000, dsGroupBox7, 2 );
68
    widthQLabel = new QLabel( tr( "&Width:" ), dsGroupBox7, "widthLabel" );
69
    widthMSpinBox->setEnabled( false );
70
    widthMSpinBox->setSuffix(ein);
71
        widthMSpinBox->setValue(Breite);
72
    widthQLabel->setBuddy(widthMSpinBox);
73
    dsLayout4->addWidget( widthQLabel, 1, 0 );
74
    dsLayout4->addWidget( widthMSpinBox, 1, 1 );
75
 
76
    heightMSpinBox = new MSpinBox( 1, 10000, dsGroupBox7, 2 );
77
    heightQLabel = new QLabel( tr( "&Height:" ), dsGroupBox7, "heightLabel" );
78
    heightMSpinBox->setEnabled( false );
79
    heightMSpinBox->setSuffix(ein);
80
        heightMSpinBox->setValue(Hoehe);
81
    heightQLabel->setBuddy(heightMSpinBox);
82
    dsLayout4->addWidget( heightQLabel, 1, 2 );
83
    dsLayout4->addWidget( heightMSpinBox, 1, 3 );
84
 
85
        dsGroupBox7Layout->addLayout( dsLayout4 );
86
        ReformDocLayout->addWidget( dsGroupBox7 );
87
 
88
 
89
 
249 Franz 90
        GroupBox7 = new QGroupBox( this, "GroupBox7" );
91
        GroupBox7->setTitle( tr( "Margin Guides" ) );
92
        GroupBox7->setColumnLayout(0, Qt::Vertical );
93
        GroupBox7->layout()->setSpacing( 0 );
94
        GroupBox7->layout()->setMargin( 0 );
95
        GroupBox7Layout = new QHBoxLayout( GroupBox7->layout() );
96
        GroupBox7Layout->setAlignment( Qt::AlignTop );
97
        GroupBox7Layout->setSpacing( 0 );
98
        GroupBox7Layout->setMargin( 10 );
99
        Layout4 = new QGridLayout;
100
        Layout4->setSpacing( 6 );
101
        Layout4->setMargin( 0 );
340 Franz 102
 
249 Franz 103
        TopR = new MSpinBox( GroupBox7, 4 );
104
        TopR->setSuffix( ein );
173 Franz 105
        TopR->setDecimals( decimals );
249 Franz 106
        TopR->setMaxValue(Hoehe);
107
        TopR->setValue(t * UmReFaktor);
108
        Layout4->addWidget( TopR, 0, 1 );
340 Franz 109
        TextLabel5 = new QLabel( tr( "&Top:" ), GroupBox7, "TextLabel5" );
110
        TextLabel5->setBuddy(TopR);
111
        Layout4->addWidget( TextLabel5, 0, 0 );
112
 
249 Franz 113
        LeftR = new MSpinBox( GroupBox7, 4 );
114
        LeftR->setSuffix( ein );
173 Franz 115
        LeftR->setDecimals( decimals );
249 Franz 116
        LeftR->setMaxValue(Breite);
117
        LeftR->setValue(l * UmReFaktor);
118
        Layout4->addWidget( LeftR, 0, 3 );
340 Franz 119
        Links = new QLabel( tr( "&Left:" ), GroupBox7, "Links" );
120
        Links->setBuddy(LeftR);
121
        Layout4->addWidget( Links, 0, 2 );
122
 
249 Franz 123
        BottomR = new MSpinBox( GroupBox7, 4 );
124
        BottomR->setSuffix( ein );
173 Franz 125
        BottomR->setDecimals( decimals );
249 Franz 126
        BottomR->setMaxValue(Hoehe);
127
        BottomR->setValue(b * UmReFaktor);
128
        Layout4->addWidget( BottomR, 1, 1 );
340 Franz 129
        TextLabel7 = new QLabel( tr( "&Bottom:" ), GroupBox7, "TextLabel7" );
130
        TextLabel7->setBuddy(BottomR);
131
        Layout4->addWidget( TextLabel7, 1, 0 );
132
 
249 Franz 133
        RightR = new MSpinBox( GroupBox7, 4 );
134
        RightR->setSuffix( ein );
173 Franz 135
        RightR->setDecimals( decimals );
249 Franz 136
        RightR->setMaxValue(Breite);
137
        RightR->setValue(r * UmReFaktor);
138
        Layout4->addWidget( RightR, 1, 3 );
340 Franz 139
        Rechts = new QLabel( tr( "&Right:" ), GroupBox7, "Rechts" );
140
        Rechts->setBuddy(RightR);
141
        Layout4->addWidget( Rechts, 1, 2 );
142
 
143
        Doppelseiten = new QCheckBox( tr( "&Facing Pages" ),GroupBox7, "Doppelseiten" );
249 Franz 144
        Doppelseiten->setChecked( fp );
145
        Layout4->addMultiCellWidget( Doppelseiten, 2, 2, 0, 1 );
340 Franz 146
        ErsteSeite = new QCheckBox( tr( "Left &Page First" ), GroupBox7, "n" );
249 Franz 147
        ErsteSeite->setChecked( fpe );
148
        Layout4->addMultiCellWidget( ErsteSeite, 2, 2, 2, 3 );
149
        if (!fp)
150
                ErsteSeite->setEnabled(false);
151
        setDS();
534 fschmid 152
        TextLabel1_3 = new QLabel( tr( "F&irst Page Number:" ), GroupBox7, "TextLabel1_3" );
153
        Layout4->addMultiCellWidget( TextLabel1_3, 3, 3, 0, 1 );
154
        PgNr = new QSpinBox( GroupBox7, "PgNr" );
155
        PgNr->setMaxValue( 1000 );
156
        PgNr->setMinValue( 1 );
157
        PgNr->setValue(PageNr);
158
        Layout4->addWidget( PgNr, 3, 2, Qt::AlignRight );
159
        TextLabel1_3->setBuddy(PgNr);
249 Franz 160
        GroupBox7Layout->addLayout( Layout4 );
161
        ReformDocLayout->addWidget( GroupBox7 );
162
        Layout3 = new QHBoxLayout;
163
        Layout3->setSpacing( 6 );
164
        Layout3->setMargin( 0 );
348 Franz 165
        QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
166
        Layout3->addItem( spacer );
340 Franz 167
        OKButton = new QPushButton(tr( "&OK" ), this, "OKButton" );
249 Franz 168
        OKButton->setDefault( true );
169
        Layout3->addWidget( OKButton );
340 Franz 170
        CancelB = new QPushButton( tr( "&Cancel" ), this, "CancelB" );
249 Franz 171
        CancelB->setAutoDefault( false );
172
        Layout3->addWidget( CancelB );
173
        ReformDocLayout->addLayout( Layout3 );
174
        RightR->setMaxValue(Breite - LeftR->value());
175
        LeftR->setMaxValue(Breite - RightR->value());
176
        TopR->setMaxValue(Hoehe - BottomR->value());
177
        BottomR->setMaxValue(Hoehe - TopR->value());
178
        //tooltips
179
        QToolTip::add( Doppelseiten, tr( "Enable single or spread based layout" ) );
180
        QToolTip::add( ErsteSeite, tr( "Make the first page the left page of the document" ) );
181
        QToolTip::add( TopR, tr( "Distance between the top margin guide and the edge of the page" ) );
182
        QToolTip::add( BottomR, tr( "Distance between the bottom margin guide and the edge of the page" ) );
183
        QToolTip::add( LeftR, tr( "Distance between the left margin guide and the edge of the page.\nIf Facing Pages is selected, this margin space can be used to achieve the correct margins for binding" ) );
184
        QToolTip::add( RightR, tr( "Distance between the right margin guide and the edge of the page.\nIf Facing Pages is selected, this margin space can be used to achieve the correct margins for binding" ) );
3 paul 185
 
249 Franz 186
        // signals and slots connections
187
        connect( Doppelseiten, SIGNAL( clicked() ), this, SLOT( setDS() ) );
188
        connect( OKButton, SIGNAL( clicked() ), this, SLOT( accept() ) );
189
        connect( CancelB, SIGNAL( clicked() ), this, SLOT( reject() ) );
190
        connect(TopR, SIGNAL(valueChanged(int)), this, SLOT(setTop(int)));
191
        connect(BottomR, SIGNAL(valueChanged(int)), this, SLOT(setBottom(int)));
192
        connect(LeftR, SIGNAL(valueChanged(int)), this, SLOT(setLeft(int)));
193
        connect(RightR, SIGNAL(valueChanged(int)), this, SLOT(setRight(int)));
3 paul 194
}
195
 
36 Franz 196
void ReformDoc::setTop(int v)
197
{
198
        BottomR->setMaxValue(Hoehe - TopR->value());
199
}
3 paul 200
 
36 Franz 201
void ReformDoc::setBottom(int v)
202
{
203
        TopR->setMaxValue(Hoehe - BottomR->value());
204
}
205
 
206
void ReformDoc::setLeft(int v)
207
{
208
        RightR->setMaxValue(Breite - LeftR->value());
209
}
210
 
211
void ReformDoc::setRight(int v)
212
{
213
        LeftR->setMaxValue(Breite - RightR->value());
214
}
215
 
3 paul 216
void ReformDoc::setDS()
217
{
249 Franz 218
        if (Doppelseiten->isChecked())
219
        {
340 Franz 220
                Links->setText( tr( "&Inside:" ) );
221
                Rechts->setText( tr( "&Outside:" ) );
249 Franz 222
                ErsteSeite->setEnabled(true);
223
        }
224
        else
225
        {
340 Franz 226
                Links->setText( tr( "&Left:" ) );
227
                Rechts->setText( tr( "&Right:" ) );
249 Franz 228
                ErsteSeite->setEnabled(false);
229
        }
348 Franz 230
}