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 <dakerfp@gmail.com>
This commit is contained in:
Daker Fernandes Pinheiro 2011-07-18 18:20:49 -03:00
parent 83bd875a44
commit 487d79bce3
2 changed files with 13 additions and 1 deletions

View File

@ -37,10 +37,14 @@ Item {
property QtObject theme: PlasmaCore.Theme { } property QtObject theme: PlasmaCore.Theme { }
function pressButton() { function pressButton() {
surface.prefix = "pressed"; if (button.enabled)
surface.prefix = "pressed";
} }
function releaseButton() { function releaseButton() {
if (!button.enabled)
return;
if (button.checkable) if (button.checkable)
button.checked = !button.checked; button.checked = !button.checked;
@ -56,6 +60,7 @@ Item {
width: 50 width: 50
height: 20 height: 20
opacity: enabled ? 1.0 : 0.5 // XXX: temporary solution
Keys.onSpacePressed: pressButton(); Keys.onSpacePressed: pressButton();
Keys.onReturnPressed: pressButton(); Keys.onReturnPressed: pressButton();

View File

@ -89,4 +89,11 @@ Column {
Keys.onTabPressed: bt1.forceActiveFocus(); Keys.onTabPressed: bt1.forceActiveFocus();
} }
PlasmaComponents.Button {
width: 140
height: 30
text: "Disabled Button"
enabled: false
}
} }