Subversion Repositories Scribus

Rev

Rev 455 | Rev 534 | 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
 
519 cbradney 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)
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();
152
        GroupBox7Layout->addLayout( Layout4 );
153
        ReformDocLayout->addWidget( GroupBox7 );
154
        Layout3 = new QHBoxLayout;
155
        Layout3->setSpacing( 6 );
156
        Layout3->setMargin( 0 );
348 Franz 157
        QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
158
        Layout3->addItem( spacer );
340 Franz 159
        OKButton = new QPushButton(tr( "&OK" ), this, "OKButton" );
249 Franz 160
        OKButton->setDefault( true );
161
        Layout3->addWidget( OKButton );
340 Franz 162
        CancelB = new QPushButton( tr( "&Cancel" ), this, "CancelB" );
249 Franz 163
        CancelB->setAutoDefault( false );
164
        Layout3->addWidget( CancelB );
165
        ReformDocLayout->addLayout( Layout3 );
166
        RightR->setMaxValue(Breite - LeftR->value());
167
        LeftR->setMaxValue(Breite - RightR->value());
168
        TopR->setMaxValue(Hoehe - BottomR->value());
169
        BottomR->setMaxValue(Hoehe - TopR->value());
170
        //tooltips
171
        QToolTip::add( Doppelseiten, tr( "Enable single or spread based layout" ) );
172
        QToolTip::add( ErsteSeite, tr( "Make the first page the left page of the document" ) );
173
        QToolTip::add( TopR, tr( "Distance between the top margin guide and the edge of the page" ) );
174
        QToolTip::add( BottomR, tr( "Distance between the bottom margin guide and the edge of the page" ) );
175
        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" ) );
176
        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 177
 
249 Franz 178
        // signals and slots connections
179
        connect( Doppelseiten, SIGNAL( clicked() ), this, SLOT( setDS() ) );
180
        connect( OKButton, SIGNAL( clicked() ), this, SLOT( accept() ) );
181
        connect( CancelB, SIGNAL( clicked() ), this, SLOT( reject() ) );
182
        connect(TopR, SIGNAL(valueChanged(int)), this, SLOT(setTop(int)));
183
        connect(BottomR, SIGNAL(valueChanged(int)), this, SLOT(setBottom(int)));
184
        connect(LeftR, SIGNAL(valueChanged(int)), this, SLOT(setLeft(int)));
185
        connect(RightR, SIGNAL(valueChanged(int)), this, SLOT(setRight(int)));
3 paul 186
}
187
 
36 Franz 188
void ReformDoc::setTop(int v)
189
{
190
        BottomR->setMaxValue(Hoehe - TopR->value());
191
}
3 paul 192
 
36 Franz 193
void ReformDoc::setBottom(int v)
194
{
195
        TopR->setMaxValue(Hoehe - BottomR->value());
196
}
197
 
198
void ReformDoc::setLeft(int v)
199
{
200
        RightR->setMaxValue(Breite - LeftR->value());
201
}
202
 
203
void ReformDoc::setRight(int v)
204
{
205
        LeftR->setMaxValue(Breite - RightR->value());
206
}
207
 
3 paul 208
void ReformDoc::setDS()
209
{
249 Franz 210
        if (Doppelseiten->isChecked())
211
        {
340 Franz 212
                Links->setText( tr( "&Inside:" ) );
213
                Rechts->setText( tr( "&Outside:" ) );
249 Franz 214
                ErsteSeite->setEnabled(true);
215
        }
216
        else
217
        {
340 Franz 218
                Links->setText( tr( "&Left:" ) );
219
                Rechts->setText( tr( "&Right:" ) );
249 Franz 220
                ErsteSeite->setEnabled(false);
221
        }
348 Franz 222
}