Changeset View
Changeset View
Standalone View
Standalone View
src/ExportManager.h
Show All 20 Lines | |||||
21 | #define EXPORTMANAGER_H | 21 | #define EXPORTMANAGER_H | ||
22 | 22 | | |||
23 | #include <QObject> | 23 | #include <QObject> | ||
24 | #include <QIODevice> | 24 | #include <QIODevice> | ||
25 | #include <QPrinter> | 25 | #include <QPrinter> | ||
26 | #include <QPixmap> | 26 | #include <QPixmap> | ||
27 | #include <QUrl> | 27 | #include <QUrl> | ||
28 | 28 | | |||
29 | #include "PlatformBackends/ImageGrabber.h" | ||||
rkflx: If you do this, you'd give up the nice separation between those components. We might not need… | |||||
SpectacleCore does #include "PlatformBackends/ImageGrabber.h" too. In my opion it's OK. rominf: SpectacleCore does `#include "PlatformBackends/ImageGrabber.h"` too. In my opion it's OK.
| |||||
30 | | ||||
29 | class QTemporaryDir; | 31 | class QTemporaryDir; | ||
30 | 32 | | |||
31 | class ExportManager : public QObject | 33 | class ExportManager : public QObject | ||
32 | { | 34 | { | ||
33 | Q_OBJECT | 35 | Q_OBJECT | ||
34 | 36 | | |||
35 | // singleton-ize the class | 37 | // singleton-ize the class | ||
36 | 38 | | |||
Show All 10 Lines | |||||
47 | void operator= (ExportManager const&) = delete; | 49 | void operator= (ExportManager const&) = delete; | ||
48 | 50 | | |||
49 | // now the usual stuff | 51 | // now the usual stuff | ||
50 | 52 | | |||
51 | public: | 53 | public: | ||
52 | 54 | | |||
53 | Q_PROPERTY(QString saveLocation READ saveLocation WRITE setSaveLocation NOTIFY saveLocationChanged) | 55 | Q_PROPERTY(QString saveLocation READ saveLocation WRITE setSaveLocation NOTIFY saveLocationChanged) | ||
54 | Q_PROPERTY(QPixmap pixmap READ pixmap WRITE setPixmap NOTIFY pixmapChanged) | 56 | Q_PROPERTY(QPixmap pixmap READ pixmap WRITE setPixmap NOTIFY pixmapChanged) | ||
57 | Q_PROPERTY(QString windowTitle READ windowTitle WRITE setWindowTitle) | ||||
58 | Q_PROPERTY(ImageGrabber::GrabMode grabMode READ grabMode WRITE setGrabMode) | ||||
55 | 59 | | |||
56 | void setSaveLocation(const QString &location); | 60 | void setSaveLocation(const QString &location); | ||
57 | QString saveLocation() const; | 61 | QString saveLocation() const; | ||
58 | QUrl lastSavePath() const; | 62 | QUrl lastSavePath() const; | ||
59 | bool isFileExists(const QUrl &url) const; | 63 | bool isFileExists(const QUrl &url) const; | ||
60 | void setPixmap(const QPixmap &pixmap); | 64 | void setPixmap(const QPixmap &pixmap); | ||
61 | QPixmap pixmap() const; | 65 | QPixmap pixmap() const; | ||
62 | QString pixmapDataUri() const; | 66 | QString pixmapDataUri() const; | ||
67 | void setWindowTitle(const QString &windowTitle); | ||||
68 | QString windowTitle() const; | ||||
69 | ImageGrabber::GrabMode grabMode() const; | ||||
70 | void setGrabMode(const ImageGrabber::GrabMode &grabMode); | ||||
If we know windowTitle in this class, why would we need to remember grabMode too? IOW, if windowTitle is set appropriately everywhere, we would not need to fiddle around with it later on again. rkflx: If we know `windowTitle` in this class, why would we need to remember `grabMode` too? IOW, if… | |||||
rominf: It's needed for "Full screen", "Desktop", "Region" in filename. | |||||
63 | 71 | | |||
64 | signals: | 72 | signals: | ||
65 | 73 | | |||
66 | void errorMessage(const QString &str); | 74 | void errorMessage(const QString &str); | ||
67 | void saveLocationChanged(const QString &location); | 75 | void saveLocationChanged(const QString &location); | ||
68 | void pixmapChanged(const QPixmap &pixmap); | 76 | void pixmapChanged(const QPixmap &pixmap); | ||
69 | void imageSaved(const QUrl &savedAt); | 77 | void imageSaved(const QUrl &savedAt); | ||
70 | void forceNotify(const QUrl &savedAt); | 78 | void forceNotify(const QUrl &savedAt); | ||
71 | 79 | | |||
72 | public slots: | 80 | public slots: | ||
73 | 81 | | |||
74 | QUrl getAutosaveFilename(); | 82 | QUrl getAutosaveFilename(); | ||
75 | QUrl tempSave(const QString &mimetype = QStringLiteral("png")); | 83 | QUrl tempSave(const QString &mimetype = QStringLiteral("png")); | ||
76 | 84 | | |||
77 | void doSave(const QUrl &url = QUrl(), bool notify = false); | 85 | void doSave(const QUrl &url = QUrl(), bool notify = false); | ||
78 | bool doSaveAs(QWidget *parentWindow = 0, bool notify = false); | 86 | bool doSaveAs(QWidget *parentWindow = 0, bool notify = false); | ||
79 | void doCopyToClipboard(); | 87 | void doCopyToClipboard(); | ||
80 | void doPrint(QPrinter *printer); | 88 | void doPrint(QPrinter *printer); | ||
81 | 89 | | |||
82 | private: | 90 | private: | ||
83 | 91 | | |||
92 | QString truncatedFilename(const QString &filename); | ||||
84 | QString makeAutosaveFilename(); | 93 | QString makeAutosaveFilename(); | ||
85 | using FileNameAlreadyUsedCheck = bool (ExportManager::*)(const QUrl&) const; | 94 | using FileNameAlreadyUsedCheck = bool (ExportManager::*)(const QUrl&) const; | ||
86 | QString autoIncrementFilename(const QString &baseName, const QString &extension, | 95 | QString autoIncrementFilename(const QString &baseName, const QString &extension, | ||
87 | FileNameAlreadyUsedCheck isFileNameUsed); | 96 | FileNameAlreadyUsedCheck isFileNameUsed); | ||
88 | QString makeSaveMimetype(const QUrl &url); | 97 | QString makeSaveMimetype(const QUrl &url); | ||
89 | bool writeImage(QIODevice *device, const QByteArray &format); | 98 | bool writeImage(QIODevice *device, const QByteArray &format); | ||
90 | bool save(const QUrl &url); | 99 | bool save(const QUrl &url); | ||
91 | bool localSave(const QUrl &url, const QString &mimetype); | 100 | bool localSave(const QUrl &url, const QString &mimetype); | ||
92 | bool remoteSave(const QUrl &url, const QString &mimetype); | 101 | bool remoteSave(const QUrl &url, const QString &mimetype); | ||
93 | bool isTempFileAlreadyUsed(const QUrl &url) const; | 102 | bool isTempFileAlreadyUsed(const QUrl &url) const; | ||
94 | 103 | | |||
95 | QPixmap mSavePixmap; | 104 | QPixmap mSavePixmap; | ||
96 | QUrl mLastSavePath; | 105 | QUrl mLastSavePath; | ||
97 | QUrl mTempFile; | 106 | QUrl mTempFile; | ||
98 | QTemporaryDir *mTempDir; | 107 | QTemporaryDir *mTempDir; | ||
99 | QList<QUrl> mUsedTempFileNames; | 108 | QList<QUrl> mUsedTempFileNames; | ||
109 | QString mWindowTitle; | ||||
110 | ImageGrabber::GrabMode mGrabMode; | ||||
100 | }; | 111 | }; | ||
101 | 112 | | |||
102 | #endif // EXPORTMANAGER_H | 113 | #endif // EXPORTMANAGER_H |
If you do this, you'd give up the nice separation between those components. We might not need this at all (see other comment), but if we did, the enum should be put somewhere else, possibly SpectacleCore.