diff options
| author | 2023-11-28 10:38:17 +0100 | |
|---|---|---|
| committer | 2023-11-28 10:38:17 +0100 | |
| commit | f8b64fbc38eead48cbccff4f75d11d3224b400dd (patch) | |
| tree | 26ade25e8d87abf036ea7f429f8f5121efa914e2 /src/modules/help | |
| parent | Ircview: Fix out of bound memory read when a line ends with a tab; fix #2377 (diff) | |
| download | KVIrc-f8b64fbc38eead48cbccff4f75d11d3224b400dd.tar.gz KVIrc-f8b64fbc38eead48cbccff4f75d11d3224b400dd.tar.bz2 KVIrc-f8b64fbc38eead48cbccff4f75d11d3224b400dd.zip | |
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/
Diffstat (limited to 'src/modules/help')
| -rw-r--r-- | src/modules/help/HelpWidget.cpp | 137 | ||||
| -rw-r--r-- | src/modules/help/HelpWidget.h | 29 | ||||
| -rw-r--r-- | src/modules/help/HelpWindow.cpp | 16 | ||||
| -rw-r--r-- | src/modules/help/HelpWindow.h | 12 | ||||
| -rw-r--r-- | src/modules/help/libkvihelp.cpp | 12 |
5 files changed, 1 insertions, 205 deletions
diff --git a/src/modules/help/HelpWidget.cpp b/src/modules/help/HelpWidget.cpp index 5d9fdfd8a..5ab827a82 100644 --- a/src/modules/help/HelpWidget.cpp +++ b/src/modules/help/HelpWidget.cpp @@ -45,137 +45,6 @@ extern HelpIndex * g_pDocIndex; extern KviPointerList<HelpWindow> * g_pHelpWindowList; extern KviPointerList<HelpWidget> * g_pHelpWidgetList; -#ifdef COMPILE_WEBENGINE_SUPPORT -#include <QShortcut> -#include <QAction> - -HelpWidget::HelpWidget(QWidget * par, bool bIsStandalone) - : QWidget(par) -{ - setObjectName("help_widget"); - setMinimumWidth(80); - if(bIsStandalone) - g_pHelpWidgetList->append(this); - m_bIsStandalone = bIsStandalone; - - new QShortcut(QKeySequence::Copy, this, SLOT(slotCopy()), nullptr, Qt::WidgetWithChildrenShortcut); - new QShortcut(QKeySequence::Find, this, SLOT(slotShowHideFind()), nullptr, bIsStandalone ? Qt::WidgetWithChildrenShortcut : Qt::WindowShortcut); - - // layout - m_pLayout = new QVBoxLayout(this); - m_pLayout->setContentsMargins(0, 0, 0, 0); - m_pLayout->setSpacing(0); - setLayout(m_pLayout); - - // upper toolbar - m_pToolBar = new QToolBar(this); - m_pLayout->addWidget(m_pToolBar); - - // webview - m_pTextBrowser = new QWebEngineView(this); - m_pTextBrowser->setObjectName("text_browser"); - m_pTextBrowser->setStyleSheet("QTextBrowser { background-color:white; color:black; }"); - m_pLayout->addWidget(m_pTextBrowser); - connect(m_pTextBrowser, SIGNAL(loadFinished(bool)), this, SLOT(slotLoadFinished(bool))); - - // lower toolbar - m_pToolBarHighlight = new QToolBar(this); - m_pLayout->addWidget(m_pToolBarHighlight); - m_pToolBarHighlight->hide(); - - QLabel * pHighlightLabel = new QLabel(); - pHighlightLabel->setText(__tr2qs("Find: ")); - m_pToolBarHighlight->addWidget(pHighlightLabel); - - m_pFindText = new QLineEdit(); - m_pToolBarHighlight->addWidget(m_pFindText); - connect(m_pFindText, SIGNAL(textChanged(const QString)), this, SLOT(slotTextChanged(const QString))); - - m_pToolBarHighlight->addAction(*g_pIconManager->getBigIcon(KVI_BIGICON_HELPBACK), __tr2qs("Find previous"), this, SLOT(slotFindPrev())); - m_pToolBarHighlight->addAction(*g_pIconManager->getBigIcon(KVI_BIGICON_HELPFORWARD), __tr2qs("Find next"), this, SLOT(slotFindNext())); - m_pToolBarHighlight->addAction(*g_pIconManager->getSmallIcon(KviIconManager::Discard), __tr2qs("Close"), this, SLOT(slotShowHideFind())); - - // upper toolbar contents (depends on webview) - m_pToolBar->addAction(*g_pIconManager->getBigIcon(KVI_BIGICON_HELPINDEX), __tr2qs("Show index"), this, SLOT(showIndex())); - - QAction * pAction; - pAction = m_pTextBrowser->pageAction(QWebEnginePage::Back); - pAction->setIcon(*g_pIconManager->getBigIcon(KVI_BIGICON_HELPBACK)); - m_pToolBar->addAction(pAction); - pAction = m_pTextBrowser->pageAction(QWebEnginePage::Forward); - pAction->setIcon(*g_pIconManager->getBigIcon(KVI_BIGICON_HELPFORWARD)); - m_pToolBar->addAction(pAction); - - m_pToolBar->addAction(*(g_pIconManager->getSmallIcon(KviIconManager::Minus)), __tr2qs("Zoom out"), this, SLOT(slotZoomOut())); - m_pToolBar->addAction(*(g_pIconManager->getSmallIcon(KviIconManager::Plus)), __tr2qs("Zoom in"), this, SLOT(slotZoomIn())); - - if(bIsStandalone) - { - setAttribute(Qt::WA_DeleteOnClose); - m_pToolBar->addAction(*g_pIconManager->getBigIcon(KVI_BIGICON_HELPCLOSE), __tr2qs("Close"), this, SLOT(close())); - } -} - -void HelpWidget::slotCopy() -{ - m_pTextBrowser->triggerPageAction(QWebEnginePage::Copy); -} - -void HelpWidget::slotShowHideFind() -{ - if(m_pToolBarHighlight->isVisible()) - { - m_pToolBarHighlight->hide(); - m_pTextBrowser->findText(""); - } - else - { - m_pToolBarHighlight->show(); - m_pFindText->setFocus(); - } -} - -void HelpWidget::slotLoadFinished(bool) -{ - m_pTextBrowser->findText(m_pFindText->text()); -} - -void HelpWidget::slotTextChanged(const QString szFind) -{ - m_pTextBrowser->findText(""); - m_pTextBrowser->findText(szFind); -} - -void HelpWidget::slotFindPrev() -{ - m_pTextBrowser->findText(m_pFindText->text(), QWebEnginePage::FindBackward); -} - -void HelpWidget::slotFindNext() -{ - m_pTextBrowser->findText(m_pFindText->text()); -} - -void HelpWidget::slotZoomIn() -{ - kvs_real_t dZoom = m_pTextBrowser->zoomFactor(); - if(dZoom >= 2) - return; - dZoom += 0.05; - m_pTextBrowser->setZoomFactor(dZoom); -} - -void HelpWidget::slotZoomOut() -{ - kvs_real_t dZoom = m_pTextBrowser->zoomFactor(); - if(dZoom <= 0.5) - return; - dZoom -= 0.05; - m_pTextBrowser->setZoomFactor(dZoom); -} - -#else - HelpWidget::HelpWidget(QWidget * par, bool bIsStandalone) : QWidget(par) { @@ -223,8 +92,6 @@ HelpWidget::HelpWidget(QWidget * par, bool bIsStandalone) connect(m_pTextBrowser, SIGNAL(forwardAvailable(bool)), m_pForwardAction, SLOT(setEnabled(bool))); } -#endif - HelpWidget::~HelpWidget() { if(m_bIsStandalone) @@ -238,9 +105,5 @@ void HelpWidget::showIndex() g_pApp->getGlobalKvircDirectory(szHelpDir, KviApplication::Help); dirHelp = QDir(szHelpDir); -#ifdef COMPILE_WEBENGINE_SUPPORT - m_pTextBrowser->load(QUrl::fromLocalFile(dirHelp.absoluteFilePath("index.html"))); -#else m_pTextBrowser->setSource(QUrl::fromLocalFile(dirHelp.absoluteFilePath("index.html"))); -#endif } diff --git a/src/modules/help/HelpWidget.h b/src/modules/help/HelpWidget.h index 732d7a118..420511de0 100644 --- a/src/modules/help/HelpWidget.h +++ b/src/modules/help/HelpWidget.h @@ -27,11 +27,7 @@ #include "HelpIndex.h" #include "kvi_settings.h" -#ifdef COMPILE_WEBENGINE_SUPPORT -#include <QWebEngineView> -#else #include <QTextBrowser> -#endif #include <QToolBar> #include <QVBoxLayout> #include <QProgressBar> @@ -48,45 +44,20 @@ public: ~HelpWidget(); private: -#ifdef COMPILE_WEBENGINE_SUPPORT - QVBoxLayout * m_pLayout; - QToolBar * m_pToolBar; - QToolBar * m_pToolBarHighlight; - QLineEdit * m_pFindText; - QWebEngineView * m_pTextBrowser; -#else QVBoxLayout * m_pLayout; QToolBar * m_pToolBar; QAction * m_pBackAction; QAction * m_pForwardAction; QTextBrowser * m_pTextBrowser; -#endif bool m_bIsStandalone; protected slots: void showIndex(); -#ifdef COMPILE_WEBENGINE_SUPPORT - void slotLoadFinished(bool ok); - void slotFindNext(); - void slotFindPrev(); - void slotZoomIn(); - void slotZoomOut(); - void slotTextChanged(const QString); - void slotCopy(); - void slotShowHideFind(); -#endif public: -#ifdef COMPILE_WEBENGINE_SUPPORT - QWebEngineView * textBrowser() - { - return m_pTextBrowser; - } -#else QTextBrowser * textBrowser() { return m_pTextBrowser; } -#endif }; #endif //_HELPWIDGET_H_ diff --git a/src/modules/help/HelpWindow.cpp b/src/modules/help/HelpWindow.cpp index 8c05461e0..f48778a36 100644 --- a/src/modules/help/HelpWindow.cpp +++ b/src/modules/help/HelpWindow.cpp @@ -268,11 +268,7 @@ void HelpWindow::startSearch() setCursor(Qt::ArrowCursor); } -#ifdef COMPILE_WEBENGINE_SUPPORT -QWebEngineView * HelpWindow::textBrowser() -#else QTextBrowser * HelpWindow::textBrowser() -#endif { return m_pHelpWidget->textBrowser(); } @@ -282,11 +278,7 @@ void HelpWindow::showIndexTopic() if(m_pIndexSearch->text().isEmpty() || !m_pIndexListWidget->selectedItems().count()) return; int i = g_pDocIndex->titlesList().indexOf(m_pIndexListWidget->selectedItems().at(0)->text()); -#ifdef COMPILE_WEBENGINE_SUPPORT - textBrowser()->load(QUrl(g_pDocIndex->documentList()[i])); -#else textBrowser()->setSource(QUrl(g_pDocIndex->documentList()[i])); -#endif } void HelpWindow::searchInIndex(const QString & s) @@ -311,11 +303,7 @@ void HelpWindow::indexSelected(QListWidgetItem * item) if(!item) return; int i = g_pDocIndex->titlesList().indexOf(item->text()); -#ifdef COMPILE_WEBENGINE_SUPPORT - textBrowser()->load(QUrl(g_pDocIndex->documentList()[i])); -#else textBrowser()->setSource(QUrl(g_pDocIndex->documentList()[i])); -#endif } void HelpWindow::searchSelected(QListWidgetItem * item) @@ -323,11 +311,7 @@ void HelpWindow::searchSelected(QListWidgetItem * item) if(!item) return; int i = g_pDocIndex->titlesList().indexOf(item->text()); -#ifdef COMPILE_WEBENGINE_SUPPORT - textBrowser()->load(QUrl(g_pDocIndex->documentList()[i])); -#else textBrowser()->setSource(QUrl(g_pDocIndex->documentList()[i])); -#endif } QPixmap * HelpWindow::myIconPtr() diff --git a/src/modules/help/HelpWindow.h b/src/modules/help/HelpWindow.h index 25de74611..4aee40f69 100644 --- a/src/modules/help/HelpWindow.h +++ b/src/modules/help/HelpWindow.h @@ -31,17 +31,11 @@ #include "kvi_settings.h" #include <QTabWidget> -#ifdef COMPILE_WEBENGINE_SUPPORT -#include <QWebEngineView> -#else -class QTextBrowser; -#endif - #include <QLineEdit> +class QTextBrowser; class QProgressBar; class QPushButton; - class HelpWidget; class HelpWindow : public KviWindow @@ -79,11 +73,7 @@ protected: void loadProperties(KviConfigurationFile * cfg) override; public: -#ifdef COMPILE_WEBENGINE_SUPPORT - QWebEngineView * textBrowser(); -#else QTextBrowser * textBrowser(); -#endif public slots: void indexSelected(QListWidgetItem *); void searchInIndex(const QString & s); diff --git a/src/modules/help/libkvihelp.cpp b/src/modules/help/libkvihelp.cpp index 7eeb4e57e..9c0b5e583 100644 --- a/src/modules/help/libkvihelp.cpp +++ b/src/modules/help/libkvihelp.cpp @@ -185,11 +185,7 @@ static bool help_kvs_cmd_open(KviKvsModuleCommandCall * c) if(w) { -#ifdef COMPILE_WEBENGINE_SUPPORT - w->textBrowser()->load(QUrl::fromLocalFile(f.absoluteFilePath())); -#else w->textBrowser()->setSource(QUrl::fromLocalFile(f.absoluteFilePath())); -#endif HelpWindow * pHelpWindow = g_pHelpWindowList->first(); if (pHelpWindow) pHelpWindow->delayedAutoRaise(); @@ -199,21 +195,13 @@ static bool help_kvs_cmd_open(KviKvsModuleCommandCall * c) if(c->switches()->find('m', "mdi")) { HelpWindow * w = new HelpWindow("Help browser"); -#ifdef COMPILE_WEBENGINE_SUPPORT - w->textBrowser()->load(QUrl::fromLocalFile(f.absoluteFilePath())); -#else w->textBrowser()->setSource(QUrl::fromLocalFile(f.absoluteFilePath())); -#endif g_pMainWindow->addWindow(w); } else { HelpWidget * w = new HelpWidget(g_pMainWindow->splitter(), true); -#ifdef COMPILE_WEBENGINE_SUPPORT - w->textBrowser()->load(QUrl::fromLocalFile(f.absoluteFilePath())); -#else w->textBrowser()->setSource(QUrl::fromLocalFile(f.absoluteFilePath())); -#endif w->show(); } |
