moment/src/gui/Popups/ImageViewerPopup/ViewerButtons.qml

165 lines
4.7 KiB
QML
Raw Normal View History

2020-07-21 09:32:22 +10:00
// SPDX-License-Identifier: LGPL-3.0-or-later
import QtQuick 2.12
import QtQuick.Window 2.12
2020-07-21 11:34:00 +10:00
import ".."
2020-07-21 09:32:22 +10:00
import "../../Base"
HFlow {
2020-07-22 07:34:45 +10:00
id: root
2020-07-21 09:32:22 +10:00
property HPopup viewer
2020-07-22 07:34:45 +10:00
property color backgroundsColor:
viewer.info.y === viewer.height - viewer.info.height ?
"transparent" :
theme.controls.button.background
2020-07-21 09:32:22 +10:00
readonly property real calculatedWidth:
utils.sumChildrenImplicitWidths(visibleChildren)
2020-07-21 09:32:22 +10:00
HButton {
2020-07-21 11:34:00 +10:00
id: pause
2020-07-22 07:34:45 +10:00
backgroundColor: root.backgroundsColor
2020-07-21 09:32:22 +10:00
icon.name: viewer.imagesPaused ? "image-play" : "image-pause"
toolTip.text: viewer.imagesPaused ? qsTr("Play") : qsTr("Pause")
onClicked: viewer.imagesPaused = ! viewer.imagesPaused
visible: viewer.isAnimated
2020-07-21 11:34:00 +10:00
HPopupShortcut {
sequences: window.settings.keys.imageViewer.pause
onActivated: pause.clicked()
}
2020-07-21 09:32:22 +10:00
}
HButton {
2020-07-22 07:34:45 +10:00
backgroundColor: root.backgroundsColor
2020-07-21 09:32:22 +10:00
text: qsTr("%1x").arg(utils.round(viewer.imagesSpeed))
label.font.pixelSize: theme.fontSize.big
2020-07-21 11:34:00 +10:00
height: pause.height
2020-07-21 09:32:22 +10:00
topPadding: 0
bottomPadding: 0
toolTip.text: qsTr("Change speed")
onClicked: speedMenu.popup()
visible: viewer.isAnimated
2020-07-21 11:34:00 +10:00
HPopupShortcut {
sequences: window.settings.keys.imageViewer.previousSpeed
onActivated: viewer.imagesSpeed = viewer.availableSpeeds[Math.min(
viewer.availableSpeeds.indexOf(viewer.imagesSpeed) + 1,
viewer.availableSpeeds.length - 1,
)]
}
HPopupShortcut {
sequences: window.settings.keys.imageViewer.nextSpeed
onActivated: viewer.imagesSpeed = viewer.availableSpeeds[Math.max(
viewer.availableSpeeds.indexOf(viewer.imagesSpeed) - 1, 0,
)]
}
HPopupShortcut {
sequences: window.settings.keys.imageViewer.resetSpeed
onActivated: viewer.imagesSpeed = 1
}
2020-07-21 09:32:22 +10:00
}
HButton {
2020-07-21 11:34:00 +10:00
id: rotateLeft
2020-07-22 07:34:45 +10:00
backgroundColor: root.backgroundsColor
2020-07-21 09:32:22 +10:00
icon.name: "image-rotate-left"
toolTip.text: qsTr("Rotate left")
autoRepeat: true
autoRepeatDelay: 20
autoRepeatInterval: theme.animationDuration * 3
onPressed: viewer.animatedRotationTarget -= 45
2020-07-21 11:34:00 +10:00
HPopupShortcut {
sequences: window.settings.keys.imageViewer.rotateLeft
onActivated: viewer.animatedRotationTarget -= 45
}
2020-07-21 09:32:22 +10:00
}
HButton {
2020-07-21 11:34:00 +10:00
id: rotateRight
2020-07-22 07:34:45 +10:00
backgroundColor: root.backgroundsColor
2020-07-21 09:32:22 +10:00
icon.name: "image-rotate-right"
toolTip.text: qsTr("Rotate right")
autoRepeat: true
autoRepeatDelay: 20
autoRepeatInterval: theme.animationDuration * 3
onPressed: viewer.animatedRotationTarget += 45
2020-07-21 11:34:00 +10:00
HPopupShortcut {
sequences: window.settings.keys.imageViewer.rotateRight
onActivated: viewer.animatedRotationTarget += 45
}
}
HPopupShortcut {
sequences: window.settings.keys.imageViewer.rotateReset
onActivated: viewer.animatedRotationTarget = 0
2020-07-21 09:32:22 +10:00
}
HButton {
2020-07-21 11:34:00 +10:00
id: expand
2020-07-22 07:34:45 +10:00
backgroundColor: root.backgroundsColor
2020-07-21 09:32:22 +10:00
icon.name: "image-alt-scale-mode"
toolTip.text:
viewer.imageLargerThanWindow ?
qsTr("Expand to original size") :
qsTr("Expand to screen")
checked: viewer.alternateScaling
onClicked: viewer.alternateScaling = ! viewer.alternateScaling
2020-07-21 11:34:00 +10:00
HPopupShortcut {
sequences: window.settings.keys.imageViewer.expand
onActivated: expand.clicked()
}
2020-07-21 09:32:22 +10:00
}
HButton {
2020-07-21 11:34:00 +10:00
id: fullScreen
2020-07-22 07:34:45 +10:00
backgroundColor: root.backgroundsColor
2020-07-21 09:32:22 +10:00
icon.name: "image-fullscreen"
toolTip.text: qsTr("Fullscreen")
checked: window.visibility === Window.FullScreen
onClicked: viewer.toggleFullScreen()
visible: Qt.application.supportsMultipleWindows
2020-07-21 11:34:00 +10:00
HPopupShortcut {
sequences: window.settings.keys.imageViewer.fullScreen
onActivated: fullScreen.clicked()
}
2020-07-21 09:32:22 +10:00
}
HButton {
2020-07-21 11:34:00 +10:00
id: close // always visible
2020-07-22 07:34:45 +10:00
backgroundColor: root.backgroundsColor
2020-07-21 09:32:22 +10:00
icon.name: "image-close"
toolTip.text: qsTr("Close")
onClicked: viewer.close()
2020-07-21 11:34:00 +10:00
HPopupShortcut {
sequences: window.settings.keys.imageViewer.close
onActivated: close.clicked()
}
2020-07-21 09:32:22 +10:00
}
HMenu {
id: speedMenu
Repeater {
model: viewer.availableSpeeds
HMenuItem {
text: qsTr("%1x").arg(modelData)
onClicked: viewer.imagesSpeed = modelData
label.horizontalAlignment: HLabel.AlignHCenter
}
}
}
}