From 28d7ab5213ec34988ba0d193b3efbbdffafac516 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Blin?=
 <sebastien.blin@savoirfairelinux.com>
Date: Thu, 2 Jun 2022 07:36:49 -0400
Subject: [PATCH] swarmdetailspanel: improve about buttons

Change-Id: I4b8e162f8a39363eae614545047056eb4b0ea55a
---
 qml.qrc                                       |  1 +
 .../mainview/components/SwarmDetailsItem.qml  | 39 ++++++++
 .../mainview/components/SwarmDetailsPanel.qml | 98 +++++++++----------
 .../settingsview/components/ToggleSwitch.qml  |  8 ++
 4 files changed, 97 insertions(+), 49 deletions(-)
 create mode 100644 src/app/mainview/components/SwarmDetailsItem.qml

diff --git a/qml.qrc b/qml.qrc
index a2811172e..b186f1c12 100644
--- a/qml.qrc
+++ b/qml.qrc
@@ -115,6 +115,7 @@
         <file>src/app/mainview/components/CallViewContextMenu.qml</file>
         <file>src/app/mainview/components/UserProfile.qml</file>
         <file>src/app/mainview/components/SwarmDetailsPanel.qml</file>
+        <file>src/app/mainview/components/SwarmDetailsItem.qml</file>
         <file>src/app/mainview/components/AddMemberPanel.qml</file>
         <file>src/app/mainview/components/SelectScreen.qml</file>
         <file>src/app/mainview/components/ScreenRubberBand.qml</file>
