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 --- plugins/webengine/webview.cpp | 1 + plugins/webengine/webview.h | 2 + src/CMakeLists.txt | 3 + src/application.cpp | 98 ++++--------------- src/application.hpp | 23 +++-- src/application_instance.cpp | 8 +- 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/pluginloader.h | 4 +- src/plugins/rview.hpp | 2 + src/tabwindow/rekonqwindow.cpp | 210 ---------------------------------------- src/tabwindow/rekonqwindow.h | 89 ----------------- 16 files changed, 628 insertions(+), 390 deletions(-) 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 delete mode 100644 src/tabwindow/rekonqwindow.cpp delete mode 100644 src/tabwindow/rekonqwindow.h diff --git a/plugins/webengine/webview.cpp b/plugins/webengine/webview.cpp index 1aef01e2..fab941a9 100644 --- a/plugins/webengine/webview.cpp +++ b/plugins/webengine/webview.cpp @@ -23,3 +23,4 @@ WebView::WebView(const QUrl &url, QWidget *parent) : rView(url, parent), view(ne connect(view, &QWebEngineView::titleChanged, this, [this](const QString &title) { emit titleChanged(title); }); view->load(url); } +QString WebView::title() const { return view->title(); } diff --git a/plugins/webengine/webview.h b/plugins/webengine/webview.h index 0b8d0dae..5bb90696 100644 --- a/plugins/webengine/webview.h +++ b/plugins/webengine/webview.h @@ -20,6 +20,8 @@ public: explicit WebView(const QUrl &url = QUrl(), QWidget *parent = nullptr); ~WebView() final = default; + QString title() const override; + private: QWebEngineView *view; }; diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f1596ceb..e71d4184 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -217,6 +217,9 @@ ADD_DEFINITIONS ( ${KDE4_DEFINITIONS} ) add_executable(rekonq 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 + # ---------------------------------------- plugins/rplugininterface.hpp plugins/rview.hpp ) diff --git a/src/application.cpp b/src/application.cpp index f3bb5559..126eb020 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -38,17 +38,13 @@ Application::~Application() // saveConfiguration(); // Destroy all windows... - /*Q_FOREACH(QWeakPointer pointer, m_rekonqWindows) - { - delete pointer.data(); - pointer.clear(); - }*/ + for (const auto &window : m_windows) delete window; // Destroy all web apps - for (auto *webApp : m_webApps) delete webApp; + for (const auto &view : m_views) delete view; // Unload all plugins - for (auto *plugin : m_plugins) { + for (const auto &plugin : m_plugins) { plugin->unload(); delete plugin; } @@ -322,74 +318,6 @@ void Application::saveConfiguration() const // -------------------------------------------------------------------------------------------------------------------- -RekonqWindow *Application::rekonqWindow(const QString & activityID) -{ - RekonqWindow *active = qobject_cast(QApplication::activeWindow()); - - if (!active) - { - RekonqWindowList wList = m_rekonqWindows; -#ifdef HAVE_KACTIVITIES - wList = tabsForActivity(activityID); -#endif - - if (wList.isEmpty()) - return 0; - - Q_FOREACH(const QWeakPointer &pointer, wList) - { - if (KWindowInfo(pointer.data()->effectiveWinId(), NET::WMDesktop, 0).isOnCurrentDesktop()) - return pointer.data(); - } - return wList.at(0).data(); - } - return active; -} - - -RekonqWindowList Application::tabsForActivity(const QString & activityID) -{ -#ifdef HAVE_KACTIVITIES - QString id = activityID; - if ( id.isEmpty() ) - id = m_activityConsumer->currentActivity(); - - return m_activityRekonqWindowsMap[id]; -#else - return m_rekonqWindows; -#endif -} - - -bool Application::haveWindowsForActivity(const QString & activityID) -{ - return (!tabsForActivity(activityID).isEmpty()); -} - - -// ----------------------------------------------------------------------------------------------------------- - - -RekonqWindow *Application::newWindow(bool withTab, bool PrivateBrowsingMode) -{ - RekonqWindow *w = new RekonqWindow(withTab, PrivateBrowsingMode); - setWindowInfo(w); - w->show(); - - return w; -} - - -RekonqWindow *Application::newWindow(WebPage *pg) -{ - RekonqWindow *w = new RekonqWindow(pg); - setWindowInfo(w); - w->show(); - - return w; -} - - void Application::setWindowInfo(RekonqWindow *w) { // set object name @@ -410,10 +338,19 @@ void Application::setWindowInfo(RekonqWindow *w) // ----------------------------------------------------------------------------------------------------------- // Slots -rView *Application::newWebApp(const QUrl &url) +RekonqWindow *Application::newWindow() +{ + auto *window = new RekonqWindow; + m_windows.append(window); + + window->show(); + return window; +} + +rView *Application::newView(const QUrl &url, RekonqWindow *window) { RekonqPluginInterface *interface = nullptr; - for (auto *plugin : m_plugins) + for (const auto &plugin : m_plugins) if (plugin->hasScheme(url.scheme())) { interface = plugin->interface(); break; @@ -425,9 +362,12 @@ rView *Application::newWebApp(const QUrl &url) Q_CHECK_PTR(view); // tab->installEventFilter(this); - m_webApps.append(view); + if (window) window->addView(view); + else { + m_views.append(view); + view->show(); + } - view->show(); return view; } diff --git a/src/application.hpp b/src/application.hpp index e74350f1..ce4bbfd1 100644 --- a/src/application.hpp +++ b/src/application.hpp @@ -11,7 +11,9 @@ #pragma once +#include "mainwindow/rekonqwindow.h" #include "rekonq.hpp" +#include #include #include #include @@ -19,13 +21,13 @@ // Forward Declarations class rView; class PluginLoader; -// class RekonqWindow; // class WebTab; // class WebPage; -// typedef QList< QWeakPointer > RekonqWindowList; -// typedef QList WebAppList; +typedef QList> RekonqPluginList; +typedef QList> RekonqWindowList; +typedef QList> RekonqViewList; // --------------------------------------------------------------------------------------------------------------- @@ -40,12 +42,14 @@ public: ~Application() override; bool registerPlugin(const QString &path); + [[nodiscard]] auto pluginList() const { return m_plugins; }; // int newInstance(); - [[deprecated]] static Application *instance() { return (qobject_cast(QCoreApplication::instance())); } + static Application *instance() { return (qobject_cast(QCoreApplication::instance())); } // RekonqWindow *rekonqWindow(const QString &activityID = QString()); - // RekonqWindowList rekonqWindowList(); + [[nodiscard]] auto windowList() const { return m_windows; } + [[nodiscard]] auto viewList() const { return m_views; } /** * @returns the list of windows associated with activity whose id is @param activityID @@ -90,7 +94,8 @@ public slots: // RekonqWindow *newWindow(bool withTab = true, bool PrivateBrowsingMode = false); // RekonqWindow *newWindow(WebPage *pg); - rView *newWebApp(const QUrl &url = QUrl()); + RekonqWindow *newWindow(); + rView *newView(const QUrl &url = QUrl(), RekonqWindow *window = nullptr); // void createWebAppShortcut(const QString & urlString = QString(), const QString & titleString = QString()); @@ -117,7 +122,7 @@ private slots: // void pageCreated(WebPage *); private: - QList m_plugins; - // RekonqWindowList m_rekonqWindows; - QList m_webApps; + RekonqPluginList m_plugins; + RekonqWindowList m_windows; + RekonqViewList m_views; }; diff --git a/src/application_instance.cpp b/src/application_instance.cpp index c2005acd..42c77dc1 100644 --- a/src/application_instance.cpp +++ b/src/application_instance.cpp @@ -45,6 +45,10 @@ void Application::parseCommandLine(int instanceId, const QByteArray &message) const auto positionalArguments = parser.positionalArguments(); if (parser.isSet(options_webapp)) - positionalArguments.isEmpty() ? this->newWebApp() - : this->newWebApp(QUrl::fromUserInput(positionalArguments.first())); + positionalArguments.isEmpty() ? this->newView() : this->newView(QUrl::fromUserInput(positionalArguments.first())); + else { + // create main window + auto *window = newWindow(); + for (const auto &url : positionalArguments) newView(QUrl::fromUserInput(url), window); + } } 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 + + + + + diff --git a/src/plugins/pluginloader.h b/src/plugins/pluginloader.h index f764da9f..319e985a 100644 --- a/src/plugins/pluginloader.h +++ b/src/plugins/pluginloader.h @@ -16,7 +16,9 @@ class PluginLoader : public QPluginLoader { public: explicit PluginLoader(const QString &path, QObject *parent = nullptr); - [[nodiscard]] bool hasScheme(const QString &scheme) { return m_schemes.contains(scheme); } + + [[nodiscard]] auto schemes() const { return m_schemes; } + [[nodiscard]] bool hasScheme(const QString &scheme) const { return m_schemes.contains(scheme); } [[nodiscard]] RekonqPluginInterface *interface() { return qobject_cast(instance()); } diff --git a/src/plugins/rview.hpp b/src/plugins/rview.hpp index 71bf5ddf..6f0652d5 100644 --- a/src/plugins/rview.hpp +++ b/src/plugins/rview.hpp @@ -18,6 +18,8 @@ class rView : public QWidget { 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 &); diff --git a/src/tabwindow/rekonqwindow.cpp b/src/tabwindow/rekonqwindow.cpp deleted file mode 100644 index 98f60f30..00000000 --- a/src/tabwindow/rekonqwindow.cpp +++ /dev/null @@ -1,210 +0,0 @@ -/* ============================================================ -* -* This file is a part of the rekonq project -* -* Copyright (C) 2013 by Andrea Diamantini -* -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License as -* published by the Free Software Foundation; either version 2 of -* the License or (at your option) version 3 or any later version -* accepted by the membership of KDE e.V. (or its successor approved -* by the membership of KDE e.V.), which shall act as a proxy -* defined in Section 14 of version 3 of the license. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -* -* ============================================================ */ - - -// Self Includes -#include "rekonqwindow.h" -#include "rekonqwindow.moc" - -// Auto Includes -#include "rekonq.h" - -// Local Includes -#include "application.h" - -#include "tabwidget.h" -#include "tabbar.h" -#include "rekonqfactory.h" - -#include "webpage.h" -#include "webwindow.h" - -// KDE Includes -#include -#include - -// Qt Includes -#include -#include -#include - - -RekonqWindow::RekonqWindow(bool withTab, bool privateBrowsingMode, QWidget *parent) - : RWindow(parent) - , _tabWidget(new TabWidget(withTab, privateBrowsingMode, this)) - , _splitter(new QSplitter(this)) -{ - init(); -} - - -RekonqWindow::RekonqWindow(WebPage *pg, QWidget *parent) - : RWindow(parent) - , _tabWidget(new TabWidget(pg, this)) - , _splitter(new QSplitter(this)) -{ - init(); -} - - -RekonqWindow::~RekonqWindow() -{ -} - - -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))); -} - - -void RekonqWindow::registerWindow() -{ - // This is needed to properly support appmenu-qt feature - RekonqFactory::createWidget(QL1S("menuBar"), this); - QDBusConnection::sessionBus().registerObject(QL1S("/rekonq"), this); -} - - -// -------------------------------------------------------------------------------------------------- - - -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/tabwindow/rekonqwindow.h b/src/tabwindow/rekonqwindow.h deleted file mode 100644 index 0166d0d0..00000000 --- a/src/tabwindow/rekonqwindow.h +++ /dev/null @@ -1,89 +0,0 @@ -/* ============================================================ -* -* This file is a part of the rekonq project -* -* Copyright (C) 2013 by Andrea Diamantini -* -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License as -* published by the Free Software Foundation; either version 2 of -* the License or (at your option) version 3 or any later version -* accepted by the membership of KDE e.V. (or its successor approved -* by the membership of KDE e.V.), which shall act as a proxy -* defined in Section 14 of version 3 of the license. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -* -* ============================================================ */ - - - -#ifndef REKONQ_WINDOW_H -#define REKONQ_WINDOW_H - - -// Rekonq Includes -#include "rekonq_defines.h" - -// Local Includes -#include "rwindow.h" -#include "tabwidget.h" - -#include "bookmarkspanel.h" -#include "historypanel.h" - -// Qt Includes -#include -#include - -// Forward Declarations -class TabBar; - -class WebPage; -class WebWindow; - - -class RekonqWindow : public RWindow -{ - Q_OBJECT - -public: - explicit RekonqWindow(bool withTab = true, bool PrivateBrowsingMode = false, QWidget *parent = 0); - explicit RekonqWindow(WebPage *pg, QWidget *parent = 0); - - virtual ~RekonqWindow(); - - TabWidget *tabWidget(); - TabBar *tabBar(); - WebWindow *currentWebWindow() const; - - bool isPrivateBrowsingMode(); - -private: - void init(); - -public Q_SLOTS: - void loadUrl(const KUrl &, Rekonq::OpenType type = Rekonq::CurrentTab, TabHistory *history = 0); - -private Q_SLOTS: - void showBookmarksPanel(bool); - void showHistoryPanel(bool); - void registerWindow(); - -private: - TabWidget *_tabWidget; - - QSplitter *_splitter; - - QWeakPointer _historyPanel; - QWeakPointer _bookmarksPanel; -}; - -#endif // REKONQ_WINDOW_H -- cgit v1.2.1