From 29fe130f6d5d5fa95221fb193a274b9a59440b1e Mon Sep 17 00:00:00 2001 From: Carl Schwan Date: Tue, 1 Dec 2020 15:45:41 +0100 Subject: [PATCH] Use standard Ctrl+Shift+Comma shortcut for showing settings Fix: #42 --- qml/main.qml | 1 + src/controller.cpp | 6 ++++++ src/controller.h | 6 ++++++ 3 files changed, 13 insertions(+) diff --git a/qml/main.qml b/qml/main.qml index 7b7bfcc7d..8e6325db0 100644 --- a/qml/main.qml +++ b/qml/main.qml @@ -156,6 +156,7 @@ Kirigami.ApplicationWindow { icon.name: "settings-configure" onTriggered: pushReplaceLayer("qrc:/imports/NeoChat/Page/SettingsPage.qml") enabled: pageStack.layers.currentItem.title !== i18n("Settings") + shortcut: Controller.preferencesShortcuts[0] }, Kirigami.Action { text: i18n("About Neochat") diff --git a/src/controller.cpp b/src/controller.cpp index 771deb5bd..7baa65e90 100644 --- a/src/controller.cpp +++ b/src/controller.cpp @@ -46,6 +46,7 @@ #include "neochatuser.h" #include "settings.h" #include "utils.h" +#include #ifndef Q_OS_ANDROID #include "trayicon.h" @@ -550,3 +551,8 @@ void Controller::setActiveConnection(Connection *connection) m_connection = connection; Q_EMIT activeConnectionChanged(); } + +QList Controller::preferencesShortcuts() const +{ + return KStandardShortcut::preferences(); +} diff --git a/src/controller.h b/src/controller.h index 4506f3c56..ffd27a249 100644 --- a/src/controller.h +++ b/src/controller.h @@ -12,6 +12,7 @@ #include #include +class QKeySequences; #include "connection.h" #include "csapi/list_public_rooms.h" @@ -30,6 +31,9 @@ class Controller : public QObject Q_PROPERTY(bool busy READ busy WRITE setBusy NOTIFY busyChanged) Q_PROPERTY(KAboutData aboutData READ aboutData WRITE setAboutData NOTIFY aboutDataChanged) + /// Get the list of shortcuts activating the preferences page + Q_PROPERTY(QList preferencesShortcuts READ preferencesShortcuts CONSTANT) + public: static Controller &instance(); @@ -48,6 +52,8 @@ public: [[nodiscard]] int accountCount() const; + [[nodiscard]] QList preferencesShortcuts() const; + [[nodiscard]] static bool quitOnLastWindowClosed(); void setQuitOnLastWindowClosed(bool value);