diff --git a/src/app/mainview/components/SwarmDetailsItem.qml b/src/app/mainview/components/SwarmDetailsItem.qml
new file mode 100644
index 000000000..4249ebbff
--- /dev/null
+++ b/src/app/mainview/components/SwarmDetailsItem.qml
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2022 Savoir-faire Linux Inc.
+ * Author: Sébastien Blin <sebastien.blin@savoirfairelinux.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ */
+
+import QtQuick
+import QtQuick.Controls
+import QtQuick.Layouts
+
+import net.jami.Models 1.1
+import net.jami.Adapters 1.1
+import net.jami.Constants 1.1
+
+Rectangle {
+    id: root
+
+    color: "transparent"
+
+    HoverHandler {
+        target: parent
+        enabled: parent.visible
+        onHoveredChanged: {
+            parent.color = hovered ? Qt.darker(JamiTheme.selectedColor, 1.05) : "transparent"
+        }
+    }
+}
\ No newline at end of file
diff --git a/src/app/mainview/components/SwarmDetailsPanel.qml b/src/app/mainview/components/SwarmDetailsPanel.qml
index 4836a1aef..a74879d97 100644
--- a/src/app/mainview/components/SwarmDetailsPanel.qml
+++ b/src/app/mainview/components/SwarmDetailsPanel.qml
@@ -227,30 +227,33 @@ Rectangle {
                 anchors.left: parent.left
                 anchors.right: parent.right
                 anchors.rightMargin: JamiTheme.settingsMarginSize
-                spacing: JamiTheme.preferredMarginSize
                 visible: tabBar.currentIndex === 0
                 Layout.alignment: Qt.AlignTop
 
-                ToggleSwitch {
-                    id: ignoreSwarm
-
+                SwarmDetailsItem {
                     Layout.fillWidth: true
-                    Layout.leftMargin: JamiTheme.preferredMarginSize
-                    Layout.topMargin: JamiTheme.preferredMarginSize
+                    Layout.preferredHeight: JamiTheme.settingsFontSize + 2 * JamiTheme.preferredMarginSize + 4
+
+                    ToggleSwitch {
+                        id: ignoreSwarm
+
+                        anchors.fill: parent
+                        anchors.leftMargin: JamiTheme.preferredMarginSize
 
-                    checked: false // TODO
+                        checked: false // TODO
 
-                    labelText: JamiStrings.ignoreTheSwarm
-                    fontPointSize: JamiTheme.settingsFontSize
+                        labelText: JamiStrings.ignoreTheSwarm
+                        fontPointSize: JamiTheme.settingsFontSize
 
-                    tooltipText: JamiStrings.ignoreTheSwarmTooltip
+                        tooltipText: JamiStrings.ignoreTheSwarmTooltip
 
-                    onSwitchToggled: {
-                        // TODO
+                        onSwitchToggled: {
+                            // TODO
+                        }
                     }
                 }
 
-                Rectangle {
+                SwarmDetailsItem {
                     Layout.fillWidth: true
                     Layout.preferredHeight: JamiTheme.settingsFontSize + 2 * JamiTheme.preferredMarginSize + 4
 
@@ -268,16 +271,6 @@ Rectangle {
                         color: JamiTheme.textColor
                     }
 
-                    color: "transparent"
-
-                    HoverHandler {
-                        target: parent
-                        enabled: parent.visible
-                        onHoveredChanged: {
-                            parent.color = hovered ? Qt.darker(JamiTheme.selectedColor, 1.05) : "transparent"
-                        }
-                    }
-
                     TapHandler {
                         target: parent
                         enabled: parent.visible
@@ -287,40 +280,47 @@ Rectangle {
                     }
                 }
 
-                RowLayout {
-                    Layout.leftMargin: JamiTheme.preferredMarginSize
+                SwarmDetailsItem {
+                    Layout.fillWidth: true
+                    Layout.preferredHeight: JamiTheme.settingsFontSize + 2 * JamiTheme.preferredMarginSize + 4
 
-                    Text {
-                        Layout.fillWidth: true
-                        Layout.preferredHeight: 30
-                        Layout.rightMargin: JamiTheme.preferredMarginSize
+                    RowLayout {
+                        anchors.fill: parent
+                        anchors.leftMargin: JamiTheme.preferredMarginSize
 
-                        text: JamiStrings.chooseAColor
-                        font.pointSize: JamiTheme.settingsFontSize
-                        font.kerning: true
-                        elide: Text.ElideRight
-                        horizontalAlignment: Text.AlignLeft
-                        verticalAlignment: Text.AlignVCenter
+                        Text {
+                            Layout.fillWidth: true
+                            Layout.preferredHeight: 30
+                            Layout.rightMargin: JamiTheme.preferredMarginSize
 
-                        color: JamiTheme.textColor
-                    }
+                            text: JamiStrings.chooseAColor
+                            font.pointSize: JamiTheme.settingsFontSize
+                            font.kerning: true
+                            elide: Text.ElideRight
+                            horizontalAlignment: Text.AlignLeft
+                            verticalAlignment: Text.AlignVCenter
 
-                    Rectangle {
-                        id: chooseAColorBtn
+                            color: JamiTheme.textColor
+                        }
 
-                        Layout.alignment: Qt.AlignRight
+                        Rectangle {
+                            id: chooseAColorBtn
 
-                        width: JamiTheme.aboutBtnSize
-                        height: JamiTheme.aboutBtnSize
-                        radius: JamiTheme.aboutBtnSize / 2
+                            Layout.alignment: Qt.AlignRight
 
-                        color: CurrentConversation.color
+                            width: JamiTheme.aboutBtnSize
+                            height: JamiTheme.aboutBtnSize
+                            radius: JamiTheme.aboutBtnSize / 2
+
+                            color: CurrentConversation.color
+                        }
+                    }
 
-                        MouseArea {
-                            id: mouseArea
-                            anchors.fill: parent
-                            hoverEnabled: true
-                            onClicked: colorDialog.open()
+                    TapHandler {
+                        target: parent
+                        enabled: parent.visible
+                        onTapped: function onTapped(eventPoint) {
+                            colorDialog.open()
                         }
                     }
                 }
diff --git a/src/app/settingsview/components/ToggleSwitch.qml b/src/app/settingsview/components/ToggleSwitch.qml
index eaa5e734e..952dca9ba 100644
--- a/src/app/settingsview/components/ToggleSwitch.qml
+++ b/src/app/settingsview/components/ToggleSwitch.qml
@@ -70,4 +70,12 @@ RowLayout {
 
         onToggled: switchToggled()
     }
+
+    TapHandler {
+        target: parent
+        enabled: parent.visible
+        onTapped: function onTapped(eventPoint) {
+            switchOfLayout.checked = !switchOfLayout.checked
+        }
+    }
 }
-- 
GitLab