[education/rkward] rkward: Fix some problems with navigating help:-urls
Thomas Friedrichsmeier
null at kde.org
Wed Jul 10 21:58:48 BST 2024
Git commit 5d961d8c9484df54b05cd12509aac72a20942fcb by Thomas Friedrichsmeier.
Committed on 10/07/2024 at 20:58.
Pushed by tfry into branch 'master'.
Fix some problems with navigating help:-urls
M +1 -1 rkward/main.cpp
M +1 -1 rkward/rbackend/rpackages/rkward/R/internal.R
M +6 -7 rkward/rbackend/rpackages/rkward/R/internal_help.R
M +1 -2 rkward/windows/rkhtmlwindow.cpp
M +1 -1 rkward/windows/rkworkplace.cpp
https://invent.kde.org/education/rkward/-/commit/5d961d8c9484df54b05cd12509aac72a20942fcb
diff --git a/rkward/main.cpp b/rkward/main.cpp
index ced1b8d63..2804e99d8 100644
--- a/rkward/main.cpp
+++ b/rkward/main.cpp
@@ -151,7 +151,7 @@ int main (int argc, char *argv[]) {
// annoyingly, QWebEngineUrlSchemes have to be registered before creating the app.
QWebEngineUrlScheme scheme("help");
scheme.setSyntax(QWebEngineUrlScheme::Syntax::Path);
- scheme.setFlags(QWebEngineUrlScheme::LocalScheme|QWebEngineUrlScheme::LocalAccessAllowed);
+ scheme.setFlags(QWebEngineUrlScheme::LocalAccessAllowed);
QWebEngineUrlScheme::registerScheme(scheme);
BreezeIcons::initIcons(); // install as fallback theme. Too many issues with missing icons, otherwise
QApplication app(argc, argv);
diff --git a/rkward/rbackend/rpackages/rkward/R/internal.R b/rkward/rbackend/rpackages/rkward/R/internal.R
index 395cd3365..b5862e448 100755
--- a/rkward/rbackend/rpackages/rkward/R/internal.R
+++ b/rkward/rbackend/rpackages/rkward/R/internal.R
@@ -11,7 +11,7 @@
# this function shall test if the rkward package was loaded in a running RKWard session
#' @export
.rk.inside.rkward.session <- function(warn = FALSE){
- inside.rkward <- is.loaded("rk.do.generic.request")
+ inside.rkward <- is.loaded("rk.call")
if(isTRUE(warn) & !isTRUE(inside.rkward)){
warning("You've loaded the package 'rkward', but RKWard doesn't appear to be running. If this causes trouble, try detach(\"package:rkward\").",
call. = FALSE)
diff --git a/rkward/rbackend/rpackages/rkward/R/internal_help.R b/rkward/rbackend/rpackages/rkward/R/internal_help.R
index ba3f6cdbf..16a4c8670 100644
--- a/rkward/rbackend/rpackages/rkward/R/internal_help.R
+++ b/rkward/rbackend/rpackages/rkward/R/internal_help.R
@@ -9,15 +9,14 @@
#' @export
".rk.getHelpBaseUrl" <- function () {
port <- NA
- if (compareVersion (as.character (getRversion()), "2.10.0") >= 0) {
+ try ({
+ port <- tools::startDynamicHelp ()
+ })
+ if (is.na (port)) {
try ({
- port <- tools::startDynamicHelp ()
+ port <- tools:::httpdPort
+ if (is.function(port)) port <- port()
})
- if (is.na (port)) {
- try ({
- port <- tools:::httpdPort
- })
- }
}
if (is.na (port)) {
return (paste ("file://", R.home (), sep=""))
diff --git a/rkward/windows/rkhtmlwindow.cpp b/rkward/windows/rkhtmlwindow.cpp
index b44bee4d7..41ac74ef2 100644
--- a/rkward/windows/rkhtmlwindow.cpp
+++ b/rkward/windows/rkhtmlwindow.cpp
@@ -211,6 +211,7 @@ class RKWebEngineKIOForwarder : public QWebEngineUrlSchemeHandler {
public:
explicit RKWebEngineKIOForwarder(QObject *parent) : QWebEngineUrlSchemeHandler(parent) {}
void requestStarted (QWebEngineUrlRequestJob *request) override {
+ RK_DEBUG(APP, DL_DEBUG, "new KIO request to %s", qPrintable(request->requestUrl().url()));
KIO::StoredTransferJob *job = KIO::storedGet(request->requestUrl (), KIO::NoReload, KIO::HideProgressInfo);
connect (job, &KIO::StoredTransferJob::result, this, [this, job](){ kioJobFinished(job); });
jobs.insert (job, request);
@@ -877,13 +878,11 @@ void RKHTMLWindowPart::initActions () {
window->page->action (RKWebPage::Forward)->setVisible (false);
// For now we won't bother with this one: Does not behave well, in particular (but not only) WRT to rkward://-links
window->page->action (RKWebPage::DownloadLinkToDisk)->setVisible (false);
-#ifndef NO_QT_WEBENGINE
// Not really useful for us, and cannot easily be made to work, as all new pages go through RKWorkplace::openAnyUrl()
window->page->action (RKWebPage::ViewSource)->setVisible (false);
// Well, technically, all our windows are tabs, but we're calling them "window".
// At any rate, we don't need both "open link in new tab" and "open link in new window".
window->page->action (RKWebPage::OpenLinkInNewTab)->setVisible (false);
-#endif
// common actions
actionCollection()->addAction(KStandardAction::Copy, "copy", window->view->pageAction(RKWebPage::Copy), &QAction::trigger);
diff --git a/rkward/windows/rkworkplace.cpp b/rkward/windows/rkworkplace.cpp
index 3084fedfe..300f1dd90 100644
--- a/rkward/windows/rkworkplace.cpp
+++ b/rkward/windows/rkworkplace.cpp
@@ -418,7 +418,7 @@ bool RKWorkplace::openAnyUrl (const QUrl &url, const QString &known_mimetype, bo
if (!force_external) {
// NOTE: Currently a known mimetype implies that the URL is local or served from the local machine.
// Thus, external web pages are *not* opened, here. Which is the behavior we want, although the implementation is ugly
- if (mimetype.inherits ("text/html")) {
+ if (mimetype.inherits("text/html") || url.scheme().toLower().startsWith(QLatin1String("help"))) {
openHelpWindow (url, true);
return true; // TODO
} else if (mimetype.inherits("application/pdf")) {
More information about the rkward-tracker
mailing list