feat(StatusMenuItem): add support for "checked" indicator
- it is displayed on the trailing edge, next to the main text, iff the item/action is `checked` - fix the text elide (must have a width set) - fix for setting the icon name/source/color if we directly use a (Status)MenuItem (as opposed to going via (Status)Action)
This commit is contained in:
parent
b4459c5858
commit
d180001f84
|
@ -1,5 +1,6 @@
|
|||
import QtQuick 2.13
|
||||
import QtQuick.Controls 2.13
|
||||
import QtQuick.Layouts 1.15
|
||||
|
||||
import StatusQ.Core 0.1
|
||||
import StatusQ.Core.Theme 0.1
|
||||
|
@ -83,9 +84,9 @@ MenuItem {
|
|||
rotation: 0
|
||||
// Link to standard Qt properties. Not because it's a good idea,
|
||||
// but because it we use it in some places and it will make refactor easier.
|
||||
name: d.isSubMenu ? "" : root.action.icon.name
|
||||
source: d.isSubMenu ? "" : root.action.icon.source
|
||||
color: d.isSubMenu ? "" : root.action.icon.color
|
||||
name: d.isSubMenu ? "" : (d.hasAction ? root.action.icon.name : root.icon.name)
|
||||
source: d.isSubMenu ? "" : (d.hasAction ? root.action.icon.source : root.icon.source)
|
||||
color: d.isSubMenu ? "" : (d.hasAction ? root.action.icon.color : root.icon.color)
|
||||
}
|
||||
|
||||
readonly property StatusFontSettings defaultFontSettings: StatusFontSettings {
|
||||
|
@ -119,7 +120,9 @@ MenuItem {
|
|||
}
|
||||
}
|
||||
|
||||
contentItem: StatusBaseText {
|
||||
contentItem: RowLayout {
|
||||
StatusBaseText {
|
||||
Layout.fillWidth: true
|
||||
readonly property real arrowPadding: root.spacing + (root.subMenu && root.arrow ? root.arrow.width : 0)
|
||||
readonly property real indicatorPadding: root.spacing + (root.indicator.visible ? root.indicator.width : 0)
|
||||
|
||||
|
@ -132,14 +135,21 @@ MenuItem {
|
|||
text: root.text
|
||||
color: !root.enabled ? Theme.palette.baseColor1
|
||||
: d.isStatusDangerAction ? Theme.palette.dangerColor1
|
||||
: d.isStatusSuccessAction?
|
||||
Theme.palette.successColor1 : Theme.palette.directColor1
|
||||
: d.isStatusSuccessAction ? Theme.palette.successColor1 : Theme.palette.directColor1
|
||||
|
||||
font.pixelSize: d.fontSettings ? d.fontSettings.pixelSize : d.defaultFontSettings.pixelSize
|
||||
font.bold: d.fontSettings ? d.fontSettings.bold : d.defaultFontSettings.bold
|
||||
font.italic: d.fontSettings ? d.fontSettings.italic : d.defaultFontSettings.italic
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
StatusIcon {
|
||||
Layout.preferredHeight: 16
|
||||
Layout.alignment: Qt.AlignRight
|
||||
visible: root.checkable && root.checked
|
||||
icon: "checkmark"
|
||||
color: Theme.palette.primaryColor1
|
||||
}
|
||||
}
|
||||
|
||||
arrow: StatusIcon {
|
||||
id: arrowIcon
|
||||
|
|
Loading…
Reference in New Issue