NIconButton: better disabled state

This commit is contained in:
LemmyCook 2025-08-31 14:44:22 -04:00
parent 0f5bbb961d
commit 40579e1b80
2 changed files with 7 additions and 5 deletions

View file

@ -32,7 +32,8 @@ Rectangle {
implicitWidth: size implicitWidth: size
implicitHeight: size implicitHeight: size
color: root.hovering ? colorBgHover : colorBg opacity: root.enabled ? Style.opacityFull : Style.opacityMedium
color: root.enabled && root.hovering ? colorBgHover : colorBg
radius: width * 0.5 radius: width * 0.5
border.color: root.hovering ? colorBorderHover : colorBorder border.color: root.hovering ? colorBorderHover : colorBorder
border.width: Math.max(1, Style.borderS * scaling) border.width: Math.max(1, Style.borderS * scaling)
@ -41,7 +42,6 @@ Rectangle {
text: root.icon text: root.icon
font.pointSize: root.fontPointSize * scaling font.pointSize: root.fontPointSize * scaling
color: root.hovering ? colorFgHover : colorFg color: root.hovering ? colorFgHover : colorFg
opacity: root.enabled ? Style.opacityFull : Style.opacityMedium
// Center horizontally // Center horizontally
x: (root.width - width) / 2 x: (root.width - width) / 2
// Center vertically accounting for font metrics // Center vertically accounting for font metrics
@ -56,8 +56,9 @@ Rectangle {
} }
MouseArea { MouseArea {
enabled: root.enabled
anchors.fill: parent anchors.fill: parent
cursorShape: Qt.PointingHandCursor cursorShape: root.enabled ? Qt.PointingHandCursor : Qt.ArrowCursor
acceptedButtons: Qt.LeftButton | Qt.RightButton acceptedButtons: Qt.LeftButton | Qt.RightButton
hoverEnabled: true hoverEnabled: true
onEntered: { onEntered: {

View file

@ -87,13 +87,14 @@ NBox {
colorFg: Color.mOnPrimary colorFg: Color.mOnPrimary
colorBgHover: Color.mSecondary colorBgHover: Color.mSecondary
colorFgHover: Color.mOnSecondary colorFgHover: Color.mOnSecondary
enabled: comboBox.selectedKey !== "" enabled: comboBox.currentKey !== ""
tooltipText: "Add widget to this section"
Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter
Layout.leftMargin: Style.marginS * scaling Layout.leftMargin: Style.marginS * scaling
onClicked: { onClicked: {
if (comboBox.currentKey !== "") { if (comboBox.currentKey !== "") {
addWidget(comboBox.currentKey, sectionName.toLowerCase()) addWidget(comboBox.currentKey, sectionName.toLowerCase())
comboBox.currentKey = "battery" comboBox.currentKey = ""
} }
} }
} }