diff options
-rw-r--r-- | lib/configuration/configuration.cpp | 2 | ||||
-rw-r--r-- | src/mainwindow/widgets/navigationbar.cpp | 33 |
2 files changed, 32 insertions, 3 deletions
diff --git a/lib/configuration/configuration.cpp b/lib/configuration/configuration.cpp index f09378e..6d8d1ba 100644 --- a/lib/configuration/configuration.cpp +++ b/lib/configuration/configuration.cpp @@ -79,7 +79,9 @@ Configuration::Configuration() // navigation ("navigation.movable", po::value<bool>()->default_value(false)) ("navigation.shortcuts.back", po::value<std::string>()->default_value("Ctrl+Left")) + ("navigation.shortcuts.backMenu", po::value<std::string>()->default_value("Ctrl+Down")) ("navigation.shortcuts.forward", po::value<std::string>()->default_value("Ctrl+Right")) + ("navigation.shortcuts.forwardMenu", po::value<std::string>()->default_value("Ctrl+Up")) ("navigation.shortcuts.refresh", po::value<std::string>()->default_value("F5")) ("navigation.shortcuts.reload", po::value<std::string>()->default_value("Ctrl+F5")) ("navigation.shortcuts.home", po::value<std::string>()->default_value("Ctrl+Home")) diff --git a/src/mainwindow/widgets/navigationbar.cpp b/src/mainwindow/widgets/navigationbar.cpp index 98fe0fa..177c4ad 100644 --- a/src/mainwindow/widgets/navigationbar.cpp +++ b/src/mainwindow/widgets/navigationbar.cpp @@ -25,7 +25,10 @@ NavigationBar::NavigationBar(const QHash<QString, QString> &conf, QWidget *paren // Back button backAction = addAction(qStyle->standardIcon(QStyle::SP_ArrowBack), tr("Back")); - backAction->setShortcut(QKeySequence(conf.value("navigation.shortcuts.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"))); + } connect(backAction, &QAction::triggered, this, [this]() { m_view->history()->back(); }); @@ -42,9 +45,20 @@ NavigationBar::NavigationBar(const QHash<QString, QString> &conf, QWidget *paren }); backAction->setMenu(backMenu); + auto *backMenuShortcut = new QShortcut(QKeySequence(conf.value("navigation.shortcuts.backMenu")), this); + connect(backMenuShortcut, &QShortcut::activated, backMenu, [this, backMenu]() { + if(backAction->isEnabled()) { + auto *widget = this->widgetForAction(backAction); + backMenu->exec(this->mapToGlobal(widget->pos() + QPoint(0, widget->height()))); + } + }); + // Forward button forwardAction = addAction(qStyle->standardIcon(QStyle::SP_ArrowForward), tr("Forward")); - forwardAction->setShortcut(QKeySequence(conf.value("navigation.shortcuts.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"))); + } connect(forwardAction, &QAction::triggered, this, [this]() { m_view->history()->forward(); }); @@ -61,8 +75,16 @@ NavigationBar::NavigationBar(const QHash<QString, QString> &conf, QWidget *paren }); forwardAction->setMenu(forwardMenu); + auto *forwardMenuShortcut = new QShortcut(QKeySequence(conf.value("navigation.shortcuts.forwardMenu")), this); + connect(forwardMenuShortcut, &QShortcut::activated, forwardMenu, [this, forwardMenu]() { + if(forwardAction->isEnabled()) { + auto *widget = this->widgetForAction(forwardAction); + forwardMenu->exec(this->mapToGlobal(widget->pos() + QPoint(0, widget->height()))); + } + }); + // Stop/Refresh button - stopReloadAction = addAction(qStyle->standardIcon(QStyle::SP_BrowserReload), tr("Reload")); + stopReloadAction = addAction(qStyle->standardIcon(QStyle::SP_BrowserReload), tr("Refresh")); stopReloadAction->setShortcut(QKeySequence(conf.value("navigation.shortcuts.refresh"))); connect(stopReloadAction, &QAction::triggered, this, [this]() { if(m_view->isLoaded()) @@ -71,6 +93,11 @@ NavigationBar::NavigationBar(const QHash<QString, QString> &conf, QWidget *paren m_view->stop(); }); + auto *reloadShortcut = new QShortcut(QKeySequence(conf.value("navigation.shortcuts.reload")), 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"))); |