1 /* ============================================================
4 * Description : Sane plugin interface for KDE
6 * Copyright (C) 2008 by Kare Sars <kare dot sars at iki dot fi>
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) version 3, or any
12 * later version accepted by the membership of KDE e.V. (or its
13 * successor approved by the membership of KDE e.V.), which shall
14 * act as a proxy defined in Section 6 of version 3 of the license.
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Lesser General Public License for more details.
21 * You should have received a copy of the GNU Lesser General Public
22 * License along with this program. If not, see <http://www.gnu.org/licenses/>.
24 * ============================================================ */
26 #include "sanedialog.h"
30 #include <KPluginLoader>
31 #include <KMessageBox>
33 K_PLUGIN_FACTORY(SaneDialogFactory
, registerPlugin
<SaneDialog
>();)
34 K_EXPORT_PLUGIN(SaneDialogFactory("kscanplugin"))
37 ///////////////////////////////////////////////////////////////////
40 SaneDialog::SaneDialog(QWidget
*parent
, const QVariantList
&)
41 : KScanDialog(Plain
, Close
, parent
)
43 ksanew
= new KSaneIface::KSaneWidget(this);
44 addPage(ksanew
, QString());
46 connect(ksanew
, SIGNAL(imageReady(QByteArray
&, int, int, int, int)),
47 this, SLOT(imageReady(QByteArray
&, int, int, int, int)));
53 bool SaneDialog::setup()
59 if (!openDev
.isEmpty()) {
62 // need to select a scanner
63 openDev
= ksanew
->selectDevice(0);
64 if (openDev
.isEmpty()) {
65 // either no scanner was found or then cancel was pressed.
68 if (ksanew
->openDevice(openDev
) == false) {
69 // could not open the scanner
70 KMessageBox::sorry(0, i18n("Opening the selected scanner failed."));
78 SaneDialog::~SaneDialog()
82 void SaneDialog::imageReady(QByteArray
&data
, int w
, int h
, int bpl
, int f
)
84 /* copy the image data into img */
85 QImage img
= ksanew
->toQImage(data
, w
, h
, bpl
, (KSaneIface::KSaneWidget::ImageFormat
)f
);
86 emit
finalImage(img
, nextId());
90 #include "sanedialog.moc"