From ce06956d314dc8d7080ba96b76f4ee8ad851912a Mon Sep 17 00:00:00 2001 From: aqua Date: Wed, 17 Aug 2022 22:48:01 +0300 Subject: Show main window - added Task Manager, showing all plugins, windows and view --- 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 ++++++++++++++++++++++++++++++++++++++++ 6 files changed, 578 insertions(+) create mode 100644 src/mainwindow/rekonqwindow.cpp create mode 100644 src/mainwindow/rekonqwindow.h create mode 100644 src/mainwindow/rekonqwindow.ui create mode 100644 src/mainwindow/taskmanager.cpp create mode 100644 src/mainwindow/taskmanager.h create mode 100644 src/mainwindow/taskmanager.ui (limited to 'src/mainwindow') diff --git a/src/mainwindow/rekonqwindow.cpp b/src/mainwindow/rekonqwindow.cpp new file mode 100644 index 00000000..d912bf2a --- /dev/null +++ b/src/mainwindow/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 "../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 new file mode 100644 index 00000000..73d58c04 --- /dev/null +++ b/src/mainwindow/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 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 new file mode 100644 index 00000000..9df36cf2 --- /dev/null +++ b/src/mainwindow/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/mainwindow/taskmanager.cpp b/src/mainwindow/taskmanager.cpp new file mode 100644 index 00000000..9025f461 --- /dev/null +++ b/src/mainwindow/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/mainwindow/taskmanager.h b/src/mainwindow/taskmanager.h new file mode 100644 index 00000000..073464b9 --- /dev/null +++ b/src/mainwindow/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/mainwindow/taskmanager.ui b/src/mainwindow/taskmanager.ui new file mode 100644 index 00000000..8242e43c --- /dev/null +++ b/src/mainwindow/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