From a7465aa35b4efd3bfc4bbd9be4d1572d25a05bb2 Mon Sep 17 00:00:00 2001 From: aqua Date: Sat, 27 Aug 2022 15:27:37 +0300 Subject: Rename rView to RekonqView - move rview.hpp to include/ - move src/mainwindow/* to src/ --- CMakeLists.txt | 3 +- include/rsettings.hpp | 32 +++++++ include/rview.hpp | 36 ++++++++ plugins/webengine/CMakeLists.txt | 2 +- plugins/webengine/WebEngine.json | 2 +- plugins/webengine/webengineplugin.cpp | 4 +- plugins/webengine/webengineplugin.hpp | 3 +- plugins/webengine/webview.cpp | 24 ++++- plugins/webengine/webview.h | 10 +- src/CMakeLists.txt | 6 +- src/application.cpp | 2 +- src/application.hpp | 10 +- src/application_instance.cpp | 2 +- src/mainwindow/rekonqwindow.cpp | 161 -------------------------------- src/mainwindow/rekonqwindow.h | 65 ------------- src/mainwindow/rekonqwindow.ui | 91 ------------------ src/mainwindow/taskmanager.cpp | 62 ------------- src/mainwindow/taskmanager.h | 31 ------- src/mainwindow/taskmanager.ui | 168 ---------------------------------- src/plugins/rplugininterface.hpp | 8 +- src/plugins/rview.hpp | 27 ------ src/rekonqwindow.cpp | 161 ++++++++++++++++++++++++++++++++ src/rekonqwindow.h | 65 +++++++++++++ src/rekonqwindow.ui | 91 ++++++++++++++++++ src/taskmanager.cpp | 62 +++++++++++++ src/taskmanager.h | 31 +++++++ src/taskmanager.ui | 168 ++++++++++++++++++++++++++++++++++ 27 files changed, 700 insertions(+), 627 deletions(-) create mode 100644 include/rsettings.hpp create mode 100644 include/rview.hpp delete mode 100644 src/mainwindow/rekonqwindow.cpp delete mode 100644 src/mainwindow/rekonqwindow.h delete mode 100644 src/mainwindow/rekonqwindow.ui delete mode 100644 src/mainwindow/taskmanager.cpp delete mode 100644 src/mainwindow/taskmanager.h delete mode 100644 src/mainwindow/taskmanager.ui delete mode 100644 src/plugins/rview.hpp create mode 100644 src/rekonqwindow.cpp create mode 100644 src/rekonqwindow.h create mode 100644 src/rekonqwindow.ui create mode 100644 src/taskmanager.cpp create mode 100644 src/taskmanager.h create mode 100644 src/taskmanager.ui diff --git a/CMakeLists.txt b/CMakeLists.txt index 1e582d88..154e39ba 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -110,7 +110,8 @@ feature_summary(WHAT ALL) add_subdirectory(plugins/webengine) add_subdirectory(src) -add_executable(rekonq ${rekonq_SRCS}) +add_executable(rekonq ${rekonq_SRCS} + include/rsettings.hpp include/rview.hpp) target_include_directories(rekonq PRIVATE src) target_link_libraries(rekonq Qt6::Widgets SingleApplication::SingleApplication diff --git a/include/rsettings.hpp b/include/rsettings.hpp new file mode 100644 index 00000000..2d90fe3b --- /dev/null +++ b/include/rsettings.hpp @@ -0,0 +1,32 @@ +/* ============================================================ + * The rekonq project + * ============================================================ + * SPDX-License-Identifier: GPL-3.0-only + * Copyright (C) 2022 aqua + * ============================================================ + * Description: rekonq settings interface + * ============================================================ */ + +#pragma once + +#include +#include + +class RekonqSettings : public QObject { + Q_OBJECT + +public: + explicit RekonqSettings(QObject *parent = nullptr) : QObject(parent) {} + virtual ~RekonqSettings() = default; + + virtual void beginGroup(const QString &prefix) = 0; + virtual void endGroup() = 0; + + virtual void setValue(const QString &key, const QVariant &value) = 0; + [[nodiscard]] virtual QVariant value(const QString &key, const QVariant &defaultValue = QVariant()) const = 0; + + [[nodiscard]] virtual QString filePath() const = 0; + +signals: + void changed(QString, QVariant); +}; diff --git a/include/rview.hpp b/include/rview.hpp new file mode 100644 index 00000000..46cba67c --- /dev/null +++ b/include/rview.hpp @@ -0,0 +1,36 @@ +/* ============================================================ + * The rekonq project + * ============================================================ + * SPDX-License-Identifier: GPL-3.0-only + * Copyright (C) 2022 aqua + * ============================================================ + * Description: rekonq View interface + * ============================================================ */ + +#pragma once + +#include +#include + +class RekonqView : public QWidget { + Q_OBJECT + +public: + explicit RekonqView(const QUrl & = QUrl(), QWidget *parent = nullptr) : QWidget(parent) {} + + virtual void load(const QUrl &url) = 0; + [[nodiscard]] virtual int progress() const = 0; + + [[nodiscard]] virtual QIcon icon() const = 0; + [[nodiscard]] virtual QString title() const = 0; + [[nodiscard]] virtual QUrl url() const = 0; + +signals: + void loadStarted(); + void loadProgress(int); + void loadFinished(); + + void iconChanged(const QIcon &); + void titleChanged(const QString &); + void urlChanged(const QUrl &); +}; diff --git a/plugins/webengine/CMakeLists.txt b/plugins/webengine/CMakeLists.txt index f49d9c7c..c1f8145d 100644 --- a/plugins/webengine/CMakeLists.txt +++ b/plugins/webengine/CMakeLists.txt @@ -2,7 +2,7 @@ add_library(WebEnginePlugin MODULE webengineplugin.cpp webengineplugin.hpp webview.cpp webview.h ${PROJECT_SOURCE_DIR}/src/plugins/rplugininterface.hpp - ${PROJECT_SOURCE_DIR}/src/plugins/rview.hpp + ${PROJECT_SOURCE_DIR}/include/rview.hpp ) target_include_directories(WebEnginePlugin PRIVATE ${PROJECT_SOURCE_DIR}/src/plugins) target_link_libraries(WebEnginePlugin PUBLIC Qt6::Core Qt6::WebEngineWidgets) diff --git a/plugins/webengine/WebEngine.json b/plugins/webengine/WebEngine.json index 03e2112c..8f197186 100644 --- a/plugins/webengine/WebEngine.json +++ b/plugins/webengine/WebEngine.json @@ -1,4 +1,4 @@ { "name": "WebEngine", - "schemes": [ "file", "http", "https" ] + "schemes": [ "about", "file", "http", "https" ] } diff --git a/plugins/webengine/webengineplugin.cpp b/plugins/webengine/webengineplugin.cpp index cf6811dc..0c3f2dcd 100644 --- a/plugins/webengine/webengineplugin.cpp +++ b/plugins/webengine/webengineplugin.cpp @@ -10,4 +10,6 @@ #include "webengineplugin.hpp" #include "webview.h" -rView *WebEnginePlugin::view(const QUrl &url) { return new WebView(url, nullptr); } +void WebEnginePlugin::init(RekonqSettings *) {} + +RekonqView *WebEnginePlugin::view(const QUrl &url) { return new WebView(url, nullptr); } diff --git a/plugins/webengine/webengineplugin.hpp b/plugins/webengine/webengineplugin.hpp index 3ee63ff8..dcbc2db8 100644 --- a/plugins/webengine/webengineplugin.hpp +++ b/plugins/webengine/webengineplugin.hpp @@ -19,5 +19,6 @@ class WebEnginePlugin final : public RekonqPluginInterface { public: WebEnginePlugin() = default; - rView *view(const QUrl &url) override; + void init(RekonqSettings *settings) override; + RekonqView *view(const QUrl &url) override; }; diff --git a/plugins/webengine/webview.cpp b/plugins/webengine/webview.cpp index fab941a9..fc2e4642 100644 --- a/plugins/webengine/webview.cpp +++ b/plugins/webengine/webview.cpp @@ -11,7 +11,7 @@ #include #include -WebView::WebView(const QUrl &url, QWidget *parent) : rView(url, parent), view(new QWebEngineView(this)) +WebView::WebView(const QUrl &url, QWidget *parent) : RekonqView(url, parent), view(new QWebEngineView(this)) { auto *layout = new QVBoxLayout; layout->setContentsMargins(0, 0, 0, 0); @@ -19,8 +19,28 @@ WebView::WebView(const QUrl &url, QWidget *parent) : rView(url, parent), view(ne setLayout(layout); connect(view, &QWebEngineView::iconChanged, this, [this](const QIcon &icon) { emit iconChanged(icon); }); - connect(view, &QWebEngineView::urlChanged, this, [this](const QUrl &url) { emit urlChanged(url); }); + connect(view, &QWebEngineView::urlChanged, this, [this](const QUrl &u) { emit urlChanged(u); }); connect(view, &QWebEngineView::titleChanged, this, [this](const QString &title) { emit titleChanged(title); }); + + // load progress + connect(view, &QWebEngineView::loadStarted, this, [this]() { + m_loadProgress = 0; + emit loadStarted(); + }); + connect(view, &QWebEngineView::loadProgress, this, [this](int progress) { + m_loadProgress = progress; + emit loadProgress(progress); + }); + connect(view, &QWebEngineView::loadFinished, this, [this]() { + m_loadProgress = 100; + emit loadFinished(); + }); + view->load(url); } + +void WebView::load(const QUrl &url) { view->load(url); } + +QUrl WebView::url() const { return view->url(); } QString WebView::title() const { return view->title(); } +QIcon WebView::icon() const { return view->icon(); } diff --git a/plugins/webengine/webview.h b/plugins/webengine/webview.h index 5bb90696..103b98b3 100644 --- a/plugins/webengine/webview.h +++ b/plugins/webengine/webview.h @@ -13,15 +13,21 @@ class QWebEngineView; -class WebView final : public rView { +class WebView final : public RekonqView { Q_OBJECT public: explicit WebView(const QUrl &url = QUrl(), QWidget *parent = nullptr); ~WebView() final = default; - QString title() const override; + void load(const QUrl &url) override; + [[nodiscard]] int progress() const override { return m_loadProgress; } + + [[nodiscard]] QUrl url() const override; + [[nodiscard]] QString title() const override; + [[nodiscard]] QIcon icon() const override; private: QWebEngineView *view; + int m_loadProgress = 0; }; diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a48bed28..6bf47516 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -10,10 +10,10 @@ set(rekonq_SRCS #---------------------------------------- main.cpp application.cpp application_instance.cpp application.hpp #---------------------------------------- - mainwindow/rekonqwindow.cpp mainwindow/rekonqwindow.h mainwindow/rekonqwindow.ui - mainwindow/taskmanager.cpp mainwindow/taskmanager.h mainwindow/taskmanager.ui + rekonqwindow.cpp rekonqwindow.h rekonqwindow.ui + taskmanager.cpp taskmanager.h taskmanager.ui #---------------------------------------- - plugins/rplugininterface.hpp plugins/rview.hpp + plugins/rplugininterface.hpp #---------------------------------------- ) list(TRANSFORM rekonq_SRCS PREPEND src/) diff --git a/src/application.cpp b/src/application.cpp index 126eb020..be4bb4fc 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -347,7 +347,7 @@ RekonqWindow *Application::newWindow() return window; } -rView *Application::newView(const QUrl &url, RekonqWindow *window) +RekonqView *Application::newView(const QUrl &url, RekonqWindow *window) { RekonqPluginInterface *interface = nullptr; for (const auto &plugin : m_plugins) diff --git a/src/application.hpp b/src/application.hpp index ce4bbfd1..7d75af3a 100644 --- a/src/application.hpp +++ b/src/application.hpp @@ -11,15 +11,15 @@ #pragma once -#include "mainwindow/rekonqwindow.h" #include "rekonq.hpp" +#include "rekonqwindow.h" #include #include #include #include // Forward Declarations -class rView; +class RekonqView; class PluginLoader; // class WebTab; @@ -27,7 +27,7 @@ class PluginLoader; typedef QList> RekonqPluginList; typedef QList> RekonqWindowList; -typedef QList> RekonqViewList; +typedef QList> RekonqViewList; // --------------------------------------------------------------------------------------------------------------- @@ -75,7 +75,7 @@ public slots: * @param instanceId if the current instance, check QCoreApplication::arguments instead of @param message * @param message the command line */ - void parseCommandLine(int instanceId, const QByteArray &message); + void parseCommandLine(quint32 instanceId, const QByteArray &message); /** * Save application's configuration @@ -95,7 +95,7 @@ public slots: // RekonqWindow *newWindow(bool withTab = true, bool PrivateBrowsingMode = false); // RekonqWindow *newWindow(WebPage *pg); RekonqWindow *newWindow(); - rView *newView(const QUrl &url = QUrl(), RekonqWindow *window = nullptr); + RekonqView *newView(const QUrl &url = QUrl(), RekonqWindow *window = nullptr); // void createWebAppShortcut(const QString & urlString = QString(), const QString & titleString = QString()); diff --git a/src/application_instance.cpp b/src/application_instance.cpp index 42c77dc1..53dd9885 100644 --- a/src/application_instance.cpp +++ b/src/application_instance.cpp @@ -13,7 +13,7 @@ static const char *description = "A lightweight Web Browser based on Qt WebEngine"; -void Application::parseCommandLine(int instanceId, const QByteArray &message) +void Application::parseCommandLine(quint32 instanceId, const QByteArray &message) { // Initialize command line args QCommandLineParser parser; diff --git a/src/mainwindow/rekonqwindow.cpp b/src/mainwindow/rekonqwindow.cpp deleted file mode 100644 index d912bf2a..00000000 --- a/src/mainwindow/rekonqwindow.cpp +++ /dev/null @@ -1,161 +0,0 @@ -/* ============================================================ - * The rekonq project - * ============================================================ - * SPDX-License-Identifier: GPL-2.0-or-later - * Copyright (C) 2013 by Andrea Diamantini - * SPDX-License-Identifier: GPL-3.0-only - * Copyright (C) 2022 aqua - * ============================================================ - * Description: Main Window class - * ============================================================ */ - -#include "rekonqwindow.h" -#include "../plugins/rview.hpp" -#include "application.hpp" -#include "taskmanager.h" -#include "ui_rekonqwindow.h" - -RekonqWindow::RekonqWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::RekonqWindow) -{ - ui->setupUi(this); - connect(ui->actionTaskManager, &QAction::triggered, this, [this]() { (new TaskManager(this))->show(); }); -} - -RekonqWindow::~RekonqWindow() { delete ui; } - -void RekonqWindow::addView(rView *view) -{ - const auto tabId = ui->tabWidget->addTab(view, view->title()); - connect(view, &rView::titleChanged, this, - [this, tabId](const QString &title) { ui->tabWidget->setTabText(tabId, title); }); -} - -/* -void RekonqWindow::init() -{ - setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); - - QVBoxLayout *l = new QVBoxLayout(this); - l->setMargin(0); - l->setSpacing(0); - - if (ReKonfig::showBookmarksPanel()) - showBookmarksPanel(true); - - if (ReKonfig::showHistoryPanel()) - showHistoryPanel(true); - - _splitter->addWidget(_tabWidget); - _tabWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); - - l->addWidget(_splitter); - - // fix focus handling - setFocusProxy(_tabWidget); - - // signals - connect(_tabWidget, SIGNAL(closeWindow()), this, SLOT(close())); - connect(_tabWidget, SIGNAL(windowTitleChanged(QString)), this, SLOT(setWindowTitle(QString))); -} - -// -------------------------------------------------------------------------------------------------- - - -TabWidget *RekonqWindow::tabWidget() -{ - return _tabWidget; -} - - -TabBar *RekonqWindow::tabBar() -{ - return _tabWidget->tabBar(); -} - - -WebWindow *RekonqWindow::currentWebWindow() const -{ - return _tabWidget->currentWebWindow(); -} - - -bool RekonqWindow::isPrivateBrowsingMode() -{ - return _tabWidget->isPrivateBrowsingWindowMode(); -} - - -// -------------------------------------------------------------------------------------------------- - - -void RekonqWindow::loadUrl(const KUrl &url, Rekonq::OpenType type, TabHistory *history) -{ - switch (type) - { - case Rekonq::NewWindow: - case Rekonq::NewPrivateWindow: - case Rekonq::WebApp: - rApp->loadUrl(url, type); - return; - - case Rekonq::NewTab: - case Rekonq::NewBackGroundTab: - case Rekonq::NewFocusedTab: - case Rekonq::CurrentTab: - default: - _tabWidget->loadUrl(url, type, history); - break; - }; -} - - -void RekonqWindow::showBookmarksPanel(bool on) -{ - if (on) - { - if (_bookmarksPanel.isNull()) - { - _bookmarksPanel = new BookmarksPanel(i18n("Bookmarks Panel"), this); - connect(_bookmarksPanel.data(), SIGNAL(openUrl(KUrl,Rekonq::OpenType)), this, -SLOT(loadUrl(KUrl,Rekonq::OpenType))); - - QAction *a = _tabWidget->actionByName(QL1S("show_bookmarks_panel")); - connect(_bookmarksPanel.data(), SIGNAL(visibilityChanged(bool)), a, SLOT(setChecked(bool))); - } - _splitter->insertWidget(0, _bookmarksPanel.data()); - _bookmarksPanel.data()->show(); - } - else - { - _bookmarksPanel.data()->hide(); - delete _bookmarksPanel.data(); - _bookmarksPanel.clear(); - } -} - - -void RekonqWindow::showHistoryPanel(bool on) -{ - if (on) - { - if (_historyPanel.isNull()) - { - _historyPanel = new HistoryPanel(i18n("History Panel"), this); - connect(_historyPanel.data(), SIGNAL(openUrl(KUrl,Rekonq::OpenType)), this, -SLOT(loadUrl(KUrl,Rekonq::OpenType))); - - QAction *a = _tabWidget->actionByName(QL1S("show_history_panel")); - connect(_historyPanel.data(), SIGNAL(visibilityChanged(bool)), a, SLOT(setChecked(bool))); - - } - _splitter->insertWidget(0, _historyPanel.data()); - _historyPanel.data()->show(); - } - else - { - _historyPanel.data()->hide(); - delete _historyPanel.data(); - _historyPanel.clear(); - } -} -*/ \ No newline at end of file diff --git a/src/mainwindow/rekonqwindow.h b/src/mainwindow/rekonqwindow.h deleted file mode 100644 index 73d58c04..00000000 --- a/src/mainwindow/rekonqwindow.h +++ /dev/null @@ -1,65 +0,0 @@ -/* ============================================================ - * The rekonq project - * ============================================================ - * SPDX-License-Identifier: GPL-2.0-or-later - * Copyright (C) 2013 by Andrea Diamantini - * SPDX-License-Identifier: GPL-3.0-only - * Copyright (C) 2022 aqua - * ============================================================ - * Description: Main Window class - * ============================================================ */ - -#pragma once - -#include "rekonq.hpp" -//#include "rwindow.h" -//#include "tabwidget.h" -//#include "bookmarkspanel.h" -//#include "historypanel.h" -#include -#include - -// Forward Declarations -class rView; -// class TabBar; -// class WebPage; -// class WebWindow; - -namespace Ui { -class RekonqWindow; -} - -class RekonqWindow : public QMainWindow { - Q_OBJECT - -public: - explicit RekonqWindow(QWidget *parent = nullptr); - // explicit RekonqWindow(WebPage *pg, QWidget *parent = 0); - ~RekonqWindow() override; - - // TabWidget *tabWidget(); - // TabBar *tabBar(); - // WebWindow *currentWebWindow() const; - - // bool isPrivateBrowsingMode(); - -private: - // void init(); - -public slots: - void addView(rView *view); - // void loadUrl(const KUrl &, Rekonq::OpenType type = Rekonq::CurrentTab, TabHistory *history = 0); - -private slots: - // void showBookmarksPanel(bool); - // void showHistoryPanel(bool); - -private: - Ui::RekonqWindow *ui; - // TabWidget *_tabWidget; - - QSplitter *_splitter = nullptr; - - // QWeakPointer _historyPanel; - // QWeakPointer _bookmarksPanel; -}; diff --git a/src/mainwindow/rekonqwindow.ui b/src/mainwindow/rekonqwindow.ui deleted file mode 100644 index 9df36cf2..00000000 --- a/src/mainwindow/rekonqwindow.ui +++ /dev/null @@ -1,91 +0,0 @@ - - - RekonqWindow - - - - 0 - 0 - 800 - 600 - - - - MainWindow - - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - - - - - 0 - 0 - 800 - 22 - - - - - rekonq - - - - - - - - - - - Task Manager - - - F12 - - - - - Close Window - - - - - - - actionCloseWindow - triggered() - RekonqWindow - close() - - - -1 - -1 - - - 399 - 299 - - - - - diff --git a/src/mainwindow/taskmanager.cpp b/src/mainwindow/taskmanager.cpp deleted file mode 100644 index 9025f461..00000000 --- a/src/mainwindow/taskmanager.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/* ============================================================ - * The rekonq project - * ============================================================ - * SPDX-License-Identifier: GPL-3.0-only - * Copyright (C) 2022 aqua - * ============================================================ - * Description: Task Manager - * ============================================================ */ - -#include "taskmanager.h" -#include "application.hpp" -#include "plugins/pluginloader.h" -#include "ui_taskmanager.h" - -TaskManager::TaskManager(QWidget *parent) : QDialog(parent), ui(new Ui::TaskManager) -{ - ui->setupUi(this); - ui->pluginStateBox->setVisible(false); - - auto *app = Application::instance(); - - // Plugins Tab - auto pluginList = app->pluginList(); - for (auto &plugin : pluginList) { - auto *item = new QListWidgetItem(plugin->fileName(), ui->plugins); - item->setData(Qt::UserRole, QVariant::fromValue(plugin)); - } - connect(ui->plugins, &QListWidget::itemClicked, this, &TaskManager::showPluginDetails); - connect(ui->pluginState, &QPushButton::clicked, [this](bool checked) { - auto *item = ui->plugins->currentItem(); - auto plugin = item->data(Qt::UserRole).value>(); - Q_CHECK_PTR(plugin); - - if (checked) plugin->load(); - else - plugin->unload(); - - showPluginDetails(item); - }); - - // Windows Tab - const auto windowList = app->windowList(); - for (const auto &window : windowList) ui->windows->addItem(window->windowTitle()); - - // Views Tab - const auto viewList = app->viewList(); - for (const auto &view : viewList) ui->views->addItem(view->title()); -} - -TaskManager::~TaskManager() { delete ui; } - -void TaskManager::showPluginDetails(QListWidgetItem *item) -{ - auto plugin = item->data(Qt::UserRole).value>(); - Q_CHECK_PTR(plugin); - - ui->pluginStateBox->setVisible(true); - ui->pluginState->setText(plugin->isLoaded() ? tr("Loaded") : tr("Not loaded")); - ui->pluginState->setChecked(plugin->isLoaded()); - ui->pluginError->setText(plugin->errorString()); - ui->pluginSchemes->setText(plugin->schemes().join(' ')); -} \ No newline at end of file diff --git a/src/mainwindow/taskmanager.h b/src/mainwindow/taskmanager.h deleted file mode 100644 index 073464b9..00000000 --- a/src/mainwindow/taskmanager.h +++ /dev/null @@ -1,31 +0,0 @@ -/* ============================================================ - * The rekonq project - * ============================================================ - * SPDX-License-Identifier: GPL-3.0-only - * Copyright (C) 2022 aqua - * ============================================================ - * Description: Task Manager - * ============================================================ */ - -#pragma once - -#include - -namespace Ui { -class TaskManager; -} - -class QListWidgetItem; -class TaskManager : public QDialog { - Q_OBJECT - -public: - explicit TaskManager(QWidget *parent = nullptr); - ~TaskManager() override; - -private slots: - void showPluginDetails(QListWidgetItem *item); - -private: - Ui::TaskManager *ui; -}; diff --git a/src/mainwindow/taskmanager.ui b/src/mainwindow/taskmanager.ui deleted file mode 100644 index 8242e43c..00000000 --- a/src/mainwindow/taskmanager.ui +++ /dev/null @@ -1,168 +0,0 @@ - - - TaskManager - - - - 0 - 0 - 800 - 600 - - - - Task Manager - - - - - - 0 - - - - Plugins - - - - - - QAbstractItemView::NoEditTriggers - - - QAbstractItemView::SelectRows - - - - - - - - 200 - 0 - - - - Plugin State - - - - - - State - - - - - - - - - - true - - - - - - - Error - - - - - - - - - - - - - - Schemes - - - - - - - - - - - - - - - - - - Windows - - - - - - - - - - Views - - - - - - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Close - - - - - - - - - buttonBox - accepted() - TaskManager - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - TaskManager - reject() - - - 316 - 260 - - - 286 - 274 - - - - - diff --git a/src/plugins/rplugininterface.hpp b/src/plugins/rplugininterface.hpp index 16186591..e45f2422 100644 --- a/src/plugins/rplugininterface.hpp +++ b/src/plugins/rplugininterface.hpp @@ -9,15 +9,17 @@ #pragma once -#include "rview.hpp" #include +#include +#include class RekonqPluginInterface : public QObject { Q_OBJECT public: - virtual rView *view(const QUrl &url) = 0; + virtual void init(RekonqSettings *settings) = 0; + virtual RekonqView *view(const QUrl &url) = 0; }; -#define RekonqPluginInterface_iid "rekonq.3.RekongPluginInterface" +#define RekonqPluginInterface_iid "net.rekonq.3.RekonqPluginInterface/1" Q_DECLARE_INTERFACE(RekonqPluginInterface, RekonqPluginInterface_iid) diff --git a/src/plugins/rview.hpp b/src/plugins/rview.hpp deleted file mode 100644 index 6f0652d5..00000000 --- a/src/plugins/rview.hpp +++ /dev/null @@ -1,27 +0,0 @@ -/* ============================================================ - * The rekonq project - * ============================================================ - * SPDX-License-Identifier: GPL-3.0-only - * Copyright (C) 2022 aqua - * ============================================================ - * Description: View Interface - * ============================================================ */ - -#pragma once - -#include -#include - -class rView : public QWidget { - Q_OBJECT - -public: - explicit rView(const QUrl &url = QUrl(), QWidget *parent = nullptr) : QWidget(parent) {} - - [[nodiscard]] virtual QString title() const = 0; - -signals: - void iconChanged(const QIcon &); - void urlChanged(const QUrl &); - void titleChanged(const QString &); -}; diff --git a/src/rekonqwindow.cpp b/src/rekonqwindow.cpp new file mode 100644 index 00000000..b1380154 --- /dev/null +++ b/src/rekonqwindow.cpp @@ -0,0 +1,161 @@ +/* ============================================================ + * The rekonq project + * ============================================================ + * SPDX-License-Identifier: GPL-2.0-or-later + * Copyright (C) 2013 by Andrea Diamantini + * SPDX-License-Identifier: GPL-3.0-only + * Copyright (C) 2022 aqua + * ============================================================ + * Description: Main Window class + * ============================================================ */ + +#include "rekonqwindow.h" +#include "application.hpp" +#include "taskmanager.h" +#include "ui_rekonqwindow.h" +#include + +RekonqWindow::RekonqWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::RekonqWindow) +{ + ui->setupUi(this); + connect(ui->actionTaskManager, &QAction::triggered, this, [this]() { (new TaskManager(this))->show(); }); +} + +RekonqWindow::~RekonqWindow() { delete ui; } + +void RekonqWindow::addView(RekonqView *view) +{ + const auto tabId = ui->tabWidget->addTab(view, view->title()); + connect(view, &RekonqView::titleChanged, this, + [this, tabId](const QString &title) { ui->tabWidget->setTabText(tabId, title); }); +} + +/* +void RekonqWindow::init() +{ + setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + + QVBoxLayout *l = new QVBoxLayout(this); + l->setMargin(0); + l->setSpacing(0); + + if (ReKonfig::showBookmarksPanel()) + showBookmarksPanel(true); + + if (ReKonfig::showHistoryPanel()) + showHistoryPanel(true); + + _splitter->addWidget(_tabWidget); + _tabWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + + l->addWidget(_splitter); + + // fix focus handling + setFocusProxy(_tabWidget); + + // signals + connect(_tabWidget, SIGNAL(closeWindow()), this, SLOT(close())); + connect(_tabWidget, SIGNAL(windowTitleChanged(QString)), this, SLOT(setWindowTitle(QString))); +} + +// -------------------------------------------------------------------------------------------------- + + +TabWidget *RekonqWindow::tabWidget() +{ + return _tabWidget; +} + + +TabBar *RekonqWindow::tabBar() +{ + return _tabWidget->tabBar(); +} + + +WebWindow *RekonqWindow::currentWebWindow() const +{ + return _tabWidget->currentWebWindow(); +} + + +bool RekonqWindow::isPrivateBrowsingMode() +{ + return _tabWidget->isPrivateBrowsingWindowMode(); +} + + +// -------------------------------------------------------------------------------------------------- + + +void RekonqWindow::loadUrl(const KUrl &url, Rekonq::OpenType type, TabHistory *history) +{ + switch (type) + { + case Rekonq::NewWindow: + case Rekonq::NewPrivateWindow: + case Rekonq::WebApp: + rApp->loadUrl(url, type); + return; + + case Rekonq::NewTab: + case Rekonq::NewBackGroundTab: + case Rekonq::NewFocusedTab: + case Rekonq::CurrentTab: + default: + _tabWidget->loadUrl(url, type, history); + break; + }; +} + + +void RekonqWindow::showBookmarksPanel(bool on) +{ + if (on) + { + if (_bookmarksPanel.isNull()) + { + _bookmarksPanel = new BookmarksPanel(i18n("Bookmarks Panel"), this); + connect(_bookmarksPanel.data(), SIGNAL(openUrl(KUrl,Rekonq::OpenType)), this, +SLOT(loadUrl(KUrl,Rekonq::OpenType))); + + QAction *a = _tabWidget->actionByName(QL1S("show_bookmarks_panel")); + connect(_bookmarksPanel.data(), SIGNAL(visibilityChanged(bool)), a, SLOT(setChecked(bool))); + } + _splitter->insertWidget(0, _bookmarksPanel.data()); + _bookmarksPanel.data()->show(); + } + else + { + _bookmarksPanel.data()->hide(); + delete _bookmarksPanel.data(); + _bookmarksPanel.clear(); + } +} + + +void RekonqWindow::showHistoryPanel(bool on) +{ + if (on) + { + if (_historyPanel.isNull()) + { + _historyPanel = new HistoryPanel(i18n("History Panel"), this); + connect(_historyPanel.data(), SIGNAL(openUrl(KUrl,Rekonq::OpenType)), this, +SLOT(loadUrl(KUrl,Rekonq::OpenType))); + + QAction *a = _tabWidget->actionByName(QL1S("show_history_panel")); + connect(_historyPanel.data(), SIGNAL(visibilityChanged(bool)), a, SLOT(setChecked(bool))); + + } + _splitter->insertWidget(0, _historyPanel.data()); + _historyPanel.data()->show(); + } + else + { + _historyPanel.data()->hide(); + delete _historyPanel.data(); + _historyPanel.clear(); + } +} +*/ diff --git a/src/rekonqwindow.h b/src/rekonqwindow.h new file mode 100644 index 00000000..e6316819 --- /dev/null +++ b/src/rekonqwindow.h @@ -0,0 +1,65 @@ +/* ============================================================ + * The rekonq project + * ============================================================ + * SPDX-License-Identifier: GPL-2.0-or-later + * Copyright (C) 2013 by Andrea Diamantini + * SPDX-License-Identifier: GPL-3.0-only + * Copyright (C) 2022 aqua + * ============================================================ + * Description: Main Window class + * ============================================================ */ + +#pragma once + +#include "rekonq.hpp" +//#include "rwindow.h" +//#include "tabwidget.h" +//#include "bookmarkspanel.h" +//#include "historypanel.h" +#include +#include + +// Forward Declarations +class RekonqView; +// class TabBar; +// class WebPage; +// class WebWindow; + +namespace Ui { +class RekonqWindow; +} + +class RekonqWindow : public QMainWindow { + Q_OBJECT + +public: + explicit RekonqWindow(QWidget *parent = nullptr); + // explicit RekonqWindow(WebPage *pg, QWidget *parent = 0); + ~RekonqWindow() override; + + // TabWidget *tabWidget(); + // TabBar *tabBar(); + // WebWindow *currentWebWindow() const; + + // bool isPrivateBrowsingMode(); + +private: + // void init(); + +public slots: + void addView(RekonqView *view); + // void loadUrl(const KUrl &, Rekonq::OpenType type = Rekonq::CurrentTab, TabHistory *history = 0); + +private slots: + // void showBookmarksPanel(bool); + // void showHistoryPanel(bool); + +private: + Ui::RekonqWindow *ui; + // TabWidget *_tabWidget; + + QSplitter *_splitter = nullptr; + + // QWeakPointer _historyPanel; + // QWeakPointer _bookmarksPanel; +}; diff --git a/src/rekonqwindow.ui b/src/rekonqwindow.ui new file mode 100644 index 00000000..9df36cf2 --- /dev/null +++ b/src/rekonqwindow.ui @@ -0,0 +1,91 @@ + + + RekonqWindow + + + + 0 + 0 + 800 + 600 + + + + MainWindow + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + + + 0 + 0 + 800 + 22 + + + + + rekonq + + + + + + + + + + + Task Manager + + + F12 + + + + + Close Window + + + + + + + actionCloseWindow + triggered() + RekonqWindow + close() + + + -1 + -1 + + + 399 + 299 + + + + + diff --git a/src/taskmanager.cpp b/src/taskmanager.cpp new file mode 100644 index 00000000..9025f461 --- /dev/null +++ b/src/taskmanager.cpp @@ -0,0 +1,62 @@ +/* ============================================================ + * The rekonq project + * ============================================================ + * SPDX-License-Identifier: GPL-3.0-only + * Copyright (C) 2022 aqua + * ============================================================ + * Description: Task Manager + * ============================================================ */ + +#include "taskmanager.h" +#include "application.hpp" +#include "plugins/pluginloader.h" +#include "ui_taskmanager.h" + +TaskManager::TaskManager(QWidget *parent) : QDialog(parent), ui(new Ui::TaskManager) +{ + ui->setupUi(this); + ui->pluginStateBox->setVisible(false); + + auto *app = Application::instance(); + + // Plugins Tab + auto pluginList = app->pluginList(); + for (auto &plugin : pluginList) { + auto *item = new QListWidgetItem(plugin->fileName(), ui->plugins); + item->setData(Qt::UserRole, QVariant::fromValue(plugin)); + } + connect(ui->plugins, &QListWidget::itemClicked, this, &TaskManager::showPluginDetails); + connect(ui->pluginState, &QPushButton::clicked, [this](bool checked) { + auto *item = ui->plugins->currentItem(); + auto plugin = item->data(Qt::UserRole).value>(); + Q_CHECK_PTR(plugin); + + if (checked) plugin->load(); + else + plugin->unload(); + + showPluginDetails(item); + }); + + // Windows Tab + const auto windowList = app->windowList(); + for (const auto &window : windowList) ui->windows->addItem(window->windowTitle()); + + // Views Tab + const auto viewList = app->viewList(); + for (const auto &view : viewList) ui->views->addItem(view->title()); +} + +TaskManager::~TaskManager() { delete ui; } + +void TaskManager::showPluginDetails(QListWidgetItem *item) +{ + auto plugin = item->data(Qt::UserRole).value>(); + Q_CHECK_PTR(plugin); + + ui->pluginStateBox->setVisible(true); + ui->pluginState->setText(plugin->isLoaded() ? tr("Loaded") : tr("Not loaded")); + ui->pluginState->setChecked(plugin->isLoaded()); + ui->pluginError->setText(plugin->errorString()); + ui->pluginSchemes->setText(plugin->schemes().join(' ')); +} \ No newline at end of file diff --git a/src/taskmanager.h b/src/taskmanager.h new file mode 100644 index 00000000..073464b9 --- /dev/null +++ b/src/taskmanager.h @@ -0,0 +1,31 @@ +/* ============================================================ + * The rekonq project + * ============================================================ + * SPDX-License-Identifier: GPL-3.0-only + * Copyright (C) 2022 aqua + * ============================================================ + * Description: Task Manager + * ============================================================ */ + +#pragma once + +#include + +namespace Ui { +class TaskManager; +} + +class QListWidgetItem; +class TaskManager : public QDialog { + Q_OBJECT + +public: + explicit TaskManager(QWidget *parent = nullptr); + ~TaskManager() override; + +private slots: + void showPluginDetails(QListWidgetItem *item); + +private: + Ui::TaskManager *ui; +}; diff --git a/src/taskmanager.ui b/src/taskmanager.ui new file mode 100644 index 00000000..8242e43c --- /dev/null +++ b/src/taskmanager.ui @@ -0,0 +1,168 @@ + + + TaskManager + + + + 0 + 0 + 800 + 600 + + + + Task Manager + + + + + + 0 + + + + Plugins + + + + + + QAbstractItemView::NoEditTriggers + + + QAbstractItemView::SelectRows + + + + + + + + 200 + 0 + + + + Plugin State + + + + + + State + + + + + + + + + + true + + + + + + + Error + + + + + + + + + + + + + + Schemes + + + + + + + + + + + + + + + + + + Windows + + + + + + + + + + Views + + + + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Close + + + + + + + + + buttonBox + accepted() + TaskManager + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + TaskManager + reject() + + + 316 + 260 + + + 286 + 274 + + + + + -- cgit v1.2.1