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:
parent
83bd875a44
commit
487d79bce3
@ -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();
|
||||||
|
@ -89,4 +89,11 @@ Column {
|
|||||||
|
|
||||||
Keys.onTabPressed: bt1.forceActiveFocus();
|
Keys.onTabPressed: bt1.forceActiveFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PlasmaComponents.Button {
|
||||||
|
width: 140
|
||||||
|
height: 30
|
||||||
|
text: "Disabled Button"
|
||||||
|
enabled: false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user