Changeset View
Changeset View
Standalone View
Standalone View
src/skanlite.cpp
Show All 20 Lines | |||||
21 | * along with this program. If not, see <http://www.gnu.org/licenses/> | 21 | * along with this program. If not, see <http://www.gnu.org/licenses/> | ||
22 | * | 22 | * | ||
23 | * ============================================================ */ | 23 | * ============================================================ */ | ||
24 | 24 | | |||
25 | #include "skanlite.h" | 25 | #include "skanlite.h" | ||
26 | 26 | | |||
27 | #include "KSaneImageSaver.h" | 27 | #include "KSaneImageSaver.h" | ||
28 | #include "SaveLocation.h" | 28 | #include "SaveLocation.h" | ||
29 | #include "showimagedialog.h" | ||||
29 | 30 | | |||
30 | #include <QApplication> | 31 | #include <QApplication> | ||
31 | #include <QScrollArea> | 32 | #include <QScrollArea> | ||
32 | #include <QStringList> | 33 | #include <QStringList> | ||
33 | #include <QFileDialog> | 34 | #include <QFileDialog> | ||
34 | #include <QUrl> | 35 | #include <QUrl> | ||
35 | #include <QDialogButtonBox> | 36 | #include <QDialogButtonBox> | ||
36 | #include <QComboBox> | 37 | #include <QComboBox> | ||
37 | #include <QMessageBox> | 38 | #include <QMessageBox> | ||
38 | #include <QTemporaryFile> | 39 | #include <QTemporaryFile> | ||
39 | #include <QDebug> | 40 | #include <QDebug> | ||
40 | #include <QImageWriter> | 41 | #include <QImageWriter> | ||
41 | #include <QMimeType> | 42 | #include <QMimeType> | ||
42 | #include <QMimeDatabase> | 43 | #include <QMimeDatabase> | ||
44 | #include <QCloseEvent> | ||||
43 | 45 | | |||
44 | #include <KAboutApplicationDialog> | 46 | #include <KAboutApplicationDialog> | ||
45 | #include <KLocalizedString> | 47 | #include <KLocalizedString> | ||
46 | #include <KMessageBox> | 48 | #include <KMessageBox> | ||
47 | #include <KIO/StatJob> | 49 | #include <KIO/StatJob> | ||
48 | #include <KIO/Job> | 50 | #include <KIO/Job> | ||
49 | #include <KJobWidgets> | 51 | #include <KJobWidgets> | ||
50 | #include <kio/global.h> | 52 | #include <kio/global.h> | ||
▲ Show 20 Lines • Show All 133 Lines • ▼ Show 20 Line(s) | 172 | if (m_ksanew->openDevice(device) == false) { | |||
184 | } | 186 | } | ||
185 | } | 187 | } | ||
186 | else { | 188 | else { | ||
187 | setWindowTitle(i18nc("@title:window %1 = scanner device", "%1 - Skanlite", device)); | 189 | setWindowTitle(i18nc("@title:window %1 = scanner device", "%1 - Skanlite", device)); | ||
188 | m_deviceName = device; | 190 | m_deviceName = device; | ||
189 | } | 191 | } | ||
190 | 192 | | |||
191 | // prepare the Show Image Dialog | 193 | // prepare the Show Image Dialog | ||
192 | { | 194 | m_showImgDialog = new ShowImageDialog(this); | ||
193 | m_showImgDialog = new QDialog(this); | 195 | connect(m_showImgDialog, &ShowImageDialog::saveRequested, this, &Skanlite::saveImage); | ||
194 | 196 | connect(m_showImgDialog, &ShowImageDialog::rejected, m_ksanew, &KSaneWidget::scanCancel); | |||
195 | QVBoxLayout *mainLayout = new QVBoxLayout(m_showImgDialog); | | |||
196 | | ||||
197 | QDialogButtonBox *imgButtonBox = new QDialogButtonBox(m_showImgDialog); | | |||
198 | // "Close" (now Discard) and "User1"=Save | | |||
199 | imgButtonBox->setStandardButtons(QDialogButtonBox::Discard | QDialogButtonBox::Save); | | |||
200 | | ||||
201 | mainLayout->addWidget(&m_imageViewer); | | |||
202 | mainLayout->addWidget(imgButtonBox); | | |||
203 | | ||||
204 | m_showImgDialogSaveButton = imgButtonBox->button(QDialogButtonBox::Save); | | |||
205 | m_showImgDialogSaveButton->setDefault(true); // still needed? | | |||
206 | | ||||
207 | m_showImgDialog->resize(640, 480); | | |||
208 | connect(imgButtonBox, &QDialogButtonBox::accepted, this, &Skanlite::saveImage); | | |||
209 | //connect(imgButtonBox, &QDialogButtonBox::accepted, m_showImgDialog, &QDialog::accept); | | |||
210 | connect(imgButtonBox->button(QDialogButtonBox::Discard), &QPushButton::clicked, m_ksanew, &KSaneWidget::scanCancel); | | |||
211 | connect(imgButtonBox->button(QDialogButtonBox::Discard), &QPushButton::clicked, m_showImgDialog, &QDialog::reject); | | |||
212 | } | | |||
213 | 197 | | |||
214 | // save the default sane options for later use | 198 | // save the default sane options for later use | ||
215 | m_ksanew->getOptVals(m_defaultScanOpts); | 199 | m_ksanew->getOptVals(m_defaultScanOpts); | ||
216 | 200 | | |||
217 | // load saved options | 201 | // load saved options | ||
218 | loadScannerOptions(); | 202 | loadScannerOptions(); | ||
219 | 203 | | |||
220 | m_ksanew->initGetDeviceList(); | 204 | m_ksanew->initGetDeviceList(); | ||
▲ Show 20 Lines • Show All 150 Lines • ▼ Show 20 Line(s) | 352 | { | |||
371 | m_width = w; | 355 | m_width = w; | ||
372 | m_height = h; | 356 | m_height = h; | ||
373 | m_bytesPerLine = bpl; | 357 | m_bytesPerLine = bpl; | ||
374 | m_format = f; | 358 | m_format = f; | ||
375 | 359 | | |||
376 | if (m_settingsUi.showB4Save->isChecked() == true) { | 360 | if (m_settingsUi.showB4Save->isChecked() == true) { | ||
377 | /* copy the image data into m_img and show it*/ | 361 | /* copy the image data into m_img and show it*/ | ||
378 | m_img = m_ksanew->toQImageSilent(data, w, h, bpl, (KSaneIface::KSaneWidget::ImageFormat)f); | 362 | m_img = m_ksanew->toQImageSilent(data, w, h, bpl, (KSaneIface::KSaneWidget::ImageFormat)f); | ||
379 | m_imageViewer.setQImage(&m_img); | 363 | m_showImgDialog->setQImage(&m_img); | ||
380 | m_imageViewer.zoom2Fit(); | 364 | m_showImgDialog->zoom2Fit(); | ||
381 | m_showImgDialogSaveButton->setFocus(); | | |||
382 | m_showImgDialog->exec(); | 365 | m_showImgDialog->exec(); | ||
383 | // save has been done as a result of save or then we got cancel | 366 | // save has been done as a result of save or then we got cancel | ||
384 | } | 367 | } | ||
385 | else { | 368 | else { | ||
386 | m_img = QImage(); // clear the image to ensure we save the correct one. | 369 | m_img = QImage(); // clear the image to ensure we save the correct one. | ||
387 | saveImage(); | 370 | saveImage(); | ||
388 | } | 371 | } | ||
389 | } | 372 | } | ||
▲ Show 20 Lines • Show All 416 Lines • Show Last 20 Lines |