File indexing completed on 2024-04-28 12:07:02
0001 /************************************************************************ 0002 * * 0003 * This file is part of Kooka, a scanning/OCR application using * 0004 * Qt <http://www.qt.io> and KDE Frameworks <http://www.kde.org>. * 0005 * * 0006 * Copyright (C) 2008-2016 Jonathan Marten <jjm@keelhaul.me.uk> * 0007 * * 0008 * Kooka is free software; you can redistribute it and/or modify it * 0009 * under the terms of the GNU Library General Public License as * 0010 * published by the Free Software Foundation and appearing in the * 0011 * file COPYING included in the packaging of this file; either * 0012 * version 2 of the License, or (at your option) any later version. * 0013 * * 0014 * As a special exception, permission is given to link this program * 0015 * with any version of the KADMOS OCR/ICR engine (a product of * 0016 * reRecognition GmbH, Kreuzlingen), and distribute the resulting * 0017 * executable without including the source code for KADMOS in the * 0018 * source distribution. * 0019 * * 0020 * This program is distributed in the hope that it will be useful, * 0021 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0022 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0023 * GNU General Public License for more details. * 0024 * * 0025 * You should have received a copy of the GNU General Public * 0026 * License along with this program; see the file COPYING. If * 0027 * not, see <http://www.gnu.org/licenses/>. * 0028 * * 0029 ************************************************************************/ 0030 0031 #ifndef FORMATDIALOG_H 0032 #define FORMATDIALOG_H 0033 0034 #include "kookacore_export.h" 0035 0036 #include "dialogbase.h" 0037 0038 #include "imgsaver.h" 0039 #include "imageformat.h" 0040 0041 class QCheckBox; 0042 class QComboBox; 0043 class QLabel; 0044 class QLineEdit; 0045 class QListWidget; 0046 class QListWidgetItem; 0047 0048 0049 /** 0050 * Class FormatDialog: 0051 * Asks the user for the image-Format and gives help for 0052 * selecting it. 0053 **/ 0054 0055 class KOOKACORE_EXPORT FormatDialog : public DialogBase 0056 { 0057 Q_OBJECT 0058 0059 public: 0060 explicit FormatDialog(QWidget *parent, ScanImage::ImageType type, 0061 bool askForFormat, const ImageFormat &format, 0062 bool askForFilename, const QString &filename); 0063 0064 ImageFormat getFormat() const; 0065 QByteArray getSubFormat() const; 0066 QString getFilename() const; 0067 bool alwaysUseFormat() const; 0068 bool useAssistant() const { return (mWantAssistant); } 0069 0070 static void forgetRemembered(); 0071 0072 static bool isCompatible(const QMimeType &mime, ScanImage::ImageType type, bool recOnly = true); 0073 0074 QCheckBox *alwaysUseFormatCheck() const { return (mDontAskCheck); } 0075 0076 protected: 0077 void showEvent(QShowEvent *ev) override; 0078 protected slots: 0079 void slotOk(); 0080 void slotUser1(); 0081 0082 private slots: 0083 void checkValid(); 0084 void buildFormatList(bool recOnly); 0085 void formatSelected(QListWidgetItem *item); 0086 0087 private: 0088 void setSelectedFormat(const ImageFormat &format); 0089 void check_subformat(const ImageFormat &format); 0090 void showExtension(const ImageFormat &format); 0091 0092 ScanImage::ImageType mImageType; 0093 0094 QComboBox *mSubformatCombo; 0095 QListWidget *mFormatList; 0096 QCheckBox *mDontAskCheck; 0097 QCheckBox *mRecOnlyCheck; 0098 QLabel *mHelpLabel; 0099 QLabel *mSubformatLabel; 0100 0101 QLineEdit *mFilenameEdit; 0102 QLabel *mExtensionLabel; 0103 0104 ImageFormat mFormat; 0105 QString mFilename; 0106 bool mWantAssistant; 0107 }; 0108 0109 #endif // FORMATDIALOG_H