From 7fdd2f57408faf057738ee2e4638165c35c7b6c3 Mon Sep 17 00:00:00 2001 From: Andreas Hatziiliou <andreas.hatziiliou@savoirfairelinux.com> Date: Wed, 13 Nov 2024 17:28:13 -0500 Subject: [PATCH] add_contact: refactor and change behavior Change-Id: Ie8cfa5a39b25cd34c7706596a1c607dd1b8c8060 --- .../mainview/components/ChatViewHeader.qml | 13 ------ src/app/mainview/components/SidePanel.qml | 44 ++++++++++++++++--- .../components/SmartListItemDelegate.qml | 11 +++++ tests/qml/src/tst_ChatView.qml | 2 - 4 files changed, 50 insertions(+), 20 deletions(-) diff --git a/src/app/mainview/components/ChatViewHeader.qml b/src/app/mainview/components/ChatViewHeader.qml index 1c5c1f426..6e0f60df5 100644 --- a/src/app/mainview/components/ChatViewHeader.qml +++ b/src/app/mainview/components/ChatViewHeader.qml @@ -199,19 +199,6 @@ Rectangle { onClicked: pluginSelector() } - JamiPushButton { - id: sendContactRequestButton - QWKSetParentHitTestVisible { - } - objectName: "sendContactRequestButton" - - visible: CurrentConversation.isTemporary || CurrentConversation.isBanned - source: JamiResources.add_people_24dp_svg - toolTipText: JamiStrings.addToConversations - - onClicked: CurrentConversation.isBanned ? MessagesAdapter.unbanConversation(CurrentConversation.id) : MessagesAdapter.sendConversationRequest() - } - JamiPushButton { id: searchMessagesButton QWKSetParentHitTestVisible { diff --git a/src/app/mainview/components/SidePanel.qml b/src/app/mainview/components/SidePanel.qml index c564e847a..2de2cb67b 100644 --- a/src/app/mainview/components/SidePanel.qml +++ b/src/app/mainview/components/SidePanel.qml @@ -173,8 +173,10 @@ SidePanelBase { color: JamiTheme.backgroundColor } - header: AccountComboBox { QWKSetParentHitTestVisible {} + header: AccountComboBox { id: accountComboBox + QWKSetParentHitTestVisible { + } Shortcut { sequence: "Ctrl+J" context: Qt.ApplicationShortcut @@ -258,6 +260,13 @@ SidePanelBase { height: parent.height Layout.fillWidth: true + Behavior on width { + NumberAnimation { + duration: 1000 + easing.type: Easing.InOutQuad + } + } + onSearchBarTextChanged: function (text) { // not calling positionViewAtBeginning will cause // sort animation visual bugs @@ -285,7 +294,7 @@ SidePanelBase { preferredSize: startBar.height - visible: !swarmMemberSearchList.visible && CurrentAccount.type !== Profile.Type.SIP + visible: !swarmMemberSearchList.visible && CurrentAccount.type !== Profile.Type.SIP && !contactSearchBar.textContent source: smartListLayout.visible ? JamiResources.create_swarm_svg : JamiResources.round_close_24dp_svg toolTipText: smartListLayout.visible ? JamiStrings.newGroup : JamiStrings.cancel @@ -297,9 +306,7 @@ SidePanelBase { SidePanelTabBar { id: sidePanelTabBar - visible: ConversationsAdapter.pendingRequestCount && - !contactSearchBar.textContent && - smartListLayout.visible + visible: ConversationsAdapter.pendingRequestCount && !contactSearchBar.textContent && smartListLayout.visible contentHeight: childrenRect.height width: page.width @@ -379,6 +386,33 @@ SidePanelBase { } model: ConversationsAdapter.searchListProxyModel + + delegate: SmartListItemDelegate { + extraButtons.contentItem: JamiPushButton { + id: sendContactRequestButton + QWKSetParentHitTestVisible { + } + + anchors.right: parent.right + anchors.verticalCenter: parent.verticalCenter + visible: isTemporary || isBanned + source: JamiResources.add_people_24dp_svg + toolTipText: JamiStrings.addToConversations + + onClicked: { + console.log(isBanned); + if (isBanned) { + LRCInstance.selectConversation(UID); + MessagesAdapter.unbanConversation(CurrentConversation.id); + } else { + LRCInstance.selectConversation(UID); + MessagesAdapter.sendConversationRequest(); + } + } + } + extraButtons.height: sendContactRequestButton.height; + extraButtons.width: sendContactRequestButton.width; + } headerLabel: JamiStrings.searchResults headerVisible: true } diff --git a/src/app/mainview/components/SmartListItemDelegate.qml b/src/app/mainview/components/SmartListItemDelegate.qml index 9e75159e9..461f40749 100644 --- a/src/app/mainview/components/SmartListItemDelegate.qml +++ b/src/app/mainview/components/SmartListItemDelegate.qml @@ -33,11 +33,15 @@ ItemDelegate { width: ListView.view.width height: JamiTheme.smartListItemHeight + property alias extraButtons: extraButtons + property string accountId: "" property string convId: "" highlighted: ListView.isCurrentItem property bool interactive: true + property bool isTemporary: false + property bool isBanned: false property int lastInteractionTimeStamp: LastInteractionTimeStamp property string lastInteractionFormattedDate: MessagesAdapter.getBestFormattedDate(lastInteractionTimeStamp) @@ -66,6 +70,8 @@ ItemDelegate { // Store to avoid undefined at the end root.accountId = Qt.binding(() => CurrentAccount.id); root.convId = UID; + root.isTemporary = ContactType == Profile.Type.TEMPORARY; + root.isBanned = isBanned; } RowLayout { @@ -85,6 +91,7 @@ ItemDelegate { Layout.preferredWidth: JamiTheme.smartListAvatarSize Layout.preferredHeight: JamiTheme.smartListAvatarSize + Rectangle { id: overlayHighlighted visible: highlighted && !interactive @@ -239,6 +246,10 @@ ItemDelegate { } } + Control { + id: extraButtons + } + Accessible.role: Accessible.Button Accessible.name: Title === undefined ? "" : Title Accessible.description: LastInteraction === undefined ? "" : LastInteraction diff --git a/tests/qml/src/tst_ChatView.qml b/tests/qml/src/tst_ChatView.qml index b58af8c7e..c74d4fbe6 100644 --- a/tests/qml/src/tst_ChatView.qml +++ b/tests/qml/src/tst_ChatView.qml @@ -46,9 +46,7 @@ ListSelectionView { function test_checkBasicVisibility() { var chatviewHeader = findChild(uut, "chatViewHeader") var detailsButton = findChild(chatviewHeader, "detailsButton") - var sendContactRequestButton = findChild(chatviewHeader, "sendContactRequestButton") compare(detailsButton.visible, true) - compare(sendContactRequestButton.visible, false) var chatViewFooter = findChild(uut, "chatViewFooter") CurrentConversation.isTemporary = true -- GitLab