Changeset View
Changeset View
Standalone View
Standalone View
src/SpectacleConfig.h
Show All 14 Lines | |||||
15 | * along with this program; if not, write to the Free Software | 15 | * along with this program; if not, write to the Free Software | ||
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, | 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
17 | * Boston, MA 02110-1301, USA. | 17 | * Boston, MA 02110-1301, USA. | ||
18 | */ | 18 | */ | ||
19 | 19 | | |||
20 | #ifndef SPECTACLECONFIG_H | 20 | #ifndef SPECTACLECONFIG_H | ||
21 | #define SPECTACLECONFIG_H | 21 | #define SPECTACLECONFIG_H | ||
22 | 22 | | |||
23 | #include "BackendInterfaces/ScreenshotInterface.h" | ||||
24 | | ||||
23 | #include <QObject> | 25 | #include <QObject> | ||
24 | #include <QUrl> | 26 | #include <QUrl> | ||
25 | #include <QRect> | 27 | #include <QRect> | ||
26 | 28 | | |||
27 | #include <KActionCollection> | 29 | #include <KActionCollection> | ||
28 | #include <KSharedConfig> | 30 | #include <KSharedConfig> | ||
29 | #include <KConfigGroup> | 31 | #include <KConfigGroup> | ||
30 | 32 | | |||
31 | enum class SaveMode { | 33 | enum class SaveMode { | ||
32 | SaveAs, | 34 | SaveAs, | ||
33 | Save | 35 | Save | ||
34 | }; | 36 | }; | ||
35 | 37 | | |||
38 | struct ScreenshotPlugin { | ||||
39 | QString fileName; | ||||
40 | QJsonObject metaData; | ||||
41 | ScreenshotInterface *backend; | ||||
42 | }; | ||||
43 | | ||||
36 | class SpectacleConfig : public QObject | 44 | class SpectacleConfig : public QObject | ||
37 | { | 45 | { | ||
38 | Q_OBJECT | 46 | Q_OBJECT | ||
39 | 47 | | |||
40 | // singleton-ize the class | 48 | // singleton-ize the class | ||
41 | 49 | | |||
42 | public: | 50 | public: | ||
43 | 51 | | |||
44 | static SpectacleConfig* instance(); | 52 | static SpectacleConfig* instance(); | ||
45 | 53 | | |||
54 | bool findScreenshotBackend(const QString &name); | ||||
55 | | ||||
56 | const QString& platform() const; | ||||
57 | | ||||
58 | ScreenshotInterface* screenshotBackend() const; | ||||
59 | | ||||
60 | const std::vector<ScreenshotPlugin>& screenshotPlugins() const; | ||||
61 | | ||||
46 | QString defaultFilename() const; | 62 | QString defaultFilename() const; | ||
47 | QString defaultTimestampTemplate() const; | 63 | QString defaultTimestampTemplate() const; | ||
48 | 64 | | |||
49 | QUrl lastSaveAsLocation() const; | 65 | QUrl lastSaveAsLocation() const; | ||
50 | QUrl lastSaveLocation() const; | 66 | QUrl lastSaveLocation() const; | ||
51 | 67 | | |||
52 | enum PrintKeyActionRunning : int { | 68 | enum PrintKeyActionRunning : int { | ||
53 | TakeNewScreenshot = 0, | 69 | TakeNewScreenshot = 0, | ||
54 | StartNewInstance, | 70 | StartNewInstance, | ||
55 | FocusWindow | 71 | FocusWindow | ||
56 | }; | 72 | }; | ||
57 | 73 | | |||
58 | KActionCollection* shortCutActions; | 74 | KActionCollection* shortCutActions; | ||
59 | 75 | | |||
60 | private: | 76 | private: | ||
61 | 77 | | |||
62 | explicit SpectacleConfig(QObject *parent = nullptr); | 78 | explicit SpectacleConfig(QObject *parent = nullptr); | ||
63 | virtual ~SpectacleConfig(); | 79 | virtual ~SpectacleConfig(); | ||
64 | 80 | | |||
65 | SpectacleConfig(SpectacleConfig const&) = delete; | 81 | SpectacleConfig(SpectacleConfig const&) = delete; | ||
66 | void operator= (SpectacleConfig const&) = delete; | 82 | void operator= (SpectacleConfig const&) = delete; | ||
67 | 83 | | |||
68 | // everything else | 84 | void findPlugins(); | ||
85 | void selectScreenshotBackend(); | ||||
69 | 86 | | |||
70 | public Q_SLOTS: | 87 | public Q_SLOTS: | ||
71 | 88 | | |||
72 | QUrl lastSaveAsFile() const; | 89 | QUrl lastSaveAsFile() const; | ||
73 | void setLastSaveAsFile(const QUrl &location); | 90 | void setLastSaveAsFile(const QUrl &location); | ||
74 | 91 | | |||
75 | QUrl lastSaveFile() const; | 92 | QUrl lastSaveFile() const; | ||
76 | void setLastSaveFile(const QUrl &location); | 93 | void setLastSaveFile(const QUrl &location); | ||
▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Line(s) | |||||
127 | void setDefaultSaveLocation(const QUrl &location); | 144 | void setDefaultSaveLocation(const QUrl &location); | ||
128 | 145 | | |||
129 | bool copySaveLocationToClipboard() const; | 146 | bool copySaveLocationToClipboard() const; | ||
130 | void setCopySaveLocationToClipboard(bool enabled); | 147 | void setCopySaveLocationToClipboard(bool enabled); | ||
131 | 148 | | |||
132 | QString saveImageFormat() const; | 149 | QString saveImageFormat() const; | ||
133 | void setSaveImageFormat(const QString &saveFmt); | 150 | void setSaveImageFormat(const QString &saveFmt); | ||
134 | 151 | | |||
152 | //Backend Settings | ||||
153 | QString screenshotBackendName() const; | ||||
154 | void setScreenshotBackendName(const QString& name); | ||||
155 | | ||||
135 | PrintKeyActionRunning printKeyActionRunning() const; | 156 | PrintKeyActionRunning printKeyActionRunning() const; | ||
136 | void setPrintKeyActionRunning (PrintKeyActionRunning action); | 157 | void setPrintKeyActionRunning (PrintKeyActionRunning action); | ||
137 | 158 | | |||
159 | Q_SIGNALS: | ||||
160 | | ||||
161 | void screenshotBackendNameChanged(const QString& name); | ||||
162 | void screenshotBackendChanged(ScreenshotInterface* screenshotBackend); | ||||
163 | | ||||
138 | private: | 164 | private: | ||
139 | 165 | | |||
166 | QString screenshotXcbBackendName() const; | ||||
167 | void setScreenshotXcbBackendName(const QString& name); | ||||
168 | | ||||
169 | QString screenshotWaylandBackendName() const; | ||||
170 | void setScreenshotWaylandBackendName(const QString& name); | ||||
171 | | ||||
172 | bool setScreenshotBackend(ScreenshotPlugin &newPlugin, ScreenshotPlugin *oldPlugin); | ||||
173 | | ||||
140 | KSharedConfigPtr mConfig; | 174 | KSharedConfigPtr mConfig; | ||
141 | KConfigGroup mGeneralConfig; | 175 | KConfigGroup mGeneralConfig; | ||
142 | KConfigGroup mGuiConfig; | 176 | KConfigGroup mGuiConfig; | ||
177 | | ||||
178 | QString mPlatform; | ||||
179 | std::vector<ScreenshotPlugin> mScreenshotPlugins; | ||||
143 | }; | 180 | }; | ||
144 | 181 | | |||
145 | #endif // SPECTACLECONFIG_H | 182 | #endif // SPECTACLECONFIG_H |