Migrate monitorPanel onto the keyboard-driven panel chassis
This commit is contained in:
@@ -16,6 +16,12 @@ Rectangle {
|
||||
property string text: ""
|
||||
property bool selected: false
|
||||
|
||||
// Panel-cursor flag. Same role as PillButton.hasCursor: panels that own
|
||||
// their own cursor state bind this to drive the keyboard highlight
|
||||
// separately from real activeFocus. Visuals match the activeFocus look
|
||||
// (foreground 2px border) so cursor and Tab focus read the same.
|
||||
property bool hasCursor: false
|
||||
|
||||
property color foreground: Color.foreground
|
||||
property color background: Color.background
|
||||
property color accent: Color.accent
|
||||
@@ -23,6 +29,7 @@ Rectangle {
|
||||
property real fontSize: 12
|
||||
|
||||
signal clicked()
|
||||
signal hovered(bool isHovered)
|
||||
|
||||
activeFocusOnTab: true
|
||||
Keys.onReturnPressed: root.clicked()
|
||||
@@ -38,8 +45,8 @@ Rectangle {
|
||||
: (mouse.containsMouse ? Style.hotFill : background)
|
||||
border.color: selected
|
||||
? accent
|
||||
: (activeFocus ? foreground : Qt.rgba(foreground.r, foreground.g, foreground.b, 0.4))
|
||||
border.width: selected ? 2 : (activeFocus ? 2 : 1)
|
||||
: (activeFocus || hasCursor ? foreground : Qt.rgba(foreground.r, foreground.g, foreground.b, 0.4))
|
||||
border.width: selected ? 2 : (activeFocus || hasCursor ? 2 : 1)
|
||||
|
||||
Behavior on color { ColorAnimation { duration: 100 } }
|
||||
|
||||
@@ -63,4 +70,8 @@ Rectangle {
|
||||
root.clicked()
|
||||
}
|
||||
}
|
||||
|
||||
HoverHandler {
|
||||
onHoveredChanged: root.hovered(hovered)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,12 @@ Rectangle {
|
||||
property string description: ""
|
||||
property bool checked: false
|
||||
|
||||
// Panel-cursor flag. Same role as PillButton.hasCursor / ChoiceButton.hasCursor:
|
||||
// panels with their own keyboard cursor bind this to drive the highlight
|
||||
// separately from activeFocus. Visuals match the activeFocus look (accent
|
||||
// border + tinted fill via Style tokens) so cursor and Tab focus read the same.
|
||||
property bool hasCursor: false
|
||||
|
||||
property color foreground: Color.foreground
|
||||
property color accent: Color.accent
|
||||
property string fontFamily: "monospace"
|
||||
@@ -23,6 +29,7 @@ Rectangle {
|
||||
property real descriptionSize: 10
|
||||
|
||||
signal clicked()
|
||||
signal hovered(bool isHovered)
|
||||
|
||||
activeFocusOnTab: true
|
||||
Keys.onReturnPressed: root.clicked()
|
||||
@@ -33,13 +40,13 @@ Rectangle {
|
||||
implicitWidth: 240
|
||||
radius: Style.cornerRadius
|
||||
|
||||
color: activeFocus
|
||||
color: activeFocus || hasCursor
|
||||
? Style.focusFillColor
|
||||
: (mouse.containsMouse ? Style.hotFill : Qt.rgba(foreground.r, foreground.g, foreground.b, 0.03))
|
||||
border.color: activeFocus
|
||||
border.color: activeFocus || hasCursor
|
||||
? Style.focusBorderColor
|
||||
: Qt.rgba(foreground.r, foreground.g, foreground.b, 0.12)
|
||||
border.width: activeFocus ? Style.focusBorderWidth : 1
|
||||
border.width: activeFocus || hasCursor ? Style.focusBorderWidth : 1
|
||||
|
||||
Behavior on color { ColorAnimation { duration: 100 } }
|
||||
|
||||
@@ -115,4 +122,8 @@ Rectangle {
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: root.clicked()
|
||||
}
|
||||
|
||||
HoverHandler {
|
||||
onHoveredChanged: root.hovered(hovered)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user