diff options
author | aqua <aqua@iserlohn-fortress.net> | 2022-09-18 09:57:29 +0300 |
---|---|---|
committer | aqua <aqua@iserlohn-fortress.net> | 2022-09-18 09:57:29 +0300 |
commit | 1b1e327cb73491c17972a33a07c3c9beafe7f938 (patch) | |
tree | 57fa4bc121fc2e172db42288fec7cdd7ff95399c /src/panels/navigationtoolbar.cpp | |
parent | Add Bookmarks toolbar (diff) | |
download | rekonq-1b1e327cb73491c17972a33a07c3c9beafe7f938.tar.xz |
Add Navigation and Tab toolbars
Diffstat (limited to 'src/panels/navigationtoolbar.cpp')
-rw-r--r-- | src/panels/navigationtoolbar.cpp | 49 |
1 files changed, 49 insertions, 0 deletions
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); +} |