File indexing completed on 2024-05-12 05:09:48

0001 /***************************************************************************
0002     Copyright (C) 2003-2009 Robby Stephenson <robby@periapsis.org>
0003  ***************************************************************************/
0004 
0005 /***************************************************************************
0006  *                                                                         *
0007  *   This program is free software; you can redistribute it and/or         *
0008  *   modify it under the terms of the GNU General Public License as        *
0009  *   published by the Free Software Foundation; either version 2 of        *
0010  *   the License or (at your option) version 3 or any later version        *
0011  *   accepted by the membership of KDE e.V. (or its successor approved     *
0012  *   by the membership of KDE e.V.), which shall act as a proxy            *
0013  *   defined in Section 14 of version 3 of the license.                    *
0014  *                                                                         *
0015  *   This program is distributed in the hope that it will be useful,       *
0016  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
0017  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
0018  *   GNU General Public License for more details.                          *
0019  *                                                                         *
0020  *   You should have received a copy of the GNU General Public License     *
0021  *   along with this program.  If not, see <http://www.gnu.org/licenses/>. *
0022  *                                                                         *
0023  ***************************************************************************/
0024 
0025 #ifndef TELLICO_IMAGEWIDGET_H
0026 #define TELLICO_IMAGEWIDGET_H
0027 
0028 #include <KService>
0029 
0030 #include <QWidget>
0031 #include <QPixmap>
0032 #include <QImage>
0033 #include <QPoint>
0034 #include <QDateTime>
0035 #include <QPointer>
0036 #include <QUrl>
0037 
0038 #include <config.h>
0039 #ifdef HAVE_KSANE
0040 #include <ksane_version.h>
0041 #endif
0042 
0043 class QLabel;
0044 class QResizeEvent;
0045 class QMouseEvent;
0046 class QDragEnterEvent;
0047 class QDropEvent;
0048 class QCheckBox;
0049 class QLabel;
0050 class QToolButton;
0051 class QMenu;
0052 class QProgressDialog;
0053 
0054 class KProcess;
0055 #ifdef HAVE_KSANE
0056 class KPageDialog;
0057 namespace KSaneIface { class KSaneWidget; }
0058 #endif
0059 namespace Tellico {
0060   namespace GUI {
0061 
0062 /**
0063  * @author Robby Stephenson
0064  */
0065 class ImageWidget : public QWidget {
0066 Q_OBJECT
0067 
0068 public:
0069   ImageWidget(QWidget* parent);
0070   virtual ~ImageWidget();
0071 
0072   const QString& id() const { return m_imageID; }
0073   void setImage(const QString& id);
0074   void setLinkOnlyChecked(bool l);
0075 
0076 public Q_SLOTS:
0077   void slotClear();
0078 
0079 Q_SIGNALS:
0080   void signalModified();
0081 
0082 protected:
0083   virtual void resizeEvent(QResizeEvent* ev) Q_DECL_OVERRIDE;
0084   virtual void mousePressEvent(QMouseEvent* ev) Q_DECL_OVERRIDE;
0085   virtual void mouseMoveEvent(QMouseEvent* ev) Q_DECL_OVERRIDE;
0086   virtual void dragEnterEvent(QDragEnterEvent* ev) Q_DECL_OVERRIDE;
0087   virtual void dropEvent(QDropEvent* ev) Q_DECL_OVERRIDE;
0088 
0089 private Q_SLOTS:
0090   void slotGetImage();
0091   void slotLinkOnlyClicked();
0092   void slotScanImage();
0093 #ifdef HAVE_KSANE
0094 #if KSANE_VERSION < QT_VERSION_CHECK(21,8,0)
0095   void imageReady(QByteArray &data, int w, int h, int bpl, int f);
0096 #else
0097   void imageReady(const QImage& scannedImage);
0098 #endif
0099 #endif
0100   void slotEditImage();
0101   void slotEditMenu(QAction* action);
0102   void slotFinished();
0103   void cancelScan();
0104   void copyImage();
0105   void saveImageAs();
0106 
0107 private:
0108   void contextMenuEvent(QContextMenuEvent* event) Q_DECL_OVERRIDE;
0109   void scale();
0110   void loadImage(const QUrl& url);
0111 
0112   QString m_imageID;
0113   QPixmap m_pixmap;
0114   QPixmap m_scaled;
0115   QLabel* m_label;
0116   QCheckBox* m_cbLinkOnly;
0117   QUrl m_originalURL;
0118   QPoint m_dragStart;
0119   QMenu* m_editMenu;
0120   QToolButton* m_edit;
0121   KService::Ptr m_editor;
0122   QString m_img;
0123   KProcess* m_editProcess;
0124   QProgressDialog* m_waitDlg;
0125   QDateTime m_editedFileDateTime;
0126 #ifdef HAVE_KSANE
0127   QPointer<KSaneIface::KSaneWidget> m_saneWidget;
0128   QPointer<KPageDialog> m_saneDlg;
0129   QString m_saneDevice;
0130   bool m_saneDeviceIsOpen;
0131 #endif
0132 };
0133 
0134   } // end GUI namespace
0135 } // end namespace
0136 #endif