aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@digia.com>2015-08-21 16:24:52 +0200
committerShawn Rutledge <shawn.rutledge@theqtcompany.com>2015-09-03 08:18:25 +0000
commitba3a9fd2d0592c288ebc64c6c659fb4ace6e317f (patch)
tree82ed35c414de81a387fb6ad2bfea92ac84ce7416
parent8b09653cb22807f09ec4e6c0ffc7dcf7f11bc1a0 (diff)
Photosurface demo: add Shortcuts for open and quit, tooltip for open
Demonstrates the new Shortcut.sequenceString property. Change-Id: I6c523a46b595610b310070214c31f3fbd79a3d28 Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@theqtcompany.com>
-rw-r--r--examples/quick/demos/photosurface/photosurface.qml46
1 files changed, 42 insertions, 4 deletions
diff --git a/examples/quick/demos/photosurface/photosurface.qml b/examples/quick/demos/photosurface/photosurface.qml
index e5cfd827dc..22cef62157 100644
--- a/examples/quick/demos/photosurface/photosurface.qml
+++ b/examples/quick/demos/photosurface/photosurface.qml
@@ -37,7 +37,7 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-import QtQuick 2.5
+import QtQuick 2.6
import QtQuick.Dialogs 1.0
import QtQuick.Window 2.1
import Qt.labs.folderlistmodel 1.0
@@ -172,7 +172,7 @@ Window {
height: flick.height * (flick.height / flick.contentHeight) - (width - anchors.margins) * 2
y: flick.contentY * (flick.height / flick.contentHeight)
NumberAnimation on opacity { id: vfade; to: 0; duration: 500 }
- onYChanged: { opacity = 1.0; fadeTimer.restart() }
+ onYChanged: { opacity = 1.0; scrollFadeTimer.restart() }
}
Rectangle {
@@ -188,10 +188,10 @@ Window {
width: flick.width * (flick.width / flick.contentWidth) - (height - anchors.margins) * 2
x: flick.contentX * (flick.width / flick.contentWidth)
NumberAnimation on opacity { id: hfade; to: 0; duration: 500 }
- onXChanged: { opacity = 1.0; fadeTimer.restart() }
+ onXChanged: { opacity = 1.0; scrollFadeTimer.restart() }
}
- Timer { id: fadeTimer; interval: 1000; onTriggered: { hfade.start(); vfade.start() } }
+ Timer { id: scrollFadeTimer; interval: 1000; onTriggered: { hfade.start(); vfade.start() } }
Image {
anchors.top: parent.top
@@ -202,6 +202,42 @@ Window {
anchors.fill: parent
anchors.margins: -10
onClicked: fileDialog.open()
+ hoverEnabled: true
+ onPositionChanged: {
+ tooltip.visible = false
+ hoverTimer.start()
+ }
+ onExited: {
+ tooltip.visible = false
+ hoverTimer.stop()
+ }
+ Timer {
+ id: hoverTimer
+ interval: 1000
+ onTriggered: {
+ tooltip.x = parent.mouseX
+ tooltip.y = parent.mouseY
+ tooltip.visible = true
+ }
+ }
+ Rectangle {
+ id: tooltip
+ border.color: "black"
+ color: "beige"
+ width: tooltipText.implicitWidth + 8
+ height: tooltipText.implicitHeight + 8
+ visible: false
+ Text {
+ id: tooltipText
+ anchors.centerIn: parent
+ text: "Open an image directory (" + openShortcut.sequenceString + ")"
+ }
+ }
+ }
+ Shortcut {
+ id: openShortcut
+ sequence: StandardKey.Open
+ onActivated: fileDialog.open()
}
}
@@ -217,5 +253,7 @@ Window {
"With a mouse: drag normally, use the vertical wheel to zoom, horizontal wheel to rotate, or hold Ctrl while using the vertical wheel to rotate"
}
+ Shortcut { sequence: StandardKey.Quit; onActivated: Qt.quit() }
+
Component.onCompleted: fileDialog.open()
}