diff options
Diffstat (limited to 'src/mainwindow')
-rw-r--r-- | src/mainwindow/rekonqwindow.cpp | 161 | ||||
-rw-r--r-- | src/mainwindow/rekonqwindow.h | 65 | ||||
-rw-r--r-- | src/mainwindow/rekonqwindow.ui | 91 | ||||
-rw-r--r-- | src/mainwindow/taskmanager.cpp | 62 | ||||
-rw-r--r-- | src/mainwindow/taskmanager.h | 31 | ||||
-rw-r--r-- | src/mainwindow/taskmanager.ui | 168 |
6 files changed, 578 insertions, 0 deletions
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 <adjam7 at gmail dot com> + * SPDX-License-Identifier: GPL-3.0-only + * Copyright (C) 2022 aqua <aqua@iserlohn-fortress.net> + * ============================================================ + * 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 <adjam7 at gmail dot com> + * SPDX-License-Identifier: GPL-3.0-only + * Copyright (C) 2022 aqua <aqua@iserlohn-fortress.net> + * ============================================================ + * Description: Main Window class + * ============================================================ */ + +#pragma once + +#include "rekonq.hpp" +//#include "rwindow.h" +//#include "tabwidget.h" +//#include "bookmarkspanel.h" +//#include "historypanel.h" +#include <QMainWindow> +#include <QSplitter> + +// 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> _historyPanel; + // QWeakPointer<BookmarksPanel> _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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>RekonqWindow</class> + <widget class="QMainWindow" name="RekonqWindow"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>800</width> + <height>600</height> + </rect> + </property> + <property name="windowTitle"> + <string>MainWindow</string> + </property> + <widget class="QWidget" name="centralwidget"> + <layout class="QVBoxLayout" name="verticalLayout"> + <property name="spacing"> + <number>0</number> + </property> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item> + <widget class="QTabWidget" name="tabWidget"/> + </item> + </layout> + </widget> + <widget class="QMenuBar" name="menubar"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>800</width> + <height>22</height> + </rect> + </property> + <widget class="QMenu" name="menurekonq"> + <property name="title"> + <string>rekonq</string> + </property> + <addaction name="actionTaskManager"/> + <addaction name="separator"/> + <addaction name="actionCloseWindow"/> + </widget> + <addaction name="menurekonq"/> + </widget> + <widget class="QStatusBar" name="statusbar"/> + <action name="actionTaskManager"> + <property name="text"> + <string>Task Manager</string> + </property> + <property name="shortcut"> + <string>F12</string> + </property> + </action> + <action name="actionCloseWindow"> + <property name="text"> + <string>Close Window</string> + </property> + </action> + </widget> + <resources/> + <connections> + <connection> + <sender>actionCloseWindow</sender> + <signal>triggered()</signal> + <receiver>RekonqWindow</receiver> + <slot>close()</slot> + <hints> + <hint type="sourcelabel"> + <x>-1</x> + <y>-1</y> + </hint> + <hint type="destinationlabel"> + <x>399</x> + <y>299</y> + </hint> + </hints> + </connection> + </connections> +</ui> 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 <aqua@iserlohn-fortress.net> + * ============================================================ + * 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<QPointer<PluginLoader>>(); + 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<QPointer<PluginLoader>>(); + 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 <aqua@iserlohn-fortress.net> + * ============================================================ + * Description: Task Manager + * ============================================================ */ + +#pragma once + +#include <QDialog> + +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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>TaskManager</class> + <widget class="QDialog" name="TaskManager"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>800</width> + <height>600</height> + </rect> + </property> + <property name="windowTitle"> + <string>Task Manager</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QTabWidget" name="tabWidget"> + <property name="currentIndex"> + <number>0</number> + </property> + <widget class="QWidget" name="plugins_tab"> + <attribute name="title"> + <string>Plugins</string> + </attribute> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QListWidget" name="plugins"> + <property name="editTriggers"> + <set>QAbstractItemView::NoEditTriggers</set> + </property> + <property name="selectionBehavior"> + <enum>QAbstractItemView::SelectRows</enum> + </property> + </widget> + </item> + <item> + <widget class="QGroupBox" name="pluginStateBox"> + <property name="minimumSize"> + <size> + <width>200</width> + <height>0</height> + </size> + </property> + <property name="title"> + <string>Plugin State</string> + </property> + <layout class="QFormLayout" name="formLayout"> + <item row="0" column="0"> + <widget class="QLabel" name="pluginState_label"> + <property name="text"> + <string>State</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QPushButton" name="pluginState"> + <property name="text"> + <string/> + </property> + <property name="checkable"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="pluginError_label"> + <property name="text"> + <string>Error</string> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QLabel" name="pluginError"> + <property name="text"> + <string/> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="pluginSchemes_label"> + <property name="text"> + <string>Schemes</string> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QLabel" name="pluginSchemes"> + <property name="text"> + <string/> + </property> + </widget> + </item> + </layout> + </widget> + </item> + </layout> + </widget> + <widget class="QWidget" name="windows_tab"> + <attribute name="title"> + <string>Windows</string> + </attribute> + <layout class="QVBoxLayout" name="verticalLayout_3"> + <item> + <widget class="QListWidget" name="windows"/> + </item> + </layout> + </widget> + <widget class="QWidget" name="views_tab"> + <attribute name="title"> + <string>Views</string> + </attribute> + <layout class="QVBoxLayout" name="verticalLayout_4"> + <item> + <widget class="QListWidget" name="views"/> + </item> + </layout> + </widget> + </widget> + </item> + <item> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="standardButtons"> + <set>QDialogButtonBox::Close</set> + </property> + </widget> + </item> + </layout> + </widget> + <resources/> + <connections> + <connection> + <sender>buttonBox</sender> + <signal>accepted()</signal> + <receiver>TaskManager</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel"> + <x>248</x> + <y>254</y> + </hint> + <hint type="destinationlabel"> + <x>157</x> + <y>274</y> + </hint> + </hints> + </connection> + <connection> + <sender>buttonBox</sender> + <signal>rejected()</signal> + <receiver>TaskManager</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel"> + <x>316</x> + <y>260</y> + </hint> + <hint type="destinationlabel"> + <x>286</x> + <y>274</y> + </hint> + </hints> + </connection> + </connections> +</ui> |