Auto-hide image viewer bars when needed
This commit is contained in:
parent
fdc06d81fd
commit
377b11220e
4
TODO.md
4
TODO.md
|
@ -1,7 +1,9 @@
|
||||||
# TODO
|
# TODO
|
||||||
|
|
||||||
- Image viewer:
|
- Image viewer:
|
||||||
- auto-hide buttons & header when needed
|
- fix: manual WM fullscreen > press f
|
||||||
|
- fix e in small window
|
||||||
|
- http not loading on click
|
||||||
- hflickable: support kinetic scrolling disabler
|
- hflickable: support kinetic scrolling disabler
|
||||||
|
|
||||||
- compress png in a thread
|
- compress png in a thread
|
||||||
|
|
|
@ -29,6 +29,7 @@ HPopup {
|
||||||
readonly property alias info: info
|
readonly property alias info: info
|
||||||
readonly property alias canvas: canvas
|
readonly property alias canvas: canvas
|
||||||
readonly property alias buttons: buttons
|
readonly property alias buttons: buttons
|
||||||
|
readonly property alias autoHideTimer: autoHideTimer
|
||||||
|
|
||||||
readonly property bool isAnimated:
|
readonly property bool isAnimated:
|
||||||
canvas.thumbnail.animated || canvas.full.animated
|
canvas.thumbnail.animated || canvas.full.animated
|
||||||
|
@ -50,6 +51,14 @@ HPopup {
|
||||||
canvas.full.animatedPaintedHeight || canvas.full.paintedHeight :
|
canvas.full.animatedPaintedHeight || canvas.full.paintedHeight :
|
||||||
canvas.thumbnail.animatedPaintedHeight || canvas.thumbnail.paintedHeight
|
canvas.thumbnail.animatedPaintedHeight || canvas.thumbnail.paintedHeight
|
||||||
|
|
||||||
|
readonly property bool canAutoHide:
|
||||||
|
paintedHeight * canvas.thumbnail.scale >
|
||||||
|
height - info.implicitHeight - buttons.implicitHeight &&
|
||||||
|
! infoHover.hovered &&
|
||||||
|
! buttonsHover.hovered
|
||||||
|
|
||||||
|
readonly property bool autoHide: canAutoHide && ! autoHideTimer.running
|
||||||
|
|
||||||
signal openExternallyRequested()
|
signal openExternallyRequested()
|
||||||
|
|
||||||
function showFullScreen() {
|
function showFullScreen() {
|
||||||
|
@ -98,22 +107,51 @@ HPopup {
|
||||||
viewer: popup
|
viewer: popup
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HoverHandler {
|
||||||
|
readonly property point position: point.position
|
||||||
|
|
||||||
|
enabled: popup.canAutoHide
|
||||||
|
onPositionChanged:
|
||||||
|
if (Math.abs(point.velocity.x + point.velocity.y) >= 0.05)
|
||||||
|
autoHideTimer.restart()
|
||||||
|
}
|
||||||
|
|
||||||
|
Timer {
|
||||||
|
id: autoHideTimer
|
||||||
|
interval: 3000
|
||||||
|
}
|
||||||
|
|
||||||
ViewerInfo {
|
ViewerInfo {
|
||||||
id: info
|
id: info
|
||||||
viewer: popup
|
viewer: popup
|
||||||
width: parent.width
|
width: parent.width
|
||||||
y: parent.width < buttons.width * 4 ? 0 : parent.height - height
|
y:
|
||||||
maxTitleWidth: y === 0 ? -1 : buttons.x - buttons.width / 2
|
(parent.width < buttons.width * 4 || layout.vertical) &&
|
||||||
|
popup.autoHide ?
|
||||||
|
-height :
|
||||||
|
|
||||||
|
parent.width < buttons.width * 4 || layout.vertical ?
|
||||||
|
0 :
|
||||||
|
|
||||||
|
parent.height - (popup.autoHide ? 0 : height)
|
||||||
|
|
||||||
|
maxTitleWidth: y <= 0 ? -1 : buttons.x - buttons.width / 2
|
||||||
|
|
||||||
Behavior on y { HNumberAnimation {} }
|
Behavior on y { HNumberAnimation {} }
|
||||||
|
|
||||||
|
HoverHandler { id: infoHover }
|
||||||
}
|
}
|
||||||
|
|
||||||
ViewerButtons {
|
ViewerButtons {
|
||||||
id: buttons
|
id: buttons
|
||||||
anchors.bottom: parent.bottom
|
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
width: Math.min(calculatedWidth, parent.width)
|
width: Math.min(calculatedWidth, parent.width)
|
||||||
|
y: parent.height - (popup.autoHide ? 0 : height)
|
||||||
viewer: popup
|
viewer: popup
|
||||||
|
|
||||||
|
Behavior on y { HNumberAnimation {} }
|
||||||
|
|
||||||
|
HoverHandler { id: buttonsHover }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ HFlow {
|
||||||
property HPopup viewer
|
property HPopup viewer
|
||||||
|
|
||||||
property color backgroundsColor:
|
property color backgroundsColor:
|
||||||
viewer.info.y === viewer.height - viewer.info.height ?
|
viewer.info.y >= viewer.height - viewer.info.height ?
|
||||||
"transparent" :
|
"transparent" :
|
||||||
theme.controls.button.background
|
theme.controls.button.background
|
||||||
|
|
||||||
|
|
|
@ -172,6 +172,7 @@ HFlickable {
|
||||||
height: viewer.paintedHeight
|
height: viewer.paintedHeight
|
||||||
|
|
||||||
TapHandler {
|
TapHandler {
|
||||||
|
acceptedPointerTypes: PointerDevice.GenericPointer
|
||||||
gesturePolicy: TapHandler.ReleaseWithinBounds
|
gesturePolicy: TapHandler.ReleaseWithinBounds
|
||||||
onTapped: {
|
onTapped: {
|
||||||
thumbnail.scale === 1 ?
|
thumbnail.scale === 1 ?
|
||||||
|
@ -180,6 +181,12 @@ HFlickable {
|
||||||
}
|
}
|
||||||
onDoubleTapped: viewer.toggleFullScreen()
|
onDoubleTapped: viewer.toggleFullScreen()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TapHandler {
|
||||||
|
acceptedPointerTypes: PointerDevice.Finger | PointerDevice.Pen
|
||||||
|
gesturePolicy: TapHandler.ReleaseWithinBounds
|
||||||
|
onTapped: viewer.autoHideTimer.restart()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user