From 4769a78c507c61977cd0421b3c4510460399a754 Mon Sep 17 00:00:00 2001
From: Aline Gondim Santos <aline.gondimsantos@savoirfairelinux.com>
Date: Thu, 25 May 2023 09:28:42 -0300
Subject: [PATCH] RTL: fix shortcut keyboard and download folder setting

GitLab: #1133

Change-Id: If71e23c23974d74345d68469606cb3cc25e78b30
---
 .../components/KeyboardShortcutKeyDelegate.qml       |  5 +++++
 .../mainview/components/KeyboardShortcutTable.qml    | 12 +++++++++---
 .../settingsview/components/SystemSettingsPage.qml   |  2 ++
 3 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/src/app/mainview/components/KeyboardShortcutKeyDelegate.qml b/src/app/mainview/components/KeyboardShortcutKeyDelegate.qml
index dbbcd8926..c30392a75 100644
--- a/src/app/mainview/components/KeyboardShortcutKeyDelegate.qml
+++ b/src/app/mainview/components/KeyboardShortcutKeyDelegate.qml
@@ -18,10 +18,13 @@
 import QtQuick
 import QtQuick.Layouts
 import net.jami.Constants 1.1
+import net.jami.Adapters 1.1
 
 RowLayout {
     id: root
 
+    layoutDirection: UtilsAdapter.isRTL ? Qt.RightToLeft : Qt.LeftToRight
+
     Rectangle {
         id: descriptionTextRect
 
@@ -29,6 +32,7 @@ RowLayout {
         Layout.preferredHeight: descriptionText.contentHeight + 10
         Layout.preferredWidth: descriptionText.contentWidth + 10
         Layout.leftMargin: 10
+        Layout.rightMargin: 10
 
         color: JamiTheme.transparentColor
 
@@ -50,6 +54,7 @@ RowLayout {
         Layout.alignment: Qt.AlignVCenter | Qt.AlignRight
         Layout.preferredHeight: shortcutText.contentHeight + 10
         Layout.preferredWidth: shortcutText.contentWidth + 10
+        Layout.leftMargin: 10
         Layout.rightMargin: 10
 
         color: JamiTheme.backgroundColor
diff --git a/src/app/mainview/components/KeyboardShortcutTable.qml b/src/app/mainview/components/KeyboardShortcutTable.qml
index 187e590b5..d5288c44d 100644
--- a/src/app/mainview/components/KeyboardShortcutTable.qml
+++ b/src/app/mainview/components/KeyboardShortcutTable.qml
@@ -284,7 +284,8 @@ Window {
 
                 font.pointSize: JamiTheme.titleFontSize
                 text: {
-                    switch (selectionBar.currentIndex) {
+                    var modelId = UtilsAdapter.isRTL ? 4 - selectionBar.currentIndex : selectionBar.currentIndex
+                    switch (modelId) {
                     case 0:
                         return JamiStrings.generalSettingsTitle;
                     case 1:
@@ -312,7 +313,8 @@ Window {
             height: parent.height - titleRect.height - JamiTheme.titleRectMargin - keyboardShortCutList.anchors.topMargin - selectionBar.height - selectionBar.anchors.bottomMargin
 
             model: {
-                switch (selectionBar.currentIndex) {
+                var modelId = UtilsAdapter.isRTL ? 4 - selectionBar.currentIndex : selectionBar.currentIndex
+                switch (modelId) {
                 case 0:
                     return keyboardGeneralShortcutsModel;
                 case 1:
@@ -346,13 +348,17 @@ Window {
             }
 
             Repeater {
-                model: ["1", "2", "3", "4", "5"]
+                model: UtilsAdapter.isRTL ? ["5", "4", "3", "2", "1"] : ["1", "2", "3", "4", "5"]
 
                 KeyboardShortcutTabButton {
                     currentIndex: selectionBar.currentIndex
                     text: modelData
                 }
             }
+
+            Component.onCompleted: {
+                setCurrentIndex(UtilsAdapter.isRTL ? 4 : 0);
+            }
         }
     }
 }
diff --git a/src/app/settingsview/components/SystemSettingsPage.qml b/src/app/settingsview/components/SystemSettingsPage.qml
index 2a85be471..3eb128380 100644
--- a/src/app/settingsview/components/SystemSettingsPage.qml
+++ b/src/app/settingsview/components/SystemSettingsPage.qml
@@ -102,6 +102,8 @@ SettingsPageBase {
                 Layout.fillWidth: true
                 Layout.minimumHeight: JamiTheme.preferredFieldHeight
 
+                layoutDirection: UtilsAdapter.isRTL ? Qt.RightToLeft : Qt.LeftToRight
+
                 Text {
                     Layout.fillWidth: true
                     Layout.fillHeight: true
-- 
GitLab