Warning, file /graphics/kooka/plugins/destination/abstractdestination.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
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) 2000-2018 Klaas Freitag <freitag@suse.de> * 0007 * Jonathan Marten <jjm@keelhaul.me.uk> * 0008 * * 0009 * Kooka is free software; you can redistribute it and/or modify it * 0010 * under the terms of the GNU Library General Public License as * 0011 * published by the Free Software Foundation and appearing in the * 0012 * file COPYING included in the packaging of this file; either * 0013 * version 2 of the License, or (at your option) any later version. * 0014 * * 0015 * As a special exception, permission is given to link this program * 0016 * with any version of the KADMOS OCR/ICR engine (a product of * 0017 * reRecognition GmbH, Kreuzlingen), and distribute the resulting * 0018 * executable without including the source code for KADMOS in the * 0019 * source distribution. * 0020 * * 0021 * This program is distributed in the hope that it will be useful, * 0022 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0023 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0024 * GNU General Public License for more details. * 0025 * * 0026 * You should have received a copy of the GNU General Public * 0027 * License along with this program; see the file COPYING. If * 0028 * not, see <http://www.gnu.org/licenses/>. * 0029 * * 0030 ************************************************************************/ 0031 0032 #ifndef ABSTRACTDESTINATION_H 0033 #define ABSTRACTDESTINATION_H 0034 0035 #include <klocalizedstring.h> 0036 0037 #include "abstractplugin.h" 0038 #include "scanimage.h" 0039 #include "imageformat.h" 0040 0041 0042 class QComboBox; 0043 class ScanGallery; 0044 class ScanParamsPage; 0045 0046 #ifndef PLUGIN_EXPORT 0047 #define PLUGIN_EXPORT 0048 #endif 0049 0050 0051 class PLUGIN_EXPORT AbstractDestination : public AbstractPlugin 0052 { 0053 Q_OBJECT 0054 0055 public: 0056 /** 0057 * Destructor. 0058 **/ 0059 virtual ~AbstractDestination() = default; 0060 0061 /** 0062 * Indicates that a scan is starting. The plugin should prepare 0063 * to receive the image. 0064 * 0065 * This is always called before the start of the scan, but not for 0066 * a preview. However, if SANE did not provide enough information 0067 * to determine the format of the scanned image then @p type may be 0068 * @c ScanImage::None. If the plugin needs to ask for a file name 0069 * to save or send the scan, then it should take account of the @p type 0070 * and should also honour the "ask before or after scan" setting. 0071 * 0072 * The base class implementation ignores the image type and always 0073 * returns @c true. There is no need for a plugin which overrides 0074 * this function to call the base class implementation. 0075 * 0076 * @param type The type of the image that is about to be scanned. 0077 * @return @c true if the scan is to go ahead, or @c false if it 0078 * is to be cancelled. 0079 **/ 0080 virtual bool scanStarting(ScanImage::ImageType type) { return (true); } 0081 0082 /** 0083 * Indicates that an image has been scanned. The plugin should 0084 * save or send the image as required. 0085 * 0086 * @param img The image that has been scanned, 0087 **/ 0088 virtual void imageScanned(ScanImage::Ptr img) = 0; 0089 0090 /** 0091 * Get a description string for the scan destination. 0092 * 0093 * This is shown along with the scan progress indicator. It may 0094 * contain KUIT markup, which will be finalised when the progress 0095 * is shown. If the string contains KUIT markup then it should be 0096 * generated by @c kxi18n(), although no context is required. 0097 * Otherwise, it may be generated by @c ki18n(). 0098 * 0099 * If the description is an empty string then only the default label 0100 * ("Scan in progress") will be shown. The base class implementation 0101 * returns an empty string. 0102 0103 * @return The descriptive title, or an empty string for none. 0104 * @note @c scanStarting() will always be called before this function. 0105 **/ 0106 virtual KLocalizedString scanDestinationString() { return (KLocalizedString()); } 0107 0108 /** 0109 * Create GUI widgets as required for the selected destination 0110 * plugin. This includes loading the saved settings if the 0111 * plugin has any. 0112 * 0113 * The base class implementation adds nothing. 0114 * 0115 * @param page The parent frame. 0116 * 0117 * @note The current row of the @p page is the first reserved 0118 * parameter row. 0119 **/ 0120 virtual void createGUI(ScanParamsPage *page) { } 0121 0122 /** 0123 * Sets the scan gallery, in the event that the plugin needs 0124 * to locate it. 0125 * 0126 * @param gallery The scan gallery. 0127 * @see @c gallery() 0128 **/ 0129 void setScanGallery(ScanGallery *gallery) { mGallery = gallery; } 0130 0131 /** 0132 * Save the plugin settings, either to the application settings or 0133 * a private configuration. 0134 * 0135 * The base class implementation does nothing. 0136 **/ 0137 virtual void saveSettings() const { } 0138 0139 protected: 0140 /** 0141 * Constructor. 0142 * 0143 * @param pnt The parent object. 0144 * @param name The Qt object name. 0145 **/ 0146 explicit AbstractDestination(QObject *pnt, const char *name); 0147 0148 /** 0149 * Get the scan gallery, if needed by the plugin. 0150 * 0151 * @return the scan gallery, or @c nullptr if none has been set. 0152 * @see @c setScanGallery() 0153 **/ 0154 ScanGallery *gallery() const { return (mGallery); } 0155 0156 /** 0157 * Get a format to save the image, from the user specified MIME type. 0158 * 0159 * If a valid MIME type is selected, then use that. If "Other" is 0160 * selected or the selected format is not valid for saving, then use 0161 * a @c FormatDialog to prompt for a format. 0162 * 0163 * @param mimeName The MIME type name. 0164 * @param img The image which is to be saved, 0165 * @return an @c ImageFormat for saving the image. 0166 **/ 0167 ImageFormat getSaveFormat(const QString &mimeName, ScanImage::Ptr img); 0168 0169 /** 0170 * Save a temporary image for sending to a destination. 0171 * 0172 * @param fmt The image format to save in. 0173 * @param img The image which is to be saved, 0174 * @return the URL of a temporary file, or a null URL if there was 0175 * a problem saving the image. If the URL is valid then the temporary 0176 * file will not be deleted even when the application exits, the 0177 * caller must delete the file when it is no longer required. 0178 **/ 0179 QUrl saveTempImage(const ImageFormat &fmt, ScanImage::Ptr img); 0180 0181 /** 0182 * Create a combo box for selecting an image format. 0183 * 0184 * @param mimeTypes A list of MIME types to show in the combo box. 0185 * @param configuredType The MIME type that is to be initially 0186 * selected, or @c QString() if the "Other" option is to be selected. 0187 * @return a combo box, with no parent widget assigned. The caller may 0188 * assign the combo box a parent or delete it when it is no longer required. 0189 * @note The relevant MIME type is stored in the @c data(Qt::UserRole) 0190 * of the combo box items, with a null string for "Other". 0191 **/ 0192 QComboBox *createFormatCombo(const QStringList &mimeTypes, const QString &configuredType); 0193 0194 /** 0195 * Delete a file in the background, after a time delay. 0196 * 0197 * @param url The file to delete. 0198 **/ 0199 void delayedDelete(const QUrl &url); 0200 0201 private: 0202 ScanGallery *mGallery; 0203 ImageFormat mLastUsedFormat; 0204 }; 0205 0206 #endif // ABSTRACTDESTINATION_H