[rkward/frameworks] rkward/windows: Fix basic help page navigation.

Thomas Friedrichsmeier thomas.friedrichsmeier at ruhr-uni-bochum.de
Tue Nov 24 10:06:18 UTC 2015


Git commit b8f1cd6295193d9d8058facf09669a0fcea19dbc by Thomas Friedrichsmeier.
Committed on 24/11/2015 at 08:36.
Pushed by tfry into branch 'frameworks'.

Fix basic help page navigation.

M  +33   -1    rkward/windows/rkhtmlwindow.cpp
M  +2    -0    rkward/windows/rkhtmlwindow.h

http://commits.kde.org/rkward/b8f1cd6295193d9d8058facf09669a0fcea19dbc

diff --git a/rkward/windows/rkhtmlwindow.cpp b/rkward/windows/rkhtmlwindow.cpp
index fca490b..8bd0a37 100644
--- a/rkward/windows/rkhtmlwindow.cpp
+++ b/rkward/windows/rkhtmlwindow.cpp
@@ -65,7 +65,9 @@
 #include "../windows/rkworkplaceview.h"
 #include "../debug.h"
 
-RKWebPage::RKWebPage (RKHTMLWindow* window): KWebPage (window, KIOIntegration | KPartsIntegration) {
+// TODO: We used to have KioIntegration in addition to KPartsIntegration. But this is just buggy, buggy, buggy in KF5 5.9.0. (e.g. navigation to previous
+// // page in history just doesn't work).
+RKWebPage::RKWebPage (RKHTMLWindow* window): KWebPage (window, KPartsIntegration) {
 	RK_TRACE (APP);
 	RKWebPage::window = window;
 	new_window = false;
@@ -386,6 +388,8 @@ bool RKHTMLWindow::openURL (const KUrl &url) {
 		if ((host == "127.0.0.1") || (host == "localhost") || host == QHostInfo::localHostName ()) {
 			KIO::TransferJob *job = KIO::get (url, KIO::Reload);
 			connect (job, SIGNAL (mimetype(KIO::Job*,QString)), this, SLOT (mimeTypeDetermined(KIO::Job*,QString)));
+			// WORKAROUND. See slot.
+			connect (job, SIGNAL (result(KJob*)), this, SLOT (mimeTypeJobFail(KJob*)));
 			return true;
 		}
 	}
@@ -398,6 +402,34 @@ KUrl RKHTMLWindow::url () {
 	return current_url;
 }
 
+void RKHTMLWindow::mimeTypeJobFail (KJob* job) {
+	RK_TRACE (APP);
+	
+	KIO::TransferJob* tj = static_cast<KIO::TransferJob*> (job);
+	if (tj->error ()) {
+		// WORKAROUND for bug in KIO version 5.9.0: After a redirect, the transfer job would claim "does not exist". Here, we help it get over _one_ redirect, hoping R's help server
+		// won't do more redirection than that.
+		// TODO: Report this!
+		QUrl url = tj->url ();
+		if (!tj->redirectUrl ().isEmpty ()) url = tj->redirectUrl ();
+		KIO::TransferJob *secondchance = KIO::get (url, KIO::Reload);
+		connect (secondchance, SIGNAL (mimetype(KIO::Job*,QString)), this, SLOT (mimeTypeDetermined(KIO::Job*,QString)));
+		connect (secondchance, SIGNAL (result(KJob*)), this, SLOT (mimeTypeJobFail2(KJob*)));
+	}
+}
+
+void RKHTMLWindow::mimeTypeJobFail2 (KJob* job) {
+	RK_TRACE (APP);
+	
+	KIO::TransferJob* tj = static_cast<KIO::TransferJob*> (job);
+	if (tj->error ()) {
+		// WORKAROUND continued. See above.
+		QUrl url = tj->url ();
+		if (!tj->redirectUrl ().isEmpty ()) url = tj->redirectUrl ();
+		RKWorkplace::mainWorkplace ()->openAnyUrl (url);
+	}
+}
+
 void RKHTMLWindow::mimeTypeDetermined (KIO::Job* job, const QString& type) {
 	RK_TRACE (APP);
 
diff --git a/rkward/windows/rkhtmlwindow.h b/rkward/windows/rkhtmlwindow.h
index dc50b54..3f802e6 100644
--- a/rkward/windows/rkhtmlwindow.h
+++ b/rkward/windows/rkhtmlwindow.h
@@ -113,6 +113,8 @@ public slots:
 private slots:
 	void scrollToBottom ();
 	void mimeTypeDetermined (KIO::Job*, const QString& type);
+	void mimeTypeJobFail (KJob*);
+	void mimeTypeJobFail2 (KJob*);
 	void internalNavigation (const QUrl& new_url);
 	void makeContextMenu (const QPoint& pos);
 	void findRequest (const QString& text, bool backwards, const RKFindBar *findbar, bool* found);



More information about the rkward-tracker mailing list