1 /*
2 For general Scribus (>=1.3.2) copyright and licensing information please refer
3 to the COPYING file provided with the program. Following this notice may exist
4 a copyright and/or license notice that predates the release of Scribus 1.3.2
5 for which a new license (GPL+exception) is in place.
6 */
7 #include "xpsimportoptions.h"
8 #include "ui_xpsimportoptions.h"
9 #include "ui/createrange.h"
10 #include "usertaskstructs.h"
11 #include "iconmanager.h"
12
XpsImportOptions(QWidget * parent)13 XpsImportOptions::XpsImportOptions(QWidget *parent) : QDialog(parent), ui(new Ui::XpsImportOptions)
14 {
15 ui->setupUi(this);
16 ui->pageSelectButton->setIcon(IconManager::instance().loadIcon("ellipsis.png"));
17 resize(minimumSizeHint());
18 }
19
~XpsImportOptions()20 XpsImportOptions::~XpsImportOptions()
21 {
22 delete ui;
23 }
24
getPagesString()25 QString XpsImportOptions::getPagesString()
26 {
27 if (ui->allPages->isChecked())
28 return "*";
29 if (ui->singlePage->isChecked())
30 return QString("%1").arg(ui->spinBox->value());
31 return ui->pageRangeString->text();
32 }
33
setUpOptions(const QString & fileName,int actPage,int numPages,bool interact)34 void XpsImportOptions::setUpOptions(const QString& fileName, int actPage, int numPages, bool interact)
35 {
36 ui->fileLabel->setText(fileName);
37 ui->spinBox->setMaximum(numPages);
38 ui->spinBox->setMinimum(actPage);
39 ui->spinBox->setValue(actPage);
40 if (interact)
41 {
42 ui->allPages->setChecked(false);
43 ui->selectedPages->setChecked(false);
44 ui->allPages->setEnabled(false);
45 ui->selectedPages->setEnabled(false);
46 ui->singlePage->setChecked(true);
47 ui->spinBox->setEnabled(true);
48 }
49 else
50 ui->allPages->setChecked(true);
51 ui->pageRangeString->setText("");
52 m_maxPage = numPages;
53 connect(ui->pageSelectButton, SIGNAL(clicked()), this, SLOT(createPageNumberRange()));
54 }
55
createPageNumberRange()56 void XpsImportOptions::createPageNumberRange()
57 {
58 CreateRange cr(ui->pageRangeString->text(), m_maxPage, this);
59 if (cr.exec())
60 {
61 CreateRangeData crData;
62 cr.getCreateRangeData(crData);
63 ui->pageRangeString->setText(crData.pageRange);
64 }
65 }
66