Introduces a new `WindowControls` component in the desktop top bar with minimize, maximize/restore, and close actions for the focused window. `WindowService` now exposes focused-window presence/maximized state plus focused-window convenience actions to support this UI. Also extends Nebula UI with a reusable `NebulaToolTip`, keyboard/pressed-state support in `NebulaIconButton`, new window-control glyphs in `NebulaIcon`, and theme tokens for pressed/danger hover states, with CMake and README updates to register/document the new components.
89 lines
2.1 KiB
QML
89 lines
2.1 KiB
QML
import QtQuick
|
|
|
|
Item {
|
|
id: root
|
|
|
|
property string label: ""
|
|
property bool active: false
|
|
property bool danger: false
|
|
readonly property bool hovered: hover.containsMouse
|
|
readonly property bool pressed: hover.pressed
|
|
readonly property color iconColor: {
|
|
if (danger && hovered)
|
|
return Theme.danger
|
|
if (active)
|
|
return Theme.accentStrong
|
|
if (hovered)
|
|
return Theme.textPrimary
|
|
return Theme.textSecondary
|
|
}
|
|
|
|
default property alias icon: iconHolder.data
|
|
|
|
signal clicked()
|
|
|
|
implicitWidth: Theme.controlHeight
|
|
implicitHeight: Theme.controlHeight
|
|
activeFocusOnTab: true
|
|
Accessible.role: Accessible.Button
|
|
Accessible.name: root.label
|
|
Accessible.onPressAction: root.clicked()
|
|
|
|
Keys.onReturnPressed: {
|
|
event.accepted = true
|
|
root.clicked()
|
|
}
|
|
Keys.onSpacePressed: {
|
|
event.accepted = true
|
|
root.clicked()
|
|
}
|
|
|
|
Rectangle {
|
|
anchors.fill: parent
|
|
radius: Theme.radiusSmall
|
|
color: {
|
|
if (root.danger && hover.pressed)
|
|
return Theme.dangerSoftStrong
|
|
if (root.danger && hover.containsMouse)
|
|
return Theme.dangerSoft
|
|
if (root.active)
|
|
return Theme.accentSoft
|
|
if (hover.pressed)
|
|
return Theme.pressedFill
|
|
if (hover.containsMouse)
|
|
return Theme.hoverFill
|
|
return "transparent"
|
|
}
|
|
|
|
Behavior on color {
|
|
ColorAnimation {
|
|
duration: Theme.animationFast
|
|
}
|
|
}
|
|
}
|
|
|
|
Item {
|
|
id: iconHolder
|
|
anchors.centerIn: parent
|
|
width: 16
|
|
height: 16
|
|
}
|
|
|
|
MouseArea {
|
|
id: hover
|
|
anchors.fill: parent
|
|
hoverEnabled: true
|
|
cursorShape: Qt.PointingHandCursor
|
|
onClicked: root.clicked()
|
|
}
|
|
|
|
FocusFrame {
|
|
radius: Theme.radiusSmall
|
|
}
|
|
|
|
NebulaToolTip {
|
|
text: root.label
|
|
active: hover.containsMouse && !hover.pressed && root.label.length > 0
|
|
}
|
|
}
|