author | leseb <leseb> | 2002-03-27 17:09:29 (UTC) |
---|---|---|
committer | leseb <leseb> | 2002-03-27 17:09:29 (UTC) |
commit | 4372bb8e59eb4b0d2fa5fba8f6525dc14873f239 (patch) (unidiff) | |
tree | 6947938ca5d22d3a373741ba3acfc20e8dd67729 /noncore/graphics/drawpad/exportdialog.cpp | |
parent | fb056735d9a021787f83c6a791225a7ca70c1eb5 (diff) | |
download | opie-4372bb8e59eb4b0d2fa5fba8f6525dc14873f239.zip opie-4372bb8e59eb4b0d2fa5fba8f6525dc14873f239.tar.gz opie-4372bb8e59eb4b0d2fa5fba8f6525dc14873f239.tar.bz2 |
Import/export dialogs, improved new page dialog, new tools, ...
Diffstat (limited to 'noncore/graphics/drawpad/exportdialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/graphics/drawpad/exportdialog.cpp | 173 |
1 files changed, 173 insertions, 0 deletions
diff --git a/noncore/graphics/drawpad/exportdialog.cpp b/noncore/graphics/drawpad/exportdialog.cpp new file mode 100644 index 0000000..0a980fc --- a/dev/null +++ b/noncore/graphics/drawpad/exportdialog.cpp | |||
@@ -0,0 +1,173 @@ | |||
1 | /*************************************************************************** | ||
2 | * * | ||
3 | * DrawPad - a drawing program for Opie Environment * | ||
4 | * * | ||
5 | * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> * | ||
6 | * * | ||
7 | * This program is free software; you can redistribute it and/or modify * | ||
8 | * it under the terms of the GNU General Public License as published by * | ||
9 | * the Free Software Foundation; either version 2 of the License, or * | ||
10 | * (at your option) any later version. * | ||
11 | * * | ||
12 | ***************************************************************************/ | ||
13 | |||
14 | #include "exportdialog.h" | ||
15 | |||
16 | #include <qpe/fileselector.h> | ||
17 | |||
18 | #include <qbuttongroup.h> | ||
19 | #include <qcombobox.h> | ||
20 | #include <qgroupbox.h> | ||
21 | #include <qimage.h> | ||
22 | #include <qlabel.h> | ||
23 | #include <qlayout.h> | ||
24 | #include <qlineedit.h> | ||
25 | #include <qradiobutton.h> | ||
26 | #include <qspinbox.h> | ||
27 | |||
28 | #include <stdlib.h> | ||
29 | |||
30 | ExportDialog::ExportDialog(uint pageAt, uint pageCount, QWidget* parent, const char* name) | ||
31 | : QDialog(parent, name, true) | ||
32 | { | ||
33 | setCaption(tr("Export")); | ||
34 | |||
35 | m_pageAt = pageAt; | ||
36 | m_pageCount = pageCount; | ||
37 | |||
38 | QButtonGroup* selectionButtonGroup = new QButtonGroup(0, Qt::Vertical, tr("Page Selection"), this); | ||
39 | connect(selectionButtonGroup, SIGNAL(pressed(int)), this, SLOT(selectionChanged(int))); | ||
40 | |||
41 | QRadioButton* selectAllRadioButton = new QRadioButton(tr("All"), selectionButtonGroup); | ||
42 | QRadioButton* selectCurrentRadioButton = new QRadioButton(tr("Current"), selectionButtonGroup); | ||
43 | QRadioButton* selectRangeRadioButton = new QRadioButton(tr("Range"), selectionButtonGroup); | ||
44 | |||
45 | QLabel* toLabel = new QLabel(tr("To:"), selectionButtonGroup); | ||
46 | |||
47 | m_pFromPageSpinBox = new QSpinBox(1, m_pageCount, 1, selectionButtonGroup); | ||
48 | connect(m_pFromPageSpinBox, SIGNAL(valueChanged(int)), this, SLOT(fromPageChanged(int))); | ||
49 | |||
50 | m_pToPageSpinBox = new QSpinBox(1, m_pageCount, 1, selectionButtonGroup); | ||
51 | connect(m_pToPageSpinBox, SIGNAL(valueChanged(int)), this, SLOT(toPageChanged(int))); | ||
52 | |||
53 | selectionButtonGroup->setButton(1); | ||
54 | selectionChanged(1); | ||
55 | |||
56 | m_pFromPageSpinBox->setValue(pageAt); | ||
57 | m_pToPageSpinBox->setValue(pageAt); | ||
58 | |||
59 | QGroupBox* exportGroupBox = new QGroupBox(0, Qt::Vertical, tr("Export As"), this); | ||
60 | |||
61 | QLabel* nameLabel = new QLabel(tr("Name:"), exportGroupBox); | ||
62 | QLabel* formatLabel = new QLabel(tr("Format:"), exportGroupBox); | ||
63 | |||
64 | m_pNameLineEdit = new QLineEdit(exportGroupBox); | ||
65 | |||
66 | m_pFormatComboBox = new QComboBox(exportGroupBox); | ||
67 | m_pFormatComboBox->insertStrList(QImageIO::outputFormats()); | ||
68 | |||
69 | FileSelector* fileSelector = new FileSelector("image/*", this, "fileselector"); | ||
70 | fileSelector->setNewVisible(false); | ||
71 | fileSelector->setCloseVisible(false); | ||
72 | |||
73 | QVBoxLayout* mainLayout = new QVBoxLayout(this, 4, 4); | ||
74 | selectionButtonGroup->layout()->setSpacing(4); | ||
75 | exportGroupBox->layout()->setSpacing(4); | ||
76 | QGridLayout* selectionLayout = new QGridLayout(selectionButtonGroup->layout(), 2, 2); | ||
77 | QHBoxLayout* rangeLayout = new QHBoxLayout(); | ||
78 | QGridLayout* exportLayout = new QGridLayout(exportGroupBox->layout(), 2, 2); | ||
79 | |||
80 | selectionLayout->addWidget(selectAllRadioButton, 0, 0); | ||
81 | selectionLayout->addWidget(selectCurrentRadioButton, 1, 0); | ||
82 | selectionLayout->addWidget(selectRangeRadioButton, 0, 1); | ||
83 | selectionLayout->addLayout(rangeLayout, 1, 1); | ||
84 | |||
85 | rangeLayout->addWidget(m_pFromPageSpinBox); | ||
86 | rangeLayout->addWidget(toLabel); | ||
87 | rangeLayout->addWidget(m_pToPageSpinBox); | ||
88 | |||
89 | exportLayout->addWidget(nameLabel, 0, 0); | ||
90 | exportLayout->addWidget(formatLabel, 1, 0); | ||
91 | |||
92 | exportLayout->addWidget(m_pNameLineEdit, 0, 1); | ||
93 | exportLayout->addWidget(m_pFormatComboBox, 1, 1); | ||
94 | |||
95 | exportLayout->setColStretch(1, 1); | ||
96 | |||
97 | mainLayout->addWidget(selectionButtonGroup); | ||
98 | mainLayout->addWidget(exportGroupBox); | ||
99 | mainLayout->addWidget(fileSelector); | ||
100 | |||
101 | m_pNameLineEdit->setFocus(); | ||
102 | } | ||
103 | |||
104 | ExportDialog::~ExportDialog() | ||
105 | { | ||
106 | } | ||
107 | |||
108 | uint ExportDialog::selectedFromPage() | ||
109 | { | ||
110 | return (m_pFromPageSpinBox->value()); | ||
111 | } | ||
112 | |||
113 | uint ExportDialog::selectedToPage() | ||
114 | { | ||
115 | return (m_pToPageSpinBox->value()); | ||
116 | } | ||
117 | |||
118 | QString ExportDialog::selectedName() | ||
119 | { | ||
120 | return (m_pNameLineEdit->text()); | ||
121 | } | ||
122 | |||
123 | QString ExportDialog::selectedFormat() | ||
124 | { | ||
125 | return (m_pFormatComboBox->currentText()); | ||
126 | } | ||
127 | |||
128 | void ExportDialog::accept() | ||
129 | { | ||
130 | if (!(m_pNameLineEdit->text().isEmpty())) { | ||
131 | QDialog::accept(); | ||
132 | } | ||
133 | } | ||
134 | |||
135 | void ExportDialog::selectionChanged(int id) | ||
136 | { | ||
137 | switch (id) { | ||
138 | case 0: | ||
139 | m_pFromPageSpinBox->setValue(1); | ||
140 | m_pToPageSpinBox->setValue(m_pageCount); | ||
141 | |||
142 | m_pFromPageSpinBox->setEnabled(false); | ||
143 | m_pToPageSpinBox->setEnabled(false); | ||
144 | break; | ||
145 | case 1: | ||
146 | m_pFromPageSpinBox->setValue(m_pageAt); | ||
147 | m_pToPageSpinBox->setValue(m_pageAt); | ||
148 | |||
149 | m_pFromPageSpinBox->setEnabled(false); | ||
150 | m_pToPageSpinBox->setEnabled(false); | ||
151 | break; | ||
152 | case 2: | ||
153 | m_pFromPageSpinBox->setEnabled(true); | ||
154 | m_pToPageSpinBox->setEnabled(true); | ||
155 | break; | ||
156 | default: | ||
157 | break; | ||
158 | } | ||
159 | } | ||
160 | |||
161 | void ExportDialog::fromPageChanged(int value) | ||
162 | { | ||
163 | if (m_pToPageSpinBox->value() < value) { | ||
164 | m_pToPageSpinBox->setValue(value); | ||
165 | } | ||
166 | } | ||
167 | |||
168 | void ExportDialog::toPageChanged(int value) | ||
169 | { | ||
170 | if (m_pFromPageSpinBox->value() > value) { | ||
171 | m_pFromPageSpinBox->setValue(value); | ||
172 | } | ||
173 | } | ||