Implement basic image viewer popup
Current features: - Show scaled up thumbnail while the full image is loading - Click to alternate between scaling mode (or reset zoom if not 1x) - Click outside of image to close - Double click to toggle fullscreen - Middle click to open externally (also for thumbnail in timeline) - Right click anywhere to close - Ctrl+wheel to zoom - Click-drag to pan when image larger than window
This commit is contained in:
@@ -62,6 +62,38 @@ HMxcImage {
|
||||
callback(toOpen)
|
||||
}
|
||||
|
||||
function openUrlExternally() {
|
||||
getOpenUrl(Qt.openUrlExternally)
|
||||
}
|
||||
|
||||
function openImageViewer() {
|
||||
utils.makePopup(
|
||||
"Popups/ImageViewerPopup.qml",
|
||||
{
|
||||
thumbnailTitle: loader.thumbnailTitle,
|
||||
thumbnailMxc: loader.thumbnailMxc,
|
||||
thumbnailPath: image.cachedPath,
|
||||
thumbnailCryptDict:
|
||||
JSON.parse(loader.singleMediaInfo.thumbnail_crypt_dict),
|
||||
|
||||
fullTitle: loader.title,
|
||||
// The thumbnail/cached path will be the full GIF
|
||||
fullMxc: animated ? "" : loader.mediaUrl,
|
||||
fullCryptDict:
|
||||
JSON.parse(loader.singleMediaInfo.media_crypt_dict),
|
||||
|
||||
overallSize: Qt.size(
|
||||
loader.singleMediaInfo.media_width ||
|
||||
loader.singleMediaInfo.thumbnail_width,
|
||||
|
||||
loader.singleMediaInfo.media_height ||
|
||||
loader.singleMediaInfo.thumbnail_height,
|
||||
)
|
||||
},
|
||||
obj => { obj.openExternallyRequested.connect(openUrlExternally) },
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
width: fitSize.width
|
||||
height: fitSize.height
|
||||
@@ -81,14 +113,23 @@ HMxcImage {
|
||||
)
|
||||
|
||||
TapHandler {
|
||||
acceptedButtons: Qt.LeftButton
|
||||
acceptedModifiers: Qt.NoModifier
|
||||
onTapped:
|
||||
eventList.selectedCount ?
|
||||
eventDelegate.toggleChecked() : getOpenUrl(Qt.openUrlExternally)
|
||||
eventDelegate.toggleChecked() :
|
||||
openImageViewer()
|
||||
|
||||
gesturePolicy: TapHandler.ReleaseWithinBounds
|
||||
}
|
||||
|
||||
TapHandler {
|
||||
acceptedButtons: Qt.MiddleButton
|
||||
acceptedModifiers: Qt.NoModifier
|
||||
onTapped: getOpenUrl(Qt.openUrlExternally)
|
||||
gesturePolicy: TapHandler.ReleaseWithinBounds
|
||||
}
|
||||
|
||||
TapHandler {
|
||||
acceptedModifiers: Qt.ShiftModifier
|
||||
onTapped:
|
||||
|
Reference in New Issue
Block a user