[education/rkward] rkward/windows: Add workaround for visual quirk

Thomas Friedrichsmeier null at kde.org
Tue Jun 11 22:01:17 BST 2024


Git commit 07fadfca2f1dbcbbd033a27ab0720dff6caf4ba1 by Thomas Friedrichsmeier.
Committed on 11/06/2024 at 21:01.
Pushed by tfry into branch 'master'.

Add workaround for visual quirk

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

https://invent.kde.org/education/rkward/-/commit/07fadfca2f1dbcbbd033a27ab0720dff6caf4ba1

diff --git a/rkward/windows/rkhtmlwindow.cpp b/rkward/windows/rkhtmlwindow.cpp
index 4708c7c88..170ad6008 100644
--- a/rkward/windows/rkhtmlwindow.cpp
+++ b/rkward/windows/rkhtmlwindow.cpp
@@ -590,7 +590,11 @@ bool RKHTMLWindow::openURL (const QUrl &url) {
 				page->setHtmlWrapper(f.readAll(), url.adjusted(QUrl::RemoveFilename));
 				f.close ();
 			} else {
-				page->load (url);
+				// NOTE: Quirk in Qt 6.7: When first loading a page, the window is somehow brought to the front, again. In preview windows
+				//       (initially hidden), this leads to a strange pulsing effect. Delay the actual page load until the window is
+				//       actually shown (showEvent(), below).
+				//       With this, the flicker is still there, but feels more "natural"
+				if (isVisible()) page->load(url);
 			}
 			if (!restore_position.isNull()) page->setScrollPositionWhenDone(restore_position);
 		} else {
@@ -626,9 +630,20 @@ bool RKHTMLWindow::openURL (const QUrl &url) {
 	return true;
 }
 
+void RKHTMLWindow::showEvent(QShowEvent *event) {
+	RK_TRACE (APP);
+	RKMDIWindow::showEvent(event);
+	// see comment in openURL, above
+	if (page->url().isEmpty() && !current_url.isEmpty() && current_url != page->url()) {
+		QUrl real_url = current_url;
+		current_url.clear();
+		openURL(real_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
diff --git a/rkward/windows/rkhtmlwindow.h b/rkward/windows/rkhtmlwindow.h
index 5c7b4a01d..c341095b1 100644
--- a/rkward/windows/rkhtmlwindow.h
+++ b/rkward/windows/rkhtmlwindow.h
@@ -123,6 +123,7 @@ friend class RKHTMLWindowPart;
 	bool url_change_is_from_history;	// dirty!!!
 
 	QUrl current_url;
+	void showEvent(QShowEvent *event) override;
 	void startNewCacheFile ();
 	QTemporaryFile *current_cache_file;
 


More information about the rkward-tracker mailing list