internal: fix binding loops

This commit is contained in:
2 * r + 2 * t 2025-05-24 13:31:36 +08:00
parent 41004e5d0c
commit 01b38be6af
7 changed files with 31 additions and 7 deletions

View file

@ -15,12 +15,16 @@ Item {
implicitWidth: child.implicitWidth implicitWidth: child.implicitWidth
implicitHeight: child.implicitHeight implicitHeight: child.implicitHeight
StyledRect { Item {
id: child id: child
readonly property bool vertical: root.vertical
anchors.centerIn: parent anchors.centerIn: parent
clip: true clip: true
implicitWidth: root.vertical ? Math.max(icon.implicitWidth, text.implicitHeight) : icon.implicitWidth + text.implicitWidth + text.anchors.leftMargin
implicitHeight: root.vertical ? icon.implicitHeight + text.implicitWidth + text.anchors.topMargin : Math.max(icon.implicitHeight, text.implicitheight)
MaterialIcon { MaterialIcon {
id: icon id: icon

View file

@ -3,11 +3,15 @@ import "root:/services"
import "root:/config" import "root:/config"
import QtQuick import QtQuick
StyledRect { Item {
id: root id: root
readonly property bool vertical: parent?.vertical ?? false
property color colour: Colours.palette.peach property color colour: Colours.palette.peach
implicitWidth: vertical ? Math.max(icon.implicitWidth, text.implicitWidth) : icon.implicitWidth + text.implicitWidth + text.anchors.leftMargin
implicitHeight: vertical ? icon.implicitHeight + text.implicitHeight + text.anchors.topMargin : Math.max(icon.implicitHeight, text.implicitHeight)
MaterialIcon { MaterialIcon {
id: icon id: icon
@ -18,6 +22,8 @@ StyledRect {
} }
AnchorText { AnchorText {
id: text
prevAnchor: icon prevAnchor: icon
horizontalAlignment: StyledText.AlignHCenter horizontalAlignment: StyledText.AlignHCenter

View file

@ -5,12 +5,15 @@ import "root:/config"
import Quickshell import Quickshell
import QtQuick import QtQuick
StyledRect { Item {
id: root id: root
readonly property bool vertical: parent?.vertical ?? false
property color colour: Colours.palette.rosewater property color colour: Colours.palette.rosewater
clip: true clip: true
implicitWidth: vertical ? Math.max(network.implicitWidth, bluetooth.implicitWidth, devices.implicitWidth) : network.implicitWidth + bluetooth.implicitWidth + bluetooth.anchors.leftMargin + (repeater.count > 0 ? devices.implicitWidth + devices.anchors.leftMargin : 0)
implicitHeight: vertical ? network.implicitHeight + bluetooth.implicitHeight + bluetooth.anchors.topMargin + (repeater.count > 0 ? devices.implicitHeight + devices.anchors.topMargin : 0) : Math.max(network.implicitHeight, bluetooth.implicitHeight, devices.implicitHeight)
MaterialIcon { MaterialIcon {
id: network id: network
@ -35,6 +38,8 @@ StyledRect {
} }
Box { Box {
id: devices
anchors.left: vertical ? undefined : bluetooth.right anchors.left: vertical ? undefined : bluetooth.right
anchors.leftMargin: vertical ? 0 : Appearance.padding.smaller anchors.leftMargin: vertical ? 0 : Appearance.padding.smaller
anchors.top: vertical ? bluetooth.bottom : undefined anchors.top: vertical ? bluetooth.bottom : undefined
@ -44,6 +49,8 @@ StyledRect {
anchors.verticalCenter: vertical ? undefined : bluetooth.verticalCenter anchors.verticalCenter: vertical ? undefined : bluetooth.verticalCenter
Repeater { Repeater {
id: repeater
model: ScriptModel { model: ScriptModel {
values: Bluetooth.devices.filter(d => d.connected) values: Bluetooth.devices.filter(d => d.connected)
} }

View file

@ -4,15 +4,21 @@ import "root:/config"
import Quickshell.Services.SystemTray import Quickshell.Services.SystemTray
import QtQuick import QtQuick
StyledRect { Item {
id: root id: root
readonly property bool vertical: parent?.vertical ?? false
property color colour: Colours.palette.lavender property color colour: Colours.palette.lavender
clip: true clip: true
visible: width > 0 && height > 0 // To avoid warnings about being visible with no size visible: width > 0 && height > 0 // To avoid warnings about being visible with no size
implicitWidth: layout.implicitWidth
implicitHeight: layout.implicitHeight
BoxLayout { BoxLayout {
id: layout
Repeater { Repeater {
model: SystemTray.items model: SystemTray.items

View file

@ -50,6 +50,8 @@ Item {
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
anchors.margins: root.padding anchors.margins: root.padding
implicitHeight: Math.max(searchIcon.implicitHeight, search.implicitHeight, clearIcon.implicitHeight)
MaterialIcon { MaterialIcon {
id: searchIcon id: searchIcon
@ -139,6 +141,7 @@ Item {
anchors.fill: parent anchors.fill: parent
hoverEnabled: true hoverEnabled: true
cursorShape: search.text ? Qt.PointingHandCursor : undefined
onEntered: hovered = true onEntered: hovered = true
onExited: hovered = false onExited: hovered = false

View file

@ -21,7 +21,7 @@ StyledRect {
color: root.modelData?.urgency === NotificationUrgency.Critical ? Colours.palette.m3secondaryContainer : Colours.palette.m3surfaceContainer color: root.modelData?.urgency === NotificationUrgency.Critical ? Colours.palette.m3secondaryContainer : Colours.palette.m3surfaceContainer
radius: Appearance.rounding.normal radius: Appearance.rounding.normal
implicitWidth: NotifsConfig.sizes.width implicitWidth: NotifsConfig.sizes.width
implicitHeight: inner.height implicitHeight: inner.implicitHeight
x: NotifsConfig.sizes.width x: NotifsConfig.sizes.width
Component.onCompleted: x = 0 Component.onCompleted: x = 0

View file

@ -7,8 +7,6 @@ Rectangle {
property bool vertical: parent?.vertical ?? false // Convenience property for propagation to children property bool vertical: parent?.vertical ?? false // Convenience property for propagation to children
color: "transparent" color: "transparent"
implicitWidth: childrenRect.width
implicitHeight: childrenRect.height
Behavior on color { Behavior on color {
ColorAnimation { ColorAnimation {