Changeset View
Changeset View
Standalone View
Standalone View
src/SpectacleCore.cpp
Show First 20 Lines • Show All 92 Lines • ▼ Show 20 Line(s) | 56 | { | |||
---|---|---|---|---|---|
93 | case StartMode::DBus: | 93 | case StartMode::DBus: | ||
94 | break; | 94 | break; | ||
95 | case StartMode::Background: { | 95 | case StartMode::Background: { | ||
96 | auto lMsec = (KWindowSystem::compositingActive() ? 200 : 50) + theDelayMsec; | 96 | auto lMsec = (KWindowSystem::compositingActive() ? 200 : 50) + theDelayMsec; | ||
97 | auto lShutterMode = lImmediateAvailable ? Platform::ShutterMode::Immediate : Platform::ShutterMode::OnClick; | 97 | auto lShutterMode = lImmediateAvailable ? Platform::ShutterMode::Immediate : Platform::ShutterMode::OnClick; | ||
98 | auto lIncludePointer = lGuiConfig.readEntry("includePointer", true); | 98 | auto lIncludePointer = lGuiConfig.readEntry("includePointer", true); | ||
99 | auto lIncludeDecorations = lGuiConfig.readEntry("includeDecorations", true); | 99 | auto lIncludeDecorations = lGuiConfig.readEntry("includeDecorations", true); | ||
100 | const Platform::GrabMode lCaptureMode = toPlatformGrabMode(theCaptureMode); | 100 | const Platform::GrabMode lCaptureMode = toPlatformGrabMode(theCaptureMode); | ||
101 | QTimer::singleShot(lMsec, [ this, lCaptureMode, lShutterMode, lIncludePointer, lIncludeDecorations ]() { | 101 | QTimer::singleShot(lMsec, this, [ this, lCaptureMode, lShutterMode, lIncludePointer, lIncludeDecorations ]() { | ||
102 | mPlatform->doGrab(lShutterMode, lCaptureMode, lIncludePointer, lIncludeDecorations); | 102 | mPlatform->doGrab(lShutterMode, lCaptureMode, lIncludePointer, lIncludeDecorations); | ||
103 | }); | 103 | }); | ||
104 | } | 104 | } | ||
105 | break; | 105 | break; | ||
106 | case StartMode::Gui: | 106 | case StartMode::Gui: | ||
107 | initGui(lGuiConfig.readEntry("includePointer", true), lGuiConfig.readEntry("includeDecorations", true)); | 107 | initGui(lGuiConfig.readEntry("includePointer", true), lGuiConfig.readEntry("includeDecorations", true)); | ||
108 | break; | 108 | break; | ||
109 | } | 109 | } | ||
▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Line(s) | 155 | if (!(mStartMode == StartMode::Gui)) { | |||
156 | mStartMode = StartMode::Gui; | 156 | mStartMode = StartMode::Gui; | ||
157 | initGui(lIncludePointer, lIncludeDecorations); | 157 | initGui(lIncludePointer, lIncludeDecorations); | ||
158 | } else { | 158 | } else { | ||
159 | using Actions = SpectacleConfig::PrintKeyActionRunning; | 159 | using Actions = SpectacleConfig::PrintKeyActionRunning; | ||
160 | switch (SpectacleConfig::instance()->printKeyActionRunning()) { | 160 | switch (SpectacleConfig::instance()->printKeyActionRunning()) { | ||
161 | case Actions::TakeNewScreenshot: { | 161 | case Actions::TakeNewScreenshot: { | ||
162 | auto lShutterMode = mPlatform->supportedShutterModes().testFlag(Platform::ShutterMode::Immediate) ? Platform::ShutterMode::Immediate : Platform::ShutterMode::OnClick; | 162 | auto lShutterMode = mPlatform->supportedShutterModes().testFlag(Platform::ShutterMode::Immediate) ? Platform::ShutterMode::Immediate : Platform::ShutterMode::OnClick; | ||
163 | auto lGrabMode = toPlatformGrabMode(ExportManager::instance()->captureMode()); | 163 | auto lGrabMode = toPlatformGrabMode(ExportManager::instance()->captureMode()); | ||
164 | QTimer::singleShot(KWindowSystem::compositingActive() ? 200 : 50, [this, lShutterMode, lGrabMode, lIncludePointer, lIncludeDecorations]() { | 164 | QTimer::singleShot(KWindowSystem::compositingActive() ? 200 : 50, this, [this, lShutterMode, lGrabMode, lIncludePointer, lIncludeDecorations]() { | ||
165 | mPlatform->doGrab(lShutterMode, lGrabMode, lIncludePointer, lIncludeDecorations); | 165 | mPlatform->doGrab(lShutterMode, lGrabMode, lIncludePointer, lIncludeDecorations); | ||
166 | }); | 166 | }); | ||
167 | break; | 167 | break; | ||
168 | } | 168 | } | ||
169 | case Actions::FocusWindow: | 169 | case Actions::FocusWindow: | ||
170 | if (mMainWindow->isMinimized()) { | 170 | if (mMainWindow->isMinimized()) { | ||
171 | mMainWindow->setWindowState(mMainWindow->windowState() & ~Qt::WindowMinimized); | 171 | mMainWindow->setWindowState(mMainWindow->windowState() & ~Qt::WindowMinimized); | ||
172 | } | 172 | } | ||
Show All 23 Lines | 188 | { | |||
196 | 196 | | |||
197 | // when compositing is enabled, we need to give it enough time for the window | 197 | // when compositing is enabled, we need to give it enough time for the window | ||
198 | // to disappear and all the effects are complete before we take the shot. there's | 198 | // to disappear and all the effects are complete before we take the shot. there's | ||
199 | // no way of knowing how long the disappearing effects take, but as per default | 199 | // no way of knowing how long the disappearing effects take, but as per default | ||
200 | // settings (and unless the user has set an extremely slow effect), 200 | 200 | // settings (and unless the user has set an extremely slow effect), 200 | ||
201 | // milliseconds is a good amount of wait time. | 201 | // milliseconds is a good amount of wait time. | ||
202 | 202 | | |||
203 | auto lMsec = KWindowSystem::compositingActive() ? 200 : 50; | 203 | auto lMsec = KWindowSystem::compositingActive() ? 200 : 50; | ||
204 | QTimer::singleShot(theTimeout + lMsec, [this, lGrabMode, theIncludePointer, theIncludeDecorations]() { | 204 | QTimer::singleShot(theTimeout + lMsec, this, [this, lGrabMode, theIncludePointer, theIncludeDecorations]() { | ||
205 | mPlatform->doGrab(Platform::ShutterMode::Immediate, lGrabMode, theIncludePointer, theIncludeDecorations); | 205 | mPlatform->doGrab(Platform::ShutterMode::Immediate, lGrabMode, theIncludePointer, theIncludeDecorations); | ||
206 | }); | 206 | }); | ||
207 | } | 207 | } | ||
208 | 208 | | |||
209 | void SpectacleCore::showErrorMessage(const QString &theErrString) | 209 | void SpectacleCore::showErrorMessage(const QString &theErrString) | ||
210 | { | 210 | { | ||
211 | qCDebug(SPECTACLE_CORE_LOG) << "ERROR: " << theErrString; | 211 | qCDebug(SPECTACLE_CORE_LOG) << "ERROR: " << theErrString; | ||
212 | 212 | | |||
▲ Show 20 Lines • Show All 180 Lines • ▼ Show 20 Line(s) | 390 | if (!mIsGuiInited) { | |||
393 | connect(mMainWindow.get(), &KSMainWindow::newScreenshotRequest, this, &SpectacleCore::takeNewScreenshot); | 393 | connect(mMainWindow.get(), &KSMainWindow::newScreenshotRequest, this, &SpectacleCore::takeNewScreenshot); | ||
394 | connect(mMainWindow.get(), &KSMainWindow::dragAndDropRequest, this, &SpectacleCore::doStartDragAndDrop); | 394 | connect(mMainWindow.get(), &KSMainWindow::dragAndDropRequest, this, &SpectacleCore::doStartDragAndDrop); | ||
395 | 395 | | |||
396 | mIsGuiInited = true; | 396 | mIsGuiInited = true; | ||
397 | 397 | | |||
398 | auto lShutterMode = mPlatform->supportedShutterModes().testFlag(Platform::ShutterMode::Immediate) ? Platform::ShutterMode::Immediate : Platform::ShutterMode::OnClick; | 398 | auto lShutterMode = mPlatform->supportedShutterModes().testFlag(Platform::ShutterMode::Immediate) ? Platform::ShutterMode::Immediate : Platform::ShutterMode::OnClick; | ||
399 | auto lGrabMode = toPlatformGrabMode(ExportManager::instance()->captureMode()); | 399 | auto lGrabMode = toPlatformGrabMode(ExportManager::instance()->captureMode()); | ||
400 | 400 | | |||
401 | QTimer::singleShot(0, [this, lShutterMode, lGrabMode, theIncludePointer, theIncludeDecorations]() { | 401 | QTimer::singleShot(0, this, [this, lShutterMode, lGrabMode, theIncludePointer, theIncludeDecorations]() { | ||
402 | mPlatform->doGrab(lShutterMode, lGrabMode, theIncludePointer, theIncludeDecorations); | 402 | mPlatform->doGrab(lShutterMode, lGrabMode, theIncludePointer, theIncludeDecorations); | ||
403 | }); | 403 | }); | ||
404 | } | 404 | } | ||
405 | } | 405 | } |