Changeset View
Standalone View
src/KSaneImageSaver.h
Show All 28 Lines | |||||
29 | #include <QByteArray> | 29 | #include <QByteArray> | ||
30 | #include <QThread> | 30 | #include <QThread> | ||
31 | #include <QString> | 31 | #include <QString> | ||
32 | 32 | | |||
33 | class KSaneImageSaver : public QThread | 33 | class KSaneImageSaver : public QThread | ||
34 | { | 34 | { | ||
35 | Q_OBJECT | 35 | Q_OBJECT | ||
36 | public: | 36 | public: | ||
37 | explicit KSaneImageSaver(QObject *parent = 0); | 37 | explicit KSaneImageSaver(QObject *parent = nullptr); | ||
38 | ~KSaneImageSaver(); | 38 | ~KSaneImageSaver(); | ||
39 | 39 | | |||
40 | bool savePng(const QString &name, const QByteArray &data, int width, int height, int format, int dpi); | 40 | bool saveQImage(const QUrl &url, const QString &name, const QByteArray &data, int width, int height, int bpl, int dpi, int format, const QString& fileFormat, int quality); | ||
41 | 41 | bool save16BitPng(const QUrl &url, const QString &name, const QByteArray &data, int width, int height, int bpl, int dpi, int format, const QString& fileFormat, int quality); | |||
sars: Maybe we should just remove the sync versions as we will not be using the sync versions in… | |||||
Why both url and name? From Skanlite.cpp I can see that you have url for the final destination and name for the local file. I think KSaneImageSaver should not need to know about the KIO remote/local stuff so I would say that we only need a local filename. sars: Why both url and name? From Skanlite.cpp I can see that you have url for the final destination… | |||||
It was done just to pass QUrl to imageSaved slot via KSaneImageSaver. I'm trying to avoid case than the slot could be called with wrong url. An alternative would be passing it via SkanLite's class member; KSaneWIdget allows selection of multiple regions on single page. So if imageReady() signal is connected with Qt::QueuedConnection we can get Skanlite::imageReady() slot called twice in a raw (each for its region) or something like that. Skanlite::imageReady slot will launch KSaneImageSaver thread and than could be called again. Second slot will hang on KSaneImageSaver bcs of mutex inside it, but before that it'll change fileUrl. So passing fileUrl via class member from saveImage() to imageSaved() (that is connected to KSaneImageSaver::imageSaved) is safe unless KSaneWidgetPrivate::imageReady() and Skanlite::imageReady() aren't in different threads and user have several regions selected. And it seems they are definitely in different threads and connection type must be Qt::QueuedConnection. trufanov: It was done just to pass QUrl to imageSaved slot via KSaneImageSaver. I'm trying to avoid case… | |||||
Why do you pass a const QImage & to KSaneImageSaver? You don't need to do that from what I can see. I don't think we need a member variable either.... sars: Why do you pass a const QImage & to KSaneImageSaver? You don't need to do that from what I can… | |||||
42 | bool savePngSync(const QString &name, const QByteArray &data, int width, int height, int format, int dpi); | | |||
43 | | ||||
44 | bool saveTiff(const QString &name, const QByteArray &data, int width, int height, int format); | | |||
45 | | ||||
46 | bool saveTiffSync(const QString &name, const QByteArray &data, int width, int height, int format); | | |||
47 | | ||||
48 | Q_SIGNALS: | 42 | Q_SIGNALS: | ||
49 | void imageSaved(bool success); | 43 | void imageSaved(const QUrl &url, const QString &name, bool success); | ||
50 | 44 | | |||
51 | protected: | 45 | protected: | ||
This Tiff saver has always been a stub and I have not heard any request to get it implemented yet so we could just as well remove it until we get a real need for it. So this would be replaced with saveQImage(.....) for the non 16bit/color saves. sars: This Tiff saver has always been a stub and I have not heard any request to get it implemented… | |||||
52 | void run() Q_DECL_OVERRIDE; | 46 | void run() Q_DECL_OVERRIDE; | ||
53 | 47 | | |||
54 | private: | 48 | private: | ||
55 | struct Private; | 49 | struct Private; | ||
56 | Private *const d; | 50 | Private *const d; | ||
57 | | ||||
58 | }; | 51 | }; | ||
sars: Move this to the d-pointer Private struct | |||||
59 | 52 | | |||
60 | #endif | 53 | #endif | ||
61 | 54 | |
Maybe we should just remove the sync versions as we will not be using the sync versions in Skanlite after this.