diff options
Diffstat (limited to 'examples/declarative/modelviews/listview/content')
-rw-r--r-- | examples/declarative/modelviews/listview/content/PressAndHoldButton.qml (renamed from examples/declarative/modelviews/listview/content/ClickAutoRepeating.qml) | 42 | ||||
-rw-r--r-- | examples/declarative/modelviews/listview/content/TextButton.qml (renamed from examples/declarative/modelviews/listview/content/MediaButton.qml) | 47 |
2 files changed, 50 insertions, 39 deletions
diff --git a/examples/declarative/modelviews/listview/content/ClickAutoRepeating.qml b/examples/declarative/modelviews/listview/content/PressAndHoldButton.qml index dc23b78..7c174e3 100644 --- a/examples/declarative/modelviews/listview/content/ClickAutoRepeating.qml +++ b/examples/declarative/modelviews/listview/content/PressAndHoldButton.qml @@ -40,32 +40,40 @@ import Qt 4.7 -Item { - id: page - property int repeatdelay: 300 - property int repeatperiod: 75 - property bool isPressed: false +Image { + id: container + + property int repeatDelay: 300 + property int repeatDuration: 75 + property bool pressed: false - signal pressed - signal released signal clicked - SequentialAnimation on isPressed { + scale: pressed ? 0.9 : 1 + + SequentialAnimation on pressed { + id: autoRepeatClicks running: false - id: autoRepeat - PropertyAction { target: page; property: "isPressed"; value: true } - ScriptAction { script: page.pressed() } - ScriptAction { script: page.clicked() } - PauseAnimation { duration: repeatdelay } + + PropertyAction { target: container; property: "pressed"; value: true } + ScriptAction { script: container.clicked() } + PauseAnimation { duration: repeatDelay } + SequentialAnimation { loops: Animation.Infinite - ScriptAction { script: page.clicked() } - PauseAnimation { duration: repeatperiod } + ScriptAction { script: container.clicked() } + PauseAnimation { duration: repeatDuration } } } + MouseArea { anchors.fill: parent - onPressed: autoRepeat.start() - onReleased: { autoRepeat.stop(); parent.isPressed = false; page.released() } + + onPressed: autoRepeatClicks.start() + onReleased: { + autoRepeatClicks.stop() + container.pressed = false + } } } + diff --git a/examples/declarative/modelviews/listview/content/MediaButton.qml b/examples/declarative/modelviews/listview/content/TextButton.qml index 2aed6e0..ded7a11 100644 --- a/examples/declarative/modelviews/listview/content/MediaButton.qml +++ b/examples/declarative/modelviews/listview/content/TextButton.qml @@ -40,36 +40,39 @@ import Qt 4.7 -Item { - property variant text +Rectangle { + id: container + + property alias text: label.text + signal clicked - id: container - Image { - id: normal - source: "pics/button.png" - } - Image { - id: pressed - source: "pics/button-pressed.png" - opacity: 0 + width: label.width + 20; height: label.height + 6 + smooth: true + radius: 10 + + gradient: Gradient { + GradientStop { id: gradientStop; position: 0.0; color: palette.light } + GradientStop { position: 1.0; color: palette.button } } + + SystemPalette { id: palette } + MouseArea { - id: clickRegion - anchors.fill: normal - onClicked: { container.clicked(); } + id: mouseArea + anchors.fill: parent + onClicked: { container.clicked() } } + Text { - font.bold: true - color: "white" - anchors.centerIn: normal - text: container.text + id: label + anchors.centerIn: parent } - width: normal.width states: State { - name: "Pressed" - when: clickRegion.pressed == true - PropertyChanges { target: pressed; opacity: 1 } + name: "pressed" + when: mouseArea.pressed + PropertyChanges { target: gradientStop; color: palette.dark } } } + |