Changeset View
Changeset View
Standalone View
Standalone View
src/SpectacleCore.cpp
Show First 20 Lines • Show All 92 Lines • ▼ Show 20 Line(s) | 75 | #endif | |||
---|---|---|---|---|---|
93 | } | 93 | } | ||
94 | 94 | | |||
95 | connect(mExportManager, &ExportManager::errorMessage, this, &SpectacleCore::showErrorMessage); | 95 | connect(mExportManager, &ExportManager::errorMessage, this, &SpectacleCore::showErrorMessage); | ||
96 | connect(this, &SpectacleCore::errorMessage, this, &SpectacleCore::showErrorMessage); | 96 | connect(this, &SpectacleCore::errorMessage, this, &SpectacleCore::showErrorMessage); | ||
97 | connect(mImageGrabber, &ImageGrabber::pixmapChanged, this, &SpectacleCore::screenshotUpdated); | 97 | connect(mImageGrabber, &ImageGrabber::pixmapChanged, this, &SpectacleCore::screenshotUpdated); | ||
98 | connect(mImageGrabber, &ImageGrabber::windowTitleChanged, mExportManager, &ExportManager::setWindowTitle); | 98 | connect(mImageGrabber, &ImageGrabber::windowTitleChanged, mExportManager, &ExportManager::setWindowTitle); | ||
99 | connect(mImageGrabber, &ImageGrabber::imageGrabFailed, this, &SpectacleCore::screenshotFailed); | 99 | connect(mImageGrabber, &ImageGrabber::imageGrabFailed, this, &SpectacleCore::screenshotFailed); | ||
100 | connect(mExportManager, &ExportManager::imageSaved, this, &SpectacleCore::doCopyPath); | 100 | connect(mExportManager, &ExportManager::imageSaved, this, &SpectacleCore::doCopyPath); | ||
101 | connect(mExportManager, &ExportManager::forceNotify, this, &SpectacleCore::doNotify); | | |||
102 | | ||||
103 | switch (startMode) { | 101 | switch (startMode) { | ||
104 | case DBusMode: | 102 | case DBusMode: | ||
105 | default: | 103 | default: | ||
106 | break; | 104 | break; | ||
107 | case BackgroundMode: { | 105 | case BackgroundMode: { | ||
108 | int msec = (KWindowSystem::compositingActive() ? 200 : 50) + delayMsec; | 106 | int msec = (KWindowSystem::compositingActive() ? 200 : 50) + delayMsec; | ||
109 | QTimer::singleShot(msec, mImageGrabber, &ImageGrabber::doImageGrab); | 107 | QTimer::singleShot(msec, mImageGrabber, &ImageGrabber::doImageGrab); | ||
110 | } | 108 | } | ||
▲ Show 20 Lines • Show All 100 Lines • ▼ Show 20 Line(s) | 206 | { | |||
211 | 209 | | |||
212 | switch (mStartMode) { | 210 | switch (mStartMode) { | ||
213 | case BackgroundMode: | 211 | case BackgroundMode: | ||
214 | case DBusMode: | 212 | case DBusMode: | ||
215 | default: | 213 | default: | ||
216 | { | 214 | { | ||
217 | if (mNotify) { | 215 | if (mNotify) { | ||
218 | connect(mExportManager, &ExportManager::imageSaved, this, &SpectacleCore::doNotify); | 216 | connect(mExportManager, &ExportManager::imageSaved, this, &SpectacleCore::doNotify); | ||
217 | connect(mExportManager, &ExportManager::imageCopied, this, [this]{doNotify(QUrl());}); | ||||
219 | } | 218 | } | ||
220 | 219 | | |||
221 | if (copyToClipboard) { | 220 | if (copyToClipboard) { | ||
222 | mExportManager->doCopyToClipboard(mNotify); | 221 | mExportManager->doCopyToClipboard(); | ||
223 | } else { | 222 | } else { | ||
224 | QUrl savePath = (mStartMode == BackgroundMode && mFileNameUrl.isValid() && mFileNameUrl.isLocalFile()) ? | 223 | QUrl savePath = (mStartMode == BackgroundMode && mFileNameUrl.isValid() && mFileNameUrl.isLocalFile()) ? | ||
225 | mFileNameUrl : QUrl(); | 224 | mFileNameUrl : QUrl(); | ||
226 | mExportManager->doSave(savePath); | 225 | mExportManager->doSave(savePath); | ||
227 | } | 226 | } | ||
228 | | ||||
229 | // if we notify, we emit allDone only if the user either dismissed the notification or pressed | 227 | // if we notify, we emit allDone only if the user either dismissed the notification or pressed | ||
230 | // the "Open" button, otherwise the app closes before it can react to it. | 228 | // the "Open" button, otherwise the app closes before it can react to it. | ||
231 | if (!mNotify) { | 229 | if (!mNotify) { | ||
232 | emit allDone(); | 230 | emit allDone(); | ||
233 | } | 231 | } | ||
234 | } | 232 | } | ||
235 | break; | 233 | break; | ||
236 | case GuiMode: | 234 | case GuiMode: | ||
▲ Show 20 Lines • Show All 97 Lines • ▼ Show 20 Line(s) | |||||
334 | 332 | | |||
335 | void SpectacleCore::initGui() | 333 | void SpectacleCore::initGui() | ||
336 | { | 334 | { | ||
337 | if (!isGuiInited) { | 335 | if (!isGuiInited) { | ||
338 | mMainWindow = new KSMainWindow(mImageGrabber->supportedModes(), mImageGrabber->onClickGrabSupported()); | 336 | mMainWindow = new KSMainWindow(mImageGrabber->supportedModes(), mImageGrabber->onClickGrabSupported()); | ||
339 | 337 | | |||
340 | connect(mMainWindow, &KSMainWindow::newScreenshotRequest, this, &SpectacleCore::takeNewScreenshot); | 338 | connect(mMainWindow, &KSMainWindow::newScreenshotRequest, this, &SpectacleCore::takeNewScreenshot); | ||
341 | connect(mMainWindow, &KSMainWindow::dragAndDropRequest, this, &SpectacleCore::doStartDragAndDrop); | 339 | connect(mMainWindow, &KSMainWindow::dragAndDropRequest, this, &SpectacleCore::doStartDragAndDrop); | ||
342 | 340 | connect(mExportManager, &ExportManager::imageSaved, this, &SpectacleCore::imageExported); | |||
341 | connect(mExportManager, &ExportManager::imageCopied, this, [this] { | ||||
342 | copyToClipboard = true; | ||||
343 | imageExported(QUrl()); | ||||
344 | }); | ||||
nicolasfella: break line | |||||
343 | isGuiInited = true; | 345 | isGuiInited = true; | ||
344 | QMetaObject::invokeMethod(mImageGrabber, "doImageGrab", Qt::QueuedConnection); | 346 | QMetaObject::invokeMethod(mImageGrabber, "doImageGrab", Qt::QueuedConnection); | ||
345 | } | 347 | } | ||
346 | } | 348 | } | ||
349 | | ||||
350 | void SpectacleCore::imageExported(const QUrl &savedAt) | ||||
351 | { | ||||
352 | if (SpectacleConfig::instance()->quitAfterSaveOrCopyChecked()) { | ||||
353 | qApp->setQuitOnLastWindowClosed(false); | ||||
354 | mMainWindow->hide(); | ||||
355 | doNotify(savedAt); | ||||
356 | } | ||||
357 | } |
break line