Changeset View
Changeset View
Standalone View
Standalone View
src/SpectacleCore.cpp
Show All 29 Lines | |||||
30 | #include <KMessageBox> | 30 | #include <KMessageBox> | ||
31 | #include <KNotification> | 31 | #include <KNotification> | ||
32 | #include <KRun> | 32 | #include <KRun> | ||
33 | #include <KWayland/Client/connection_thread.h> | 33 | #include <KWayland/Client/connection_thread.h> | ||
34 | #include <KWayland/Client/plasmashell.h> | 34 | #include <KWayland/Client/plasmashell.h> | ||
35 | #include <KWayland/Client/registry.h> | 35 | #include <KWayland/Client/registry.h> | ||
36 | #include <KWindowSystem> | 36 | #include <KWindowSystem> | ||
37 | 37 | | |||
38 | #include <KScreen/kscreen/configmonitor.h> | ||||
39 | #include <KScreen/kscreen/getconfigoperation.h> | ||||
40 | | ||||
38 | #include <QApplication> | 41 | #include <QApplication> | ||
39 | #include <QClipboard> | 42 | #include <QClipboard> | ||
40 | #include <QDir> | 43 | #include <QDir> | ||
41 | #include <QDrag> | 44 | #include <QDrag> | ||
42 | #include <QKeySequence> | 45 | #include <QKeySequence> | ||
43 | #include <QMimeData> | 46 | #include <QMimeData> | ||
44 | #include <QProcess> | 47 | #include <QProcess> | ||
45 | #include <QTimer> | 48 | #include <QTimer> | ||
▲ Show 20 Lines • Show All 58 Lines • ▼ Show 20 Line(s) | 106 | connect(registry, &Registry::plasmaShellAnnounced, this, | |||
104 | [this, registry] (quint32 name, quint32 version) { | 107 | [this, registry] (quint32 name, quint32 version) { | ||
105 | mWaylandPlasmashell = registry->createPlasmaShell(name, version, this); | 108 | mWaylandPlasmashell = registry->createPlasmaShell(name, version, this); | ||
106 | } | 109 | } | ||
107 | ); | 110 | ); | ||
108 | registry->setup(); | 111 | registry->setup(); | ||
109 | connection->roundtrip(); | 112 | connection->roundtrip(); | ||
110 | } | 113 | } | ||
111 | 114 | | |||
115 | // load screen configuration, necessary to get scaling per screen info for QuickEditor | ||||
116 | connect(new KScreen::GetConfigOperation(), &KScreen::ConfigOperation::finished, this, | ||||
117 | [this](KScreen::ConfigOperation *op) { | ||||
118 | mScreenConfiguration = qobject_cast<KScreen::GetConfigOperation *>(op)->config(); | ||||
119 | | ||||
120 | screenConfigurationReceived(mScreenConfiguration); | ||||
121 | }); | ||||
122 | | ||||
112 | switch (theStartMode) { | 123 | switch (theStartMode) { | ||
113 | case StartMode::DBus: | 124 | case StartMode::DBus: | ||
114 | break; | 125 | break; | ||
115 | case StartMode::Background: { | 126 | case StartMode::Background: { | ||
116 | auto lMsec = (KWindowSystem::compositingActive() ? 200 : 50) + theDelayMsec; | 127 | auto lMsec = (KWindowSystem::compositingActive() ? 200 : 50) + theDelayMsec; | ||
117 | auto lShutterMode = lImmediateAvailable ? Platform::ShutterMode::Immediate : Platform::ShutterMode::OnClick; | 128 | auto lShutterMode = lImmediateAvailable ? Platform::ShutterMode::Immediate : Platform::ShutterMode::OnClick; | ||
118 | auto lIncludePointer = Settings::includePointer(); | 129 | auto lIncludePointer = Settings::includePointer(); | ||
119 | auto lIncludeDecorations = Settings::includeDecorations(); | 130 | auto lIncludeDecorations = Settings::includeDecorations(); | ||
▲ Show 20 Lines • Show All 110 Lines • ▼ Show 20 Line(s) | |||||
230 | { | 241 | { | ||
231 | auto lExportManager = ExportManager::instance(); | 242 | auto lExportManager = ExportManager::instance(); | ||
232 | 243 | | |||
233 | // if we were running in rectangular crop mode, now would be | 244 | // if we were running in rectangular crop mode, now would be | ||
234 | // the time to further process the image | 245 | // the time to further process the image | ||
235 | 246 | | |||
236 | if (lExportManager->captureMode() == Spectacle::CaptureMode::RectangularRegion) { | 247 | if (lExportManager->captureMode() == Spectacle::CaptureMode::RectangularRegion) { | ||
237 | if(!mQuickEditor) { | 248 | if(!mQuickEditor) { | ||
238 | mQuickEditor = std::make_unique<QuickEditor>(thePixmap, mWaylandPlasmashell); | 249 | mQuickEditor = std::make_unique<QuickEditor>(thePixmap, mWaylandPlasmashell, mScreenConfiguration); | ||
239 | connect(mQuickEditor.get(), &QuickEditor::grabDone, this, &SpectacleCore::screenshotUpdated); | 250 | connect(mQuickEditor.get(), &QuickEditor::grabDone, this, &SpectacleCore::screenshotUpdated); | ||
240 | connect(mQuickEditor.get(), &QuickEditor::grabCancelled, this, &SpectacleCore::screenshotFailed); | 251 | connect(mQuickEditor.get(), &QuickEditor::grabCancelled, this, &SpectacleCore::screenshotFailed); | ||
252 | connect(this, &SpectacleCore::screenConfigurationReceived, mQuickEditor.get(), &QuickEditor::onScreenConfigurationReceived); | ||||
241 | mQuickEditor->show(); | 253 | mQuickEditor->show(); | ||
242 | return; | 254 | return; | ||
243 | } else { | 255 | } else { | ||
244 | mQuickEditor->hide(); | 256 | mQuickEditor->hide(); | ||
245 | mQuickEditor.reset(nullptr); | 257 | mQuickEditor.reset(nullptr); | ||
246 | } | 258 | } | ||
247 | } | 259 | } | ||
248 | 260 | | |||
▲ Show 20 Lines • Show All 151 Lines • ▼ Show 20 Line(s) | |||||
400 | // Private | 412 | // Private | ||
401 | 413 | | |||
402 | Platform::GrabMode SpectacleCore::toPlatformGrabMode(Spectacle::CaptureMode theCaptureMode) | 414 | Platform::GrabMode SpectacleCore::toPlatformGrabMode(Spectacle::CaptureMode theCaptureMode) | ||
403 | { | 415 | { | ||
404 | switch(theCaptureMode) { | 416 | switch(theCaptureMode) { | ||
405 | case Spectacle::CaptureMode::InvalidChoice: | 417 | case Spectacle::CaptureMode::InvalidChoice: | ||
406 | return Platform::GrabMode::InvalidChoice; | 418 | return Platform::GrabMode::InvalidChoice; | ||
407 | case Spectacle::CaptureMode::AllScreens: | 419 | case Spectacle::CaptureMode::AllScreens: | ||
408 | case Spectacle::CaptureMode::RectangularRegion: | | |||
409 | return Platform::GrabMode::AllScreens; | 420 | return Platform::GrabMode::AllScreens; | ||
421 | case Spectacle::CaptureMode::RectangularRegion: | ||||
422 | return Platform::GrabMode::AllScreensNativeSize; | ||||
410 | case Spectacle::CaptureMode::TransientWithParent: | 423 | case Spectacle::CaptureMode::TransientWithParent: | ||
411 | return Platform::GrabMode::TransientWithParent; | 424 | return Platform::GrabMode::TransientWithParent; | ||
412 | case Spectacle::CaptureMode::CurrentScreen: | 425 | case Spectacle::CaptureMode::CurrentScreen: | ||
413 | return Platform::GrabMode::CurrentScreen; | 426 | return Platform::GrabMode::CurrentScreen; | ||
414 | case Spectacle::CaptureMode::ActiveWindow: | 427 | case Spectacle::CaptureMode::ActiveWindow: | ||
415 | return Platform::GrabMode::ActiveWindow; | 428 | return Platform::GrabMode::ActiveWindow; | ||
416 | case Spectacle::CaptureMode::WindowUnderCursor: | 429 | case Spectacle::CaptureMode::WindowUnderCursor: | ||
417 | return Platform::GrabMode::WindowUnderCursor; | 430 | return Platform::GrabMode::WindowUnderCursor; | ||
Show All 22 Lines |