From fe9745ce232bcb3f9fbbd597496e18423f0914cb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Blin?=
 <sebastien.blin@savoirfairelinux.com>
Date: Wed, 22 Sep 2021 14:01:42 -0400
Subject: [PATCH] messagewebviewheader: clean code

+ Change name to ChatviewHeader as no webview
+ Avoid anchors hell and use a RowLayout

Change-Id: Iff4bbeabc70cfa496a7a208ee5da0c9ea1b6ff08
---
 qml.qrc                                       |  2 +-
 src/constant/JamiTheme.qml                    |  2 +-
 src/mainview/components/ChatView.qml          |  6 ++--
 ...geWebViewHeader.qml => ChatViewHeader.qml} | 30 +++----------------
 4 files changed, 9 insertions(+), 31 deletions(-)
 rename src/mainview/components/{MessageWebViewHeader.qml => ChatViewHeader.qml} (82%)

diff --git a/qml.qrc b/qml.qrc
index 91803d64b..8597566ea 100644
--- a/qml.qrc
+++ b/qml.qrc
@@ -95,7 +95,7 @@
         <file>src/mainview/components/SidePanel.qml</file>
         <file>src/mainview/components/WelcomePage.qml</file>
         <file>src/mainview/components/ChatView.qml</file>
-        <file>src/mainview/components/MessageWebViewHeader.qml</file>
+        <file>src/mainview/components/ChatViewHeader.qml</file>
         <file>src/mainview/components/AccountComboBox.qml</file>
         <file>src/mainview/components/CallStackView.qml</file>
         <file>src/mainview/components/InitialCallPage.qml</file>
diff --git a/src/constant/JamiTheme.qml b/src/constant/JamiTheme.qml
index 4f0c93ef7..a16114497 100644
--- a/src/constant/JamiTheme.qml
+++ b/src/constant/JamiTheme.qml
@@ -272,8 +272,8 @@ Item {
 
     // MessageWebView
     property real chatViewHairLineSize: 1
-    property real messageWebViewHeaderPreferredHeight: 64
     property real chatViewMaximumWidth: 900
+    property real chatViewHeaderPreferredHeight: 64
     property real chatViewFooterPreferredHeight: 50
     property real chatViewFooterMaximumHeight: 280
     property real chatViewFooterRowSpacing: 1
diff --git a/src/mainview/components/ChatView.qml b/src/mainview/components/ChatView.qml
index 1336f1435..fe8be3a1e 100644
--- a/src/mainview/components/ChatView.qml
+++ b/src/mainview/components/ChatView.qml
@@ -52,13 +52,13 @@ Rectangle {
 
         spacing: 0
 
-        MessageWebViewHeader {
+        ChatViewHeader {
             id: messageWebViewHeader
 
             Layout.alignment: Qt.AlignHCenter
             Layout.fillWidth: true
-            Layout.preferredHeight: JamiTheme.messageWebViewHeaderPreferredHeight
-            Layout.maximumHeight: JamiTheme.messageWebViewHeaderPreferredHeight
+            Layout.preferredHeight: JamiTheme.chatViewHeaderPreferredHeight
+            Layout.maximumHeight: JamiTheme.chatViewHeaderPreferredHeight
 
             userAliasLabelText: headerUserAliasLabelText
             userUserNameLabelText: headerUserUserNameLabelText
diff --git a/src/mainview/components/MessageWebViewHeader.qml b/src/mainview/components/ChatViewHeader.qml
similarity index 82%
rename from src/mainview/components/MessageWebViewHeader.qml
rename to src/mainview/components/ChatViewHeader.qml
index de14a33f1..f2ce5da90 100644
--- a/src/mainview/components/MessageWebViewHeader.qml
+++ b/src/mainview/components/ChatViewHeader.qml
@@ -1,6 +1,7 @@
 /*
  * Copyright (C) 2020 by Savoir-faire Linux
  * Author: Mingrui Zhang <mingrui.zhang@savoirfairelinux.com>
+ * 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
@@ -82,9 +83,8 @@ Rectangle {
             Layout.alignment: Qt.AlignLeft | Qt.AlignTop
 
             // Width + margin.
-            Layout.preferredWidth: root.width
-                                   - backToWelcomeViewButton.width - buttonGroup.width - 45
             Layout.fillHeight: true
+            Layout.fillWidth: true
             Layout.topMargin: 7
             Layout.bottomMargin: 7
             Layout.leftMargin: 8
@@ -130,12 +130,11 @@ Rectangle {
             }
         }
 
-        Item {
+        RowLayout {
             id: buttonGroup
 
             Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
-            Layout.preferredWidth: childrenRect.width + 18
-            Layout.preferredHeight: childrenRect.height
+            Layout.fillWidth: true
             Layout.rightMargin: 8
 
             PushButton {
@@ -143,10 +142,6 @@ Rectangle {
 
                 visible: interactionButtonsVisibility
 
-                anchors.right: startAVideoCallButton.left
-                anchors.rightMargin: 8
-                anchors.verticalCenter: buttonGroup.verticalCenter
-
                 source: JamiResources.place_audiocall_24dp_svg
                 toolTipText: JamiStrings.placeAudioCall
 
@@ -161,13 +156,6 @@ Rectangle {
 
                 visible: interactionButtonsVisibility
 
-                anchors.right: selectPluginButton.visible ? selectPluginButton.left :
-                                   sendContactRequestButton.visible ?
-                                   sendContactRequestButton.left :
-                                   buttonGroup.right
-                anchors.rightMargin: 8
-                anchors.verticalCenter: buttonGroup.verticalCenter
-
                 source: JamiResources.videocam_24dp_svg
                 toolTipText: JamiStrings.placeVideoCall
 
@@ -183,12 +171,6 @@ Rectangle {
                 visible: PluginAdapter.chatHandlersListCount &&
                          interactionButtonsVisibility
 
-                anchors.right: sendContactRequestButton.visible ?
-                                   sendContactRequestButton.left :
-                                   buttonGroup.right
-                anchors.rightMargin: sendContactRequestButton.visible ? 8 : 16
-                anchors.verticalCenter: buttonGroup.verticalCenter
-
                 source: JamiResources.plugins_24dp_svg
                 toolTipText: JamiStrings.showPlugins
 
@@ -203,10 +185,6 @@ Rectangle {
 
                 visible: CurrentConversation.isTemporary
 
-                anchors.right: buttonGroup.right
-                anchors.rightMargin: 8
-                anchors.verticalCenter: buttonGroup.verticalCenter
-
                 source: JamiResources.add_people_24dp_svg
                 toolTipText: JamiStrings.addToConversations
 
-- 
GitLab