Consider preview thumbnails to calculate msg width

Also move thumbnails width setting from settings.json to the theme
This commit is contained in:
miruka 2019-09-06 17:46:48 -04:00
parent ea9caa69f6
commit 6e40f29ebe
5 changed files with 10 additions and 7 deletions

View File

@ -40,7 +40,6 @@
- Make scroll wheel usable - Make scroll wheel usable
- Copy to X11 selection - Copy to X11 selection
- Link previews - Link previews
- Take the previews into account to calculate delegate min height
- Support images not just at the end of the message - Support images not just at the end of the message
- Just use Shortcut onHeld instead of analyzing the current velocity - Just use Shortcut onHeld instead of analyzing the current velocity

View File

@ -105,7 +105,6 @@ class UISettings(JSONConfigFile):
async def default_data(self) -> JsonData: async def default_data(self) -> JsonData:
return { return {
"alertOnMessageForMsec": 4000, "alertOnMessageForMsec": 4000,
"messageImageMaxThumbnailSize": 256,
"theme": "Default.qpl", "theme": "Default.qpl",
"writeAliases": {}, "writeAliases": {},
"keys": { "keys": {

View File

@ -54,9 +54,14 @@ Row {
width: Math.min( width: Math.min(
eventList.width - avatar.width - eventContent.spacing, eventList.width - avatar.width - eventContent.spacing,
theme.fontSize.normal * 0.5 * 75, // 600 with 16px font theme.fontSize.normal * 0.5 * 75, // 600 with 16px font
Math.max( Math.max(
nameLabel.visible ? (nameLabel.implicitWidth + 1) : 0, nameLabel.visible ? (nameLabel.implicitWidth + 1) : 0,
contentLabel.implicitWidth + 1, contentLabel.implicitWidth + 1,
previewLinksRepeater.count > 0 ?
theme.chat.message.thumbnailWidth : 0,
) )
) )
height: childrenRect.height height: childrenRect.height

View File

@ -4,16 +4,14 @@ import "../../Base"
HImage { HImage {
id: image id: image
x: eventContent.spacing x: eventContent.spacing
sourceSize.width: maxDimension sourceSize.width: theme.chat.message.thumbnailWidth
sourceSize.height: maxDimension sourceSize.height: theme.chat.message.thumbnailWidth
width: Math.min( width: Math.min(
mainColumn.width - eventContent.spacing * 2, mainColumn.width - eventContent.spacing * 2,
implicitWidth, implicitWidth,
maxDimension, theme.chat.message.thumbnailWidth,
) )
property int maxDimension: window.settings.messageImageMaxThumbnailSize
TapHandler { TapHandler {
onTapped: Qt.openUrlExternally(image.source) onTapped: Qt.openUrlExternally(image.source)
} }

View File

@ -307,6 +307,8 @@ chat:
string styleInclude: string styleInclude:
'<style type"text/css">\n' + styleSheet + '\n</style>\n' '<style type"text/css">\n' + styleSheet + '\n</style>\n'
int thumbnailWidth: 256
daybreak: daybreak:
color background: colors.strongBackground color background: colors.strongBackground
color text: colors.text color text: colors.text