From 45b86d56d99c3322b0701d032a654aa1303e28a9 Mon Sep 17 00:00:00 2001
From: Ming Rui Zhang <mingrui.zhang@savoirfairelinux.com>
Date: Mon, 27 Sep 2021 16:58:50 -0400
Subject: [PATCH] shortcut: fix settings menu selection shortcut

Change-Id: I19cab014fc119ae0fe0b3e742d1ec59ca8dfadc3
---
 src/mainview/MainView.qml                    |  8 ++++----
 src/settingsview/components/SettingsMenu.qml | 14 ++++++++++++++
 2 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/src/mainview/MainView.qml b/src/mainview/MainView.qml
index aa22b3078..a416ba27a 100644
--- a/src/mainview/MainView.qml
+++ b/src/mainview/MainView.qml
@@ -479,7 +479,7 @@ Rectangle {
             if (!inSettingsView) {
                 toggleSettingsView()
             }
-            settingsMenu.btnMediaSettings.clicked()
+            settingsMenu.buttonSelectedManually(SettingsView.Media)
         }
     }
 
@@ -490,7 +490,7 @@ Rectangle {
             if (!inSettingsView) {
                 toggleSettingsView()
             }
-            settingsMenu.btnGeneralSettings.clicked()
+            settingsMenu.buttonSelectedManually(SettingsView.General)
         }
     }
 
@@ -501,7 +501,7 @@ Rectangle {
             if (!inSettingsView) {
                 toggleSettingsView()
             }
-            settingsMenu.btnAccountSettings.clicked()
+            settingsMenu.buttonSelectedManually(SettingsView.Account)
         }
     }
 
@@ -512,7 +512,7 @@ Rectangle {
             if (!inSettingsView) {
                 toggleSettingsView()
             }
-            settingsMenu.btnPluginSettings.clicked()
+            settingsMenu.buttonSelectedManually(SettingsView.Plugin)
         }
     }
 
diff --git a/src/settingsview/components/SettingsMenu.qml b/src/settingsview/components/SettingsMenu.qml
index 382ba3b4f..b596c2437 100644
--- a/src/settingsview/components/SettingsMenu.qml
+++ b/src/settingsview/components/SettingsMenu.qml
@@ -30,6 +30,7 @@ Rectangle {
     id: root
 
     signal itemSelected(int index)
+    signal buttonSelectedManually(int index)
 
     Component.onCompleted: {
         listModel.append({ 'type': SettingsView.Account, 'name': JamiStrings.accountSettingsMenuTitle,
@@ -46,6 +47,8 @@ Rectangle {
     color: JamiTheme.backgroundColor
 
     ButtonGroup {
+        id: buttonGroup
+
         buttons: buttons.children
         onCheckedButtonChanged: itemSelected(checkedButton.menuType)
     }
@@ -64,8 +67,19 @@ Rectangle {
             model: ListModel { id: listModel }
 
             PushButton {
+                id: pushButton
+
                 property int menuType: type
 
+                Connections {
+                    target: root
+
+                    function onButtonSelectedManually(index) {
+                        if (pushButton.menuType === index)
+                            buttonGroup.checkedButton = pushButton
+                    }
+                }
+
                 Component.onCompleted: checked = type === SettingsView.Account
 
                 preferredHeight: 64
-- 
GitLab