Add enabled/disable support for Slider plasma component

- The current disabled slider have less opacity when disabled
   instead of custom graphics. Needs to be defined if this is
   the expected behaviour.

- The gallery example was also updated.

Signed-off-by: Daker Fernandes Pinheiro <dakerfp@gmail.com>
This commit is contained in:
Daker Fernandes Pinheiro 2011-07-18 19:09:50 -03:00
parent 3ab58b3877
commit b9e69695bd
3 changed files with 32 additions and 27 deletions

View File

@ -45,9 +45,12 @@ Item {
width: _isVertical ? 22 : 200
height: _isVertical ? 200 : 22
// TODO: needs to define if there will be specific graphics for
// disabled sliders
opacity: enabled ? 1.0 : 0.5
Keys.onUpPressed: {
if (!_isVertical)
if (!enabled || !_isVertical)
return;
if (inverted)
@ -57,6 +60,9 @@ Item {
}
Keys.onDownPressed: {
if (!enabled || !enabled)
return;
if (!_isVertical)
return;
@ -67,7 +73,7 @@ Item {
}
Keys.onLeftPressed: {
if (_isVertical)
if (!enabled || _isVertical)
return;
if (inverted)
@ -77,7 +83,7 @@ Item {
}
Keys.onRightPressed: {
if (_isVertical)
if (!enabled || _isVertical)
return;
if (inverted)
@ -189,6 +195,7 @@ Item {
id: mouseArea
anchors.fill: parent
enabled: slider.enabled
drag {
target: fakeHandle
axis: Drag.XAxis

View File

@ -30,8 +30,7 @@ Rectangle {
anchors.fill: parent
contentWidth: 2200
contentHeight: 600
// contentX: 500
contentHeight: 1000
Row {
x: 30

View File

@ -90,33 +90,32 @@ Column {
}
}
Text { text: "Disabled Horizontal Slider" }
PlasmaComponents.Slider {
id: slider1
id: horizontalSlider
width: 140
height: 20
animated: true
Component.onCompleted: {
forceActiveFocus();
enabled: false
}
Text { text: "Vertical Slider" }
Row {
spacing: 30
PlasmaComponents.Slider {
id: verticalSlider
width: 20
height: 140
orientation: Qt.Vertical
minimumValue: 10
maximumValue: 1000
stepSize: 50
inverted: true
animated: true
}
Text { text: verticalSlider.value }
}
Text {
text: slider1.value
}
PlasmaComponents.Slider {
id: slider2
width: 20
height: 140
orientation: Qt.Vertical
minimumValue: 10
maximumValue: 1000
stepSize: 50
inverted: true
animated: true
}
Text {
text: slider2.value
}
}