calligra/calligra-3.2.1-Repair-KFileWidget-integration.patch

67 lines
2.5 KiB
Diff
Raw Permalink Normal View History

From 4e9bc810ae78efb52dc2e7807032e32b6134a42e Mon Sep 17 00:00:00 2001
From: David Faure <faure@kde.org>
Date: Sun, 9 Aug 2020 13:04:00 +0200
Subject: [PATCH 19/54] Repair KFileWidget integration
We need to do like KDEPlatformFileDialog and call slotOk, to let it
process the selected files (or the location-lineedit text).
---
plugins/pictureshape/PictureShapeConfigWidget.cpp | 14 ++++++++++++--
plugins/pictureshape/PictureShapeConfigWidget.h | 3 +++
2 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/plugins/pictureshape/PictureShapeConfigWidget.cpp b/plugins/pictureshape/PictureShapeConfigWidget.cpp
index ac26c7ba8d6..9a7f289f838 100644
--- a/plugins/pictureshape/PictureShapeConfigWidget.cpp
+++ b/plugins/pictureshape/PictureShapeConfigWidget.cpp
@@ -98,20 +98,30 @@ void PictureShapeConfigWidget::open(KoShape *shape)
m_fileWidget->setMimeFilter(imageFilters);
layout->addWidget(m_fileWidget);
setLayout(layout);
- connect(m_fileWidget, SIGNAL(accepted()), this, SIGNAL(accept()));
+ connect(m_fileWidget, &KFileWidget::accepted, this, &PictureShapeConfigWidget::slotAccept);
}
+// The page dialog's own accept() is called by the OK button
+// This makes exec() return, then we get here.
+// For KFileWidget, nothing happened yet. It still needs to process things in slotOk.
void PictureShapeConfigWidget::save()
{
if (!m_shape)
return;
+ m_fileWidget->slotOk(); // emits accepted, possibly async
+}
+
+// Called by slotOk, possibly async
+void PictureShapeConfigWidget::slotAccept()
+{
m_fileWidget->accept();
- QUrl url = m_fileWidget->selectedUrl();
+ const QUrl url = m_fileWidget->selectedUrl();
if (!url.isEmpty()) {
KIO::StoredTransferJob *job = KIO::storedGet(url, KIO::NoReload, 0);
PictureShapeLoadWaiter *waiter = new PictureShapeLoadWaiter(m_shape);
connect(job, SIGNAL(result(KJob*)), waiter, SLOT(setImageData(KJob*)));
}
+ Q_EMIT accept();
}
bool PictureShapeConfigWidget::showOnShapeCreate()
diff --git a/plugins/pictureshape/PictureShapeConfigWidget.h b/plugins/pictureshape/PictureShapeConfigWidget.h
index 83ca0d042b0..ed051915d9b 100644
--- a/plugins/pictureshape/PictureShapeConfigWidget.h
+++ b/plugins/pictureshape/PictureShapeConfigWidget.h
@@ -43,6 +43,9 @@ public:
/// reimplemented from KoShapeConfigWidgetBase
bool showOnShapeSelect() override;
+private:
+ void slotAccept();
+
private:
PictureShape *m_shape;
KFileWidget *m_fileWidget;
--
2.31.1