From ba3a9fd2d0592c288ebc64c6c659fb4ace6e317f Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Fri, 21 Aug 2015 16:24:52 +0200 Subject: 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 --- examples/quick/demos/photosurface/photosurface.qml | 46 ++++++++++++++++++++-- 1 file changed, 42 insertions(+), 4 deletions(-) (limited to 'examples/quick/demos') 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() } -- cgit v1.2.3