1
0
Fork 0
mirror of https://git.jami.net/savoirfairelinux/jami-client-qt.git synced 2025-04-21 21:52:03 +02:00

add_contact: refactor and change behavior

Change-Id: Ie8cfa5a39b25cd34c7706596a1c607dd1b8c8060
This commit is contained in:
Andreas Hatziiliou 2024-11-13 17:28:13 -05:00
parent 0f7e33cf33
commit 7fdd2f5740
4 changed files with 50 additions and 20 deletions

View file

@ -199,19 +199,6 @@ Rectangle {
onClicked: pluginSelector() 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 { JamiPushButton {
id: searchMessagesButton id: searchMessagesButton
QWKSetParentHitTestVisible { QWKSetParentHitTestVisible {

View file

@ -173,8 +173,10 @@ SidePanelBase {
color: JamiTheme.backgroundColor color: JamiTheme.backgroundColor
} }
header: AccountComboBox { QWKSetParentHitTestVisible {} header: AccountComboBox {
id: accountComboBox id: accountComboBox
QWKSetParentHitTestVisible {
}
Shortcut { Shortcut {
sequence: "Ctrl+J" sequence: "Ctrl+J"
context: Qt.ApplicationShortcut context: Qt.ApplicationShortcut
@ -258,6 +260,13 @@ SidePanelBase {
height: parent.height height: parent.height
Layout.fillWidth: true Layout.fillWidth: true
Behavior on width {
NumberAnimation {
duration: 1000
easing.type: Easing.InOutQuad
}
}
onSearchBarTextChanged: function (text) { onSearchBarTextChanged: function (text) {
// not calling positionViewAtBeginning will cause // not calling positionViewAtBeginning will cause
// sort animation visual bugs // sort animation visual bugs
@ -285,7 +294,7 @@ SidePanelBase {
preferredSize: startBar.height 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 source: smartListLayout.visible ? JamiResources.create_swarm_svg : JamiResources.round_close_24dp_svg
toolTipText: smartListLayout.visible ? JamiStrings.newGroup : JamiStrings.cancel toolTipText: smartListLayout.visible ? JamiStrings.newGroup : JamiStrings.cancel
@ -297,9 +306,7 @@ SidePanelBase {
SidePanelTabBar { SidePanelTabBar {
id: sidePanelTabBar id: sidePanelTabBar
visible: ConversationsAdapter.pendingRequestCount && visible: ConversationsAdapter.pendingRequestCount && !contactSearchBar.textContent && smartListLayout.visible
!contactSearchBar.textContent &&
smartListLayout.visible
contentHeight: childrenRect.height contentHeight: childrenRect.height
width: page.width width: page.width
@ -379,6 +386,33 @@ SidePanelBase {
} }
model: ConversationsAdapter.searchListProxyModel 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 headerLabel: JamiStrings.searchResults
headerVisible: true headerVisible: true
} }

View file

@ -33,11 +33,15 @@ ItemDelegate {
width: ListView.view.width width: ListView.view.width
height: JamiTheme.smartListItemHeight height: JamiTheme.smartListItemHeight
property alias extraButtons: extraButtons
property string accountId: "" property string accountId: ""
property string convId: "" property string convId: ""
highlighted: ListView.isCurrentItem highlighted: ListView.isCurrentItem
property bool interactive: true property bool interactive: true
property bool isTemporary: false
property bool isBanned: false
property int lastInteractionTimeStamp: LastInteractionTimeStamp property int lastInteractionTimeStamp: LastInteractionTimeStamp
property string lastInteractionFormattedDate: MessagesAdapter.getBestFormattedDate(lastInteractionTimeStamp) property string lastInteractionFormattedDate: MessagesAdapter.getBestFormattedDate(lastInteractionTimeStamp)
@ -66,6 +70,8 @@ ItemDelegate {
// Store to avoid undefined at the end // Store to avoid undefined at the end
root.accountId = Qt.binding(() => CurrentAccount.id); root.accountId = Qt.binding(() => CurrentAccount.id);
root.convId = UID; root.convId = UID;
root.isTemporary = ContactType == Profile.Type.TEMPORARY;
root.isBanned = isBanned;
} }
RowLayout { RowLayout {
@ -85,6 +91,7 @@ ItemDelegate {
Layout.preferredWidth: JamiTheme.smartListAvatarSize Layout.preferredWidth: JamiTheme.smartListAvatarSize
Layout.preferredHeight: JamiTheme.smartListAvatarSize Layout.preferredHeight: JamiTheme.smartListAvatarSize
Rectangle { Rectangle {
id: overlayHighlighted id: overlayHighlighted
visible: highlighted && !interactive visible: highlighted && !interactive
@ -239,6 +246,10 @@ ItemDelegate {
} }
} }
Control {
id: extraButtons
}
Accessible.role: Accessible.Button Accessible.role: Accessible.Button
Accessible.name: Title === undefined ? "" : Title Accessible.name: Title === undefined ? "" : Title
Accessible.description: LastInteraction === undefined ? "" : LastInteraction Accessible.description: LastInteraction === undefined ? "" : LastInteraction

View file

@ -46,9 +46,7 @@ ListSelectionView {
function test_checkBasicVisibility() { function test_checkBasicVisibility() {
var chatviewHeader = findChild(uut, "chatViewHeader") var chatviewHeader = findChild(uut, "chatViewHeader")
var detailsButton = findChild(chatviewHeader, "detailsButton") var detailsButton = findChild(chatviewHeader, "detailsButton")
var sendContactRequestButton = findChild(chatviewHeader, "sendContactRequestButton")
compare(detailsButton.visible, true) compare(detailsButton.visible, true)
compare(sendContactRequestButton.visible, false)
var chatViewFooter = findChild(uut, "chatViewFooter") var chatViewFooter = findChild(uut, "chatViewFooter")
CurrentConversation.isTemporary = true CurrentConversation.isTemporary = true