[education/rkward] /: Do not rely on rkward:// protocol to be registered system-wide for handling links from dialogs.

Thomas Friedrichsmeier null at kde.org
Fri Jun 3 15:18:26 BST 2022


Git commit bb25c4caff3a896f80974af45044cf18b656d87d by Thomas Friedrichsmeier.
Committed on 03/06/2022 at 14:17.
Pushed by tfry into branch 'master'.

Do not rely on rkward:// protocol to be registered system-wide for handling links from dialogs.

BUG: 454724

M  +1    -0    ChangeLog
M  +2    -0    rkward/rkward.cpp
M  +6    -0    rkward/windows/rkworkplace.cpp
M  +2    -0    rkward/windows/rkworkplace.h

https://invent.kde.org/education/rkward/commit/bb25c4caff3a896f80974af45044cf18b656d87d

diff --git a/ChangeLog b/ChangeLog
index 89d1e0ee..38590c32 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,4 @@
+- Fix problem handling rkward:// links from dialogs on some sytems
 - Allow to select search provider, when searching for a term online
 - Fix object name completion for (irregular) names starting with numbers or underscores
 - Crosstabs N to N: Simplify labels, add option to control table layout
diff --git a/rkward/rkward.cpp b/rkward/rkward.cpp
index 050d75f4..df345ce8 100644
--- a/rkward/rkward.cpp
+++ b/rkward/rkward.cpp
@@ -19,6 +19,7 @@ SPDX-License-Identifier: GPL-2.0-or-later
 #include <QHBoxLayout>
 #include <QIcon>
 #include <QComboBox>
+#include <QDesktopServices>
 
 // include files for KDE
 #include <kmessagebox.h>
@@ -128,6 +129,7 @@ RKWardMainWindow::RKWardMainWindow () : KParts::MainWindow ((QWidget *)0, (Qt::W
 	initActions();
 
 	new RKWorkplace (this);
+	QDesktopServices::setUrlHandler("rkward", RKWorkplace::mainWorkplace(), "openRKWardUrl");
 	RKWorkplace::mainWorkplace ()->initActions (actionCollection ());
 	setCentralWidget (RKWorkplace::mainWorkplace ());
 	connect (RKWorkplace::mainWorkplace ()->view (), &RKWorkplaceView::captionChanged, this, static_cast<void (RKWardMainWindow::*)(const QString&)>(&RKWardMainWindow::setCaption));
diff --git a/rkward/windows/rkworkplace.cpp b/rkward/windows/rkworkplace.cpp
index adad70c9..611fce1c 100644
--- a/rkward/windows/rkworkplace.cpp
+++ b/rkward/windows/rkworkplace.cpp
@@ -408,6 +408,12 @@ void RKWorkplace::namedWindowOwnerDestroyed (QObject* owner) {
 	}
 }
 
+void RKWorkplace::openRKWardUrl(const QUrl &url) {
+	RK_TRACE(APP);
+	RK_ASSERT(url.scheme() == "rkward");
+	RKHTMLWindow::handleRKWardURL(url);
+}
+
 bool RKWorkplace::openAnyUrl (const QUrl &url, const QString &known_mimetype, bool force_external) {
 	RK_TRACE (APP);
 
diff --git a/rkward/windows/rkworkplace.h b/rkward/windows/rkworkplace.h
index 3997a6bf..f901d7f7 100644
--- a/rkward/windows/rkworkplace.h
+++ b/rkward/windows/rkworkplace.h
@@ -224,6 +224,8 @@ public slots:
 /** When windows are attached to the workplace, their QObject::destroyed () signal is connected to this slot. Thereby deleted objects are removed from the workplace automatically */
 	void removeWindow (QObject *window);
 	void saveSettings ();
+/** Proxy for QDesktopServices::setUrlHandler(), set from RKWardMainWindow(). Simply calls RKHTMLWindow::handleRKWardUrl(). */
+	void openRKWardUrl(const QUrl& url);
 private slots:
 	void namedWindowDestroyed (QObject *);
 	void namedWindowOwnerDestroyed (QObject *);


More information about the rkward-tracker mailing list