Rev 455 | Rev 2602 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
283 | Franz | 1 | #include "dialog.h" |
2 | #include "dialog.moc" |
||
3 | #include <qvariant.h> |
||
4 | #include <qpushbutton.h> |
||
5 | #include <qlabel.h> |
||
6 | #include <qlineedit.h> |
||
7 | #include <qcombobox.h> |
||
8 | #include <qspinbox.h> |
||
9 | #include <qbuttongroup.h> |
||
359 | Franz | 10 | #include <qgroupbox.h> |
283 | Franz | 11 | #include <qlayout.h> |
12 | #include <qtooltip.h> |
||
13 | #include <qwhatsthis.h> |
||
14 | #include <qimage.h> |
||
15 | #include <qdir.h> |
||
359 | Franz | 16 | #include <qfiledialog.h> |
415 | Franz | 17 | #include <prefsfile.h> |
283 | Franz | 18 | |
415 | Franz | 19 | extern PrefsFile* prefsFile; |
20 | |||
283 | Franz | 21 | /* |
22 | * Constructs a ExportForm as a child of 'parent', with the |
||
23 | * name 'name' and widget flags set to 'f'. |
||
24 | * |
||
25 | * The dialog will by default be modeless, unless you set 'modal' to |
||
26 | * TRUE to construct a modal dialog. |
||
27 | */ |
||
28 | ExportForm::ExportForm(QWidget* parent, int size, int quality, QString type) |
||
29 | : QDialog(parent, "ExportForm", true, 0) |
||
30 | { |
||
415 | Franz | 31 | prefs = prefsFile->getPluginContext("pixmapexport"); |
552 | fschmid | 32 | ExportFormLayout = new QVBoxLayout( this, 10, 5, "ExportFormLayout"); |
33 | layout1 = new QHBoxLayout( 0, 0, 5, "layout1"); |
||
359 | Franz | 34 | TextLabel1 = new QLabel( this, "TextLabel1" ); |
35 | layout1->addWidget( TextLabel1 ); |
||
36 | OutputDirectory = new QLineEdit( this, "OutputDirectory" ); |
||
415 | Franz | 37 | OutputDirectory->setText(prefs->get("wdir", QDir::currentDirPath())); |
359 | Franz | 38 | layout1->addWidget( OutputDirectory ); |
39 | OutputDirectoryButton = new QPushButton( this, "OutputDirectoryButton" ); |
||
40 | OutputDirectoryButton->setDefault( TRUE ); |
||
41 | layout1->addWidget( OutputDirectoryButton ); |
||
42 | ExportFormLayout->addLayout( layout1 ); |
||
283 | Franz | 43 | |
552 | fschmid | 44 | layout3 = new QHBoxLayout( 0, 0, 5, "layout3"); |
359 | Franz | 45 | groupBox1 = new QGroupBox( this, "groupBox1" ); |
46 | groupBox1->setColumnLayout(0, Qt::Vertical ); |
||
47 | groupBox1->layout()->setSpacing( 5 ); |
||
48 | groupBox1->layout()->setMargin( 10 ); |
||
49 | groupBox1Layout = new QGridLayout( groupBox1->layout() ); |
||
50 | groupBox1Layout->setAlignment( Qt::AlignTop ); |
||
51 | TextLabel2 = new QLabel( groupBox1, "TextLabel2" ); |
||
52 | groupBox1Layout->addWidget( TextLabel2, 0, 0 ); |
||
53 | textLabel1 = new QLabel( groupBox1, "textLabel1" ); |
||
54 | groupBox1Layout->addWidget( textLabel1, 1, 0 ); |
||
55 | textLabel3 = new QLabel( groupBox1, "textLabel3" ); |
||
56 | groupBox1Layout->addWidget( textLabel3, 2, 0 ); |
||
552 | fschmid | 57 | textLabel4 = new QLabel( groupBox1, "textLabel4" ); |
58 | groupBox1Layout->addWidget( textLabel4, 3, 0 ); |
||
359 | Franz | 59 | BitmapType = new QComboBox( FALSE, groupBox1, "BitmapType" ); |
60 | BitmapType->clear(); |
||
283 | Franz | 61 | BitmapType->insertStrList(QImageIO::outputFormats()); |
62 | BitmapType->setCurrentText(type); |
||
63 | BitmapType->setEditable(false); |
||
359 | Franz | 64 | groupBox1Layout->addMultiCellWidget( BitmapType, 0, 0, 1, 2 ); |
65 | QualityBox = new QSpinBox( groupBox1, "QualityBox" ); |
||
66 | QualityBox->setMaxValue( 100 ); |
||
67 | QualityBox->setMinValue( 1 ); |
||
283 | Franz | 68 | QualityBox->setValue(quality); |
359 | Franz | 69 | groupBox1Layout->addWidget( QualityBox, 1, 1 ); |
552 | fschmid | 70 | DPIBox = new QSpinBox( groupBox1, "DPIBox" ); |
71 | DPIBox->setMaxValue( 2400 ); |
||
72 | DPIBox->setMinValue( 1 ); |
||
73 | DPIBox->setValue(size); |
||
74 | groupBox1Layout->addWidget( DPIBox, 2, 1 ); |
||
75 | EnlargementBox = new QSpinBox( groupBox1, "EnlargementBox" ); |
||
76 | EnlargementBox->setMaxValue( 2400 ); |
||
77 | EnlargementBox->setMinValue( 1 ); |
||
78 | EnlargementBox->setValue(size); |
||
79 | groupBox1Layout->addWidget( EnlargementBox, 3, 1 ); |
||
359 | Franz | 80 | layout3->addWidget( groupBox1 ); |
283 | Franz | 81 | |
359 | Franz | 82 | ButtonGroup1 = new QButtonGroup( this, "ButtonGroup1" ); |
83 | ButtonGroup1->setColumnLayout(0, Qt::Vertical ); |
||
84 | ButtonGroup1->layout()->setSpacing( 5 ); |
||
85 | ButtonGroup1->layout()->setMargin( 10 ); |
||
86 | ButtonGroup1Layout = new QVBoxLayout( ButtonGroup1->layout() ); |
||
87 | ButtonGroup1Layout->setAlignment( Qt::AlignTop ); |
||
88 | OnePageRadio = new QRadioButton( ButtonGroup1, "OnePageRadio" ); |
||
89 | OnePageRadio->setChecked( TRUE ); |
||
90 | ButtonGroup1Layout->addWidget( OnePageRadio ); |
||
91 | AllPagesRadio = new QRadioButton( ButtonGroup1, "AllPagesRadio" ); |
||
92 | ButtonGroup1Layout->addWidget( AllPagesRadio ); |
||
552 | fschmid | 93 | layout2 = new QHBoxLayout( 0, 0, 5, "layout2"); |
359 | Franz | 94 | IntervalPagesRadio = new QRadioButton( ButtonGroup1, "IntervalPagesRadio" ); |
95 | layout2->addWidget( IntervalPagesRadio ); |
||
96 | RangeVal = new QLineEdit( ButtonGroup1, "RangeVal" ); |
||
97 | layout2->addWidget( RangeVal ); |
||
98 | RangeVal->setEnabled(false); |
||
99 | ButtonGroup1Layout->addLayout( layout2 ); |
||
100 | layout3->addWidget( ButtonGroup1 ); |
||
101 | ExportFormLayout->addLayout( layout3 ); |
||
283 | Franz | 102 | |
552 | fschmid | 103 | layout4 = new QHBoxLayout( 0, 0, 5, "layout4"); |
359 | Franz | 104 | QSpacerItem* spacer = new QSpacerItem( 111, 21, QSizePolicy::Expanding, QSizePolicy::Minimum ); |
105 | layout4->addItem( spacer ); |
||
106 | OkButton = new QPushButton( this, "OkButton" ); |
||
107 | layout4->addWidget( OkButton ); |
||
108 | CancelButton = new QPushButton( this, "CancelButton" ); |
||
109 | layout4->addWidget( CancelButton ); |
||
110 | ExportFormLayout->addLayout( layout4 ); |
||
283 | Franz | 111 | languageChange(); |
112 | readConfig(); |
||
359 | Franz | 113 | resize( QSize(447, 206).expandedTo(minimumSizeHint()) ); |
283 | Franz | 114 | |
359 | Franz | 115 | // buddies |
116 | TextLabel1->setBuddy( OutputDirectory ); |
||
117 | TextLabel2->setBuddy( BitmapType ); |
||
118 | textLabel1->setBuddy( QualityBox ); |
||
552 | fschmid | 119 | textLabel3->setBuddy( DPIBox ); |
120 | textLabel4->setBuddy( EnlargementBox ); |
||
287 | Franz | 121 | connect(OutputDirectoryButton, SIGNAL(clicked()), this, SLOT(OutputDirectoryButton_pressed())); |
122 | connect(OkButton, SIGNAL(clicked()), this, SLOT(OkButton_pressed())); |
||
359 | Franz | 123 | connect(CancelButton, SIGNAL(clicked()), this, SLOT(reject())); |
283 | Franz | 124 | connect(IntervalPagesRadio, SIGNAL(stateChanged(int)), this, SLOT(IntervalPagesRadio_stateChanged(int))); |
125 | connect(AllPagesRadio, SIGNAL(stateChanged(int)), this, SLOT(AllPagesRadio_stateChanged(int))); |
||
126 | connect(OnePageRadio, SIGNAL(stateChanged(int)), this, SLOT(OnePageRadio_stateChanged(int))); |
||
127 | } |
||
128 | |||
359 | Franz | 129 | void ExportForm::OutputDirectoryButton_pressed() |
130 | { |
||
415 | Franz | 131 | QString lastDir = prefs->get("wdir", "."); |
132 | QString d = QFileDialog::getExistingDirectory(lastDir, this, "d", tr("Choose a Export Directory"), true); |
||
359 | Franz | 133 | if (d.length()>0) |
415 | Franz | 134 | { |
359 | Franz | 135 | OutputDirectory->setText(d); |
415 | Franz | 136 | prefs->set("wdir", d); |
137 | } |
||
359 | Franz | 138 | } |
283 | Franz | 139 | |
359 | Franz | 140 | void ExportForm::OkButton_pressed() |
141 | { |
||
142 | bitmapType = BitmapType->currentText(); |
||
143 | writeConfig(); |
||
144 | accept(); |
||
145 | } |
||
146 | |||
147 | void ExportForm::IntervalPagesRadio_stateChanged(int) |
||
148 | { |
||
149 | RangeVal->setEnabled(TRUE); |
||
150 | } |
||
151 | |||
152 | void ExportForm::AllPagesRadio_stateChanged(int) |
||
153 | { |
||
154 | RangeVal->setEnabled(FALSE); |
||
155 | } |
||
156 | |||
157 | void ExportForm::OnePageRadio_stateChanged(int) |
||
158 | { |
||
159 | RangeVal->setEnabled(FALSE); |
||
160 | } |
||
161 | |||
283 | Franz | 162 | /* |
163 | * Destroys the object and frees any allocated resources |
||
164 | */ |
||
165 | ExportForm::~ExportForm() |
||
166 | { |
||
167 | // no need to delete child widgets, Qt does it all for us |
||
168 | } |
||
169 | |||
170 | /* |
||
171 | * Sets the strings of the subwidgets using the current |
||
172 | * language. |
||
173 | */ |
||
174 | void ExportForm::languageChange() |
||
175 | { |
||
359 | Franz | 176 | setCaption( tr( "Export as Image(s)" ) ); |
177 | TextLabel1->setText( tr( "&Export to Directory:" ) ); |
||
178 | OutputDirectoryButton->setText( tr( "C&hange..." ) ); |
||
179 | groupBox1->setTitle( tr( "Options" ) ); |
||
180 | TextLabel2->setText( tr( "Image &Type:" ) ); |
||
181 | textLabel1->setText( tr( "&Quality:" ) ); |
||
182 | textLabel3->setText( tr( "&Resolution:" ) ); |
||
552 | fschmid | 183 | textLabel4->setText( tr( "&Size:" ) ); |
359 | Franz | 184 | QualityBox->setSuffix( tr( " %" ) ); |
552 | fschmid | 185 | DPIBox->setSuffix( tr( " dpi" ) ); |
186 | EnlargementBox->setSuffix( tr( " %" ) ); |
||
359 | Franz | 187 | ButtonGroup1->setTitle( tr( "Range" ) ); |
188 | OnePageRadio->setText( tr( "&Current page" ) ); |
||
189 | AllPagesRadio->setText( tr( "&All pages" ) ); |
||
190 | IntervalPagesRadio->setText( tr( "&Range" ) ); |
||
191 | OkButton->setText( tr( "&OK" ) ); |
||
192 | CancelButton->setText( tr( "&Cancel" ) ); |
||
193 | CancelButton->setAccel( QKeySequence( tr( "C" ) ) ); |
||
362 | Franz | 194 | QToolTip::add( IntervalPagesRadio, tr( "Export a range of pages" ) ); |
359 | Franz | 195 | QToolTip::add( RangeVal, tr( "Insert a comma separated list of tokens where\na token can be * for all the pages, 1-5 for\na range of pages or a single page number." ) ); |
362 | Franz | 196 | QToolTip::add( AllPagesRadio, tr( "Export all pages" ) ); |
359 | Franz | 197 | QToolTip::add( OnePageRadio, tr( "Export only the current page" ) ); |
552 | fschmid | 198 | QToolTip::add( DPIBox, tr( "Resolution of the Images\nUse 72 dpi for Images intended for the Screen" ) ); |
199 | QToolTip::add( EnlargementBox, tr( "Size of the images. 100% for no changes, 200% for two times larger etc." )); |
||
359 | Franz | 200 | QToolTip::add( QualityBox, tr( "The quality of your images - 100% is the best, 1% the lowest quality" ) ); |
201 | QToolTip::add( BitmapType, tr( "Available export formats" ) ); |
||
202 | QToolTip::add( OutputDirectory, tr( "The output directory - the place to store your images.\nName of the export file will be 'documentname-pagenumber.filetype'" ) ); |
||
203 | QToolTip::add( OutputDirectoryButton, tr( "Change the output directory" ) ); |
||
283 | Franz | 204 | } |
205 | |||
206 | |||
207 | void ExportForm::readConfig() |
||
208 | { |
||
552 | fschmid | 209 | DPIBox->setValue(prefs->getUInt("DPIBox", 72)); |
210 | EnlargementBox->setValue(prefs->getUInt("EnlargementBox", 100)); |
||
415 | Franz | 211 | QualityBox->setValue(prefs->getUInt("QualityBox", 100)); |
212 | ButtonGroup1->setButton(prefs->getUInt("ButtonGroup1", 0)); |
||
213 | if (prefs->getInt("ButtonGroup1")==2) |
||
214 | RangeVal->setEnabled(TRUE); |
||
215 | else |
||
216 | RangeVal->setEnabled(false); |
||
217 | BitmapType->setCurrentItem(prefs->getInt("BitmapType", 4)); |
||
218 | RangeVal->setText(prefs->get("RangeVal", "")); |
||
283 | Franz | 219 | } |
220 | |||
221 | void ExportForm::writeConfig() |
||
222 | { |
||
552 | fschmid | 223 | prefs->set("DPIBox", DPIBox->value()); |
224 | prefs->set("EnlargementBox", EnlargementBox->value()); |
||
415 | Franz | 225 | prefs->set("QualityBox", QualityBox->value()); |
226 | prefs->set("ButtonGroup1", ButtonGroup1->id(ButtonGroup1->selected())); |
||
227 | prefs->set("BitmapType",BitmapType->currentItem()); |
||
228 | prefs->set("RangeVal", RangeVal->text()); |
||
229 | |||
283 | Franz | 230 | } |