refactored default state stuff to be in the container component instead of repeated 4 times

This commit is contained in:
2026-08-12 12:27:12 +01:00
parent 802b077362
commit dc82f5a0ae
5 changed files with 97 additions and 194 deletions

View File

@@ -13,66 +13,18 @@ Container {
required property HyprlandMonitor monitor
property double networkDisplayHeight: 80
property bool opened: false
animOffset: 250
boxColor: Colors.red
boxHeight: 25
boxHeightOpened: root.networkDisplayHeight
boxWidth: 33
boxWidthOpened: 350
defaultItem: icon
exclusiveMonitor: root.monitor
exclusiveToScreen: true
forceHidden: !NetworkManager.connectedWifi
states: [
State {
name: "closed"
when: root.hovered == false && root.opened == false
PropertyChanges {
root.boxHeight: 25
root.boxRadius: 9
root.boxWidth: 33
}
},
State {
name: "hovered"
when: root.hovered == true && root.opened == false
PropertyChanges {
root.boxHeight: 28
root.boxWidth: 35
}
},
State {
name: "opened"
when: root.opened == true && root.hovered == true
PropertyChanges {
root.boxHeight: root.networkDisplayHeight
root.boxRadius: 12
root.boxWidth: 350
}
StateChangeScript {
script: {
stack.replace(wifiInfo);
}
}
}
]
hover.onHoveredChanged: {
if (hover.hovered == false) {
root.opened = false;
if (root.state != "icon") {
root.stack.replace(icon);
}
}
}
tap.onTapped: {
root.opened = true;
}
openedItem: networkDisplay
Component {
id: icon
@@ -86,7 +38,7 @@ Container {
}
Component {
id: wifiInfo
id: networkDisplay
Item {
id: networkDisplayRoot