Fix/improve image sizes
This commit is contained in:
parent
e4b784b407
commit
7408322fbe
4
TODO.md
4
TODO.md
|
@ -1,10 +1,9 @@
|
||||||
- Media
|
- Media
|
||||||
- Uploading progress bar (+local echo)
|
- Uploading progress bar (+local echo)
|
||||||
- Directly create cache files for our uploads before actually uploading
|
- Directly create cache files for our uploads before actually uploading
|
||||||
- Fix image sizes
|
|
||||||
- Image loading progress bar
|
|
||||||
- Downloading
|
- Downloading
|
||||||
- Bottom/top bar
|
- Bottom/top bar
|
||||||
|
- Image loading progress bar
|
||||||
- Verify things work with chat.privacytools.io (subdomain weirdness)
|
- Verify things work with chat.privacytools.io (subdomain weirdness)
|
||||||
|
|
||||||
- Support m.file thumbnails
|
- Support m.file thumbnails
|
||||||
|
@ -34,6 +33,7 @@
|
||||||
- When qml syntax highlighting supports ES6 string interpolation, use that
|
- When qml syntax highlighting supports ES6 string interpolation, use that
|
||||||
|
|
||||||
- Fixes
|
- Fixes
|
||||||
|
- Code not colored in room subtitle
|
||||||
- In the "Leave me" room, "join > Hi > left" aren't combined
|
- In the "Leave me" room, "join > Hi > left" aren't combined
|
||||||
- Event delegates changing height don't scroll the list
|
- Event delegates changing height don't scroll the list
|
||||||
- When selecting text and scrolling up, selection stops working after a while
|
- When selecting text and scrolling up, selection stops working after a while
|
||||||
|
|
|
@ -14,7 +14,7 @@ from functools import partial
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from types import ModuleType
|
from types import ModuleType
|
||||||
from typing import (
|
from typing import (
|
||||||
Any, BinaryIO, DefaultDict, Dict, Optional, Set, Tuple, Type, Union
|
Any, BinaryIO, DefaultDict, Dict, Optional, Set, Tuple, Type, Union,
|
||||||
)
|
)
|
||||||
from uuid import uuid4
|
from uuid import uuid4
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ HImage {
|
||||||
if (! image) return // if it was destroyed
|
if (! image) return // if it was destroyed
|
||||||
|
|
||||||
if (! image.mxc.startsWith("mxc://")) {
|
if (! image.mxc.startsWith("mxc://")) {
|
||||||
source = mxc
|
if (source != mxc) source = mxc
|
||||||
show = image.visible
|
show = image.visible
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ HImage {
|
||||||
py.callClientCoro(
|
py.callClientCoro(
|
||||||
clientUserId, "media_cache." + method, args, path => {
|
clientUserId, "media_cache." + method, args, path => {
|
||||||
if (! image) return
|
if (! image) return
|
||||||
image.cachedPath = path
|
if (image.cachedPath != path) image.cachedPath = path
|
||||||
show = image.visible
|
show = image.visible
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
|
@ -156,15 +156,18 @@ HRowLayout {
|
||||||
Layout.leftMargin: pureMedia ? 0 : contentLabel.leftPadding
|
Layout.leftMargin: pureMedia ? 0 : contentLabel.leftPadding
|
||||||
Layout.rightMargin: pureMedia ? 0 : contentLabel.rightPadding
|
Layout.rightMargin: pureMedia ? 0 : contentLabel.rightPadding
|
||||||
|
|
||||||
Layout.minimumWidth:
|
Layout.preferredWidth: item ? item.width : -1
|
||||||
type === EventDelegate.Media.Image ?
|
Layout.preferredHeight: item ? item.height : -1
|
||||||
(singleMediaInfo.media_width ||
|
|
||||||
(item ? item.loadingLabel.implicitWidth : -1)) : -1
|
|
||||||
|
|
||||||
Layout.minimumHeight:
|
// Layout.minimumWidth:
|
||||||
type === EventDelegate.Media.Image ?
|
// type === EventDelegate.Media.Image ?
|
||||||
(singleMediaInfo.media_height ||
|
// (singleMediaInfo.media_width ||
|
||||||
(item ? item.loadingLabel.implicitHeight : -1)) : -1
|
// (item ? item.loadingLabel.implicitWidth : -1)) : -1
|
||||||
|
|
||||||
|
// Layout.minimumHeight:
|
||||||
|
// type === EventDelegate.Media.Image ?
|
||||||
|
// (singleMediaInfo.media_height ||
|
||||||
|
// (item ? item.loadingLabel.implicitHeight : -1)) : -1
|
||||||
|
|
||||||
// Layout.minimumWidth:
|
// Layout.minimumWidth:
|
||||||
// type === EventDelegate.Media.File ?
|
// type === EventDelegate.Media.File ?
|
||||||
|
@ -179,8 +182,8 @@ HRowLayout {
|
||||||
|
|
||||||
// -1
|
// -1
|
||||||
|
|
||||||
Layout.maximumWidth: messageBodyWidth
|
// Layout.maximumWidth: messageBodyWidth
|
||||||
Layout.maximumHeight: eventList.height / 2
|
// Layout.maximumHeight: eventList.height / 2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,9 +4,9 @@ import "../../utils.js" as Utils
|
||||||
|
|
||||||
HMxcImage {
|
HMxcImage {
|
||||||
id: image
|
id: image
|
||||||
|
width: fitSize.width
|
||||||
|
height: fitSize.height
|
||||||
horizontalAlignment: Image.AlignLeft
|
horizontalAlignment: Image.AlignLeft
|
||||||
sourceSize.width: 640 // FIXME
|
|
||||||
sourceSize.height: 480 // FIXME
|
|
||||||
animated: loader.singleMediaInfo.media_mime === "image/gif" ||
|
animated: loader.singleMediaInfo.media_mime === "image/gif" ||
|
||||||
Utils.urlExtension(loader.mediaUrl) === "gif"
|
Utils.urlExtension(loader.mediaUrl) === "gif"
|
||||||
clientUserId: chatPage.userId
|
clientUserId: chatPage.userId
|
||||||
|
@ -23,6 +23,27 @@ HMxcImage {
|
||||||
readonly property bool isEncrypted: ! Utils.isEmptyObject(cryptDict)
|
readonly property bool isEncrypted: ! Utils.isEmptyObject(cryptDict)
|
||||||
readonly property string openUrl: isEncrypted ? cachedPath : image.httpUrl
|
readonly property string openUrl: isEncrypted ? cachedPath : image.httpUrl
|
||||||
|
|
||||||
|
readonly property size fitSize: Utils.fitSize(
|
||||||
|
// Minimum display size
|
||||||
|
192,
|
||||||
|
192,
|
||||||
|
|
||||||
|
// Real size
|
||||||
|
loader.singleMediaInfo.thumbnail_width ||
|
||||||
|
loader.singleMediaInfo.media_width ||
|
||||||
|
implicitWidth ||
|
||||||
|
800,
|
||||||
|
|
||||||
|
loader.singleMediaInfo.thumbnail_height ||
|
||||||
|
loader.singleMediaInfo.media_height ||
|
||||||
|
implicitHeight ||
|
||||||
|
600,
|
||||||
|
|
||||||
|
// Maximum display size
|
||||||
|
Math.min(eventList.height / 3, eventContent.messageBodyWidth),
|
||||||
|
eventList.height / 3,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
TapHandler {
|
TapHandler {
|
||||||
onTapped: if (! image.animated) Qt.openUrlExternally(openUrl)
|
onTapped: if (! image.animated) Qt.openUrlExternally(openUrl)
|
||||||
|
|
|
@ -155,12 +155,13 @@ function filterModelSource(source, filter_text, property="filter_string") {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function fitSize(width, height, max) {
|
function fitSize(minWidth, minHeight, width, height, maxWidth, maxHeight) {
|
||||||
if (width >= height) {
|
if (width >= height) {
|
||||||
let new_width = Math.min(width, max)
|
let new_width = Math.max(Math.min(width, maxWidth), minWidth)
|
||||||
return Qt.size(new_width, height / (width / new_width))
|
return Qt.size(new_width, height / (width / new_width))
|
||||||
}
|
}
|
||||||
let new_height = Math.min(height, max)
|
|
||||||
|
let new_height = Math.max(Math.min(height, maxHeight), minHeight)
|
||||||
return Qt.size(width / (height / new_height), new_height)
|
return Qt.size(width / (height / new_height), new_height)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user