Changeset View
Changeset View
Standalone View
Standalone View
src/SpectacleCore.cpp
Show First 20 Lines • Show All 47 Lines • ▼ Show 20 Line(s) | 42 | SpectacleCore::SpectacleCore(StartMode theStartMode, | |||
---|---|---|---|---|---|
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) | 56 | mCopyImageToClipboard(false), | ||
57 | mAutoSaveImage(false) | ||||
57 | { | 58 | { | ||
58 | auto lConfig = KSharedConfig::openConfig(QStringLiteral("spectaclerc")); | 59 | auto lConfig = KSharedConfig::openConfig(QStringLiteral("spectaclerc")); | ||
59 | KConfigGroup lGuiConfig(lConfig, "GuiConfig"); | 60 | KConfigGroup lGuiConfig(lConfig, "GuiConfig"); | ||
60 | 61 | | |||
61 | if (!(theSaveFileName.isEmpty() || theSaveFileName.isNull())) { | 62 | if (!(theSaveFileName.isEmpty() || theSaveFileName.isNull())) { | ||
62 | if (QDir::isRelativePath(theSaveFileName)) { | 63 | if (QDir::isRelativePath(theSaveFileName)) { | ||
63 | theSaveFileName = QDir::current().absoluteFilePath(theSaveFileName); | 64 | theSaveFileName = QDir::current().absoluteFilePath(theSaveFileName); | ||
64 | } | 65 | } | ||
▲ Show 20 Lines • Show All 195 Lines • ▼ Show 20 Line(s) | 246 | { | |||
260 | if (!mNotify) { | 261 | if (!mNotify) { | ||
261 | emit allDone(); | 262 | emit allDone(); | ||
262 | } | 263 | } | ||
263 | } | 264 | } | ||
264 | break; | 265 | break; | ||
265 | case StartMode::Gui: | 266 | case StartMode::Gui: | ||
266 | mMainWindow->setScreenshotAndShow(thePixmap); | 267 | mMainWindow->setScreenshotAndShow(thePixmap); | ||
267 | 268 | | |||
268 | mCopyImageToClipboard = (SpectacleConfig::instance()->afterTakingScreenshotAction() == 1); | 269 | mAutoSaveImage = SpectacleConfig::instance()->autoSaveImage(); | ||
269 | using Actions = SpectacleConfig::AfterTakingScreenshotAction; | 270 | mCopyImageToClipboard = SpectacleConfig::instance()->copyImageToClipboard(); | ||
270 | switch (SpectacleConfig::instance()->afterTakingScreenshotAction()) { | 271 | | ||
271 | case Actions::DoNothing: | 272 | if (mAutoSaveImage && mCopyImageToClipboard) { | ||
272 | break; | 273 | QUrl lSavePath = (mFileNameUrl.isValid() && mFileNameUrl.isLocalFile()) ? mFileNameUrl : QUrl(); | ||
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: | 274 | lExportManager->doSaveAndCopy(lSavePath); | ||
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 | { | 275 | } else if (mAutoSaveImage) { | ||
276 | QUrl lSavePath = (mFileNameUrl.isValid() && mFileNameUrl.isLocalFile()) ? mFileNameUrl : QUrl(); | ||||
277 | lExportManager->doSave(lSavePath); | ||||
278 | } else if (mCopyImageToClipboard) { | ||||
275 | lExportManager->doCopyToClipboard(false); | 279 | lExportManager->doCopyToClipboard(false); | ||
276 | mMainWindow->showInlineMessage(i18n("The screenshot has been copied to the clipboard."), | 280 | mMainWindow->showInlineMessage(i18n("The screenshot has been copied to the clipboard."), | ||
277 | KMessageWidget::Information); | 281 | KMessageWidget::Information); | ||
278 | } | 282 | } | ||
279 | break; | | |||
280 | } | | |||
281 | } | 283 | } | ||
282 | } | 284 | } | ||
283 | 285 | | |||
284 | void SpectacleCore::screenshotFailed() | 286 | void SpectacleCore::screenshotFailed() | ||
285 | { | 287 | { | ||
286 | if (ExportManager::instance()->captureMode() == Spectacle::CaptureMode::RectangularRegion && mQuickEditor) { | 288 | if (ExportManager::instance()->captureMode() == Spectacle::CaptureMode::RectangularRegion && mQuickEditor) { | ||
287 | mQuickEditor->hide(); | 289 | mQuickEditor->hide(); | ||
288 | mQuickEditor.reset(nullptr); | 290 | 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()