From f8b64fbc38eead48cbccff4f75d11d3224b400dd Mon Sep 17 00:00:00 2001 From: ctrlaltca Date: Tue, 28 Nov 2023 10:38:17 +0100 Subject: Remove QWebEngine usage in core. Rewrite web package manager (#2570) * Remove use of QWebEngine from help module * Rewrite the WebPackageManagementDialog to use an http/json API instead of a webpage; drop QWebEngine usage * Edited repository urls to https://kvirc.github.io/--- src/modules/addon/AddonManagementDialog.cpp | 28 ++++++++++++++------------- src/modules/addon/AddonManagementDialog.h | 5 +---- src/modules/addon/WebAddonInterfaceDialog.cpp | 9 ++------- src/modules/addon/WebAddonInterfaceDialog.h | 4 ---- 4 files changed, 18 insertions(+), 28 deletions(-) (limited to 'src/modules/addon') diff --git a/src/modules/addon/AddonManagementDialog.cpp b/src/modules/addon/AddonManagementDialog.cpp index 1e2316c7e..bc67931f6 100644 --- a/src/modules/addon/AddonManagementDialog.cpp +++ b/src/modules/addon/AddonManagementDialog.cpp @@ -56,9 +56,7 @@ #include #include -#ifdef COMPILE_WEBENGINE_SUPPORT #include "WebAddonInterfaceDialog.h" -#endif //COMPILE_WEBENGINE_SUPPORT AddonManagementDialog * AddonManagementDialog::m_pInstance = nullptr; extern QRect g_rectManagementDialogGeometry; @@ -98,9 +96,7 @@ AddonManagementDialog::AddonManagementDialog(QWidget * p) setObjectName("Addon manager"); setWindowIcon(*(g_pIconManager->getSmallIcon(KviIconManager::Addons))); -#ifdef COMPILE_WEBENGINE_SUPPORT m_pWebInterfaceDialog = nullptr; -#endif //COMPILE_WEBENGINE_SUPPORT m_pInstance = this; QGridLayout * g = new QGridLayout(this); @@ -200,10 +196,8 @@ AddonManagementDialog::AddonManagementDialog(QWidget * p) AddonManagementDialog::~AddonManagementDialog() { -#ifdef COMPILE_WEBENGINE_SUPPORT if(m_pWebInterfaceDialog) delete m_pWebInterfaceDialog; -#endif //COMPILE_WEBENGINE_SUPPORT g_rectManagementDialogGeometry = QRect(pos().x(), pos().y(), size().width(), size().height()); m_pInstance = nullptr; } @@ -292,14 +286,22 @@ void AddonManagementDialog::uninstallScript() void AddonManagementDialog::getMoreScripts() { -#ifdef COMPILE_WEBENGINE_SUPPORT if(m_pWebInterfaceDialog) - return; - m_pWebInterfaceDialog = new WebAddonInterfaceDialog(); -#else //!COMPILE_WEBENGINE_SUPPORT - // If change this introducing not-fixed text, remember to escape this using KviQString::escapeKvs()! - KviKvsScript::run("openurl http://www.kvirc.net/?id=addons&version=" KVI_VERSION "." KVI_SOURCES_DATE, g_pActiveWindow); -#endif //!COMPILE_WEBENGINE_SUPPORT + { + m_pWebInterfaceDialog->show(); + } + else + { + m_pWebInterfaceDialog = new WebAddonInterfaceDialog(); + QObject::connect(m_pWebInterfaceDialog, SIGNAL(destroyed()), this, SLOT(webInterfaceDialogDestroyed())); + m_pWebInterfaceDialog->show(); + } +} + +void AddonManagementDialog::webInterfaceDialogDestroyed() +{ + m_pWebInterfaceDialog = nullptr; + fillListView(); } void AddonManagementDialog::installScript() diff --git a/src/modules/addon/AddonManagementDialog.h b/src/modules/addon/AddonManagementDialog.h index 698d87ac2..b233c5630 100644 --- a/src/modules/addon/AddonManagementDialog.h +++ b/src/modules/addon/AddonManagementDialog.h @@ -54,9 +54,7 @@ public: KviKvsScriptAddon * addon() { return m_pAddon; }; }; -#ifdef COMPILE_WEBENGINE_SUPPORT class WebAddonInterfaceDialog; -#endif //COMPILE_WEBENGINE_SUPPORT class AddonManagementDialog : public QWidget { @@ -74,9 +72,7 @@ protected: QToolButton * m_pHelpButton; QToolButton * m_pPackButton; QToolButton * m_pUninstallButton; -#ifdef COMPILE_WEBENGINE_SUPPORT QPointer m_pWebInterfaceDialog; -#endif //COMPILE_WEBENGINE_SUPPORT public: static AddonManagementDialog * instance() { return m_pInstance; }; static void display(bool bTopLevel); @@ -94,6 +90,7 @@ protected slots: void uninstallScript(); void getMoreScripts(); void installScript(); + void webInterfaceDialogDestroyed(); virtual void reject(); }; diff --git a/src/modules/addon/WebAddonInterfaceDialog.cpp b/src/modules/addon/WebAddonInterfaceDialog.cpp index bf6ed8ced..648e20597 100644 --- a/src/modules/addon/WebAddonInterfaceDialog.cpp +++ b/src/modules/addon/WebAddonInterfaceDialog.cpp @@ -24,8 +24,6 @@ #include "kvi_settings.h" -#ifdef COMPILE_WEBENGINE_SUPPORT - #include "WebAddonInterfaceDialog.h" #include "AddonFunctions.h" @@ -41,10 +39,9 @@ WebAddonInterfaceDialog::WebAddonInterfaceDialog(QWidget * par) { setWindowTitle(__tr2qs_ctx("Download Addons - KVIrc", "theme")); - setPackagePageUrl( - QString::fromLatin1("https://www.kvirc.net/app/addons.php?version=" KVI_VERSION "&lang=%1") - .arg(KviLocale::instance()->localeName())); + setPackagePageUrl("https://kvirc.github.io/kvirc-addons/"); } + WebAddonInterfaceDialog::~WebAddonInterfaceDialog() = default; @@ -65,5 +62,3 @@ bool WebAddonInterfaceDialog::packageIsInstalled(const QString & szId, const QSt // FIXME: If the version of the installed addon is lower than allow upgrading! return KviMiscUtils::compareVersions(pAddon->version(), szVersion) < 0; } - -#endif //COMPILE_WEBENGINE_SUPPORT diff --git a/src/modules/addon/WebAddonInterfaceDialog.h b/src/modules/addon/WebAddonInterfaceDialog.h index 79e2c9180..a1a202c37 100644 --- a/src/modules/addon/WebAddonInterfaceDialog.h +++ b/src/modules/addon/WebAddonInterfaceDialog.h @@ -26,8 +26,6 @@ #include "kvi_settings.h" -#ifdef COMPILE_WEBENGINE_SUPPORT - #include "KviWebPackageManagementDialog.h" /// @@ -58,6 +56,4 @@ protected: }; // class WebAddonInterfaceDialog -#endif //COMPILE_WEBENGINE_SUPPORT - #endif //!_WebAddonInterfaceDialog_h_ -- cgit v1.3.1-10-gc9f91