feat(StatusPopupMenu): make menu items invisible when disabled

Closes #135
This commit is contained in:
Pascal Precht 2021-06-11 13:20:26 +02:00 committed by Michał Cieślak
parent 666908d93a
commit 7d96ad02ca
2 changed files with 7 additions and 4 deletions

View File

@ -102,6 +102,7 @@ Rectangle {
StatusMenuItem { StatusMenuItem {
text: qsTr("Edit Community") text: qsTr("Edit Community")
icon.name: "edit" icon.name: "edit"
enabled: false
} }
StatusMenuSeparator {} StatusMenuSeparator {}

View File

@ -27,7 +27,7 @@ Menu {
delegate: MenuItem { delegate: MenuItem {
id: statusPopupMenuItem id: statusPopupMenuItem
implicitHeight: 38 implicitHeight: action.enabled ? 38 : 0
property int subMenuIndex property int subMenuIndex
@ -71,8 +71,9 @@ Menu {
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left anchors.left: parent.left
anchors.leftMargin: 8 anchors.leftMargin: 8
active: parent.subMenu && !!statusPopupMenu.subMenuItemIcons[parent.subMenuIndex] || active: (parent.subMenu && !!statusPopupMenu.subMenuItemIcons[parent.subMenuIndex] ||
!!statusPopupMenuItem.action.icon.name !!statusPopupMenuItem.action.icon.name) &&
statusPopupMenuItem.action.enabled
} }
contentItem: StatusBaseText { contentItem: StatusBaseText {
@ -94,6 +95,7 @@ Menu {
} }
font.pixelSize: 13 font.pixelSize: 13
elide: Text.ElideRight elide: Text.ElideRight
visible: statusPopupMenuItem.action.enabled
} }
arrow: StatusIcon { arrow: StatusIcon {
@ -120,7 +122,7 @@ Menu {
anchors.fill: parent anchors.fill: parent
cursorShape: Qt.PointingHandCursor cursorShape: Qt.PointingHandCursor
hoverEnabled: true hoverEnabled: statusPopupMenuItem.action.enabled
onPressed: mouse.accepted = false onPressed: mouse.accepted = false
} }
} }