From 256abbfb073774f6b9b502ac56a67af65c075dae Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Fri, 19 Jan 2018 12:23:38 +0100 Subject: Added shortcuts to navbar actions --- data/poi.cfg | 15 ++++++++++++--- src/mainwindow/widgets/navigationbar.cpp | 17 ++++++++++++++++- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/data/poi.cfg b/data/poi.cfg index 557cda5..2cf50d6 100644 --- a/data/poi.cfg +++ b/data/poi.cfg @@ -30,14 +30,23 @@ browser = { about = "F1"; quit = "Ctrl+Q"; - toggleSearchBox = "F3"; - focusAddress = "F4"; - fullscreen = "F11"; + // navigation + back = "Ctrl+Left"; + forward = "Ctrl+Right"; + refresh = "F5"; + reload = "Ctrl+F5"; + //stop = ""; + home = "Ctrl+Home"; // tabs tabClose = "Ctrl+X"; tabLeft = "Ctrl+O"; tabRight = "Ctrl+P"; + + // page + toggleSearchBox = "F3"; + focusAddress = "F4"; + fullscreen = "F11"; }; }; diff --git a/src/mainwindow/widgets/navigationbar.cpp b/src/mainwindow/widgets/navigationbar.cpp index 648bb23..3e50b8a 100644 --- a/src/mainwindow/widgets/navigationbar.cpp +++ b/src/mainwindow/widgets/navigationbar.cpp @@ -8,8 +8,8 @@ #include "navigationbar.h" #include "mainwindow/mainwindow.h" -#include "webengine/webview.h" #include +#include #include #include #include @@ -20,8 +20,10 @@ NavigationBar::NavigationBar(MainWindow *parent) { qStyle = parent->style(); + // Back button backButton = new QToolButton(parent); backButton->setIcon(qStyle->standardIcon(QStyle::SP_ArrowBack)); + backButton->setShortcut(QString::fromStdString(parent->m_config->value("browser.shortcuts.back").value())); connect(backButton, &QToolButton::clicked, this, [this]() { m_view->history()->back(); }); @@ -39,8 +41,10 @@ NavigationBar::NavigationBar(MainWindow *parent) } }); + // Forward button forwardButton = new QToolButton(parent); forwardButton->setIcon(qStyle->standardIcon(QStyle::SP_ArrowForward)); + forwardButton->setShortcut(QString::fromStdString(parent->m_config->value("browser.shortcuts.forward").value())); connect(forwardButton, &QToolButton::clicked, this, [this]() { m_view->history()->forward(); }); @@ -58,8 +62,10 @@ NavigationBar::NavigationBar(MainWindow *parent) } }); + // Stop/Refresh button stopReloadButton = new QToolButton(parent); stopReloadButton->setIcon(qStyle->standardIcon(QStyle::SP_BrowserReload)); + stopReloadButton->setShortcut(QString::fromStdString(parent->m_config->value("browser.shortcuts.refresh").value())); connect(stopReloadButton, &QToolButton::clicked, this, [this]() { if(m_view->isLoaded()) m_view->reload(); @@ -67,8 +73,17 @@ NavigationBar::NavigationBar(MainWindow *parent) m_view->stop(); }); + auto *reloadShortcut = new QShortcut( + QString::fromStdString(parent->m_config->value("browser.shortcuts.reload").value()), + parent); + connect(reloadShortcut, &QShortcut::activated, this, [this]() { + m_view->reload(); + }); + + // Home button homeButton = new QToolButton(parent); homeButton->setIcon(qStyle->standardIcon(QStyle::SP_DirHomeIcon)); + homeButton->setShortcut(QString::fromStdString(parent->m_config->value("browser.shortcuts.home").value())); connect(homeButton, &QToolButton::clicked, this, [this, parent]() { m_view->load(parent->m_profile->homepage()); }); -- cgit v1.2.1