Commit 7380f22b authored by Amy spark's avatar Amy spark 👉
Browse files

Create New Document: fix Create button enabled when the clipboard has no images

BUG: 459800
parent f5efdda3
......@@ -113,13 +113,25 @@ void KisImageFromClipboardWidget::showEvent(QShowEvent *event)
void KisImageFromClipboardWidget::createClipboardPreview()
{
if (!KisClipboard::instance()->hasClip()) return;
if (!KisClipboard::instance()->hasClip()) {
enableImageCreation(QImage());
}
QApplication::setOverrideCursor(Qt::BusyCursor);
QImage qimage = QApplication::clipboard()->image();
enableImageCreation(qimage);
if (!qimage.isNull()) {
QApplication::restoreOverrideCursor();
}
void KisImageFromClipboardWidget::enableImageCreation(const QImage &qimage)
{
if (qimage.isNull()) {
doubleWidth->setValue(0);
doubleHeight->setValue(0);
newDialogConfirmationButtonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
lblPreview->hide();
} else {
QSize previewSize = QSize(75, 75) * devicePixelRatioF();
QPixmap preview = QPixmap::fromImage(qimage.scaled(previewSize, Qt::KeepAspectRatio));
preview.setDevicePixelRatio(devicePixelRatioF());
......@@ -129,15 +141,5 @@ void KisImageFromClipboardWidget::createClipboardPreview()
doubleWidth->setValue(qimage.width());
doubleHeight->setValue(qimage.height());
} else {
doubleWidth->setValue(0);
doubleHeight->setValue(0);
newDialogConfirmationButtonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
lblPreview->hide();
}
QApplication::restoreOverrideCursor();
}
......@@ -34,15 +34,14 @@ public:
KisImageFromClipboardWidget(QWidget *parent, qint32 defWidth, qint32 defHeight, double resolution, const QString & defColorModel, const QString & defColorDepth, const QString & defColorProfile, const QString & imageName);
~KisImageFromClipboardWidget() override;
private Q_SLOTS:
void createImage();
void clipboardDataChanged();
protected:
void showEvent(QShowEvent *event) override;
private Q_SLOTS:
void createClipboardPreview();
void createImage();
void clipboardDataChanged();
void enableImageCreation(const QImage &);
};
#endif
......
Supports Markdown
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