summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt6
-rw-r--r--src/bookmarks/CMakeLists.txt3
-rw-r--r--src/bookmarks/bookmarkstreeitem.cpp4
-rw-r--r--src/bookmarks/bookmarkstreeitem.hpp31
-rw-r--r--src/panels/bookmarksmenu.cpp (renamed from src/bookmarks/bookmarksmenu.cpp)2
-rw-r--r--src/panels/bookmarksmenu.hpp (renamed from src/bookmarks/bookmarksmenu.hpp)0
-rw-r--r--src/panels/bookmarkstoolbar.cpp (renamed from src/bookmarks/bookmarkstoolbar.cpp)6
-rw-r--r--src/panels/bookmarkstoolbar.hpp (renamed from src/bookmarks/bookmarkstoolbar.hpp)0
-rw-r--r--src/panels/navigationtoolbar.cpp49
-rw-r--r--src/panels/navigationtoolbar.hpp36
-rw-r--r--src/panels/tabtoolbar.cpp49
-rw-r--r--src/panels/tabtoolbar.hpp33
-rw-r--r--src/rekonqwindow.cpp31
-rw-r--r--src/rekonqwindow.hpp1
-rw-r--r--src/rekonqwindow.ui143
-rw-r--r--src/rekonqwindow_class.cpp27
-rw-r--r--src/tabbar/tabbar.cpp28
-rw-r--r--src/tabbar/tabbar.h5
-rw-r--r--src/test/rekonqwindow_mock.hpp1
-rw-r--r--src/test/test_rekonqwindow.cpp1
-rw-r--r--src/urlbar/urlbar.cpp14
-rw-r--r--src/urlbar/urlbar.hpp7
22 files changed, 260 insertions, 217 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index e3a03dba..a2e16cad 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -11,7 +11,13 @@ set(rekonqwindow_SRCS
rekonqwindow_class.cpp rekonqwindow.hpp rekonqwindow.ui
tabbar/tabbar.cpp tabbar/tabbar.h
urlbar/urlbar.cpp urlbar/urlbar.hpp urlbar/completer.cpp urlbar/completer.hpp
+ # navigation
+ panels/tabtoolbar.cpp panels/tabtoolbar.hpp
+ panels/navigationtoolbar.cpp panels/navigationtoolbar.hpp
+ # bookmarks
panels/bookmarkspanel.cpp panels/bookmarkspanel.hpp
+ panels/bookmarkstoolbar.cpp panels/bookmarkstoolbar.hpp
+ panels/bookmarksmenu.cpp panels/bookmarksmenu.hpp
)
set(rekonqwindow_IFACES ${PROJECT_SOURCE_DIR}/include/rview.hpp)
diff --git a/src/bookmarks/CMakeLists.txt b/src/bookmarks/CMakeLists.txt
index d2651ce9..0fdbbad8 100644
--- a/src/bookmarks/CMakeLists.txt
+++ b/src/bookmarks/CMakeLists.txt
@@ -5,9 +5,6 @@ add_library(bookmarks STATIC
bookmarkstreemodel.cpp bookmarkstreemodel.hpp
bookmarkstreeformats.hpp
bookmarkstreeformat_xbel_read.cpp bookmarkstreeformat_xbel_write.cpp
- # UI
- bookmarksmenu.cpp bookmarksmenu.hpp
- bookmarkstoolbar.cpp bookmarkstoolbar.hpp
)
target_include_directories(bookmarks PUBLIC ${CMAKE_SOURCE_DIR}/src)
target_link_libraries(bookmarks PUBLIC Qt6::Core Qt6::Widgets)
diff --git a/src/bookmarks/bookmarkstreeitem.cpp b/src/bookmarks/bookmarkstreeitem.cpp
index fba1cc19..b868a14a 100644
--- a/src/bookmarks/bookmarkstreeitem.cpp
+++ b/src/bookmarks/bookmarkstreeitem.cpp
@@ -1,10 +1,8 @@
/* ============================================================
- * rekonq
+ * The rekonq project
* ============================================================
* SPDX-License-Identifier: GPL-3.0-only
* Copyright (C) 2022 aqua <aqua@iserlohn-fortress.net>
- * ============================================================
- * Description: rekonq bookmarks model
* ============================================================ */
#include "bookmarkstreeitem.hpp"
diff --git a/src/bookmarks/bookmarkstreeitem.hpp b/src/bookmarks/bookmarkstreeitem.hpp
index 1f87ecad..05a71ce2 100644
--- a/src/bookmarks/bookmarkstreeitem.hpp
+++ b/src/bookmarks/bookmarkstreeitem.hpp
@@ -4,11 +4,13 @@
* SPDX-License-Identifier: GPL-3.0-only
* Copyright (C) 2022 aqua <aqua@iserlohn-fortress.net>
* ============================================================
- * Description: rekonq bookmarks model
+ * Description: rekonq bookmark tree item
* ============================================================ */
#pragma once
+#include "rekonq.hpp"
+#include <QAction>
#include <QDateTime>
#include <QIcon>
#include <QUrl>
@@ -18,25 +20,6 @@
class BookmarksTreeItem {
public:
- enum BookmarkAction {
- OPEN = 0,
- OPEN_IN_TAB,
- OPEN_IN_WINDOW,
- OPEN_FOLDER,
- BOOKMARK_PAGE,
- NEW_FOLDER,
- NEW_SEPARATOR,
- COPY,
- EDIT,
-#ifdef HAVE_NEPOMUK
- FANCYBOOKMARK,
-#endif
- DELETE,
- NUM_ACTIONS,
- SET_TOOLBAR_FOLDER,
- UNSET_TOOLBAR_FOLDER
- };
-
enum Types { Root, Folder, Bookmark, Separator, Alias };
constexpr static int TypesCount = 5;
@@ -55,6 +38,14 @@ public:
explicit BookmarksTreeItem(Types type, Attributes_t &&args, BookmarksTreeItem *parent);
~BookmarksTreeItem();
+ template <typename T> [[nodiscard]] QAction *action(T *sender, rekonq::OpenType type) const
+ {
+ auto *action = new QAction(m_data.title, sender);
+ QObject::connect(action, &QAction::triggered, sender,
+ [this, sender, type]() { emit sender->loadUrl(m_data.href, type); });
+ return action;
+ };
+
[[nodiscard]] BookmarksTreeItem *parent() const { return m_parent; }
/**
diff --git a/src/bookmarks/bookmarksmenu.cpp b/src/panels/bookmarksmenu.cpp
index aad7289e..94615ff4 100644
--- a/src/bookmarks/bookmarksmenu.cpp
+++ b/src/panels/bookmarksmenu.cpp
@@ -9,7 +9,7 @@
* ============================================================ */
#include "bookmarksmenu.hpp"
-#include "bookmarkstreemodel.hpp"
+#include "bookmarks/bookmarkstreemodel.hpp"
BookmarksMenu::BookmarksMenu(QWidget *parent) : QMenu(parent)
{
diff --git a/src/bookmarks/bookmarksmenu.hpp b/src/panels/bookmarksmenu.hpp
index f162244e..f162244e 100644
--- a/src/bookmarks/bookmarksmenu.hpp
+++ b/src/panels/bookmarksmenu.hpp
diff --git a/src/bookmarks/bookmarkstoolbar.cpp b/src/panels/bookmarkstoolbar.cpp
index 353e61b9..7c3517ec 100644
--- a/src/bookmarks/bookmarkstoolbar.cpp
+++ b/src/panels/bookmarkstoolbar.cpp
@@ -9,7 +9,7 @@
* ============================================================ */
#include "bookmarkstoolbar.hpp"
-#include "bookmarkstreemodel.hpp"
+#include "bookmarks/bookmarkstreemodel.hpp"
#include <QShowEvent>
BookmarkToolBar::BookmarkToolBar(QWidget *parent) : QToolBar(parent)
@@ -42,9 +42,7 @@ void BookmarkToolBar::showEvent(QShowEvent *event)
for (int i = 0; i < root->childCount(); ++i) {
const auto *child = root->child(i);
if (child->type() != BookmarksTreeItem::Bookmark) continue;
- auto *action = addAction(child->data(BookmarksTreeItem::Title).toString(), this, [this, child]() {
- emit loadUrl(child->data(BookmarksTreeItem::Href).toUrl(), rekonq::CurrentTab);
- });
+ addAction(child->action(this, rekonq::CurrentTab));
}
event->accept();
diff --git a/src/bookmarks/bookmarkstoolbar.hpp b/src/panels/bookmarkstoolbar.hpp
index 6aaa750a..6aaa750a 100644
--- a/src/bookmarks/bookmarkstoolbar.hpp
+++ b/src/panels/bookmarkstoolbar.hpp
diff --git a/src/panels/navigationtoolbar.cpp b/src/panels/navigationtoolbar.cpp
new file mode 100644
index 00000000..ae55ac02
--- /dev/null
+++ b/src/panels/navigationtoolbar.cpp
@@ -0,0 +1,49 @@
+/* ============================================================
+ * The rekonq project
+ * ============================================================
+ * SPDX-License-Identifier: GPL-3.0-only
+ * Copyright (C) 2022 aqua <aqua@iserlohn-fortress.net>
+ * ============================================================ */
+
+#include "navigationtoolbar.hpp"
+
+NavigationToolBar::NavigationToolBar(QWidget *parent) : QToolBar(parent), urlBar(new UrlBar(this))
+{
+ auto *backAction = addAction(QIcon::fromTheme("go-previous"), "Back", this, [this]() { m_view->back(); });
+ backAction->setObjectName("actionBack");
+ auto *forwardAction = addAction(QIcon::fromTheme("go-next"), "Forward", this, [this]() { m_view->forward(); });
+ forwardAction->setObjectName("actionForward");
+ auto *refreshAction = addAction(QIcon::fromTheme("view-refresh"), "Refresh", this, [this]() { m_view->refresh(); });
+ refreshAction->setObjectName("actionRefresh");
+ addAction(QIcon::fromTheme("go-home"), "Home", this,
+ [this]() { emit loadUrl(rekonq::HomePage, rekonq::CurrentTab); });
+ // TODO homeAction->setObjectName("actionHome");
+
+ addWidget(urlBar);
+
+ auto *actionFocusUrlBar = new QAction(parent);
+ actionFocusUrlBar->setShortcut({"F6"});
+ connect(actionFocusUrlBar, &QAction::triggered, urlBar, [this]() {
+ urlBar->setFocus();
+ urlBar->selectAll();
+ });
+ parent->addAction(actionFocusUrlBar);
+}
+
+void NavigationToolBar::setCurrentView(RekonqView *view)
+{
+ Q_CHECK_PTR(view);
+ m_view = view;
+
+ disconnect(urlChanged_conn);
+ disconnect(loadStarted_conn);
+ disconnect(loadProgress_conn);
+ disconnect(loadFinished_conn);
+
+ urlChanged_conn = connect(view, &RekonqView::urlChanged, urlBar, &UrlBar::setUrl);
+ loadStarted_conn = connect(view, &RekonqView::loadStarted, urlBar, &UrlBar::loadStarted);
+ loadProgress_conn = connect(view, &RekonqView::loadProgress, urlBar, &UrlBar::loadProgress);
+ loadFinished_conn = connect(view, &RekonqView::loadFinished, urlBar, &UrlBar::loadFinished);
+
+ urlBar->setCurrentView(view);
+}
diff --git a/src/panels/navigationtoolbar.hpp b/src/panels/navigationtoolbar.hpp
new file mode 100644
index 00000000..eaf5b145
--- /dev/null
+++ b/src/panels/navigationtoolbar.hpp
@@ -0,0 +1,36 @@
+/* ============================================================
+ * The rekonq project
+ * ============================================================
+ * SPDX-License-Identifier: GPL-3.0-only
+ * Copyright (C) 2022 aqua <aqua@iserlohn-fortress.net>
+ * ============================================================ */
+
+#pragma once
+
+#include "rekonq.hpp"
+#include "urlbar/urlbar.hpp"
+#include <QToolBar>
+
+class RekonqView;
+class NavigationToolBar : public QToolBar {
+ Q_OBJECT
+
+public:
+ explicit NavigationToolBar(QWidget *parent = nullptr);
+ ~NavigationToolBar() override = default;
+
+signals:
+ void loadUrl(rekonq::DefaultUrl url, rekonq::OpenType type = rekonq::CurrentTab);
+
+public slots:
+ void setCurrentView(RekonqView *view);
+
+private:
+ RekonqView *m_view;
+ UrlBar *urlBar;
+
+ QMetaObject::Connection urlChanged_conn;
+ QMetaObject::Connection loadStarted_conn;
+ QMetaObject::Connection loadProgress_conn;
+ QMetaObject::Connection loadFinished_conn;
+};
diff --git a/src/panels/tabtoolbar.cpp b/src/panels/tabtoolbar.cpp
new file mode 100644
index 00000000..be3f1384
--- /dev/null
+++ b/src/panels/tabtoolbar.cpp
@@ -0,0 +1,49 @@
+/* ============================================================
+ * The rekonq project
+ * ============================================================
+ * SPDX-License-Identifier: GPL-3.0-only
+ * Copyright (C) 2022 aqua <aqua@iserlohn-fortress.net>
+ * ============================================================ */
+
+#include "tabtoolbar.hpp"
+
+TabToolBar::TabToolBar(QWidget *parent) : QToolBar(parent), tabs(new TabBar(this))
+{
+ addWidget(tabs);
+
+ auto *spacer = new QWidget(this);
+ spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
+ addWidget(spacer);
+
+ auto *actionNewTab = parent->findChild<QAction *>("actionNewTab");
+ Q_CHECK_PTR(actionNewTab);
+ addAction(QIcon::fromTheme("document-new"), "Add Tab", actionNewTab, &QAction::trigger);
+
+ // currentViewChanged
+ connect(tabs, &QTabBar::currentChanged, this, [this](int index) {
+ if (index == -1) emit currentViewChanged(nullptr);
+ else {
+ auto view = tabs->view(index);
+ Q_CHECK_PTR(view);
+ emit currentViewChanged(view);
+ }
+ });
+
+ // removeView
+ connect(tabs, &QTabBar::tabCloseRequested, this, [this](int index) { emit tabClosed(tabs->removeTab(index)); });
+}
+
+int TabToolBar::addView(RekonqView *view)
+{
+ Q_CHECK_PTR(view);
+ return tabs->addTab(view);
+}
+
+void TabToolBar::setCurrentView(RekonqView *view) { tabs->setCurrentView(view); }
+
+RekonqView *TabToolBar::currentView() const
+{
+ auto *view = tabs->view(tabs->currentIndex());
+ Q_CHECK_PTR(view);
+ return view;
+}
diff --git a/src/panels/tabtoolbar.hpp b/src/panels/tabtoolbar.hpp
new file mode 100644
index 00000000..1c61ed2a
--- /dev/null
+++ b/src/panels/tabtoolbar.hpp
@@ -0,0 +1,33 @@
+/* ============================================================
+ * The rekonq project
+ * ============================================================
+ * SPDX-License-Identifier: GPL-3.0-only
+ * Copyright (C) 2022 aqua <aqua@iserlohn-fortress.net>
+ * ============================================================ */
+
+#pragma once
+
+#include "tabbar/tabbar.h"
+#include <QToolBar>
+
+class TabToolBar : public QToolBar {
+ Q_OBJECT
+
+public:
+ explicit TabToolBar(QWidget *parent = nullptr);
+ ~TabToolBar() override = default;
+
+ int addView(RekonqView *view);
+ void setCurrentView(RekonqView *view);
+ [[nodiscard]] RekonqView *currentView() const;
+
+signals:
+ void currentViewChanged(RekonqView *view);
+ void tabClosed(RekonqView *view);
+
+public slots:
+ void closeCurrentTab() { emit tabs->tabCloseRequested(tabs->currentIndex()); }
+
+private:
+ TabBar *tabs;
+};
diff --git a/src/rekonqwindow.cpp b/src/rekonqwindow.cpp
index 461de12e..2295cd50 100644
--- a/src/rekonqwindow.cpp
+++ b/src/rekonqwindow.cpp
@@ -15,36 +15,11 @@
// --------------------------------------------------------------------------------------------------
-RekonqView *RekonqWindow::currentView()
-{
- auto *view = ui->tabs->view(ui->tabs->currentIndex());
- Q_CHECK_PTR(view);
- return view;
-}
-
int RekonqWindow::addView(RekonqView *view)
{
Q_CHECK_PTR(view);
-
ui->views->addWidget(view);
- const auto index = ui->tabs->addTab(view);
- connect(view, &RekonqView::urlChanged, [this, view](const QUrl &url) {
- if (view == currentView()) ui->urlBar->setUrl(url);
- });
- connect(view, &RekonqView::titleChanged, [this, view](const QString &title) {
- const auto idx = ui->views->indexOf(view);
- ui->tabs->setTabText(idx, title);
- });
- connect(view, &RekonqView::iconChanged, [this, view](const QIcon &icon) {
- const auto idx = ui->views->indexOf(view);
- ui->tabs->setTabIcon(idx, icon);
- });
-
- connect(view, &RekonqView::loadStarted, ui->urlBar, &UrlBar::loadStarted);
- connect(view, &RekonqView::loadProgress, ui->urlBar, &UrlBar::loadProgress);
- connect(view, &RekonqView::loadFinished, ui->urlBar, &UrlBar::loadFinished);
-
- return index;
+ return ui->tabToolBar->addView(view);
}
void RekonqWindow::loadUrl(rekonq::DefaultUrl url, rekonq::OpenType type)
@@ -67,13 +42,13 @@ void RekonqWindow::loadUrl(const QUrl &url, rekonq::OpenType type)
{
switch (type) {
case rekonq::CurrentTab:
- currentView()->load(url);
+ ui->tabToolBar->currentView()->load(url);
break;
case rekonq::NewTab:
Application::instance()->newView(url, this);
break;
case rekonq::NewFocusedTab:
- ui->tabs->setCurrentView(Application::instance()->newView(url, this));
+ ui->tabToolBar->setCurrentView(Application::instance()->newView(url, this));
break;
case rekonq::NewBackGroundTab:
break;
diff --git a/src/rekonqwindow.hpp b/src/rekonqwindow.hpp
index 04287a90..82542274 100644
--- a/src/rekonqwindow.hpp
+++ b/src/rekonqwindow.hpp
@@ -30,7 +30,6 @@ public:
~RekonqWindow() override;
void setupShortcuts(RekonqSettings *settings);
- [[nodiscard]] REKONQ_TEST_VIRTUAL RekonqView *currentView() REKONQ_TEST_PURE;
public slots:
REKONQ_TEST_VIRTUAL int addView(RekonqView *view) REKONQ_TEST_PURE;
diff --git a/src/rekonqwindow.ui b/src/rekonqwindow.ui
index 7879f848..a00f33f6 100644
--- a/src/rekonqwindow.ui
+++ b/src/rekonqwindow.ui
@@ -16,100 +16,6 @@
<widget class="QWidget" name="centralwidget">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
- <layout class="QHBoxLayout" name="tabBarLayout">
- <item>
- <widget class="TabBar" name="tabs" native="true"/>
- </item>
- <item>
- <widget class="QToolButton" name="newTab">
- <property name="styleSheet">
- <string notr="true">border: none;</string>
- </property>
- <property name="text">
- <string>Add Tab</string>
- </property>
- <property name="icon">
- <iconset theme="document-new">
- <normaloff>.</normaloff>.</iconset>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" name="urlBarLayout">
- <item>
- <widget class="QToolButton" name="back">
- <property name="text">
- <string>Back</string>
- </property>
- <property name="icon">
- <iconset theme="go-previous">
- <normaloff>.</normaloff>.</iconset>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QToolButton" name="forward">
- <property name="text">
- <string>Forward</string>
- </property>
- <property name="icon">
- <iconset theme="go-next">
- <normaloff>.</normaloff>.</iconset>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QToolButton" name="refresh">
- <property name="text">
- <string>Reload</string>
- </property>
- <property name="icon">
- <iconset theme="view-refresh">
- <normaloff>.</normaloff>.</iconset>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QToolButton" name="home">
- <property name="text">
- <string>Home</string>
- </property>
- <property name="icon">
- <iconset theme="go-home">
- <normaloff>.</normaloff>.</iconset>
- </property>
- </widget>
- </item>
- <item>
- <widget class="UrlBar" name="urlBar"/>
- </item>
- <item>
- <widget class="QToolButton" name="load">
- <property name="text">
- <string>Load</string>
- </property>
- <property name="icon">
- <iconset theme="bookmarks">
- <normaloff>.</normaloff>.</iconset>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QToolButton" name="menu">
- <property name="text">
- <string>Menu</string>
- </property>
- <property name="icon">
- <iconset theme="preferences">
- <normaloff>.</normaloff>.</iconset>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
<widget class="QSplitter" name="splitter">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
@@ -209,7 +115,7 @@
<addaction name="menuHelp"/>
</widget>
<widget class="QStatusBar" name="statusbar"/>
- <widget class="BookmarkToolBar" name="bookmarksToolBar">
+ <widget class="TabToolBar" name="tabToolBar">
<property name="windowTitle">
<string>toolBar</string>
</property>
@@ -220,6 +126,28 @@
<bool>false</bool>
</attribute>
</widget>
+ <widget class="NavigationToolBar" name="navigationToolBar">
+ <property name="windowTitle">
+ <string>toolBar</string>
+ </property>
+ <attribute name="toolBarArea">
+ <enum>TopToolBarArea</enum>
+ </attribute>
+ <attribute name="toolBarBreak">
+ <bool>true</bool>
+ </attribute>
+ </widget>
+ <widget class="BookmarkToolBar" name="bookmarksToolBar">
+ <property name="windowTitle">
+ <string>toolBar</string>
+ </property>
+ <attribute name="toolBarArea">
+ <enum>TopToolBarArea</enum>
+ </attribute>
+ <attribute name="toolBarBreak">
+ <bool>true</bool>
+ </attribute>
+ </widget>
<action name="actionTaskManager">
<property name="text">
<string>Task Manager</string>
@@ -269,17 +197,6 @@
</widget>
<customwidgets>
<customwidget>
- <class>UrlBar</class>
- <extends>QLineEdit</extends>
- <header>urlbar/urlbar.hpp</header>
- </customwidget>
- <customwidget>
- <class>TabBar</class>
- <extends>QWidget</extends>
- <header>tabbar/tabbar.h</header>
- <container>1</container>
- </customwidget>
- <customwidget>
<class>BookmarksPanel</class>
<extends>QTreeView</extends>
<header>panels/bookmarkspanel.hpp</header>
@@ -287,12 +204,22 @@
<customwidget>
<class>BookmarksMenu</class>
<extends>QMenu</extends>
- <header>bookmarks/bookmarksmenu.hpp</header>
+ <header>panels/bookmarksmenu.hpp</header>
</customwidget>
<customwidget>
<class>BookmarkToolBar</class>
<extends>QToolBar</extends>
- <header>bookmarks/bookmarkstoolbar.hpp</header>
+ <header>panels/bookmarkstoolbar.hpp</header>
+ </customwidget>
+ <customwidget>
+ <class>NavigationToolBar</class>
+ <extends>QToolBar</extends>
+ <header>panels/navigationtoolbar.hpp</header>
+ </customwidget>
+ <customwidget>
+ <class>TabToolBar</class>
+ <extends>QToolBar</extends>
+ <header>panels/tabtoolbar.hpp</header>
</customwidget>
</customwidgets>
<resources/>
diff --git a/src/rekonqwindow_class.cpp b/src/rekonqwindow_class.cpp
index cf721448..996e1b6f 100644
--- a/src/rekonqwindow_class.cpp
+++ b/src/rekonqwindow_class.cpp
@@ -34,6 +34,8 @@ RekonqWindow::RekonqWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::Re
ui->bookmarksToolBar->setModel(Application::instance()->bookmarks());
ui->menuBookmarks->setModel(Application::instance()->bookmarks());
#endif
+ connect(ui->navigationToolBar, &NavigationToolBar::loadUrl, this,
+ qOverload<rekonq::DefaultUrl, rekonq::OpenType>(&RekonqWindow::loadUrl));
connect(ui->bookmarksPanel, &BookmarksPanel::loadUrl, this,
qOverload<const QUrl &, rekonq::OpenType>(&RekonqWindow::loadUrl));
connect(ui->bookmarksToolBar, &BookmarkToolBar::loadUrl, this,
@@ -41,29 +43,17 @@ RekonqWindow::RekonqWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::Re
connect(ui->menuBookmarks, &BookmarksMenu::loadUrl, this,
qOverload<const QUrl &, rekonq::OpenType>(&RekonqWindow::loadUrl));
- connect(ui->tabs, &TabBar::currentChanged, this, [this](RekonqView *view) {
+ // ::setCurrentView
+ connect(ui->tabToolBar, &TabToolBar::currentViewChanged, this, [this](RekonqView *view) {
if (view == nullptr) { // last tab has been closed
close();
return;
}
ui->views->setCurrentWidget(view);
- ui->urlBar->setCurrentView(view);
+ ui->navigationToolBar->setCurrentView(view);
});
- connect(ui->tabs, &TabBar::removeView, this, [this](RekonqView *view) { ui->views->removeWidget(view); });
-
- connect(ui->back, &QToolButton::clicked, this, [this]() { currentView()->back(); });
- connect(ui->forward, &QToolButton::clicked, this, [this]() { currentView()->forward(); });
- connect(ui->refresh, &QToolButton::clicked, this, [this]() { currentView()->refresh(); });
- connect(ui->home, &QToolButton::clicked, this, [this]() { loadUrl(rekonq::HomePage, rekonq::CurrentTab); });
-
- auto *actionFocusUrlBar = new QAction(this);
- actionFocusUrlBar->setShortcut({"F6"});
- connect(actionFocusUrlBar, &QAction::triggered, this, [this]() {
- ui->urlBar->setFocus();
- ui->urlBar->selectAll();
- });
- addAction(actionFocusUrlBar);
+ connect(ui->tabToolBar, &TabToolBar::tabClosed, this, [this](RekonqView *view) { ui->views->removeWidget(view); });
// connect menu actions
// file menu
@@ -76,8 +66,7 @@ RekonqWindow::RekonqWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::Re
#endif
connect(ui->actionNewTab, &QAction::triggered, this,
[this]() { loadUrl(rekonq::NewTabPage, rekonq::NewFocusedTab); });
- connect(ui->actionCloseTab, &QAction::triggered, this,
- [this]() { emit ui->tabs->tabCloseRequested(ui->tabs->currentIndex()); });
+ connect(ui->actionCloseTab, &QAction::triggered, ui->tabToolBar, &TabToolBar::closeCurrentTab);
connect(ui->actionQuit, &QAction::triggered, qApp, &QApplication::quit);
// edit menu
// view menu
@@ -92,8 +81,6 @@ RekonqWindow::RekonqWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::Re
#endif
// help menu
connect(ui->actionAboutQt, &QAction::triggered, qApp, &QApplication::aboutQt);
-
- connect(ui->newTab, &QToolButton::clicked, ui->actionNewTab, &QAction::trigger);
}
RekonqWindow::~RekonqWindow() { delete ui; }
diff --git a/src/tabbar/tabbar.cpp b/src/tabbar/tabbar.cpp
index 849dfbc1..4cd39550 100644
--- a/src/tabbar/tabbar.cpp
+++ b/src/tabbar/tabbar.cpp
@@ -22,23 +22,8 @@ TabBar::TabBar(QWidget *parent) : QTabBar(parent)
setMovable(true);
setAcceptDrops(true);
- connect(this, &QTabBar::currentChanged, this, [this](int index) {
- if (index == -1) {
- emit currentChanged(nullptr);
- return;
- }
- auto view = m_views.at(index);
- Q_ASSERT(!view.isNull());
- emit currentChanged(view);
- });
connect(this, &QTabBar::tabMoved, this, [this](int from, int to) { m_views.move(from, to); });
- connect(this, &QTabBar::tabCloseRequested, this, [this](int index) {
- removeTab(index);
- emit removeView(m_views.at(index));
- m_views.removeAt(index);
- });
-
/*
// context menu(s)
setContextMenuPolicy(Qt::CustomContextMenu);
@@ -62,10 +47,23 @@ int TabBar::addTab(RekonqView *view)
const int index = m_views.indexOf(view);
setTabText(index, title);
});
+ connect(view, &RekonqView::iconChanged, this, [this, view](const QIcon &icon) {
+ const int index = m_views.indexOf(view);
+ setTabIcon(index, icon);
+ });
return id;
}
+RekonqView *TabBar::removeTab(int index)
+{
+ RekonqView *view = m_views.at(index);
+ m_views.removeAt(index);
+ QTabBar::removeTab(index);
+
+ return view;
+}
+
// ------------------------------------------------------------------------------------
QSize TabBar::tabSizeHint(int index) const
diff --git a/src/tabbar/tabbar.h b/src/tabbar/tabbar.h
index 793e2acf..db2e6d1c 100644
--- a/src/tabbar/tabbar.h
+++ b/src/tabbar/tabbar.h
@@ -23,6 +23,7 @@ public:
explicit TabBar(QWidget *parent = nullptr);
int addTab(RekonqView *view);
+ RekonqView *removeTab(int index);
[[nodiscard]] RekonqView *view(int index) { return m_views.at(index); }
/*
void setTabHighlighted(int index, bool b);
@@ -35,10 +36,6 @@ public:
setCurrentIndex(index);
}
-signals:
- void currentChanged(RekonqView *view);
- void removeView(RekonqView *);
-
protected:
[[nodiscard]] QSize tabSizeHint(int index) const override;
/*
diff --git a/src/test/rekonqwindow_mock.hpp b/src/test/rekonqwindow_mock.hpp
index 403237d4..7ec30d88 100644
--- a/src/test/rekonqwindow_mock.hpp
+++ b/src/test/rekonqwindow_mock.hpp
@@ -10,7 +10,6 @@ public:
explicit FakeWindow(QWidget *parent = nullptr) : RekonqWindow(parent) {}
~FakeWindow() override = default;
- MOCK_METHOD(RekonqView *, currentView, (), (override));
MOCK_METHOD(int, addView, (RekonqView *), (override));
MOCK_METHOD(void, loadUrl, (rekonq::DefaultUrl, rekonq::OpenType), (override));
MOCK_METHOD(void, loadUrl, (const QUrl &, rekonq::OpenType), (override));
diff --git a/src/test/test_rekonqwindow.cpp b/src/test/test_rekonqwindow.cpp
index 9e90cd94..46c63e53 100644
--- a/src/test/test_rekonqwindow.cpp
+++ b/src/test/test_rekonqwindow.cpp
@@ -11,7 +11,6 @@ using ::testing::ReturnArg;
TEST(RekonqWindow, mock_shortcuts)
{
FakeWindow window;
- EXPECT_CALL(window, currentView).Times(0);
EXPECT_CALL(window, addView).Times(0);
EXPECT_CALL(window, loadUrl(Matcher<rekonq::DefaultUrl>(_), _)).Times(0);
EXPECT_CALL(window, loadUrl(Matcher<const QUrl &>(_), _)).Times(0);
diff --git a/src/urlbar/urlbar.cpp b/src/urlbar/urlbar.cpp
index 18067f09..6c726d5a 100644
--- a/src/urlbar/urlbar.cpp
+++ b/src/urlbar/urlbar.cpp
@@ -80,8 +80,13 @@ UrlBar::UrlBar(QWidget *parent)
// connect(_suggestionTimer, SIGNAL(timeout()), this, SLOT(suggest()));
}
+// -----------------------------------------------------------------------------------------------------------
+// slots
+
void UrlBar::setUrl(const QUrl &url)
{
+ Q_ASSERT(sender() == m_currentView);
+
if (url.scheme() == QL1S("rekonq")) return;
// we don't set empty url
@@ -100,9 +105,6 @@ void UrlBar::setUrl(const QUrl &url)
setCursorPosition(0);
}
-// -----------------------------------------------------------------------------------------------------------
-// slots
-
void UrlBar::loadRequestedUrl(const QUrl &url, rekonq::OpenType type)
{
clearFocus();
@@ -114,7 +116,7 @@ void UrlBar::loadRequestedUrl(const QUrl &url, rekonq::OpenType type)
void UrlBar::loadStarted()
{
- if (sender() != m_currentView) return;
+ Q_ASSERT(sender() == m_currentView);
m_currentView_progress = 1;
_icon->setIcon(QIcon::fromTheme("text-html"));
// clearRightIcons();
@@ -124,14 +126,14 @@ void UrlBar::loadStarted()
void UrlBar::loadProgress(int progress)
{
- if (sender() != m_currentView) return;
+ Q_ASSERT(sender() == m_currentView);
m_currentView_progress = progress;
repaint();
}
void UrlBar::loadFinished()
{
- if (sender() != m_currentView) return;
+ Q_ASSERT(sender() == m_currentView);
m_currentView_progress = 100;
// refreshFavicon();
// updateRightIcons();
diff --git a/src/urlbar/urlbar.hpp b/src/urlbar/urlbar.hpp
index 8be97838..3e3b9059 100644
--- a/src/urlbar/urlbar.hpp
+++ b/src/urlbar/urlbar.hpp
@@ -42,8 +42,11 @@ public slots:
void setCurrentView(RekonqView *view)
{
m_currentView = view;
- loadProgress(view->progress());
- setUrl(view->url());
+ m_currentView_progress = view->progress();
+
+ emit view->urlChanged(view->url());
+ // setUrl(view->url());
+ repaint();
}
void setUrl(const QUrl &url);