Verified Commit 86d5227e authored by Antonio Prcela's avatar Antonio Prcela 🏞
Browse files

Disable buttons that shouldn't be available when no screenshot was taken

BUG: 446578
parent c8eedb63
......@@ -307,6 +307,7 @@ void KSMainWindow::setDefaultSaveAction()
mSaveButton->setDefaultAction(mSaveAction);
break;
}
mSaveButton->setEnabled(mPixmapExists);
}
void KSMainWindow::setDefaultCopyAction()
......@@ -321,6 +322,7 @@ void KSMainWindow::setDefaultCopyAction()
mClipboardButton->setDefaultAction(mClipboardLocationAction);
break;
}
mClipboardButton->setEnabled(mPixmapExists);
}
// overrides
......@@ -389,23 +391,30 @@ void KSMainWindow::captureScreenshot(Spectacle::CaptureMode theCaptureMode, int
void KSMainWindow::setScreenshotAndShow(const QPixmap &pixmap)
{
if (!pixmap.isNull()) {
mPixmapExists = !pixmap.isNull();
if (mPixmapExists) {
mKSWidget->setScreenshotPixmap(pixmap);
mExportMenu->imageUpdated();
setWindowTitle(i18nc("@title:window Unsaved Screenshot", "Unsaved[*]"));
setWindowModified(true);
#ifdef KIMAGEANNOTATOR_FOUND
mAnnotateButton->setEnabled(true);
#endif
} else {
restoreWindowTitle();
}
#ifdef KIMAGEANNOTATOR_FOUND
mAnnotateButton->setEnabled(mPixmapExists);
#endif
mToolsButton->setEnabled(mPixmapExists);
mSendToButton->setEnabled(mPixmapExists);
mClipboardButton->setEnabled(mPixmapExists);
mSaveButton->setEnabled(mPixmapExists);
mKSWidget->setButtonState(KSWidget::State::TakeNewScreenshot);
show();
activateWindow();
/* NOTE windowWidth only produces the right result if it is called after the window is visible.
* Because of this the call is not moved into the if above */
if (!pixmap.isNull()) {
if (mPixmapExists) {
resize(QSize(windowWidth(pixmap), DEFAULT_WINDOW_HEIGHT));
}
}
......
......@@ -104,6 +104,7 @@ private:
Platform::ShutterModes mShutterModes;
QTimer *mHideMessageWidgetTimer = nullptr;
QStackedLayout *mStack = nullptr;
bool mPixmapExists = false;
#ifdef KIMAGEANNOTATOR_FOUND
QToolButton *const mAnnotateButton;
......
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