Commit a9f1e855 authored by David Redondo's avatar David Redondo 🏎
Browse files

Fix issue preventing spectacle from opening

Summary:
Commit dbb1600c attempted to unify the way how
copy and save are handled. However there was one oversight. On image copy the
check whether to quit doesn't happen on button press but after a image is copied.
This includes when the copy is triggered automatically. If the user has automatic
copying of screenshots enabled, spectacle will not open again because upon start
the automatically taken screenshot is copied and spectacle terminates itself.
This introduces a `copy` method similiar to `save()` and `saveAs()` which does
the check and triggers copying.

Test Plan:
Enable automatic copying of screenshots and check quit after save or copy.
Close Spectacle.
Open Spectacle.

Reviewers: #spectacle, ngraham

Reviewed By: #spectacle, ngraham

Subscribers: ngraham

Tags: #spectacle

Differential Revision: https://phabricator.kde.org/D25765
parent 10a63203
......@@ -157,7 +157,7 @@ void KSMainWindow::init()
mSendToButton->setAutoDefault(false);
mDialogButtonBox->addButton(mSendToButton, QDialogButtonBox::ActionRole);
mClipboardButton->setDefaultAction(KStandardAction::copy(ExportManager::instance(), &ExportManager::doCopyToClipboard, this));
mClipboardButton->setDefaultAction(KStandardAction::copy(this, &KSMainWindow::copy, this));
mClipboardButton->setText(i18n("Copy to Clipboard"));
mClipboardButton->setToolTip(i18n("Copy the current screenshot image to the clipboard."));
mClipboardButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
......@@ -462,12 +462,19 @@ void KSMainWindow::showImageSharedFeedback(bool error, const QString &message)
}
}
void KSMainWindow::copy()
{
const bool quitChecked = SpectacleConfig::instance()->quitAfterSaveOrCopyChecked();
ExportManager::instance()->doCopyToClipboard();
if (quitChecked) {
quit(QuitBehavior::QuitExternally);
}
}
void KSMainWindow::imageCopied()
{
SpectacleConfig::instance()->quitAfterSaveOrCopyChecked()
? quit()
: showInlineMessage(i18n("The screenshot has been copied to the clipboard."),
KMessageWidget::Information);
showInlineMessage(i18n("The screenshot has been copied to the clipboard."),
KMessageWidget::Information);
}
void KSMainWindow::showPreferencesDialog()
......
......@@ -97,6 +97,7 @@ class KSMainWindow: public QDialog
private:
void keyPressEvent(QKeyEvent *event) override;
void copy();
KSWidget *mKSWidget;
QFrame *mDivider;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment