Changeset View
Changeset View
Standalone View
Standalone View
src/SpectacleCore.cpp
Show First 20 Lines • Show All 46 Lines • ▼ Show 20 Line(s) | 42 | SpectacleCore::SpectacleCore(StartMode theStartMode, | |||
---|---|---|---|---|---|
47 | bool theCopyToClipboard, | 47 | bool theCopyToClipboard, | ||
48 | QObject *parent) : | 48 | QObject *parent) : | ||
49 | QObject(parent), | 49 | QObject(parent), | ||
50 | mStartMode(theStartMode), | 50 | mStartMode(theStartMode), | ||
51 | mNotify(theNotifyOnGrab), | 51 | mNotify(theNotifyOnGrab), | ||
52 | mPlatform(loadPlatform()), | 52 | mPlatform(loadPlatform()), | ||
53 | mMainWindow(nullptr), | 53 | mMainWindow(nullptr), | ||
54 | mIsGuiInited(false), | 54 | mIsGuiInited(false), | ||
55 | mCopySaveLocationToClipboard(theCopyToClipboard), | 55 | mCopySaveLocationToClipboard(theCopyToClipboard) | ||
56 | mCopyImageToClipboard(false) | | |||
57 | { | 56 | { | ||
58 | auto lConfig = KSharedConfig::openConfig(QStringLiteral("spectaclerc")); | 57 | auto lConfig = KSharedConfig::openConfig(QStringLiteral("spectaclerc")); | ||
59 | KConfigGroup lGuiConfig(lConfig, "GuiConfig"); | 58 | KConfigGroup lGuiConfig(lConfig, "GuiConfig"); | ||
60 | 59 | | |||
61 | if (!(theSaveFileName.isEmpty() || theSaveFileName.isNull())) { | 60 | if (!(theSaveFileName.isEmpty() || theSaveFileName.isNull())) { | ||
62 | if (QDir::isRelativePath(theSaveFileName)) { | 61 | if (QDir::isRelativePath(theSaveFileName)) { | ||
63 | theSaveFileName = QDir::current().absoluteFilePath(theSaveFileName); | 62 | theSaveFileName = QDir::current().absoluteFilePath(theSaveFileName); | ||
64 | } | 63 | } | ||
▲ Show 20 Lines • Show All 195 Lines • ▼ Show 20 Line(s) | 244 | { | |||
260 | if (!mNotify) { | 259 | if (!mNotify) { | ||
261 | emit allDone(); | 260 | emit allDone(); | ||
262 | } | 261 | } | ||
263 | } | 262 | } | ||
264 | break; | 263 | break; | ||
265 | case StartMode::Gui: | 264 | case StartMode::Gui: | ||
266 | mMainWindow->setScreenshotAndShow(thePixmap); | 265 | mMainWindow->setScreenshotAndShow(thePixmap); | ||
267 | 266 | | |||
268 | mCopyImageToClipboard = (SpectacleConfig::instance()->afterTakingScreenshotAction() == 1); | 267 | bool autoSaveImage = SpectacleConfig::instance()->autoSaveImage(); | ||
269 | using Actions = SpectacleConfig::AfterTakingScreenshotAction; | 268 | bool copyImageToClipboard = SpectacleConfig::instance()->copyImageToClipboard(); | ||
270 | switch (SpectacleConfig::instance()->afterTakingScreenshotAction()) { | 269 | | ||
271 | case Actions::DoNothing: | 270 | if (autoSaveImage && copyImageToClipboard) { | ||
272 | break; | 271 | lExportManager->doSaveAndCopy(); | ||
davidre: mFileNameUrl is not used in GuiMode jus save to SpectacleConfig::defaultSaveLocation() | |||||
i can remove the whole line and send a QUrl() in the line below as: aprcela: i can remove the whole line and send a `QUrl()` in the line below as:
`lExportManager->doSave… | |||||
Since doSave and doSaveAndCopy(const QUrl &url = QUrl()) alreadyy have QUrl() as default argument you can just call them without providing a argument. davidre: Since `doSave` and `doSaveAndCopy(const QUrl &url = QUrl())` alreadyy have `QUrl()` as default… | |||||
273 | case Actions::CopyImageToClipboard: | 272 | } else if (autoSaveImage) { | ||
false doesn't help, since doSave emits imageSaved, which in turn sends an inline message via KSMainWindow::imageSaved. aprcela: `false` doesn't help, since `doSave` emits `imageSaved`, which in turn sends an inline message… | |||||
274 | { | 273 | lExportManager->doSave(); | ||
274 | } else if (copyImageToClipboard) { | ||||
275 | lExportManager->doCopyToClipboard(false); | 275 | lExportManager->doCopyToClipboard(false); | ||
276 | mMainWindow->showInlineMessage(i18n("The screenshot has been copied to the clipboard."), | 276 | mMainWindow->showInlineMessage(i18n("The screenshot has been copied to the clipboard."), | ||
277 | KMessageWidget::Information); | 277 | KMessageWidget::Information); | ||
278 | } | 278 | } | ||
279 | break; | | |||
280 | } | | |||
281 | } | 279 | } | ||
282 | } | 280 | } | ||
283 | 281 | | |||
284 | void SpectacleCore::screenshotFailed() | 282 | void SpectacleCore::screenshotFailed() | ||
285 | { | 283 | { | ||
286 | if (ExportManager::instance()->captureMode() == Spectacle::CaptureMode::RectangularRegion && mQuickEditor) { | 284 | if (ExportManager::instance()->captureMode() == Spectacle::CaptureMode::RectangularRegion && mQuickEditor) { | ||
287 | mQuickEditor->hide(); | 285 | mQuickEditor->hide(); | ||
288 | mQuickEditor.reset(nullptr); | 286 | mQuickEditor.reset(nullptr); | ||
▲ Show 20 Lines • Show All 139 Lines • Show Last 20 Lines |
mFileNameUrl is not used in GuiMode jus save to SpectacleConfig::defaultSaveLocation()