fix(MembersListSelectro): tag item should be removed only when x is clicked

Closes #8259
This commit is contained in:
Alexandra Betouni 2023-04-03 18:12:21 +03:00
parent 617ff8d98d
commit 840b9986dc
4 changed files with 37 additions and 42 deletions

View File

@ -282,7 +282,7 @@ Item {
text: model.name text: model.name
icon: model.tagIcon icon: model.tagIcon
onClicked: { onClosed: {
removeMember(model.pubKey); removeMember(model.pubKey);
namesModel.remove(index, 1); namesModel.remove(index, 1);
} }

View File

@ -1,5 +1,6 @@
import QtQuick 2.14 import QtQuick 2.14
import QtQuick.Layouts 1.15
import QtQuick.Controls 2.15
import StatusQ.Core 0.1 import StatusQ.Core 0.1
import StatusQ.Core.Theme 0.1 import StatusQ.Core.Theme 0.1
@ -26,7 +27,7 @@ import StatusQ.Core.Theme 0.1
For a list of components available see StatusQ. For a list of components available see StatusQ.
*/ */
Rectangle { Control {
id: root id: root
/*! /*!
@ -47,9 +48,9 @@ Rectangle {
/*! /*!
\qmlsignal \qmlsignal
This signal is emitted when the tag is clicked. This signal is emitted when the close button is clicked.
*/ */
signal clicked() signal closed()
QtObject { QtObject {
id: d id: d
@ -66,51 +67,45 @@ Rectangle {
} }
} }
width: tagRow.implicitWidth + 2 * d.tagMargins implicitHeight: 30
height: 30 horizontalPadding: d.tagMargins
background: Rectangle {
color: d.getTagColor(root.isReadonly) color: d.getTagColor(root.isReadonly)
radius: 8 radius: 8
Row { }
contentItem: RowLayout {
id: tagRow id: tagRow
height: parent.height
anchors.left: parent.left
anchors.leftMargin: d.tagMargins
anchors.rightMargin: d.tagMargins
spacing: 2 spacing: 2
StatusIcon { StatusIcon {
visible: root.icon visible: root.icon
anchors.verticalCenter: parent.verticalCenter
color: Theme.palette.indirectColor1 color: Theme.palette.indirectColor1
width: root.icon ? d.tagIconsSize : 0 width: root.icon ? d.tagIconsSize : 0
height: d.tagIconsSize height: d.tagIconsSize
icon: root.icon icon: root.icon
} }
StatusBaseText { StatusBaseText {
id: nameText
anchors.verticalCenter: parent.verticalCenter
color: Theme.palette.indirectColor1 color: Theme.palette.indirectColor1
font.pixelSize: 15 font.pixelSize: 15
text: root.text text: root.text
} }
StatusIcon { StatusIcon {
id: closeIcon Layout.leftMargin: d.tagMargins
visible: !root.isReadonly visible: !root.isReadonly
anchors.leftMargin: d.tagMargins
anchors.verticalCenter: parent.verticalCenter
color: Theme.palette.indirectColor1 color: Theme.palette.indirectColor1
width: d.tagIconsSize width: d.tagIconsSize
height: d.tagIconsSize height: d.tagIconsSize
icon: "close" icon: "close"
}
}
MouseArea { MouseArea {
id: mouseArea id: mouseArea
enabled: !root.isReadonly enabled: !root.isReadonly
anchors.fill: parent anchors.fill: parent
hoverEnabled: true hoverEnabled: true
cursorShape: enabled ? Qt.PointingHandCursor : Qt.ArrowCursor cursorShape: containsMouse ? Qt.PointingHandCursor : Qt.ArrowCursor
onClicked: { root.clicked() } onClicked: { root.closed() }
}
}
} }
} }

View File

@ -64,7 +64,7 @@ MembersSelectorBase {
} }
icon: model.isAdmin ? "crown" : "" icon: model.isAdmin ? "crown" : ""
onClicked: root.entryRemoved(this) onClosed: root.entryRemoved(this)
} }
Component.onCompleted: { Component.onCompleted: {

View File

@ -46,7 +46,7 @@ MembersSelectorBase {
height: ListView.view.height height: ListView.view.height
text: root.tagText(model.localNickname, model.displayName, model.alias) text: root.tagText(model.localNickname, model.displayName, model.alias)
onClicked: root.entryRemoved(this) onClosed: root.entryRemoved(this)
} }
QtObject { QtObject {