diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/application.cpp | 3 | ||||
-rw-r--r-- | src/rekonq.kcfg | 9 | ||||
-rw-r--r-- | src/rekonqwindow.hpp | 2 | ||||
-rw-r--r-- | src/rekonqwindow_class.cpp | 15 | ||||
-rw-r--r-- | src/settings/test/test_settings.cpp | 2 |
5 files changed, 27 insertions, 4 deletions
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 @@ <!-- Shortcuts --> <group name="Shortcuts"> + <entry name="About Qt" key="actionAboutQt" type="Shortcut"> + <default></default> + </entry> + <entry name="Close Window" key="actionCloseWindow" type="Shortcut"> + <default></default> + </entry> + <entry name="Task Manager" key="actionTaskManager" type="Shortcut"> + <default></default> + </entry> <entry name="Show sidebar" key="actionShowSidebar" type="Shortcut"> <default>Ctrl+B</default> </entry> 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 <QRegularExpression> +#include <qglobal.h> #include <rview.hpp> #ifndef REKONQ_TEST #include "application.hpp" #include "settings/settingsdialog.h" #include "taskmanager.h" +#include <spdlog/spdlog.h> #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<QAction *>(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 |