From 749ee367a41a484bc80acf47cc4cca1af2a6c544 Mon Sep 17 00:00:00 2001 From: aqua Date: Thu, 8 Sep 2022 17:40:11 +0300 Subject: RekonqWindow: apply shortcuts --- src/application.cpp | 3 +++ src/rekonq.kcfg | 9 +++++++++ src/rekonqwindow.hpp | 2 +- src/rekonqwindow_class.cpp | 15 +++++++++++++-- src/settings/test/test_settings.cpp | 2 +- 5 files changed, 27 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/application.cpp b/src/application.cpp index c3858a4a..55343030 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -370,7 +370,10 @@ void Application::setWindowInfo(RekonqWindow *w) RekonqWindow *Application::newWindow() { + Q_CHECK_PTR(m_settings); + auto *window = new RekonqWindow; + window->setupShortcuts(m_settings); m_windows.append(window); window->show(); diff --git a/src/rekonq.kcfg b/src/rekonq.kcfg index eab64724..7776a0b1 100644 --- a/src/rekonq.kcfg +++ b/src/rekonq.kcfg @@ -86,6 +86,15 @@ + + + + + + + + + Ctrl+B diff --git a/src/rekonqwindow.hpp b/src/rekonqwindow.hpp index 58dbe539..849bdff9 100644 --- a/src/rekonqwindow.hpp +++ b/src/rekonqwindow.hpp @@ -29,7 +29,7 @@ public: explicit RekonqWindow(QWidget *parent = nullptr); ~RekonqWindow() override; - void setupShortcuts(const RekonqSettings *settings); + void setupShortcuts(RekonqSettings *settings); [[nodiscard]] REKONQ_TEST_VIRTUAL RekonqView *currentView() REKONQ_TEST_PURE; public slots: diff --git a/src/rekonqwindow_class.cpp b/src/rekonqwindow_class.cpp index d0645cb6..037abf9a 100644 --- a/src/rekonqwindow_class.cpp +++ b/src/rekonqwindow_class.cpp @@ -10,12 +10,14 @@ #include "rekonqwindow.hpp" #include "ui_rekonqwindow.h" #include +#include #include #ifndef REKONQ_TEST #include "application.hpp" #include "settings/settingsdialog.h" #include "taskmanager.h" +#include #endif #if defined(QT_DEBUG) && !defined(REKONQ_TEST) @@ -82,10 +84,19 @@ RekonqWindow::RekonqWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::Re RekonqWindow::~RekonqWindow() { delete ui; } -void RekonqWindow::setupShortcuts(const RekonqSettings *settings) +void RekonqWindow::setupShortcuts(RekonqSettings *settings) { + settings->beginGroup("Shortcuts"); + for (auto *action : findChildren(QRegularExpression("^action.*"))) { const auto shortcut = settings->value(action->objectName()); - if (shortcut.isValid()) action->setShortcut(shortcut.toString()); + if (!shortcut.isNull()) { + action->setShortcut(shortcut.toString()); +#ifndef REKONQ_TEST + spdlog::debug("Set shortcut {} -> {}", qUtf8Printable(shortcut.toString()), qUtf8Printable(action->objectName())); +#endif + } } + + settings->endGroup(); } diff --git a/src/settings/test/test_settings.cpp b/src/settings/test/test_settings.cpp index a797a224..6f69ed35 100644 --- a/src/settings/test/test_settings.cpp +++ b/src/settings/test/test_settings.cpp @@ -99,7 +99,7 @@ TEST(settings, Settings) TEST(settings, SettingsDialog_mock) { - constexpr unsigned n_settings = 36; // there are 36 settings in total + constexpr unsigned n_settings = 39; // total number of settings MockSettings mockSettings; // There are 4 groups in total, but General should not be calling beginGroup/endGroup // beginGroup/endGroup are called twice: during the ctor and when accepted -- cgit v1.2.1