From 487d79bce30c0572093a3f4a0bb2b3d2b77639a9 Mon Sep 17 00:00:00 2001 From: Daker Fernandes Pinheiro Date: Mon, 18 Jul 2011 18:20:49 -0300 Subject: [PATCH] Add enabled/disable support for Button plasma component - The current disabled buttons have less opacity when disabled instead of custom graphics. Needs to be defined if this is the expected behaviour. Signed-off-by: Daker Fernandes Pinheiro --- declarativeimports/plasmacomponents/Button.qml | 7 ++++++- declarativeimports/test/gallery/Buttons.qml | 7 +++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/declarativeimports/plasmacomponents/Button.qml b/declarativeimports/plasmacomponents/Button.qml index 066b02b8b..2f85447d0 100644 --- a/declarativeimports/plasmacomponents/Button.qml +++ b/declarativeimports/plasmacomponents/Button.qml @@ -37,10 +37,14 @@ Item { property QtObject theme: PlasmaCore.Theme { } function pressButton() { - surface.prefix = "pressed"; + if (button.enabled) + surface.prefix = "pressed"; } function releaseButton() { + if (!button.enabled) + return; + if (button.checkable) button.checked = !button.checked; @@ -56,6 +60,7 @@ Item { width: 50 height: 20 + opacity: enabled ? 1.0 : 0.5 // XXX: temporary solution Keys.onSpacePressed: pressButton(); Keys.onReturnPressed: pressButton(); diff --git a/declarativeimports/test/gallery/Buttons.qml b/declarativeimports/test/gallery/Buttons.qml index 8685f1c4c..b1d9ecf7b 100644 --- a/declarativeimports/test/gallery/Buttons.qml +++ b/declarativeimports/test/gallery/Buttons.qml @@ -89,4 +89,11 @@ Column { Keys.onTabPressed: bt1.forceActiveFocus(); } + + PlasmaComponents.Button { + width: 140 + height: 30 + text: "Disabled Button" + enabled: false + } }