Changeset View
Changeset View
Standalone View
Standalone View
src/SpectacleCore.h
Show All 17 Lines | |||||
18 | * | 18 | * | ||
19 | * SPDX-License-Identifier: LGPL-2.0-or-later | 19 | * SPDX-License-Identifier: LGPL-2.0-or-later | ||
20 | */ | 20 | */ | ||
21 | 21 | | |||
22 | #pragma once | 22 | #pragma once | ||
23 | 23 | | |||
24 | #include <QObject> | 24 | #include <QObject> | ||
25 | 25 | | |||
26 | #include "BackendInterfaces/ScreenshotInterface.h" | ||||
26 | #include "ExportManager.h" | 27 | #include "ExportManager.h" | ||
27 | #include "Gui/KSMainWindow.h" | 28 | #include "Gui/KSMainWindow.h" | ||
28 | #include "QuickEditor/QuickEditor.h" | 29 | #include "QuickEditor/QuickEditor.h" | ||
29 | #include "Platforms/PlatformLoader.h" | | |||
30 | 30 | | |||
31 | #include <memory> | 31 | #include <memory> | ||
32 | 32 | | |||
33 | using MainWindowPtr = std::unique_ptr<KSMainWindow>; | 33 | using MainWindowPtr = std::unique_ptr<KSMainWindow>; | ||
34 | using EditorPtr = std::unique_ptr<QuickEditor>; | 34 | using EditorPtr = std::unique_ptr<QuickEditor>; | ||
35 | 35 | | |||
36 | class SpectacleCore: public QObject | 36 | class SpectacleCore: public QObject | ||
37 | { | 37 | { | ||
38 | Q_OBJECT | 38 | Q_OBJECT | ||
39 | 39 | | |||
40 | public: | 40 | public: | ||
41 | 41 | | |||
42 | enum class StartMode { | 42 | enum class StartMode { | ||
43 | Gui = 0, | 43 | Gui = 0, | ||
44 | DBus = 1, | 44 | DBus = 1, | ||
45 | Background = 2 | 45 | Background = 2 | ||
46 | }; | 46 | }; | ||
47 | 47 | | |||
48 | explicit SpectacleCore(StartMode theStartMode, | 48 | explicit SpectacleCore(StartMode theStartMode, | ||
49 | Spectacle::CaptureMode theCaptureMode, | 49 | CaptureMode theCaptureMode, | ||
50 | QString &theSaveFileName, | 50 | QString &theSaveFileName, | ||
51 | qint64 theDelayMsec, | 51 | qint64 theDelayMsec, | ||
52 | bool theNotifyOnGrab, | 52 | bool theNotifyOnGrab, | ||
53 | bool theCopyToClipboard, | 53 | bool theCopyToClipboard, | ||
54 | QObject *parent = nullptr); | 54 | QObject *parent = nullptr); | ||
55 | virtual ~SpectacleCore() = default; | 55 | virtual ~SpectacleCore() = default; | ||
56 | 56 | | |||
57 | QString filename() const; | 57 | QString filename() const; | ||
58 | void setFilename(const QString &filename); | 58 | void setFilename(const QString &filename); | ||
59 | 59 | | |||
60 | Q_SIGNALS: | 60 | Q_SIGNALS: | ||
61 | 61 | | |||
62 | void errorMessage(const QString &errString); | 62 | void errorMessage(const QString &errString); | ||
63 | void allDone(); | 63 | void allDone(); | ||
64 | void filenameChanged(const QString &filename); | 64 | void filenameChanged(const QString &filename); | ||
65 | void grabFailed(); | 65 | void grabFailed(); | ||
66 | 66 | | |||
67 | public Q_SLOTS: | 67 | public Q_SLOTS: | ||
68 | 68 | | |||
69 | void takeNewScreenshot(Spectacle::CaptureMode theCaptureMode, int theTimeout, bool theIncludePointer, bool theIncludeDecorations); | 69 | void takeNewScreenshot(CaptureMode theCaptureMode, int theTimeout, bool theIncludePointer, bool theIncludeDecorations); | ||
70 | void showErrorMessage(const QString &theErrString); | 70 | void showErrorMessage(const QString &theErrString); | ||
71 | void screenshotUpdated(const QPixmap &thePixmap); | 71 | void screenshotUpdated(const QPixmap &thePixmap); | ||
72 | void screenshotFailed(); | 72 | void screenshotFailed(); | ||
73 | void dbusStartAgent(); | 73 | void dbusStartAgent(); | ||
74 | void doStartDragAndDrop(); | 74 | void doStartDragAndDrop(); | ||
75 | void doNotify(const QUrl &theSavedAt); | 75 | void doNotify(const QUrl &theSavedAt); | ||
76 | void doCopyPath(const QUrl &savedAt); | 76 | void doCopyPath(const QUrl &savedAt); | ||
77 | 77 | | |||
78 | private: | 78 | private: | ||
79 | 79 | | |||
80 | void updateScreenshotBackendConnections(); | ||||
80 | 81 | | |||
81 | void initGui(bool theIncludePointer, bool theIncludeDecorations); | 82 | void initGui(bool theIncludePointer, bool theIncludeDecorations); | ||
82 | Platform::GrabMode toPlatformGrabMode(Spectacle::CaptureMode theCaptureMode); | | |||
83 | void setUpShortcuts(); | 83 | void setUpShortcuts(); | ||
84 | 84 | | |||
85 | StartMode mStartMode; | 85 | StartMode mStartMode; | ||
86 | bool mNotify; | 86 | bool mNotify; | ||
87 | QString mFileNameString; | 87 | QString mFileNameString; | ||
88 | QUrl mFileNameUrl; | 88 | QUrl mFileNameUrl; | ||
89 | PlatformPtr mPlatform; | 89 | ScreenshotInterface* mScreenshotPlugin; | ||
90 | MainWindowPtr mMainWindow; | 90 | MainWindowPtr mMainWindow; | ||
91 | EditorPtr mQuickEditor; | 91 | EditorPtr mQuickEditor; | ||
92 | bool mIsGuiInited; | 92 | bool mIsGuiInited; | ||
93 | bool mCopyToClipboard; | 93 | bool mCopyToClipboard; | ||
94 | }; | 94 | }; |