Changeset View
Changeset View
Standalone View
Standalone View
src/SpectacleCore.cpp
Show All 21 Lines | |||||
22 | 22 | | |||
23 | #include "Config.h" | 23 | #include "Config.h" | ||
24 | 24 | | |||
25 | #include <KGlobalAccel> | 25 | #include <KGlobalAccel> | ||
26 | #include <KLocalizedString> | 26 | #include <KLocalizedString> | ||
27 | #include <KMessageBox> | 27 | #include <KMessageBox> | ||
28 | #include <KNotification> | 28 | #include <KNotification> | ||
29 | #include <KRun> | 29 | #include <KRun> | ||
30 | #include <KWayland/Client/connection_thread.h> | ||||
31 | #include <KWayland/Client/plasmashell.h> | ||||
32 | #include <KWayland/Client/registry.h> | ||||
30 | #include <KWindowSystem> | 33 | #include <KWindowSystem> | ||
31 | 34 | | |||
32 | #include <QApplication> | 35 | #include <QApplication> | ||
33 | #include <QClipboard> | 36 | #include <QClipboard> | ||
34 | #include <QDir> | 37 | #include <QDir> | ||
35 | #include <QDrag> | 38 | #include <QDrag> | ||
36 | #include <QKeySequence> | 39 | #include <QKeySequence> | ||
37 | #include <QMimeData> | 40 | #include <QMimeData> | ||
Show All 9 Lines | 44 | SpectacleCore::SpectacleCore(StartMode theStartMode, | |||
47 | QObject *parent) : | 50 | QObject *parent) : | ||
48 | QObject(parent), | 51 | QObject(parent), | ||
49 | mStartMode(theStartMode), | 52 | mStartMode(theStartMode), | ||
50 | mNotify(theNotifyOnGrab), | 53 | mNotify(theNotifyOnGrab), | ||
51 | mPlatform(loadPlatform()), | 54 | mPlatform(loadPlatform()), | ||
52 | mMainWindow(nullptr), | 55 | mMainWindow(nullptr), | ||
53 | mIsGuiInited(false), | 56 | mIsGuiInited(false), | ||
54 | mCopyToClipboard(theCopyToClipboard) | 57 | mCopyToClipboard(theCopyToClipboard) | ||
58 | mWaylandPlasmashell(nullptr) | ||||
55 | { | 59 | { | ||
56 | auto lConfig = KSharedConfig::openConfig(QStringLiteral("spectaclerc")); | 60 | auto lConfig = KSharedConfig::openConfig(QStringLiteral("spectaclerc")); | ||
57 | KConfigGroup lGuiConfig(lConfig, "GuiConfig"); | 61 | KConfigGroup lGuiConfig(lConfig, "GuiConfig"); | ||
58 | 62 | | |||
59 | if (!(theSaveFileName.isEmpty() || theSaveFileName.isNull())) { | 63 | if (!(theSaveFileName.isEmpty() || theSaveFileName.isNull())) { | ||
60 | if (QDir::isRelativePath(theSaveFileName)) { | 64 | if (QDir::isRelativePath(theSaveFileName)) { | ||
61 | theSaveFileName = QDir::current().absoluteFilePath(theSaveFileName); | 65 | theSaveFileName = QDir::current().absoluteFilePath(theSaveFileName); | ||
62 | } | 66 | } | ||
Show All 20 Lines | |||||
83 | // set up the export manager | 87 | // set up the export manager | ||
84 | auto lExportManager = ExportManager::instance(); | 88 | auto lExportManager = ExportManager::instance(); | ||
85 | lExportManager->setCaptureMode(theCaptureMode); | 89 | lExportManager->setCaptureMode(theCaptureMode); | ||
86 | connect(lExportManager, &ExportManager::errorMessage, this, &SpectacleCore::showErrorMessage); | 90 | connect(lExportManager, &ExportManager::errorMessage, this, &SpectacleCore::showErrorMessage); | ||
87 | connect(lExportManager, &ExportManager::imageSaved, this, &SpectacleCore::doCopyPath); | 91 | connect(lExportManager, &ExportManager::imageSaved, this, &SpectacleCore::doCopyPath); | ||
88 | connect(lExportManager, &ExportManager::forceNotify, this, &SpectacleCore::doNotify); | 92 | connect(lExportManager, &ExportManager::forceNotify, this, &SpectacleCore::doNotify); | ||
89 | connect(mPlatform.get(), &Platform::windowTitleChanged, lExportManager, &ExportManager::setWindowTitle); | 93 | connect(mPlatform.get(), &Platform::windowTitleChanged, lExportManager, &ExportManager::setWindowTitle); | ||
90 | 94 | | |||
95 | // Needed so the QuickEditor can go fullscreen on wayland | ||||
96 | if (KWindowSystem::isPlatformWayland()) { | ||||
97 | using namespace KWayland::Client; | ||||
98 | ConnectionThread *connection = ConnectionThread::fromApplication(this); | ||||
99 | if (!connection) { | ||||
100 | return; | ||||
101 | } | ||||
102 | Registry *registry = new Registry(this); | ||||
103 | registry->create(connection); | ||||
104 | connect(registry, &Registry::plasmaShellAnnounced, this, | ||||
105 | [this, registry] (quint32 name, quint32 version) { | ||||
106 | mWaylandPlasmashell = registry->createPlasmaShell(name, version, this); | ||||
107 | } | ||||
108 | ); | ||||
109 | registry->setup(); | ||||
110 | connection->roundtrip(); | ||||
111 | } | ||||
112 | | ||||
91 | switch (theStartMode) { | 113 | switch (theStartMode) { | ||
92 | case StartMode::DBus: | 114 | case StartMode::DBus: | ||
93 | break; | 115 | break; | ||
94 | case StartMode::Background: { | 116 | case StartMode::Background: { | ||
95 | auto lMsec = (KWindowSystem::compositingActive() ? 200 : 50) + theDelayMsec; | 117 | auto lMsec = (KWindowSystem::compositingActive() ? 200 : 50) + theDelayMsec; | ||
96 | auto lShutterMode = lImmediateAvailable ? Platform::ShutterMode::Immediate : Platform::ShutterMode::OnClick; | 118 | auto lShutterMode = lImmediateAvailable ? Platform::ShutterMode::Immediate : Platform::ShutterMode::OnClick; | ||
97 | auto lIncludePointer = lGuiConfig.readEntry("includePointer", true); | 119 | auto lIncludePointer = lGuiConfig.readEntry("includePointer", true); | ||
98 | auto lIncludeDecorations = lGuiConfig.readEntry("includeDecorations", true); | 120 | auto lIncludeDecorations = lGuiConfig.readEntry("includeDecorations", true); | ||
▲ Show 20 Lines • Show All 119 Lines • ▼ Show 20 Line(s) | |||||
218 | { | 240 | { | ||
219 | auto lExportManager = ExportManager::instance(); | 241 | auto lExportManager = ExportManager::instance(); | ||
220 | 242 | | |||
221 | // if we were running in rectangular crop mode, now would be | 243 | // if we were running in rectangular crop mode, now would be | ||
222 | // the time to further process the image | 244 | // the time to further process the image | ||
223 | 245 | | |||
224 | if (lExportManager->captureMode() == Spectacle::CaptureMode::RectangularRegion) { | 246 | if (lExportManager->captureMode() == Spectacle::CaptureMode::RectangularRegion) { | ||
225 | if(!mQuickEditor) { | 247 | if(!mQuickEditor) { | ||
226 | mQuickEditor = std::make_unique<QuickEditor>(thePixmap); | 248 | mQuickEditor = std::make_unique<QuickEditor>(thePixmap, mWaylandPlasmashell); | ||
227 | connect(mQuickEditor.get(), &QuickEditor::grabDone, this, &SpectacleCore::screenshotUpdated); | 249 | connect(mQuickEditor.get(), &QuickEditor::grabDone, this, &SpectacleCore::screenshotUpdated); | ||
228 | connect(mQuickEditor.get(), &QuickEditor::grabCancelled, this, &SpectacleCore::screenshotFailed); | 250 | connect(mQuickEditor.get(), &QuickEditor::grabCancelled, this, &SpectacleCore::screenshotFailed); | ||
229 | mQuickEditor->show(); | 251 | mQuickEditor->show(); | ||
230 | return; | 252 | return; | ||
231 | } else { | 253 | } else { | ||
232 | mQuickEditor->hide(); | 254 | mQuickEditor->hide(); | ||
233 | mQuickEditor.reset(nullptr); | 255 | mQuickEditor.reset(nullptr); | ||
234 | } | 256 | } | ||
▲ Show 20 Lines • Show All 189 Lines • Show Last 20 Lines |