aboutsummaryrefslogtreecommitdiff
path: root/src/mainwindow
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2018-12-11 16:29:40 +0100
committerAqua-sama <aqua@iserlohn-fortress.net>2018-12-11 16:29:40 +0100
commitd6fa17aab9800e92e369a8ba5c24510de7ad37af (patch)
treeb44dc050e1a692494e734c7550be1eee29c88dd2 /src/mainwindow
parentUpdate poi_firejail.desktop (diff)
downloadsmolbote-d6fa17aab9800e92e369a8ba5c24510de7ad37af.tar.xz
Fix navigation buttons using wrong icons
Diffstat (limited to 'src/mainwindow')
-rw-r--r--src/mainwindow/mainwindow.cpp2
-rw-r--r--src/mainwindow/widgets/navigationbar.cpp37
-rw-r--r--src/mainwindow/widgets/navigationbar.h4
3 files changed, 18 insertions, 25 deletions
diff --git a/src/mainwindow/mainwindow.cpp b/src/mainwindow/mainwindow.cpp
index 9e6f187..1544e79 100644
--- a/src/mainwindow/mainwindow.cpp
+++ b/src/mainwindow/mainwindow.cpp
@@ -199,7 +199,7 @@ MainWindow::MainWindow(const std::unique_ptr<Configuration> &config, QWidget *pa
});
}
- navigationToolBar = new NavigationBar(config->section("navigation"), this);
+ navigationToolBar = new NavigationBar(config.get(), this);
navigationToolBar->setMovable(config->value<bool>("navigation.movable").value());
addToolBar(Qt::TopToolBarArea, navigationToolBar);
navigationToolBar->connectWebView(nullptr);
diff --git a/src/mainwindow/widgets/navigationbar.cpp b/src/mainwindow/widgets/navigationbar.cpp
index 0e5966f..61d17fa 100644
--- a/src/mainwindow/widgets/navigationbar.cpp
+++ b/src/mainwindow/widgets/navigationbar.cpp
@@ -17,18 +17,14 @@
#include <QToolBar>
#include <QToolButton>
#include <QWebEngineHistory>
+#include "util.h"
-NavigationBar::NavigationBar(const QHash<QString, QString> &conf, QWidget *parent)
+NavigationBar::NavigationBar(const Configuration *config, QWidget *parent)
: QToolBar(parent)
{
- qStyle = parent->style();
-
// Back button
- backAction = addAction(qStyle->standardIcon(QStyle::SP_ArrowBack), tr("Back"));
- if(conf.count("navigation.shortcuts.back") > 0) {
- backAction->setShortcut(QKeySequence(conf.value("navigation.shortcuts.back")));
- backAction->setToolTip(tr("Back (%1)").arg(conf.value("navigation.shortcuts.back")));
- }
+ backAction = addAction(Util::icon(QStyle::SP_ArrowBack), tr("Back"));
+ config->setShortcut(backAction, "navigation.shortcuts.back");
connect(backAction, &QAction::triggered, this, [this]() {
m_view->history()->back();
});
@@ -46,7 +42,7 @@ NavigationBar::NavigationBar(const QHash<QString, QString> &conf, QWidget *paren
});
backAction->setMenu(backMenu);
- auto *backMenuShortcut = new QShortcut(QKeySequence(conf.value("navigation.shortcuts.backMenu")), this);
+ auto *backMenuShortcut = new QShortcut(QKeySequence(config->value<QString>("navigation.shortcuts.backMenu").value()), this);
connect(backMenuShortcut, &QShortcut::activated, backMenu, [this, backMenu]() {
if(backAction->isEnabled()) {
auto *widget = this->widgetForAction(backAction);
@@ -55,11 +51,8 @@ NavigationBar::NavigationBar(const QHash<QString, QString> &conf, QWidget *paren
});
// Forward button
- forwardAction = addAction(qStyle->standardIcon(QStyle::SP_ArrowForward), tr("Forward"));
- if(conf.count("navigation.shortcuts.forward") > 0) {
- forwardAction->setShortcut(QKeySequence(conf.value("navigation.shortcuts.forward")));
- forwardAction->setToolTip(tr("Forward (%1)").arg(conf.value("navigation.shortcuts.forward")));
- }
+ forwardAction = addAction(Util::icon(QStyle::SP_ArrowForward), tr("Forward"));
+ config->setShortcut(forwardAction, "navigation.shortcuts.forward");
connect(forwardAction, &QAction::triggered, this, [this]() {
m_view->history()->forward();
});
@@ -77,7 +70,7 @@ NavigationBar::NavigationBar(const QHash<QString, QString> &conf, QWidget *paren
});
forwardAction->setMenu(forwardMenu);
- auto *forwardMenuShortcut = new QShortcut(QKeySequence(conf.value("navigation.shortcuts.forwardMenu")), this);
+ auto *forwardMenuShortcut = new QShortcut(QKeySequence(config->value<QString>("navigation.shortcuts.forwardMenu").value()), this);
connect(forwardMenuShortcut, &QShortcut::activated, forwardMenu, [this, forwardMenu]() {
if(forwardAction->isEnabled()) {
auto *widget = this->widgetForAction(forwardAction);
@@ -86,8 +79,8 @@ NavigationBar::NavigationBar(const QHash<QString, QString> &conf, QWidget *paren
});
// Stop/Refresh button
- stopReloadAction = addAction(qStyle->standardIcon(QStyle::SP_BrowserReload), tr("Refresh"));
- stopReloadAction->setShortcut(QKeySequence(conf.value("navigation.shortcuts.refresh")));
+ stopReloadAction = addAction(Util::icon(QStyle::SP_BrowserReload), tr("Refresh"));
+ config->setShortcut(stopReloadAction, "navigation.shortcuts.refresh");
connect(stopReloadAction, &QAction::triggered, this, [this]() {
if(m_view->isLoaded())
m_view->reload();
@@ -95,14 +88,14 @@ NavigationBar::NavigationBar(const QHash<QString, QString> &conf, QWidget *paren
m_view->stop();
});
- auto *reloadShortcut = new QShortcut(QKeySequence(conf.value("navigation.shortcuts.reload")), this);
+ auto *reloadShortcut = new QShortcut(QKeySequence(config->value<QString>("navigation.shortcuts.reload").value()), this);
connect(reloadShortcut, &QShortcut::activated, this, [this]() {
m_view->triggerPageAction(QWebEnginePage::ReloadAndBypassCache);
});
// Home button
- homeAction = addAction(qStyle->standardIcon(QStyle::SP_DirHomeIcon), tr("Home"));
- homeAction->setShortcut(QKeySequence(conf.value("navigation.shortcuts.home")));
+ homeAction = addAction(Util::icon(QStyle::SP_DirHomeIcon), tr("Home"));
+ config->setShortcut(homeAction, "navigation.shortcuts.home");
connect(homeAction, &QAction::triggered, this, [this]() {
m_view->triggerViewAction(WebView::GoHome);
});
@@ -140,12 +133,12 @@ void NavigationBar::update_loadStarted()
{
backAction->setEnabled(m_view->history()->canGoForward());
forwardAction->setEnabled(m_view->history()->canGoForward());
- stopReloadAction->setIcon(qStyle->standardIcon(QStyle::SP_BrowserStop));
+ stopReloadAction->setIcon(Util::icon(QStyle::SP_BrowserStop));
}
void NavigationBar::update_loadFinished()
{
backAction->setEnabled(m_view->history()->canGoBack());
forwardAction->setEnabled(m_view->history()->canGoForward());
- stopReloadAction->setIcon(qStyle->standardIcon(QStyle::SP_BrowserReload));
+ stopReloadAction->setIcon(Util::icon(QStyle::SP_BrowserReload));
}
diff --git a/src/mainwindow/widgets/navigationbar.h b/src/mainwindow/widgets/navigationbar.h
index 98d62dc..0b5a319 100644
--- a/src/mainwindow/widgets/navigationbar.h
+++ b/src/mainwindow/widgets/navigationbar.h
@@ -11,13 +11,14 @@
#include <QToolBar>
+class Configuration;
class WebView;
class NavigationBar : public QToolBar
{
Q_OBJECT
public:
- explicit NavigationBar(const QHash<QString, QString> &conf, QWidget *parent = nullptr);
+ explicit NavigationBar(const Configuration *config, QWidget *parent = nullptr);
public slots:
void connectWebView(WebView *view);
@@ -27,7 +28,6 @@ private slots:
void update_loadFinished();
private:
- QStyle *qStyle;
WebView *m_view;
QAction *backAction, *forwardAction;