fix: status message color and reaction to model changes

Signed-off-by: Tamás Bari <adaorcpp@gmail.com>
This commit is contained in:
Tamás Bari 2025-10-16 11:26:51 +02:00 committed by Jyrki Gadinger
parent aa7ee74781
commit b26c20e642
2 changed files with 28 additions and 8 deletions

View File

@ -54,7 +54,8 @@ Button {
y: (root.y + Style.trayWindowHeaderHeight + 2)
property real widestMenuItemWidth: 0
width: widestMenuItemWidth + leftPadding + rightPadding
property real maximumWidthAllowed: trayWindowHeader.width - (root.x + 4)
width: Math.min( widestMenuItemWidth + leftPadding + rightPadding, maximumWidthAllowed )
height: Math.min(implicitHeight, maxMenuHeight)
closePolicy: Menu.CloseOnPressOutsideParent | Menu.CloseOnEscape
@ -72,10 +73,25 @@ Button {
implicitHeight: instantiatedUserLine.height
UserLine {
id: instantiatedUserLine
width: accountMenu.widestMenuItemWidth
width: Math.min(accountMenu.widestMenuItemWidth, accountMenu.maximumWidthAllowed)
Component.onCompleted: {
accountMenu.widestMenuItemWidth = Math.max( instantiatedUserLine.implicitWidth, accountMenu.widestMenuItemWidth )
instantiatedUserLine.updateMenuWidth()
}
onImplicitWidthChanged: {
instantiatedUserLine.updateMenuWidth()
}
Connections {
target: model
function onNameChanged() {
instantiatedUserLine.updateMenuWidth()
}
function onStatusChanged() {
instantiatedUserLine.updateMenuWidth()
}
}
onShowUserStatusSelector: {
@ -87,6 +103,11 @@ Button {
accountMenu.close();
}
onClicked: UserModel.currentUserId = model.index;
function updateMenuWidth()
{
accountMenu.widestMenuItemWidth = Math.max( instantiatedUserLine.implicitWidth, accountMenu.widestMenuItemWidth )
}
}
}
onObjectAdded: function(index, object) {

View File

@ -27,7 +27,6 @@ AbstractButton {
contentItem: RowLayout {
id: userLineLayout
spacing: Style.userLineSpacing
width: parent.width
Image {
id: accountAvatar
@ -83,7 +82,7 @@ AbstractButton {
color: !userLine.parent.enabled
? userLine.parent.palette.mid
: (userLine.parent.highlighted || userLine.parent.down
? Style.contrastingColor( parent.palette.highlight )
? userLine.parent.palette.highlightedText
: userLine.parent.palette.text)
}
@ -103,7 +102,7 @@ AbstractButton {
color: !userLine.parent.enabled
? userLine.parent.palette.mid
: ((userLine.parent.highlighted || userLine.parent.down) && Qt.platform.os !== "windows"
? Style.contrastingColor( parent.palette.highlight )
? userLine.parent.palette.highlightedText
: userLine.parent.palette.text)
}
@ -135,7 +134,7 @@ AbstractButton {
color: !userLine.parent.enabled
? userLine.parent.palette.mid
: ((userLine.parent.highlighted || userLine.parent.down) && Qt.platform.os !== "windows"
? Style.contrastingColor( parent.palette.highlight )
? userLine.parent.palette.highlightedText
: userLine.parent.palette.text)
}
}
@ -159,7 +158,7 @@ AbstractButton {
property var iconColor: !userLine.parent.enabled
? userLine.parent.palette.mid
: (!hovered && ((userLine.parent.highlighted || userLine.parent.down) && Qt.platform.os !== "windows")
? Style.contrastingColor( parent.palette.highlight )
? userLine.parent.palette.highlightedText
: userLine.parent.palette.text)
icon.source: "image://svgimage-custom-color/more.svg/" + iconColor