mirror of
https://github.com/kiwix/kiwix-desktop.git
synced 2025-09-22 03:26:05 -04:00
Rename classes and files.
Mainly remove the `Kiwix` part in the name : - KiwixSchemeHandler -> UrlSchemeHandler - KiwixRequestInterceptor -> RequestInterceptor - KiwixWebView -> WebView - KTabWidget -> TabWidget
This commit is contained in:
parent
7b9968daee
commit
3e46893e2d
@ -32,26 +32,26 @@ DEFINES += QT_DEPRECATED_WARNINGS
|
||||
SOURCES += \
|
||||
src/main.cpp \
|
||||
src/mainwindow.cpp \
|
||||
src/kiwixschemehandler.cpp \
|
||||
src/kiwixapp.cpp \
|
||||
src/blobbuffer.cpp \
|
||||
src/kiwixrequestinterceptor.cpp \
|
||||
src/kiwixwebview.cpp \
|
||||
src/library.cpp \
|
||||
src/topwidget.cpp \
|
||||
src/ktabwidget.cpp
|
||||
src/requestinterceptor.cpp \
|
||||
src/urlschemehandler.cpp \
|
||||
src/tabwidget.cpp \
|
||||
src/webview.cpp
|
||||
|
||||
HEADERS += \
|
||||
src/mainwindow.h \
|
||||
src/kiwixschemehandler.h \
|
||||
src/kiwixapp.h \
|
||||
src/blobbuffer.h \
|
||||
src/kiwixrequestinterceptor.h \
|
||||
src/kiwixwebview.h \
|
||||
src/library.h \
|
||||
src/topwidget.h \
|
||||
src/ktabwidget.h \
|
||||
src/kconstants.h
|
||||
src/kconstants.h \
|
||||
src/requestinterceptor.h \
|
||||
src/urlschemehandler.h \
|
||||
src/tabwidget.h \
|
||||
src/webview.h
|
||||
|
||||
FORMS += \
|
||||
ui/mainwindow.ui
|
||||
|
@ -3,9 +3,9 @@
|
||||
|
||||
#include "library.h"
|
||||
#include "mainwindow.h"
|
||||
#include "ktabwidget.h"
|
||||
#include "kiwixschemehandler.h"
|
||||
#include "kiwixrequestinterceptor.h"
|
||||
#include "tabwidget.h"
|
||||
#include "urlschemehandler.h"
|
||||
#include "requestinterceptor.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QErrorMessage>
|
||||
@ -23,21 +23,21 @@ public:
|
||||
|
||||
void showMessage(const QString& message);
|
||||
|
||||
KiwixSchemeHandler* getSchemeHandler() { return &schemeHandler; }
|
||||
KiwixRequestInterceptor* getRequestInterceptor() { return &requestIntercetor; }
|
||||
UrlSchemeHandler* getSchemeHandler() { return &schemeHandler; }
|
||||
RequestInterceptor* getRequestInterceptor() { return &requestIntercetor; }
|
||||
Library* getLibrary() { return &library; }
|
||||
MainWindow* getMainWindow() { return mainWindow; }
|
||||
KTabWidget* getTabWidget() { return tabWidget; }
|
||||
TabWidget* getTabWidget() { return tabWidget; }
|
||||
|
||||
|
||||
private:
|
||||
Library library;
|
||||
MainWindow* mainWindow;
|
||||
KTabWidget* tabWidget;
|
||||
TabWidget* tabWidget;
|
||||
QErrorMessage* errorDialog;
|
||||
|
||||
KiwixSchemeHandler schemeHandler;
|
||||
KiwixRequestInterceptor requestIntercetor;
|
||||
UrlSchemeHandler schemeHandler;
|
||||
RequestInterceptor requestIntercetor;
|
||||
};
|
||||
|
||||
#endif // KIWIXAPP_H
|
||||
|
@ -1,14 +0,0 @@
|
||||
#ifndef KIWIXREQUESTINTERCEPTOR_H
|
||||
#define KIWIXREQUESTINTERCEPTOR_H
|
||||
|
||||
#include <QWebEngineUrlRequestInterceptor>
|
||||
|
||||
|
||||
class KiwixRequestInterceptor : public QWebEngineUrlRequestInterceptor
|
||||
{
|
||||
public:
|
||||
KiwixRequestInterceptor();
|
||||
virtual void interceptRequest(QWebEngineUrlRequestInfo &info);
|
||||
};
|
||||
|
||||
#endif // KIWIXREQUESTINTERCEPTOR_H
|
@ -1,13 +0,0 @@
|
||||
#ifndef KIWIXSCHEMEHANDLER_H
|
||||
#define KIWIXSCHEMEHANDLER_H
|
||||
|
||||
#include <QWebEngineUrlSchemeHandler>
|
||||
|
||||
class KiwixSchemeHandler : public QWebEngineUrlSchemeHandler
|
||||
{
|
||||
public:
|
||||
KiwixSchemeHandler();
|
||||
void requestStarted(QWebEngineUrlRequestJob *request);
|
||||
};
|
||||
|
||||
#endif // KIWIXSCHEMEHANDLER_H
|
@ -1,20 +0,0 @@
|
||||
#ifndef KTABWIDGET_H
|
||||
#define KTABWIDGET_H
|
||||
|
||||
#include <QTableWidget>
|
||||
#include <memory>
|
||||
#include <kiwix/reader.h>
|
||||
#include "kiwixwebview.h"
|
||||
|
||||
class KTabWidget : public QTabWidget
|
||||
{
|
||||
public:
|
||||
KTabWidget(QWidget* parent=nullptr);
|
||||
|
||||
KiwixWebView* createNewTab(bool setCurrent);
|
||||
void openUrl(std::shared_ptr<kiwix::Reader> reader, const QUrl &url, bool newTab);
|
||||
void setTitleOf(KiwixWebView* webView, const QString& title);
|
||||
void setIconOf(KiwixWebView* webView, const QIcon& icon);
|
||||
};
|
||||
|
||||
#endif // KTABWIDGET_H
|
@ -23,7 +23,7 @@ MainWindow::~MainWindow()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
KTabWidget* MainWindow::getTabWidget()
|
||||
TabWidget* MainWindow::getTabWidget()
|
||||
{
|
||||
return ui->tabWidget;
|
||||
}
|
||||
|
@ -2,8 +2,8 @@
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include <QMainWindow>
|
||||
#include "kiwixwebview.h"
|
||||
#include "ktabwidget.h"
|
||||
#include "webview.h"
|
||||
#include "tabwidget.h"
|
||||
|
||||
namespace Ui {
|
||||
class MainWindow;
|
||||
@ -17,7 +17,7 @@ public:
|
||||
explicit MainWindow(QWidget *parent = 0);
|
||||
~MainWindow();
|
||||
|
||||
KTabWidget* getTabWidget();
|
||||
TabWidget* getTabWidget();
|
||||
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
|
@ -1,16 +1,16 @@
|
||||
#include "kiwixrequestinterceptor.h"
|
||||
#include "requestinterceptor.h"
|
||||
|
||||
#include <QWebEngineUrlRequestInfo>
|
||||
#include <QDebug>
|
||||
#include <iostream>
|
||||
|
||||
KiwixRequestInterceptor::KiwixRequestInterceptor()
|
||||
RequestInterceptor::RequestInterceptor()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void KiwixRequestInterceptor::interceptRequest(QWebEngineUrlRequestInfo &info)
|
||||
void RequestInterceptor::interceptRequest(QWebEngineUrlRequestInfo &info)
|
||||
{
|
||||
auto url = info.requestUrl();
|
||||
auto urlString = url.toString();
|
14
src/requestinterceptor.h
Normal file
14
src/requestinterceptor.h
Normal file
@ -0,0 +1,14 @@
|
||||
#ifndef REQUESTINTERCEPTOR_H
|
||||
#define REQUESTINTERCEPTOR_H
|
||||
|
||||
#include <QWebEngineUrlRequestInterceptor>
|
||||
|
||||
|
||||
class RequestInterceptor : public QWebEngineUrlRequestInterceptor
|
||||
{
|
||||
public:
|
||||
RequestInterceptor();
|
||||
virtual void interceptRequest(QWebEngineUrlRequestInfo &info);
|
||||
};
|
||||
|
||||
#endif // REQUESTINTERCEPTOR_H
|
@ -1,17 +1,17 @@
|
||||
#include "ktabwidget.h"
|
||||
#include "tabwidget.h"
|
||||
|
||||
KTabWidget::KTabWidget(QWidget *parent) :
|
||||
TabWidget::TabWidget(QWidget *parent) :
|
||||
QTabWidget(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
KiwixWebView* KTabWidget::createNewTab(bool setCurrent)
|
||||
WebView* TabWidget::createNewTab(bool setCurrent)
|
||||
{
|
||||
KiwixWebView* webView = new KiwixWebView();
|
||||
QObject::connect(webView, &KiwixWebView::titleChanged, this,
|
||||
WebView* webView = new WebView();
|
||||
QObject::connect(webView, &WebView::titleChanged, this,
|
||||
[=](const QString& str) { setTitleOf(webView, str); });
|
||||
QObject::connect(webView, &KiwixWebView::iconChanged, this,
|
||||
QObject::connect(webView, &WebView::iconChanged, this,
|
||||
[=](const QIcon& icon) { setIconOf(webView, icon); });
|
||||
// Ownership of webview is passed to the tabWidget
|
||||
addTab(webView, "");
|
||||
@ -21,16 +21,16 @@ KiwixWebView* KTabWidget::createNewTab(bool setCurrent)
|
||||
return webView;
|
||||
}
|
||||
|
||||
void KTabWidget::openUrl(std::shared_ptr<kiwix::Reader> reader, const QUrl& url, bool newTab)
|
||||
void TabWidget::openUrl(std::shared_ptr<kiwix::Reader> reader, const QUrl& url, bool newTab)
|
||||
{
|
||||
KiwixWebView* webView = nullptr;
|
||||
WebView* webView = nullptr;
|
||||
if (newTab || !currentWidget()) {
|
||||
webView = createNewTab(true);
|
||||
}
|
||||
webView->setUrl(url);
|
||||
}
|
||||
|
||||
void KTabWidget::setTitleOf(KiwixWebView* webView, const QString& title)
|
||||
void TabWidget::setTitleOf(WebView* webView, const QString& title)
|
||||
{
|
||||
if (title.startsWith("zim://")) {
|
||||
auto url = QUrl(title);
|
||||
@ -40,7 +40,7 @@ void KTabWidget::setTitleOf(KiwixWebView* webView, const QString& title)
|
||||
}
|
||||
}
|
||||
|
||||
void KTabWidget::setIconOf(KiwixWebView *webView, const QIcon &icon)
|
||||
void TabWidget::setIconOf(WebView *webView, const QIcon &icon)
|
||||
{
|
||||
setTabIcon(indexOf(webView), icon);
|
||||
}
|
20
src/tabwidget.h
Normal file
20
src/tabwidget.h
Normal file
@ -0,0 +1,20 @@
|
||||
#ifndef TABWIDGET_H
|
||||
#define TABWIDGET_H
|
||||
|
||||
#include <QTableWidget>
|
||||
#include <memory>
|
||||
#include <kiwix/reader.h>
|
||||
#include "webview.h"
|
||||
|
||||
class TabWidget : public QTabWidget
|
||||
{
|
||||
public:
|
||||
TabWidget(QWidget* parent=nullptr);
|
||||
|
||||
WebView* createNewTab(bool setCurrent);
|
||||
void openUrl(std::shared_ptr<kiwix::Reader> reader, const QUrl &url, bool newTab);
|
||||
void setTitleOf(WebView* webView, const QString& title);
|
||||
void setIconOf(WebView* webView, const QIcon& icon);
|
||||
};
|
||||
|
||||
#endif // TABWIDGET_H
|
@ -1,19 +1,19 @@
|
||||
#include "kiwixapp.h"
|
||||
#include "kiwixschemehandler.h"
|
||||
#include "urlschemehandler.h"
|
||||
#include "blobbuffer.h"
|
||||
#include <QDebug>
|
||||
#include <QWebEngineUrlRequestJob>
|
||||
#include <QTextStream>
|
||||
#include <iostream>
|
||||
|
||||
KiwixSchemeHandler::KiwixSchemeHandler()
|
||||
UrlSchemeHandler::UrlSchemeHandler()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
KiwixSchemeHandler::requestStarted(QWebEngineUrlRequestJob *request)
|
||||
UrlSchemeHandler::requestStarted(QWebEngineUrlRequestJob *request)
|
||||
{
|
||||
auto qurl = request->requestUrl();
|
||||
std::string url = qurl.path().toUtf8().constData();
|
13
src/urlschemehandler.h
Normal file
13
src/urlschemehandler.h
Normal file
@ -0,0 +1,13 @@
|
||||
#ifndef URLSCHEMEHANDLER_H
|
||||
#define URLSCHEMEHANDLER_H
|
||||
|
||||
#include <QWebEngineUrlSchemeHandler>
|
||||
|
||||
class UrlSchemeHandler : public QWebEngineUrlSchemeHandler
|
||||
{
|
||||
public:
|
||||
UrlSchemeHandler();
|
||||
void requestStarted(QWebEngineUrlRequestJob *request);
|
||||
};
|
||||
|
||||
#endif // URLSCHEMEHANDLER_H
|
@ -1,23 +1,23 @@
|
||||
#include "kiwixwebview.h"
|
||||
#include "webview.h"
|
||||
|
||||
#include <QWebEngineProfile>
|
||||
#include <iostream>
|
||||
#include "kiwixapp.h"
|
||||
|
||||
KiwixWebView::KiwixWebView(QWidget *parent)
|
||||
WebView::WebView(QWidget *parent)
|
||||
: QWebEngineView(parent)
|
||||
{
|
||||
auto profile = page()->profile();
|
||||
auto app = KiwixApp::instance();
|
||||
profile->installUrlSchemeHandler("zim", app->getSchemeHandler());
|
||||
profile->setRequestInterceptor(app->getRequestInterceptor());
|
||||
QObject::connect(this, &QWebEngineView::urlChanged, this, &KiwixWebView::onUrlChanged);
|
||||
QObject::connect(this, &QWebEngineView::urlChanged, this, &WebView::onUrlChanged);
|
||||
}
|
||||
|
||||
KiwixWebView::~KiwixWebView()
|
||||
WebView::~WebView()
|
||||
{}
|
||||
|
||||
QWebEngineView* KiwixWebView::createWindow(QWebEnginePage::WebWindowType type)
|
||||
QWebEngineView* WebView::createWindow(QWebEnginePage::WebWindowType type)
|
||||
{
|
||||
if ( type==QWebEnginePage::WebBrowserBackgroundTab
|
||||
|| type==QWebEnginePage::WebBrowserTab )
|
||||
@ -28,7 +28,7 @@ QWebEngineView* KiwixWebView::createWindow(QWebEnginePage::WebWindowType type)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void KiwixWebView::onUrlChanged(const QUrl& url) {
|
||||
void WebView::onUrlChanged(const QUrl& url) {
|
||||
if (currentHost != url.host() ) {
|
||||
currentHost = url.host();
|
||||
auto app = KiwixApp::instance();
|
@ -1,19 +1,19 @@
|
||||
#ifndef KIWIXWEBVIEW_H
|
||||
#define KIWIXWEBVIEW_H
|
||||
#ifndef WEBVIEW_H
|
||||
#define WEBVIEW_H
|
||||
|
||||
#include <QWebEngineView>
|
||||
#include <QIcon>
|
||||
|
||||
#include <kiwix/reader.h>
|
||||
|
||||
class KiwixWebView : public QWebEngineView
|
||||
class WebView : public QWebEngineView
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(const QIcon icon READ icon NOTIFY iconChanged);
|
||||
|
||||
public:
|
||||
KiwixWebView(QWidget *parent = Q_NULLPTR);
|
||||
virtual ~KiwixWebView();
|
||||
WebView(QWidget *parent = Q_NULLPTR);
|
||||
virtual ~WebView();
|
||||
|
||||
const QIcon &icon() { return _icon; }
|
||||
|
||||
@ -29,4 +29,4 @@ protected:
|
||||
QIcon _icon;
|
||||
};
|
||||
|
||||
#endif // KIWIXWEBVIEW_H
|
||||
#endif // WEBVIEW_H
|
@ -19,7 +19,7 @@
|
||||
<widget class="QWidget" name="centralWidget">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="KTabWidget" name="tabWidget">
|
||||
<widget class="TabWidget" name="tabWidget">
|
||||
<property name="tabShape">
|
||||
<enum>QTabWidget::Rounded</enum>
|
||||
</property>
|
||||
@ -51,9 +51,9 @@
|
||||
<header>src/topwidget.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>KTabWidget</class>
|
||||
<class>TabWidget</class>
|
||||
<extends>QTabWidget</extends>
|
||||
<header>src/ktabwidget.h</header>
|
||||
<header>src/tabwidget.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
|
Loading…
x
Reference in New Issue
Block a user