chore(StatusItemDelegate): api extended, internals improved

Id removed from StatusBaseText used in default contentItem, what was
causing that default contentItem was instantiated even when overridden
by user. Radius and cursorShape properties exposed.
This commit is contained in:
Michał Cieślak 2023-04-20 15:29:14 +02:00 committed by Michał
parent c97fe80420
commit fb60d019b6
2 changed files with 15 additions and 10 deletions

View File

@ -1,15 +1,16 @@
import QtQuick 2.14
import QtQuick.Controls 2.14
import QtQuick.Layouts 1.14
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15
import StatusQ.Core 0.1
import StatusQ.Core.Theme 0.1
import StatusQ.Controls 0.1
ItemDelegate {
id: root
property alias textHorizontalAligment: textItem.horizontalAlignment
property bool centerTextHorizontally: false
property int radius: 0
property int cursorShape: Qt.PointingHandCursor
padding: 8
spacing: 8
@ -30,15 +31,18 @@ ItemDelegate {
}
StatusBaseText {
id: textItem
Layout.fillWidth: true
Layout.fillHeight: true
font: root.font
text: root.text
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight
color: root.enabled ? Theme.palette.directColor1 : Theme.palette.baseColor1
Binding on horizontalAlignment {
when: root.centerTextHorizontally
value: Text.AlignHCenter
}
}
}
@ -47,11 +51,12 @@ ItemDelegate {
? Theme.palette.statusMenu.hoverBackgroundColor
: "transparent"
radius: root.radius
MouseArea {
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
cursorShape: root.cursorShape
acceptedButtons: Qt.NoButton
enabled: root.enabled
}
}
}

View File

@ -111,7 +111,7 @@ Control {
type: StatusComboBox.Type.Secondary
delegate: StatusItemDelegate {
width: combo.control.width
textHorizontalAligment: Text.AlignHCenter
centerTextHorizontally: true
highlighted: combo.control.highlightedIndex === index
font: combo.control.font
text: Number(modelData) + 1