Changeset View
Changeset View
Standalone View
Standalone View
src/SpectacleCore.cpp
Show First 20 Lines • Show All 79 Lines • ▼ Show 20 Line(s) | 79 | if(!lSpectacleConfig->alwaysRememberRegion()) { | |||
---|---|---|---|---|---|
80 | lSpectacleConfig->setCropRegion(QRect()); | 80 | lSpectacleConfig->setCropRegion(QRect()); | ||
81 | } | 81 | } | ||
82 | 82 | | |||
83 | // set up the export manager | 83 | // set up the export manager | ||
84 | auto lExportManager = ExportManager::instance(); | 84 | auto lExportManager = ExportManager::instance(); | ||
85 | lExportManager->setCaptureMode(theCaptureMode); | 85 | lExportManager->setCaptureMode(theCaptureMode); | ||
86 | connect(lExportManager, &ExportManager::errorMessage, this, &SpectacleCore::showErrorMessage); | 86 | connect(lExportManager, &ExportManager::errorMessage, this, &SpectacleCore::showErrorMessage); | ||
87 | connect(lExportManager, &ExportManager::imageSaved, this, &SpectacleCore::doCopyPath); | 87 | connect(lExportManager, &ExportManager::imageSaved, this, &SpectacleCore::doCopyPath); | ||
88 | connect(lExportManager, &ExportManager::forceNotify, this, &SpectacleCore::doNotify); | | |||
89 | connect(mPlatform.get(), &Platform::windowTitleChanged, lExportManager, &ExportManager::setWindowTitle); | 88 | connect(mPlatform.get(), &Platform::windowTitleChanged, lExportManager, &ExportManager::setWindowTitle); | ||
90 | | ||||
91 | switch (theStartMode) { | 89 | switch (theStartMode) { | ||
92 | case StartMode::DBus: | 90 | case StartMode::DBus: | ||
93 | break; | 91 | break; | ||
94 | case StartMode::Background: { | 92 | case StartMode::Background: { | ||
95 | auto lMsec = (KWindowSystem::compositingActive() ? 200 : 50) + theDelayMsec; | 93 | auto lMsec = (KWindowSystem::compositingActive() ? 200 : 50) + theDelayMsec; | ||
96 | auto lShutterMode = lImmediateAvailable ? Platform::ShutterMode::Immediate : Platform::ShutterMode::OnClick; | 94 | auto lShutterMode = lImmediateAvailable ? Platform::ShutterMode::Immediate : Platform::ShutterMode::OnClick; | ||
97 | auto lIncludePointer = lGuiConfig.readEntry("includePointer", true); | 95 | auto lIncludePointer = lGuiConfig.readEntry("includePointer", true); | ||
98 | auto lIncludeDecorations = lGuiConfig.readEntry("includeDecorations", true); | 96 | auto lIncludeDecorations = lGuiConfig.readEntry("includeDecorations", true); | ||
▲ Show 20 Lines • Show All 139 Lines • ▼ Show 20 Line(s) | 216 | { | |||
238 | lExportManager->updatePixmapTimestamp(); | 236 | lExportManager->updatePixmapTimestamp(); | ||
239 | 237 | | |||
240 | switch (mStartMode) { | 238 | switch (mStartMode) { | ||
241 | case StartMode::Background: | 239 | case StartMode::Background: | ||
242 | case StartMode::DBus: | 240 | case StartMode::DBus: | ||
243 | { | 241 | { | ||
244 | if (mNotify) { | 242 | if (mNotify) { | ||
245 | connect(lExportManager, &ExportManager::imageSaved, this, &SpectacleCore::doNotify); | 243 | connect(lExportManager, &ExportManager::imageSaved, this, &SpectacleCore::doNotify); | ||
244 | connect(lExportManager, &ExportManager::imageCopied, this, [this]{doNotify(QUrl());}); | ||||
246 | } | 245 | } | ||
247 | 246 | | |||
248 | if (mCopyToClipboard) { | 247 | if (mCopyToClipboard) { | ||
249 | lExportManager->doCopyToClipboard(mNotify); | 248 | lExportManager->doCopyToClipboard(); | ||
250 | } else { | 249 | } else { | ||
251 | QUrl lSavePath = (mStartMode == StartMode::Background && mFileNameUrl.isValid() && mFileNameUrl.isLocalFile()) ? | 250 | QUrl lSavePath = (mStartMode == StartMode::Background && mFileNameUrl.isValid() && mFileNameUrl.isLocalFile()) ? | ||
252 | mFileNameUrl : QUrl(); | 251 | mFileNameUrl : QUrl(); | ||
253 | lExportManager->doSave(lSavePath); | 252 | lExportManager->doSave(lSavePath); | ||
254 | } | 253 | } | ||
255 | | ||||
256 | // if we notify, we emit allDone only if the user either dismissed the notification or pressed | 254 | // if we notify, we emit allDone only if the user either dismissed the notification or pressed | ||
257 | // the "Open" button, otherwise the app closes before it can react to it. | 255 | // the "Open" button, otherwise the app closes before it can react to it. | ||
258 | if (!mNotify) { | 256 | if (!mNotify) { | ||
259 | emit allDone(); | 257 | emit allDone(); | ||
260 | } | 258 | } | ||
261 | } | 259 | } | ||
262 | break; | 260 | break; | ||
263 | case StartMode::Gui: | 261 | case StartMode::Gui: | ||
▲ Show 20 Lines • Show All 119 Lines • ▼ Show 20 Line(s) | 366 | { | |||
383 | } | 381 | } | ||
384 | return Platform::GrabMode::InvalidChoice; | 382 | return Platform::GrabMode::InvalidChoice; | ||
385 | } | 383 | } | ||
386 | 384 | | |||
387 | void SpectacleCore::initGui(bool theIncludePointer, bool theIncludeDecorations) | 385 | void SpectacleCore::initGui(bool theIncludePointer, bool theIncludeDecorations) | ||
388 | { | 386 | { | ||
389 | if (!mIsGuiInited) { | 387 | if (!mIsGuiInited) { | ||
390 | mMainWindow = std::make_unique<KSMainWindow>(mPlatform->supportedGrabModes(), mPlatform->supportedShutterModes()); | 388 | mMainWindow = std::make_unique<KSMainWindow>(mPlatform->supportedGrabModes(), mPlatform->supportedShutterModes()); | ||
391 | | ||||
392 | connect(mMainWindow.get(), &KSMainWindow::newScreenshotRequest, this, &SpectacleCore::takeNewScreenshot); | 389 | connect(mMainWindow.get(), &KSMainWindow::newScreenshotRequest, this, &SpectacleCore::takeNewScreenshot); | ||
393 | connect(mMainWindow.get(), &KSMainWindow::dragAndDropRequest, this, &SpectacleCore::doStartDragAndDrop); | 390 | connect(mMainWindow.get(), &KSMainWindow::dragAndDropRequest, this, &SpectacleCore::doStartDragAndDrop); | ||
394 | 391 | connect(ExportManager::instance(), &ExportManager::imageSaved, this, &SpectacleCore::imageExported); | |||
392 | connect(ExportManager::instance(), &ExportManager::imageCopied, this, [this] { | ||||
393 | mCopyToClipboard = true; | ||||
394 | imageExported(QUrl()); | ||||
395 | }); | ||||
nicolasfella: break line | |||||
395 | mIsGuiInited = true; | 396 | mIsGuiInited = true; | ||
396 | 397 | | |||
397 | 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; | ||
398 | auto lGrabMode = toPlatformGrabMode(ExportManager::instance()->captureMode()); | 399 | auto lGrabMode = toPlatformGrabMode(ExportManager::instance()->captureMode()); | ||
399 | 400 | | |||
400 | QTimer::singleShot(0, this, [this, lShutterMode, lGrabMode, theIncludePointer, theIncludeDecorations]() { | 401 | QTimer::singleShot(0, this, [this, lShutterMode, lGrabMode, theIncludePointer, theIncludeDecorations]() { | ||
401 | mPlatform->doGrab(lShutterMode, lGrabMode, theIncludePointer, theIncludeDecorations); | 402 | mPlatform->doGrab(lShutterMode, lGrabMode, theIncludePointer, theIncludeDecorations); | ||
402 | }); | 403 | }); | ||
404 | mMainWindow->hide(); | ||||
405 | } | ||||
406 | } | ||||
407 | | ||||
408 | void SpectacleCore::imageExported(const QUrl &savedAt) | ||||
409 | { | ||||
410 | if (SpectacleConfig::instance()->quitAfterSaveOrCopyChecked()) { | ||||
411 | qApp->setQuitOnLastWindowClosed(false); | ||||
412 | mMainWindow->hide(); | ||||
413 | doNotify(savedAt); | ||||
403 | } | 414 | } | ||
404 | } | 415 | } |
break line