diff --git a/doc/index.docbook b/doc/index.docbook --- a/doc/index.docbook +++ b/doc/index.docbook @@ -115,7 +115,7 @@ To save a screenshot to the default location, click on the arrow portion of the Save As... button and press the Save (&Ctrl;S) button. The new save mode will be remembered for next time; this behavior can be configured in Spectacle's settings. The default save location and filename can also be configured there, as described later. - To quickly save the image and quit &spectacle;, click on the arrow portion of the Save As... button and press the Save & Exit (&Ctrl;Q) item. This saves the image as a PNG file in your default Pictures folder, and exits the application immediately. As above, this new save mode will be remembered. + To quickly save the image and quit &spectacle;, click on the checkbox beside Quit after Save or Copy, then click the arrow portion of the Save As... button and press the Save (&Ctrl;S) item. This saves the image as a PNG file in your default Pictures folder, and exits the application immediately. As above, this new save mode will be remembered. Taking A Screenshot @@ -146,7 +146,7 @@ The Window Under Cursor option takes a screenshot of the window that is under the mouse cursor. If the cursor is on top of a popup menu, &spectacle; tries to take a screenshot of the menu as well as its parent window. - While this works most of the time, in certain cases it may fail to obtain information about the parent window. In this case, &spectacle; falls back to old way of capturing the image automatically, and captures an image of only the popup menu. You can also force the old way of capturing the image by checking the Capture the current pop-up only checkbox under Content Options + While this works most of the time, in certain cases it may fail to obtain information about the parent window. In this case, &spectacle; falls back to old way of capturing the image automatically, and captures an image of only the popup menu. You can also force the old way of capturing the image by checking the Capture the current pop-up only checkbox under Options The Rectangular Region option allows you to select a rectangular region of your desktop with your mouse. This region may be spread across different outputs. @@ -161,9 +161,9 @@ - Content Options + Options - The content options settings allow you to select whether the mouse cursor should be included in the screenshots, and whether to capture window decorations along with the image of a single application window. In Window Under Cursor mode, it also allows you to select if &spectacle; shall only capture the image of the current popup menu under the cursor, or also include the parent window. + The Options settings allow you to select whether the mouse cursor should be included in the screenshots, and whether to capture window decorations along with the image of a single application window. In Window Under Cursor mode, it also allows you to select if &spectacle; shall only capture the image of the current popup menu under the cursor, or also include the parent window. Finally, Quit after Save or Copy will quit Spectacle after any save or copy operations. @@ -175,6 +175,9 @@ The Capture the current pop-up only option is only enabled when the Window Under Cursor mode is selected in the Area combo-box. Checking this option captures only the popup menu under the cursor, without its parent window. + + The Quit after Save or Copy option will quit Spectacle after any saving or copying operations. + @@ -222,9 +225,9 @@ - Save & Exit + Save As - Clicking this button saves the screenshot as a PNG image in your default Pictures folder and immediately exits the application. + Clicking this button saves the screenshot as a PNG image to a location of your choosing. Clicking on the arrow on the side will expose the other save mode, Save, which will save the screenshot as a PNG image to the standard location (which defaults to your Pictures folder). By default, the last-used save mode is remembered for next time. @@ -274,7 +277,7 @@ Save - When you use the Save & Exit or the Save functions, &spectacle; saves the image with a default filename, in your Pictures folder under your home folder. The default filename includes the date and time when the image was taken. + When you use the Save function, &spectacle; saves the image with a default filename, in your Pictures folder (which is inside your home folder). The default filename includes the date and time when the image was taken. The Save page allows you to set the default save location and filename. Clicking this option brings up a dialog box like the following: @@ -290,7 +293,7 @@ Default Save Location - In the Location text box set the folder where you'd like to save your screenshots when you press Save or Save & Exit. + In the Location text box set the folder where you'd like to save your screenshots when you press Save. diff --git a/src/ExportManager.h b/src/ExportManager.h --- a/src/ExportManager.h +++ b/src/ExportManager.h @@ -73,7 +73,7 @@ QUrl tempSave(const QString &mimetype = QStringLiteral("png")); void doSave(const QUrl &url = QUrl(), bool notify = false); - void doSaveAs(QWidget *parentWindow = 0); + bool doSaveAs(QWidget *parentWindow = 0, bool notify = false); void doCopyToClipboard(); void doPrint(QPrinter *printer); diff --git a/src/ExportManager.cpp b/src/ExportManager.cpp --- a/src/ExportManager.cpp +++ b/src/ExportManager.cpp @@ -326,7 +326,7 @@ } } -void ExportManager::doSaveAs(QWidget *parentWindow) +bool ExportManager::doSaveAs(QWidget *parentWindow, bool notify) { QStringList supportedFilters; QMimeDatabase db; @@ -354,9 +354,15 @@ if (save(saveUrl)) { emit imageSaved(saveUrl); config->setLastSaveAsLocation(saveUrl.adjusted(QUrl::RemoveFilename)); + + if (notify) { + emit forceNotify(saveUrl); + } + return true; } } } + return false; } // misc helpers diff --git a/src/Gui/KSMainWindow.h b/src/Gui/KSMainWindow.h --- a/src/Gui/KSMainWindow.h +++ b/src/Gui/KSMainWindow.h @@ -52,7 +52,6 @@ void buildSaveMenu(); void save(); void saveAs(); - void saveAndExit(); public slots: diff --git a/src/Gui/KSMainWindow.cpp b/src/Gui/KSMainWindow.cpp --- a/src/Gui/KSMainWindow.cpp +++ b/src/Gui/KSMainWindow.cpp @@ -188,6 +188,10 @@ } resize(QSize(840, 420).expandedTo(minimumSize())); + // Allow Ctrl+Q to quit the app + QAction *actionQuit = KStandardAction::quit(QApplication::instance(), SLOT(quit()), this); + actionQuit->setShortcut(QKeySequence(QKeySequence::Quit)); + addAction(actionQuit); // done with the init } @@ -200,10 +204,6 @@ // get our actions in order QAction *actionSave = KStandardAction::save(this, &KSMainWindow::save, this); QAction *actionSaveAs = KStandardAction::saveAs(this, &KSMainWindow::saveAs, this); - QAction *actionSaveExit = new QAction(QIcon::fromTheme(QStringLiteral("document-save")), i18n("Save &&& Exit"), this); - actionSaveExit->setToolTip(i18n("Save screenshot in your Pictures directory and exit")); - actionSaveExit->setShortcut(QKeySequence(QKeySequence::Quit)); - connect(actionSaveExit, &QAction::triggered, this, &KSMainWindow::saveAndExit); // static or dynamic SpectacleConfig *cfgManager = SpectacleConfig::instance(); @@ -214,17 +214,10 @@ case 0: default: mSaveButton->setDefaultAction(actionSaveAs); - mSaveMenu->addAction(actionSaveExit); mSaveMenu->addAction(actionSave); break; case 1: mSaveButton->setDefaultAction(actionSave); - mSaveMenu->addAction(actionSaveExit); - mSaveMenu->addAction(actionSaveAs); - break; - case 2: - mSaveButton->setDefaultAction(actionSaveExit); - mSaveMenu->addAction(actionSave); mSaveMenu->addAction(actionSaveAs); break; } @@ -296,6 +289,11 @@ { ExportManager::instance()->doCopyToClipboard(); + if (SpectacleConfig::instance()->quitAfterSaveOrCopyChecked()) { + qApp->setQuitOnLastWindowClosed(false); + hide(); + } + mMessageWidget->setMessageType(KMessageWidget::Information); mMessageWidget->setText(i18n("The screenshot has been copied to the clipboard.")); mMessageWidget->setIcon(QIcon::fromTheme(QStringLiteral("dialog-information"))); @@ -320,20 +318,28 @@ { SpectacleConfig::instance()->setLastUsedSaveMode(1); buildSaveMenu(); - ExportManager::instance()->doSave(); + + if (SpectacleConfig::instance()->quitAfterSaveOrCopyChecked()) { + ExportManager::instance()->doSave(QUrl(), true); + qApp->setQuitOnLastWindowClosed(false); + hide(); + } + else { + ExportManager::instance()->doSave(); + } } void KSMainWindow::saveAs() { SpectacleConfig::instance()->setLastUsedSaveMode(0); buildSaveMenu(); - ExportManager::instance()->doSaveAs(this); -} -void KSMainWindow::saveAndExit() -{ - SpectacleConfig::instance()->setLastUsedSaveMode(2); - qApp->setQuitOnLastWindowClosed(false); - ExportManager::instance()->doSave(QUrl(), true); - hide(); + if (SpectacleConfig::instance()->quitAfterSaveOrCopyChecked()) { + if (ExportManager::instance()->doSaveAs(this, true)) { + hide(); + } + } + else { + ExportManager::instance()->doSaveAs(this, false); + } } diff --git a/src/Gui/KSWidget.h b/src/Gui/KSWidget.h --- a/src/Gui/KSWidget.h +++ b/src/Gui/KSWidget.h @@ -76,6 +76,7 @@ QCheckBox *mMousePointer; QCheckBox *mWindowDecorations; QCheckBox *mCaptureTransientOnly; + QCheckBox *mQuitAfterSaveOrCopy; QLabel *mCaptureModeLabel; QLabel *mContentOptionsLabel; }; diff --git a/src/Gui/KSWidget.cpp b/src/Gui/KSWidget.cpp --- a/src/Gui/KSWidget.cpp +++ b/src/Gui/KSWidget.cpp @@ -87,10 +87,10 @@ mCaptureModeForm->addRow(i18n("Delay:"), mDelayLayout); mCaptureModeForm->setContentsMargins(24, 0, 0, 0); - // the content options (mouse pointer, window decorations) + // options (mouse pointer, window decorations, quit after saving or copying) mContentOptionsLabel = new QLabel(this); - mContentOptionsLabel->setText(i18n("Content Options")); + mContentOptionsLabel->setText(i18n("Options")); mMousePointer = new QCheckBox(i18n("Include mouse pointer"), this); mMousePointer->setToolTip(i18n("Show the mouse cursor in the screenshot image")); @@ -107,11 +107,15 @@ mCaptureTransientOnly->setEnabled(false); connect(mCaptureTransientOnly, &QCheckBox::clicked, configManager, &SpectacleConfig::setCaptureTransientWindowOnlyChecked); + mQuitAfterSaveOrCopy = new QCheckBox(i18n("Quit after Save or Copy"), this); + mQuitAfterSaveOrCopy->setToolTip(i18n("Quit Spectacle after saving or copying the image")); + connect(mQuitAfterSaveOrCopy, &QCheckBox::clicked, configManager, &SpectacleConfig::setQuitAfterSaveOrCopyChecked); + mContentOptionsForm = new QVBoxLayout; mContentOptionsForm->addWidget(mMousePointer); mContentOptionsForm->addWidget(mWindowDecorations); mContentOptionsForm->addWidget(mCaptureTransientOnly); - mContentOptionsForm->setSpacing(16); + mContentOptionsForm->addWidget(mQuitAfterSaveOrCopy); mContentOptionsForm->setContentsMargins(24, 0, 0, 0); // the take a new screenshot button @@ -134,11 +138,9 @@ mRightLayout = new QVBoxLayout; mRightLayout->addStretch(1); mRightLayout->addWidget(mCaptureModeLabel); - mRightLayout->addSpacing(10); mRightLayout->addLayout(mCaptureModeForm); mRightLayout->addStretch(1); mRightLayout->addWidget(mContentOptionsLabel); - mRightLayout->addSpacing(10); mRightLayout->addLayout(mContentOptionsForm); mRightLayout->addStretch(10); mRightLayout->addWidget(mTakeScreenshotButton, 1, Qt::AlignHCenter); @@ -156,6 +158,7 @@ mWindowDecorations->setChecked (configManager->includeDecorationsChecked()); mCaptureOnClick->setChecked (configManager->onClickChecked()); mCaptureTransientOnly->setChecked (configManager->captureTransientWindowOnlyChecked()); + mQuitAfterSaveOrCopy->setChecked (configManager->quitAfterSaveOrCopyChecked()); mCaptureArea->setCurrentIndex (configManager->captureMode()); mDelayMsec->setValue (configManager->captureDelay()); diff --git a/src/SpectacleConfig.h b/src/SpectacleConfig.h --- a/src/SpectacleConfig.h +++ b/src/SpectacleConfig.h @@ -67,6 +67,9 @@ bool captureTransientWindowOnlyChecked() const; void setCaptureTransientWindowOnlyChecked(bool enabled); + bool quitAfterSaveOrCopyChecked() const; + void setQuitAfterSaveOrCopyChecked(bool enabled); + qreal captureDelay() const; void setCaptureDelay(qreal delay); diff --git a/src/SpectacleConfig.cpp b/src/SpectacleConfig.cpp --- a/src/SpectacleConfig.cpp +++ b/src/SpectacleConfig.cpp @@ -117,6 +117,19 @@ mGuiConfig.sync(); } +// quit after saving, copying, or exporting the image + +bool SpectacleConfig::quitAfterSaveOrCopyChecked() const +{ + return mGuiConfig.readEntry(QStringLiteral("quitAfterSaveCopyExport"), false); +} + +void SpectacleConfig::setQuitAfterSaveOrCopyChecked(bool enabled) +{ + mGuiConfig.writeEntry(QStringLiteral("quitAfterSaveCopyExport"), enabled); + mGuiConfig.sync(); +} + // capture delay qreal SpectacleConfig::captureDelay() const