mirror of
https://github.com/noctalia-dev/noctalia-shell.git
synced 2026-05-11 17:08:27 +08:00
NButton: Simplified by removing the press state which was causing issues with Popups opening hover the button
This commit is contained in:
+3
-15
@@ -13,7 +13,6 @@ Rectangle {
|
||||
property color backgroundColor: Color.mPrimary
|
||||
property color textColor: Color.mOnPrimary
|
||||
property color hoverColor: Color.mTertiary
|
||||
property color pressColor: Color.mSecondary
|
||||
property bool enabled: true
|
||||
property real fontSize: Style.fontSizeM * scaling
|
||||
property int fontWeight: Style.fontWeightBold
|
||||
@@ -38,8 +37,6 @@ Rectangle {
|
||||
color: {
|
||||
if (!enabled)
|
||||
return outlined ? Color.transparent : Qt.lighter(Color.mSurfaceVariant, 1.2)
|
||||
if (pressed)
|
||||
return pressColor
|
||||
if (hovered)
|
||||
return hoverColor
|
||||
return outlined ? Color.transparent : backgroundColor
|
||||
@@ -113,7 +110,7 @@ Rectangle {
|
||||
if (!root.enabled)
|
||||
return Color.mOnSurfaceVariant
|
||||
if (root.outlined) {
|
||||
if (root.pressed || root.hovered)
|
||||
if (root.hovered)
|
||||
return root.textColor
|
||||
return root.backgroundColor
|
||||
}
|
||||
@@ -153,33 +150,24 @@ Rectangle {
|
||||
}
|
||||
onExited: {
|
||||
root.hovered = false
|
||||
root.pressed = false
|
||||
if (tooltipText) {
|
||||
tooltip.hide()
|
||||
}
|
||||
}
|
||||
onPressed: mouse => {
|
||||
root.pressed = true
|
||||
}
|
||||
onReleased: mouse => {
|
||||
root.pressed = false
|
||||
if (tooltipText) {
|
||||
tooltip.hide()
|
||||
}
|
||||
if (!root.hovered) {
|
||||
return
|
||||
}
|
||||
|
||||
if (mouse.button === Qt.LeftButton) {
|
||||
root.clicked()
|
||||
} else if (mouse.button == Qt.RightButton) {
|
||||
root.rightClicked()
|
||||
} else if (mouse.button == Qt.MiddleButton) {
|
||||
root.middleClicked
|
||||
root.middleClicked()
|
||||
}
|
||||
}
|
||||
|
||||
onCanceled: {
|
||||
root.pressed = false
|
||||
root.hovered = false
|
||||
if (tooltipText) {
|
||||
tooltip.hide()
|
||||
|
||||
@@ -47,7 +47,6 @@ RowLayout {
|
||||
backgroundColor: Color.mSecondary
|
||||
textColor: Color.mOnSecondary
|
||||
hoverColor: Color.mTertiary
|
||||
pressColor: Color.mPrimary
|
||||
enabled: root.actionButtonEnabled
|
||||
|
||||
onClicked: {
|
||||
|
||||
Reference in New Issue
Block a user