aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2018-01-19 12:23:38 +0100
committerAqua-sama <aqua@iserlohn-fortress.net>2018-01-19 12:23:38 +0100
commit256abbfb073774f6b9b502ac56a67af65c075dae (patch)
treec39ee8a884dadfb8c2b0d567e165fe024ffff5fe
parentRefactoring MainWindow (diff)
downloadsmolbote-256abbfb073774f6b9b502ac56a67af65c075dae.tar.xz
Added shortcuts to navbar actions
-rw-r--r--data/poi.cfg15
-rw-r--r--src/mainwindow/widgets/navigationbar.cpp17
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 <QHBoxLayout>
+#include <QShortcut>
#include <QStyle>
#include <QToolBar>
#include <QToolButton>
@@ -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<std::string>("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<std::string>("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<std::string>("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<std::string>("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<std::string>("browser.shortcuts.home").value()));
connect(homeButton, &QToolButton::clicked, this, [this, parent]() {
m_view->load(parent->m_profile->homepage());
});