summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoraqua <aqua@iserlohn-fortress.net>2022-09-08 17:40:11 +0300
committeraqua <aqua@iserlohn-fortress.net>2022-09-08 17:56:44 +0300
commit749ee367a41a484bc80acf47cc4cca1af2a6c544 (patch)
tree0b6cfb3e84c31a6060a59b974406c5fb9c6adfa1
parentRekonqSettings: add resetValue and remove value's defaultValue parameter (diff)
downloadrekonq-749ee367a41a484bc80acf47cc4cca1af2a6c544.tar.xz
RekonqWindow: apply shortcuts
-rw-r--r--CMakeLists.txt1
-rw-r--r--src/application.cpp3
-rw-r--r--src/rekonq.kcfg9
-rw-r--r--src/rekonqwindow.hpp2
-rw-r--r--src/rekonqwindow_class.cpp15
-rw-r--r--src/settings/test/test_settings.cpp2
6 files changed, 27 insertions, 5 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 540ed7e2..43efafac 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -92,7 +92,6 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config-version.h.cmake config-version
# ==================================================================================
# includes for all targets
-include_directories(${CMAKE_CURRENT_BINARY_DIR})
include_directories(include)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
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