diff --git a/CMakeLists.txt b/CMakeLists.txt
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -62,7 +62,6 @@
endif()
add_subdirectory( webenginepart )
-add_subdirectory( about )
add_subdirectory( pics )
#add_subdirectory( sidebar )
add_subdirectory( settings )
diff --git a/about/CMakeLists.txt b/about/CMakeLists.txt
deleted file mode 100644
--- a/about/CMakeLists.txt
+++ /dev/null
@@ -1,22 +0,0 @@
-add_library(konq_aboutpage MODULE konq_aboutpage.cpp)
-
-target_link_libraries(konq_aboutpage
- KF5::KHtml
- KF5::IconThemes
- Qt5::Widgets
-)
-
-install(TARGETS konq_aboutpage DESTINATION ${KDE_INSTALL_PLUGINDIR})
-
-install(FILES
- top-left-konqueror.png
- launch.html
- intro.html
- specs.html
- tips.html
- plugins.html
- plugins_rtl.html
- konq.css
- DESTINATION ${KDE_INSTALL_DATADIR}/konqueror/about)
-install(FILES konqaboutpage.desktop DESTINATION ${KDE_INSTALL_KSERVICETYPES5DIR})
-install(FILES konq_aboutpage.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR})
diff --git a/about/konq_aboutpage.h b/about/konq_aboutpage.h
deleted file mode 100644
--- a/about/konq_aboutpage.h
+++ /dev/null
@@ -1,47 +0,0 @@
-#ifndef __konq_aboutpage_h__
-#define __konq_aboutpage_h__
-
-#include
-
-class QUrl;
-
-class KonqAboutPageSingleton
-{
-public:
- QString launch();
- QString intro();
- QString specs();
- QString tips();
- QString plugins();
-
-private:
- QString m_launch_html, m_intro_html, m_specs_html, m_tips_html, m_plugins_html;
-};
-
-class KonqAboutPage : public KHTMLPart
-{
- Q_OBJECT
-public:
- KonqAboutPage(QWidget *parentWidget, QObject *parent, const QVariantList &args);
- ~KonqAboutPage() override;
-
- bool openUrl(const QUrl &url) override;
-
- bool openFile() override;
-
- void saveState(QDataStream &stream) override;
- void restoreState(QDataStream &stream) override;
-
-protected:
- bool urlSelected(const QString &url, int button, int state, const QString &target,
- const KParts::OpenUrlArguments &args = KParts::OpenUrlArguments(),
- const KParts::BrowserArguments &browserArgs = KParts::BrowserArguments()) override;
-
-private:
- void serve(const QString &, const QString &);
-
- QString m_htmlDoc;
- QString m_what;
-};
-
-#endif
diff --git a/autotests/konqviewmgrtest.cpp b/autotests/konqviewmgrtest.cpp
--- a/autotests/konqviewmgrtest.cpp
+++ b/autotests/konqviewmgrtest.cpp
@@ -276,7 +276,7 @@
void ViewMgrTest::testEmptyWindow()
{
QScopedPointer emptyWindow(KonqMainWindowFactory::createNewWindow());
- QCOMPARE(emptyWindow->currentView()->url().url(), QString("about:konqueror"));
+ QCOMPARE(emptyWindow->currentView()->url().url(), QString("konq:konqueror"));
QCOMPARE(emptyWindow->focusWidget()->metaObject()->className(), "KonqCombo");
}
diff --git a/settings/konqhtml/generalopts.cpp b/settings/konqhtml/generalopts.cpp
--- a/settings/konqhtml/generalopts.cpp
+++ b/settings/konqhtml/generalopts.cpp
@@ -34,7 +34,7 @@
#include "ui_advancedTabOptions.h"
// Keep in sync with konqueror.kcfg
-static const char DEFAULT_STARTPAGE[] = "about:konqueror";
+static const char DEFAULT_STARTPAGE[] = "konq:konqueror";
static const char DEFAULT_HOMEPAGE[] = "https://www.kde.org/";
// Keep in sync with the order in the combo
enum StartPage { ShowAboutPage, ShowStartUrlPage, ShowBlankPage, ShowBookmarksPage };
@@ -141,10 +141,10 @@
static StartPage urlToStartPageEnum(const QString &startUrl)
{
- if (startUrl == QLatin1String("about:blank")) {
+ if (startUrl == QLatin1String("konq:blank")) {
return ShowBlankPage;
}
- if (startUrl == QLatin1String("about:") || startUrl == QLatin1String("about:konqueror")) {
+ if (startUrl == QLatin1String("konq:") || startUrl == QLatin1String("konq:konqueror")) {
return ShowAboutPage;
}
if (startUrl == QLatin1String("bookmarks:") || startUrl == QLatin1String("bookmarks:/")) {
@@ -157,9 +157,9 @@
{
switch (startPage) {
case ShowBlankPage:
- return QStringLiteral("about:blank");
+ return QStringLiteral("konq:blank");
case ShowAboutPage:
- return QStringLiteral("about:konqueror");
+ return QStringLiteral("konq:konqueror");
case ShowBookmarksPage:
return QStringLiteral("bookmarks:/");
case ShowStartUrlPage:
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -19,6 +19,7 @@
konqhistoryproxymodel.cpp
konqhistoryview.cpp
konqhistorysettings.cpp
+ konqurl.cpp
)
ecm_qt_declare_logging_category(konquerorprivate_SRCS HEADER konqdebug.h IDENTIFIER KONQUEROR_LOG CATEGORY_NAME org.kde.konqueror)
@@ -82,6 +83,7 @@
konqcloseditem.cpp
konqhistorydialog.cpp
konqstatusbarmessagelabel.cpp
+ konqurl.cpp
)
kconfig_add_kcfg_files(konqueror_KDEINIT_SRCS konqsettingsxt.kcfgc)
diff --git a/src/konqframe.cpp b/src/konqframe.cpp
--- a/src/konqframe.cpp
+++ b/src/konqframe.cpp
@@ -19,6 +19,7 @@
// Own
#include "konqframe.h"
+#include "konqurl.h"
// Local
#include "konqtabs.h"
@@ -240,7 +241,7 @@
if (m_pView && !m_pView->isPassiveMode()) {
m_pView->mainWindow()->viewManager()->setActivePart(part());
- if (!m_pView->isLoading() && (m_pView->url().isEmpty() || m_pView->url() == QUrl(QStringLiteral("about:blank")))) {
+ if (!m_pView->isLoading() && (m_pView->url().isEmpty() || KonqUrl::isKonqBlank(m_pView->url()))) {
//qCDebug(KONQUEROR_LOG) << "SET FOCUS on the location bar";
m_pView->mainWindow()->focusLocationBar(); // #84867 usability improvement
}
diff --git a/src/konqhistorymanager.cpp b/src/konqhistorymanager.cpp
--- a/src/konqhistorymanager.cpp
+++ b/src/konqhistorymanager.cpp
@@ -20,6 +20,7 @@
#include "konqhistorymanager.h"
#include
+#include "konqurl.h"
#include
#include "konqdebug.h"
@@ -155,7 +156,7 @@
void KonqHistoryManager::insert(const QString &url)
{
QUrl u(url);
- if (!filterOut(u) || u.scheme() == QLatin1String("about")) { // remote URL
+ if (!filterOut(u) || KonqUrl::hasKonqScheme(u)) { // remote URL
return;
}
// Local URL -> add to history
diff --git a/src/konqmain.cpp b/src/konqmain.cpp
--- a/src/konqmain.cpp
+++ b/src/konqmain.cpp
@@ -26,6 +26,7 @@
#include "konqsessionmanager.h"
#include "konqview.h"
#include "konqsettingsxt.h"
+#include "konqurl.h"
#include
#include
@@ -157,6 +158,15 @@
return nullptr;
}
+static void fixOldStartUrl() {
+ QUrl startUrl(KonqSettings::startURL());
+ if (startUrl.scheme() == "about") {
+ startUrl.setScheme(KonqUrl::scheme());
+ KonqSettings::setStartURL(startUrl.url());
+ KonqSettings::self()->save();
+ }
+}
+
extern "C" Q_DECL_EXPORT int kdemain(int argc, char **argv)
{
QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts); // says QtWebEngine
@@ -247,6 +257,8 @@
KWindowSystem::forceActiveWindow(mainWindow->winId());
}
});
+
+ fixOldStartUrl();
if (app.isSessionRestored()) {
KonqSessionManager::self()->askUserToRestoreAutosavedAbandonedSessions();
@@ -262,7 +274,7 @@
++n;
}
} else if (parser.isSet("preload")) {
- new KonqMainWindow(QUrl(QStringLiteral("about:blank"))); // prepare an empty window, with the web renderer preloaded
+ new KonqMainWindow(KonqUrl::url(KonqUrl::Type::Blank)); // prepare an empty window, with the web renderer preloaded
} else {
int ret = 0;
KonqMainWindow *mainWindow = handleCommandLine(parser, QDir::currentPath(), &ret);
diff --git a/src/konqmainwindow.cpp b/src/konqmainwindow.cpp
--- a/src/konqmainwindow.cpp
+++ b/src/konqmainwindow.cpp
@@ -51,6 +51,7 @@
#include "konqhistorydialog.h"
#include
#include
+#include "konqurl.h"
#include
#include
@@ -501,27 +502,25 @@
qCDebug(KONQUEROR_LOG) << "url=" << _url << "mimeType=" << _mimeType
<< "_req=" << _req.debug() << "view=" << _view;
#endif
-
// We like modifying args in this method :)
QUrl url(_url);
QString mimeType(_mimeType);
KonqOpenURLRequest req(_req);
if (mimeType.isEmpty()) {
mimeType = req.args.mimeType();
}
-
if (!url.isValid()) {
// I think we can't really get here anymore; I tried and didn't succeed.
// URL filtering catches this case before hand, and in cases without filtering
// (e.g. HTML link), the url is empty here, not invalid.
// But just to be safe, let's keep this code path
url = KParts::BrowserRun::makeErrorUrl(KIO::ERR_MALFORMED_URL, url.url(), url);
- } else if (!KProtocolInfo::isKnownProtocol(url) && url.scheme() != QLatin1String("error") && url.scheme() != QLatin1String("about") && url.scheme() != QLatin1String("mailto")) {
+ } else if (!KProtocolInfo::isKnownProtocol(url) && url.scheme() != QLatin1String("error") && !KonqUrl::hasKonqScheme(url) && url.scheme() != QLatin1String("mailto")) {
url = KParts::BrowserRun::makeErrorUrl(KIO::ERR_UNSUPPORTED_PROTOCOL, url.scheme(), url);
}
- if (url.url() == QLatin1String("about:blank") || url.scheme() == QLatin1String("error")) {
+ if (KonqUrl::isKonqBlank(url) || url.scheme() == QLatin1String("error")) {
mimeType = QStringLiteral("text/html");
}
@@ -640,7 +639,7 @@
}
//qCDebug(KONQUEROR_LOG) << "trying openView for" << url << "( mimeType" << mimeType << ")";
- if (hasMimeType || url.url() == QLatin1String("about:") || url.url().startsWith(QLatin1String("about:konqueror")) || url.url() == QLatin1String("about:plugins")) {
+ if (hasMimeType || KonqUrl::isValidNotBlank(url)) {
// Built-in view ?
if (!openView(mimeType, url, view /* can be 0 */, req)) {
@@ -797,19 +796,18 @@
QString serviceName = req.serviceName; // default: none provided
const QString urlStr = url.url();
- if (urlStr == QLatin1String("about:") || urlStr.startsWith(QLatin1String("about:konqueror")) || urlStr == QLatin1String("about:plugins")) {
- mimeType = QStringLiteral("KonqAboutPage"); // not KParts/ReadOnlyPart, it fills the Location menu ! :)
- serviceName = QStringLiteral("konq_aboutpage");
+ if (KonqUrl::isValidNotBlank(urlStr)) {
+ mimeType = QStringLiteral("text/html");
originalURL = req.typedUrl.isEmpty() ? QString() : req.typedUrl;
- } else if (urlStr == QLatin1String("about:blank") && req.typedUrl.isEmpty()) {
+ } else if (KonqUrl::isKonqBlank(urlStr) && req.typedUrl.isEmpty()) {
originalURL.clear();
}
bool forceAutoEmbed = req.forceAutoEmbed || req.userRequestedReload;
if (!req.typedUrl.isEmpty()) { // the user _typed_ the URL, he wants it in Konq.
forceAutoEmbed = true;
}
- if (url.scheme() == QLatin1String("about") || url.scheme() == QLatin1String("error")) {
+ if (KonqUrl::hasKonqScheme(url) || url.scheme() == QLatin1String("error")) {
forceAutoEmbed = true;
}
// Related to KonqFactory::createView
@@ -1200,7 +1198,7 @@
m_pViewManager->showTab(newView);
}
- openUrl(newView, url.isEmpty() ? QUrl(QStringLiteral("about:blank")) : url, QString(), req);
+ openUrl(newView, url.isEmpty() ? KonqUrl::url(KonqUrl::Type::Blank) : url, QString(), req);
newView->setViewName(browserArgs.frameName);
*part = newView->part();
@@ -2318,16 +2316,16 @@
void KonqMainWindow::slotAddTab()
{
- // we can hardcode text/html because this is what about:blank will use anyway
+ // we can hardcode text/html because this is what konq:blank will use anyway
KonqView *newView = m_pViewManager->addTab(QStringLiteral("text/html"),
QString(),
false,
KonqSettings::openAfterCurrentPage());
if (!newView) {
return;
}
- openUrl(newView, QUrl(QStringLiteral("about:blank")), QString());
+ openUrl(newView, KonqUrl::url(KonqUrl::Type::Blank), QString());
//HACK!! QTabBar likes to steal focus when changing widgets. This can result
//in a flicker since we don't want it to get focus we want the combo to get
@@ -3908,7 +3906,7 @@
bool KonqMainWindow::isPreloaded() const
{
- return !isVisible() && m_mapViews.count() == 1 && m_currentView->url().toString() == "about:blank";
+ return !isVisible() && m_mapViews.count() == 1 && KonqUrl::isKonqBlank(m_currentView->url().toString());
}
void KonqMainWindow::updateToolBarActions(bool pendingAction /*=false*/)
@@ -4999,7 +4997,7 @@
void KonqMainWindow::slotIntro()
{
- openUrl(nullptr, QUrl(QStringLiteral("about:")));
+ openUrl(nullptr, KonqUrl::url(KonqUrl::Type::NoPath));
}
void KonqMainWindow::goURL()
@@ -5020,7 +5018,7 @@
void KonqMainWindow::slotAddClosedUrl(KonqFrameBase *tab)
{
qCDebug(KONQUEROR_LOG);
- QString title(i18n("no name")), url(QStringLiteral("about:blank"));
+ QString title(i18n("no name")), url(KonqUrl::string(KonqUrl::Type::Blank));
// Did the tab contain a single frame, or a splitter?
KonqFrame *frame = dynamic_cast(tab);
diff --git a/src/konqmainwindowfactory.cpp b/src/konqmainwindowfactory.cpp
--- a/src/konqmainwindowfactory.cpp
+++ b/src/konqmainwindowfactory.cpp
@@ -22,6 +22,8 @@
#include "konqview.h"
#include "konqsettingsxt.h"
#include "konqdebug.h"
+#include "konqurl.h"
+
#include
#include
#include
@@ -46,7 +48,7 @@
static void ensurePreloadedWindow()
{
if (KonqSettings::alwaysHavePreloaded()) {
- QTimer::singleShot(500, nullptr, []() { new KonqMainWindow(QUrl(QStringLiteral("about:blank"))); });
+ QTimer::singleShot(500, nullptr, []() { new KonqMainWindow(KonqUrl::url(KonqUrl::Type::Blank)); });
}
}
diff --git a/src/konqmisc.cpp b/src/konqmisc.cpp
--- a/src/konqmisc.cpp
+++ b/src/konqmisc.cpp
@@ -23,6 +23,7 @@
#include "konqviewmanager.h"
#include "konqview.h"
#include "konqmainwindowfactory.h"
+#include "konqurl.h"
#include "konqdebug.h"
#include
@@ -70,7 +71,7 @@
{
Q_UNUSED(parent); // Useful if we want to change the error handling again
- if (!_url.startsWith(QLatin1String("about:"))) { // Don't filter "about:" URLs
+ if (!KonqUrl::canBeKonqUrl(_url)) { // Don't filter "konq:" URLs
KUriFilterData data(_url);
if (currentDirectory.isLocalFile()) {
@@ -98,11 +99,9 @@
return KParts::BrowserRun::makeErrorUrl(KIO::ERR_MALFORMED_URL, _url, QUrl(_url));
}
- const bool isKnownAbout = (_url == QLatin1String("about:blank")
- || _url == QLatin1String("about:plugins")
- || _url.startsWith(QLatin1String("about:konqueror")));
+ const bool isKnownAbout = KonqUrl::hasKnownPathRoot(_url);
- return isKnownAbout ? QUrl(_url) : QUrl(QStringLiteral("about:"));
+ return isKnownAbout ? QUrl(_url) : KonqUrl::url(KonqUrl::Type::NoPath);
}
QString KonqMisc::encodeFilename(QString filename)
diff --git a/src/konqueror.kcfg b/src/konqueror.kcfg
--- a/src/konqueror.kcfg
+++ b/src/konqueror.kcfg
@@ -7,7 +7,7 @@
- about:konqueror
+ konq:konqueror
This is the URL of the web page where Konqueror will start from.
diff --git a/src/konqurl.h b/src/konqurl.h
new file mode 100644
--- /dev/null
+++ b/src/konqurl.h
@@ -0,0 +1,63 @@
+/*
+ * This file is part of the KDE project.
+ *
+ * Copyright (C) 2020 Stefano Crocco
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your
+ * option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see .
+ *
+*/
+
+#ifndef KONQURL_H
+#define KONQURL_H
+
+#include
+#include
+#include
+
+namespace KonqUrl {
+
+ enum class Type{
+ NoPath,
+ Blank,
+ Konqueror,
+ Launch,
+ Specs,
+ Intro,
+ Tips,
+ Plugins
+ };
+
+ QLatin1String scheme();
+
+ QLatin1String string(Type type = Type::NoPath);
+
+ QUrl url(Type type = Type::NoPath);
+
+ bool hasKonqScheme(const QUrl &url);
+
+ bool canBeKonqUrl(const QString &url);
+
+ bool hasKnownPathRoot(const QString &url);
+
+ bool isValidNotBlank(const QString &url);
+
+ bool isValidNotBlank(const QUrl &url);
+
+ bool isKonqBlank(const QString &url);
+
+ bool isKonqBlank(const QUrl &url);
+
+};
+
+#endif // KONQURL_H
diff --git a/src/konqurl.cpp b/src/konqurl.cpp
new file mode 100644
--- /dev/null
+++ b/src/konqurl.cpp
@@ -0,0 +1,81 @@
+/*
+ * This file is part of the KDE project.
+ *
+ * Copyright (C) 2020 Stefano Crocco
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your
+ * option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see .
+ *
+*/
+
+#include "konqurl.h"
+
+namespace KonqUrl {
+
+ QLatin1String string(KonqUrl::Type type)
+ {
+ static QLatin1String s_konqUrls[] = {
+ QLatin1String("konq:"),
+ QLatin1String("konq:blank"),
+ QLatin1String("konq:konqueror"),
+ QLatin1String("konq:konqueror/launch"),
+ QLatin1String("konq:konqueror/specs"),
+ QLatin1String("konq:konqueror/intro"),
+ QLatin1String("konq:konqueror/tips"),
+ QLatin1String("konq:plugins"),
+ };
+ return s_konqUrls[static_cast(type)];
+ }
+
+ QLatin1String scheme()
+ {
+ static QLatin1String s_konqScheme = QLatin1String("konq");
+ return s_konqScheme;
+ }
+
+
+ QUrl url(KonqUrl::Type type) {
+ return QUrl(string(type));
+ }
+
+ bool hasKonqScheme(const QUrl& url)
+ {
+ return url.scheme() == scheme();
+ }
+
+
+ bool canBeKonqUrl(const QString &url) {
+ return url.startsWith(string(Type::NoPath));
+ }
+
+ bool hasKnownPathRoot(const QString &url) {
+ return url == string(Type::Blank) || url == string(Type::Plugins) || url.startsWith(string(Type::Konqueror));
+ }
+
+ bool isValidNotBlank(const QString &url) {
+ return url == string(Type::NoPath) || url == string(Type::Plugins) || url.startsWith(string(Type::Konqueror));
+ }
+
+ bool isValidNotBlank(const QUrl &url) {
+ return isValidNotBlank(url.url());
+ }
+
+ bool isKonqBlank(const QString &url) {
+ return url == string(Type::Blank);
+ }
+
+ bool isKonqBlank(const QUrl &url) {
+ return url.url() == string(Type::Blank);
+ }
+
+}
diff --git a/src/konqviewmanager.cpp b/src/konqviewmanager.cpp
--- a/src/konqviewmanager.cpp
+++ b/src/konqviewmanager.cpp
@@ -29,6 +29,7 @@
#include "konqsettingsxt.h"
#include "konqframevisitor.h"
#include
+#include "konqurl.h"
#include
#include
@@ -911,7 +912,7 @@
clear();
- if (forcedUrl.url() != QLatin1String("about:blank")) {
+ if (!KonqUrl::isKonqBlank(forcedUrl)) {
loadRootItem(profileGroup, m_pMainWindow, defaultURL, openUrl && forcedUrl.isEmpty(), forcedUrl, req.serviceName);
} else {
// ## in this case we won't resize the window, so bool resetWindow could be useful after all?
@@ -1134,7 +1135,7 @@
serviceType = cfg.readEntry(QStringLiteral("ServiceType").prepend(prefix), QStringLiteral("inode/directory"));
serviceName = cfg.readEntry(QStringLiteral("ServiceName").prepend(prefix), QString());
if (serviceName == QLatin1String("konq_aboutpage")) {
- if ((!forcedUrl.isEmpty() && forcedUrl.scheme() != QLatin1String("about")) ||
+ if ((!forcedUrl.isEmpty() && !KonqUrl::hasKonqScheme(forcedUrl)) ||
(forcedUrl.isEmpty() && openUrl == false)) { // e.g. window.open
// No point in loading the about page if we're going to replace it with a KHTML part right away
serviceType = QStringLiteral("text/html");
@@ -1186,9 +1187,9 @@
const QString urlKey = QStringLiteral("URL").prepend(prefix);
QUrl url;
if (cfg.hasKey(urlKey)) {
- url = QUrl(cfg.readPathEntry(urlKey, QStringLiteral("about:blank")));
+ url = QUrl(cfg.readPathEntry(urlKey, KonqUrl::string(KonqUrl::Type::Blank)));
} else if (urlKey == QLatin1String("empty_URL")) { // old stuff, not in use anymore
- url = QUrl(QStringLiteral("about:blank"));
+ url = KonqUrl::url(KonqUrl::Type::Blank);
} else {
url = defaultURL;
}
@@ -1198,7 +1199,7 @@
//childView->openUrl( url, url.toDisplayString() );
// We need view-follows-view (for the dirtree, for instance)
KonqOpenURLRequest req;
- if (url.scheme() != QLatin1String("about")) {
+ if (!KonqUrl::hasKonqScheme(url)) {
req.typedUrl = url.toDisplayString();
}
m_pMainWindow->openView(serviceType, url, childView, req);
diff --git a/webenginepart/src/CMakeLists.txt b/webenginepart/src/CMakeLists.txt
--- a/webenginepart/src/CMakeLists.txt
+++ b/webenginepart/src/CMakeLists.txt
@@ -25,6 +25,7 @@
ui/searchbar.cpp
ui/passwordbar.cpp
ui/featurepermissionbar.cpp
+ about/konq_aboutpage.cpp
)
if(NOT Qt5WebEngineWidgets_VERSION VERSION_LESS "5.12.0")
@@ -82,3 +83,5 @@
install(FILES webenginepart.rc DESTINATION ${KDE_INSTALL_KXMLGUI5DIR}/webenginepart)
install(FILES error.html DESTINATION ${KDE_INSTALL_DATADIR}/webenginepart)
+
+add_subdirectory(about)
diff --git a/webenginepart/src/about/CMakeLists.txt b/webenginepart/src/about/CMakeLists.txt
new file mode 100644
--- /dev/null
+++ b/webenginepart/src/about/CMakeLists.txt
@@ -0,0 +1,10 @@
+install(FILES
+ top-left-konqueror.png
+ launch.html
+ intro.html
+ specs.html
+ tips.html
+ plugins.html
+ plugins_rtl.html
+ konq.css
+ DESTINATION ${KDE_INSTALL_DATADIR}/konqueror/about)
diff --git a/about/intro.html b/webenginepart/src/about/intro.html
rename from about/intro.html
rename to webenginepart/src/about/intro.html
--- a/about/intro.html
+++ b/webenginepart/src/about/intro.html
@@ -41,10 +41,10 @@
%6
@@ -70,7 +70,7 @@
%15
- %16 %18
+ %16 %18
diff --git a/about/konq.css b/webenginepart/src/about/konq.css
rename from about/konq.css
rename to webenginepart/src/about/konq.css
diff --git a/webenginepart/src/about/konq_aboutpage.h b/webenginepart/src/about/konq_aboutpage.h
new file mode 100644
--- /dev/null
+++ b/webenginepart/src/about/konq_aboutpage.h
@@ -0,0 +1,36 @@
+#ifndef __konq_aboutpage_h__
+#define __konq_aboutpage_h__
+
+#include
+
+class QUrl;
+
+class KonqAboutPageSingleton
+{
+public:
+ QString launch();
+ QString intro();
+ QString specs();
+ QString tips();
+ QString plugins();
+
+private:
+ QString m_launch_html, m_intro_html, m_specs_html, m_tips_html, m_plugins_html;
+};
+
+class KonqUrlSchemeHandler : public QWebEngineUrlSchemeHandler
+{
+ Q_OBJECT
+public:
+ KonqUrlSchemeHandler(QObject *parent=Q_NULLPTR);
+ ~KonqUrlSchemeHandler() Q_DECL_OVERRIDE;
+
+ void requestStarted(QWebEngineUrlRequestJob *req) Q_DECL_OVERRIDE;
+
+private:
+
+ QString m_htmlDoc;
+ QString m_what;
+};
+
+#endif
diff --git a/about/konq_aboutpage.cpp b/webenginepart/src/about/konq_aboutpage.cpp
rename from about/konq_aboutpage.cpp
rename to webenginepart/src/about/konq_aboutpage.cpp
--- a/about/konq_aboutpage.cpp
+++ b/webenginepart/src/about/konq_aboutpage.cpp
@@ -5,16 +5,14 @@
#include
#include
#include
+#include
+#include
+#include
+#include
+#include
-#include
-#include
#include
-#include
-#include
-#include
-#include
-
-K_PLUGIN_FACTORY(KonqAboutPageFactory, registerPlugin();)
+#include
Q_GLOBAL_STATIC(KonqAboutPageSingleton, s_staticData)
@@ -35,7 +33,7 @@
res = t.readAll();
- // otherwise all embedded objects are referenced as about:/...
+ // otherwise all embedded objects are referenced as konq/...
QString basehref = QLatin1String("\n");
@@ -216,7 +214,7 @@
.arg(i18n("Enable Java (globally) here.", QStringLiteral("exec:/kcmshell5 khtml_java_js"))) // TODO Maybe test if Java is enabled ?
.arg(i18n("NPAPI plugins (for viewing Flash®, etc.)",
QStringLiteral("https://get.adobe.com/flashplayer/"),
- QStringLiteral("about:plugins")))
+ QStringLiteral("konq:plugins")))
.arg(i18n("built-in"))
.arg(i18n("Secure Sockets Layer"))
.arg(i18n("(TLS/SSL v2/3) for secure communications up to 168bit"))
@@ -239,7 +237,7 @@
.arg(i18n("Popup"))
.arg(i18n("(Short-) Automatic"))
.arg(QStringLiteral("")).arg(continue_icon_path)
- .arg(i18nc("Link that points to the first page of the Konqueror 'about page', Starting Points contains links to Home, Network Folders, Trash, etc.", "Return to Starting Points", QStringLiteral("about:konqueror")))
+ .arg(i18nc("Link that points to the first page of the Konqueror 'about page', Starting Points contains links to Home, Network Folders, Trash, etc.", "Return to Starting Points", QStringLiteral("konq:konqueror")))
;
@@ -348,93 +346,33 @@
return res;
}
-KonqAboutPage::KonqAboutPage(QWidget *parentWidget, QObject *parent, const QVariantList &args)
- : KHTMLPart(parentWidget, parent, BrowserViewGUI)
-{
- Q_UNUSED(args)
-}
-
-KonqAboutPage::~KonqAboutPage()
-{
-}
-
-bool KonqAboutPage::openUrl(const QUrl &u)
-{
- emit started(nullptr);
- if (u.url() == QLatin1String("about:plugins")) {
- serve(s_staticData->plugins(), QStringLiteral("plugins"));
- } else if (u.url() == QLatin1String("about:konqueror/intro")) {
- serve(s_staticData->intro(), QStringLiteral("konqueror/intro"));
- } else if (u.url() == QLatin1String("about:konqueror/specs")) {
- serve(s_staticData->specs(), QStringLiteral("konqueror/specs"));
- } else if (u.url() == QLatin1String("about:konqueror/tips")) {
- serve(s_staticData->tips(), QStringLiteral("konqueror/tips"));
- } else {
- serve(s_staticData->launch(), QStringLiteral("konqueror"));
- }
- emit completed();
- return true;
-}
-
-bool KonqAboutPage::openFile()
+KonqUrlSchemeHandler::KonqUrlSchemeHandler(QObject *parent) : QWebEngineUrlSchemeHandler(parent)
{
- return true;
}
-void KonqAboutPage::saveState(QDataStream &stream)
+KonqUrlSchemeHandler::~KonqUrlSchemeHandler()
{
- stream << m_htmlDoc;
- stream << m_what;
}
-void KonqAboutPage::restoreState(QDataStream &stream)
+void KonqUrlSchemeHandler::requestStarted(QWebEngineUrlRequestJob *req)
{
- stream >> m_htmlDoc;
- stream >> m_what;
- serve(m_htmlDoc, m_what);
+ QBuffer* buf = new QBuffer(this);
+ buf->open(QBuffer::ReadWrite);
+ connect(buf, &QIODevice::aboutToClose, buf, &QObject::deleteLater);
+ QString data;
+ QString path = req->requestUrl().path();
+ if (path.endsWith("specs")) {
+ data = s_staticData->specs();
+ } else if (path.endsWith("intro")) {
+ data = s_staticData->intro();
+ } else if (path.endsWith("tips")) {
+ data = s_staticData->tips();
+ } else if (path.endsWith("plugins")) {
+ data = s_staticData->plugins();
+ } else {
+ data = s_staticData->launch();
+ }
+ buf->write(data.toUtf8());
+ buf->seek(0);
+ req->reply("text/html", buf);
}
-
-void KonqAboutPage::serve(const QString &html, const QString &what)
-{
- m_what = what;
- begin(QUrl(QStringLiteral("about:%1").arg(what)));
- write(html);
- end();
- m_htmlDoc = html;
-}
-
-bool KonqAboutPage::urlSelected(const QString &url, int button, int state, const QString &target,
- const KParts::OpenUrlArguments &args,
- const KParts::BrowserArguments &browserArgs)
-{
- QUrl u(url);
- if (u.scheme() == QLatin1String("exec")) {
- QStringList execArgs = url.mid(6).split(QChar(' '), QString::SkipEmptyParts);
- QString executable = execArgs.first();
- execArgs.erase(execArgs.begin());
- KToolInvocation::kdeinitExec(executable, execArgs);
- return true;
- }
-
- if (url == QLatin1String("about:konqueror")) {
- emit browserExtension()->openUrlNotify();
- serve(s_staticData->launch(), QStringLiteral("konqueror"));
- return true;
- } else if (url == QLatin1String("about:konqueror/intro")) {
- emit browserExtension()->openUrlNotify();
- serve(s_staticData->intro(), QStringLiteral("konqueror/intro"));
- return true;
- } else if (url == QLatin1String("about:konqueror/specs")) {
- emit browserExtension()->openUrlNotify();
- serve(s_staticData->specs(), QStringLiteral("konqueror/specs"));
- return true;
- } else if (url == QLatin1String("about:konqueror/tips")) {
- emit browserExtension()->openUrlNotify();
- serve(s_staticData->tips(), QStringLiteral("konqueror/tips"));
- return true;
- }
-
- return KHTMLPart::urlSelected(url, button, state, target, args, browserArgs);
-}
-
-#include "konq_aboutpage.moc"
diff --git a/about/konq_aboutpage.desktop b/webenginepart/src/about/konq_aboutpage.desktop
rename from about/konq_aboutpage.desktop
rename to webenginepart/src/about/konq_aboutpage.desktop
diff --git a/about/konqaboutpage.desktop b/webenginepart/src/about/konqaboutpage.desktop
rename from about/konqaboutpage.desktop
rename to webenginepart/src/about/konqaboutpage.desktop
diff --git a/about/launch.html b/webenginepart/src/about/launch.html
rename from about/launch.html
rename to webenginepart/src/about/launch.html
--- a/about/launch.html
+++ b/webenginepart/src/about/launch.html
@@ -42,9 +42,9 @@
@@ -91,7 +91,7 @@
|
- %36
+ %36
diff --git a/about/plugins.html b/webenginepart/src/about/plugins.html
rename from about/plugins.html
rename to webenginepart/src/about/plugins.html
diff --git a/about/plugins_rtl.html b/webenginepart/src/about/plugins_rtl.html
rename from about/plugins_rtl.html
rename to webenginepart/src/about/plugins_rtl.html
diff --git a/about/specs.html b/webenginepart/src/about/specs.html
rename from about/specs.html
rename to webenginepart/src/about/specs.html
--- a/about/specs.html
+++ b/webenginepart/src/about/specs.html
@@ -41,9 +41,9 @@
%6
@@ -186,7 +186,7 @@
- %48 %49
+ %48 %49
diff --git a/about/tips.html b/webenginepart/src/about/tips.html
rename from about/tips.html
rename to webenginepart/src/about/tips.html
--- a/about/tips.html
+++ b/webenginepart/src/about/tips.html
@@ -41,10 +41,10 @@
%6
@@ -108,7 +108,7 @@
- %22 %23
+ %22 %23
diff --git a/about/top-left-konqueror.png b/webenginepart/src/about/top-left-konqueror.png
rename from about/top-left-konqueror.png
rename to webenginepart/src/about/top-left-konqueror.png
diff --git a/webenginepart/src/utils.h b/webenginepart/src/utils.h
--- a/webenginepart/src/utils.h
+++ b/webenginepart/src/utils.h
@@ -11,7 +11,7 @@
inline bool isBlankUrl(const QUrl& url)
{
- return (url.isEmpty() || url.url() == QL1S("about:blank"));
+ return (url.isEmpty() || url.url() == QL1S("konq:blank"));
}
}
diff --git a/webenginepart/src/webenginepart.cpp b/webenginepart/src/webenginepart.cpp
--- a/webenginepart/src/webenginepart.cpp
+++ b/webenginepart/src/webenginepart.cpp
@@ -24,6 +24,7 @@
#include "webenginepart.h"
#include "webenginepartkiohandler.h"
+#include "about/konq_aboutpage.h"
#include
@@ -89,7 +90,7 @@
static bool needToInitUrlSchemes = true;
if (needToInitUrlSchemes) {
needToInitUrlSchemes = false;
- QVector localSchemes = {"error"};
+ QVector localSchemes = {"error", "konq"};
const QStringList protocols = KProtocolInfo::protocols();
for(const QString &prot : protocols){
#if KIO_VERSION >= QT_VERSION_CHECK(5,60,0)
@@ -131,6 +132,7 @@
QWebEngineProfile *prof = QWebEngineProfile::defaultProfile();
if (!prof->urlSchemeHandler("error")) {
prof->installUrlSchemeHandler("error", new WebEnginePartErrorSchemeHandler(prof));
+ prof->installUrlSchemeHandler("konq", new KonqUrlSchemeHandler(prof));
prof->installUrlSchemeHandler("help", new WebEnginePartKIOHandler(prof));
}
static WebEnginePartCookieJar s_cookieJar(prof, nullptr);