diff --git a/resources/qml/delegates/Encrypted.qml b/resources/qml/delegates/Encrypted.qml
index fdfe958e..7aeeb28a 100644
--- a/resources/qml/delegates/Encrypted.qml
+++ b/resources/qml/delegates/Encrypted.qml
@@ -8,37 +8,34 @@ import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15
import im.nheko 1.0
-Rectangle {
+Control {
id: r
required property int encryptionError
required property string eventId
- radius: fontMetrics.lineSpacing / 2 + Nheko.paddingMedium
- width: parent.width? parent.width : 0
- implicitWidth: encryptedText.implicitWidth+24+Nheko.paddingMedium*3 // Column doesn't provide a useful implicitWidth, should be replaced by ColumnLayout
- height: contents.implicitHeight + Nheko.paddingMedium * 2
- color: palette.alternateBase
+ padding: Nheko.paddingMedium
+ implicitHeight: contents.implicitHeight + Nheko.paddingMedium * 2
+ Layout.maximumWidth: contents.Layout.maximumWidth + padding * 2
+ Layout.fillWidth: true
- RowLayout {
+ contentItem: RowLayout {
id: contents
- anchors.fill: parent
- anchors.margins: Nheko.paddingMedium
spacing: Nheko.paddingMedium
Image {
source: "image://colorimage/:/icons/icons/ui/shield-filled-cross.svg?" + Nheko.theme.error
Layout.alignment: Qt.AlignVCenter
- width: 24
- height: width
+ Layout.preferredWidth: 24
+ Layout.preferredHeight: 24
}
- Column {
+ ColumnLayout {
spacing: Nheko.paddingSmall
Layout.fillWidth: true
- MatrixText {
+ Label {
id: encryptedText
text: {
switch (encryptionError) {
@@ -58,8 +55,11 @@ Rectangle {
return qsTr("Unknown decryption error");
}
}
+ textFormat: Text.PlainText
+ wrapMode: Label.WordWrap
color: palette.text
- width: parent.width
+ Layout.fillWidth: true
+ Layout.maximumWidth: implicitWidth + 1
}
Button {
@@ -72,4 +72,9 @@ Rectangle {
}
+ background: Rectangle {
+ color: palette.alternateBase
+ radius: fontMetrics.lineSpacing / 2 + 2 * Nheko.paddingMedium
+ visible: !Settings.bubbles // the bubble in a bubble looks odd
+ }
}
diff --git a/resources/qml/delegates/EncryptionEnabled.qml b/resources/qml/delegates/EncryptionEnabled.qml
index 0e2b7fc0..40894543 100644
--- a/resources/qml/delegates/EncryptionEnabled.qml
+++ b/resources/qml/delegates/EncryptionEnabled.qml
@@ -3,27 +3,24 @@
// SPDX-License-Identifier: GPL-3.0-or-later
import ".."
-import QtQuick 2.15
-import QtQuick.Layouts 1.15
-import im.nheko 1.0
+import QtQuick
+import QtQuick.Controls
+import QtQuick.Layouts
+import im.nheko
-Rectangle {
+Control {
id: r
- required property string username
+ required property string userName
- radius: fontMetrics.lineSpacing / 2 + Nheko.paddingMedium
- width: parent.width ? Math.min(parent.width, 700) : 0
- height: contents.implicitHeight + Nheko.paddingMedium * 2
- color: palette.alternateBase
- border.color: Nheko.theme.green
- border.width: 2
+ padding: Nheko.paddingMedium
+ //implicitHeight: contents.implicitHeight + padd * 2
+ Layout.maximumWidth: contents.Layout.maximumWidth + padding * 2
+ Layout.fillWidth: true
- RowLayout {
+ contentItem: RowLayout {
id: contents
- anchors.fill: parent
- anchors.margins: Nheko.paddingMedium
spacing: Nheko.paddingMedium
Image {
@@ -33,26 +30,36 @@ Rectangle {
Layout.preferredHeight: 24
}
- Column {
+ ColumnLayout {
spacing: Nheko.paddingSmall
Layout.fillWidth: true
MatrixText {
- text: qsTr("%1 enabled end-to-end encryption").arg(r.username)
+ text: qsTr("%1 enabled end-to-end encryption").arg(r.userName)
font.bold: true
font.pointSize: 14
color: palette.text
- width: parent.width
+ Layout.fillWidth: true
+ Layout.maximumWidth: implicitWidth + 1
}
- MatrixText {
+ Label {
text: qsTr("Encryption keeps your messages safe by only allowing the people you sent the message to to read it. For extra security, if you want to make sure you are talking to the right people, you can verify them in real life.")
- color: palette.text
- width: parent.width
+ textFormat: Text.PlainText
+ wrapMode: Label.WordWrap
+ Layout.fillWidth: true
+ Layout.maximumWidth: implicitWidth + 1
}
}
}
+ background: Rectangle {
+ radius: fontMetrics.lineSpacing / 2 + Nheko.paddingMedium
+ height: contents.implicitHeight + Nheko.paddingMedium * 2
+ color: palette.alternateBase
+ border.color: Nheko.theme.green
+ border.width: 2
+ }
}
diff --git a/resources/qml/delegates/FileMessage.qml b/resources/qml/delegates/FileMessage.qml
index 82b82c1b..9f350123 100644
--- a/resources/qml/delegates/FileMessage.qml
+++ b/resources/qml/delegates/FileMessage.qml
@@ -2,26 +2,30 @@
//
// SPDX-License-Identifier: GPL-3.0-or-later
-import QtQuick 2.12
-import QtQuick.Layouts 1.2
-import im.nheko 1.0
+import QtQuick
+import QtQuick.Layouts
+import QtQuick.Controls
+import im.nheko
+
+Control {
+ id: evRoot
-Item {
required property string eventId
required property string filename
required property string filesize
- height: rowa.height + (Settings.bubbles? 16: 24)
- implicitWidth: rowa.implicitWidth + metadataWidth
- property int metadataWidth
- property bool fitsMetadata: true
+ padding: Settings.bubbles? 8 : 12
+ //Layout.preferredHeight: rowa.implicitHeight + padding
+ //Layout.maximumWidth: rowa.Layout.maximumWidth + metadataWidth + padding
+ property int metadataWidth: 0
+ property bool fitsMetadata: false
+
+ Layout.maximumWidth: rowa.Layout.maximumWidth + padding * 2
- RowLayout {
+ contentItem: RowLayout {
id: rowa
- anchors.centerIn: parent
- width: parent.width - (Settings.bubbles? 16 : 24)
- spacing: 15
+ spacing: 16
Rectangle {
id: button
@@ -63,6 +67,7 @@ Item {
id: filename_
Layout.fillWidth: true
+ Layout.maximumWidth: implicitWidth + 1
text: filename
textFormat: Text.PlainText
elide: Text.ElideRight
@@ -73,6 +78,7 @@ Item {
id: filesize_
Layout.fillWidth: true
+ Layout.maximumWidth: implicitWidth + 1
text: filesize
textFormat: Text.PlainText
elide: Text.ElideRight
@@ -83,11 +89,9 @@ Item {
}
- Rectangle {
+ background: Rectangle {
color: palette.alternateBase
- z: -1
- radius: 10
- anchors.fill: parent
+ radius: fontMetrics.lineSpacing / 2 + 2 * Nheko.paddingSmall
visible: !Settings.bubbles // the bubble in a bubble looks odd
}
diff --git a/resources/qml/delegates/ImageMessage.qml b/resources/qml/delegates/ImageMessage.qml
index 20d727c3..9c93c25b 100644
--- a/resources/qml/delegates/ImageMessage.qml
+++ b/resources/qml/delegates/ImageMessage.qml
@@ -2,29 +2,31 @@
//
// SPDX-License-Identifier: GPL-3.0-or-later
-import QtQuick 2.15
-import QtQuick.Window 2.15
-import QtQuick.Controls 2.3
-import im.nheko 1.0
+import QtQuick
+import QtQuick.Window
+import QtQuick.Controls
+import im.nheko
AbstractButton {
required property int type
required property int originalWidth
+ required property int originalHeight
required property double proportionalHeight
required property string url
required property string blurhash
required property string body
required property string filename
- required property bool isReply
required property string eventId
- property double divisor: isReply ? 5 : 3
+ required property int containerHeight
+ property double divisor: EventDelegateChooser.isReply ? 10 : 4
- property int tempWidth: originalWidth < 1? 400: originalWidth
+ EventDelegateChooser.keepAspectRatio: true
+ EventDelegateChooser.maxWidth: originalWidth
+ EventDelegateChooser.maxHeight: containerHeight / divisor
+ EventDelegateChooser.aspectRatio: proportionalHeight
- implicitWidth: Math.round(tempWidth*Math.min((timelineView.height/divisor)/(tempWidth*proportionalHeight), 1))
- width: Math.min(parent?.width ?? 2000,implicitWidth)
- height: width*proportionalHeight
hoverEnabled: true
+ enabled: !EventDelegateChooser.isReply
state: (img.status != Image.Ready || timeline.privacyScreen.active) ? "BlurhashVisible" : "ImageVisible"
states: [
@@ -116,6 +118,7 @@ AbstractButton {
source: url != "" ? (url.replace("mxc://", "image://MxcImage/") + "?scale") : ""
asynchronous: true
fillMode: Image.PreserveAspectFit
+ horizontalAlignment: Image.AlignLeft
smooth: true
mipmap: true
@@ -127,21 +130,23 @@ AbstractButton {
id: mxcimage
visible: loaded
- anchors.fill: parent
roomm: room
play: !Settings.animateImagesOnHover || parent.hovered
eventId: parent.eventId
+
+ anchors.fill: parent
}
Image {
id: blurhash_
- anchors.fill: parent
source: blurhash ? ("image://blurhash/" + blurhash) : ("image://colorimage/:/icons/icons/ui/image-failed.svg?" + palette.buttonText)
asynchronous: true
fillMode: Image.PreserveAspectFit
sourceSize.width: parent.width * Screen.devicePixelRatio
sourceSize.height: parent.height * Screen.devicePixelRatio
+
+ anchors.fill: parent
}
onClicked: Settings.openImageExternal ? room.openMedia(eventId) : TimelineManager.openImageOverlay(room, url, eventId, originalWidth, proportionalHeight);
@@ -150,6 +155,7 @@ AbstractButton {
id: overlay
anchors.fill: parent
+
visible: parent.hovered
Rectangle {
diff --git a/resources/qml/delegates/MessageDelegate.qml b/resources/qml/delegates/MessageDelegate.qml
deleted file mode 100644
index 68f65062..00000000
--- a/resources/qml/delegates/MessageDelegate.qml
+++ /dev/null
@@ -1,779 +0,0 @@
-// SPDX-FileCopyrightText: Nheko Contributors
-//
-// SPDX-License-Identifier: GPL-3.0-or-later
-
-import QtQuick 2.6
-import QtQuick.Controls 2.1
-import QtQuick.Layouts 1.2
-import im.nheko 1.0
-
-Item {
- id: d
-
- required property bool isReply
- property bool keepFullText: !isReply
- property alias child: chooser.child
- //implicitWidth: chooser.child?.implicitWidth ?? 0
- required property double proportionalHeight
- required property int type
- required property string typeString
- required property int originalWidth
- required property int duration
- required property string blurhash
- required property string body
- required property string formattedBody
- required property string eventId
- required property string filename
- required property string filesize
- required property string url
- required property string thumbnailUrl
- required property bool isOnlyEmoji
- required property bool isStateEvent
- required property string userId
- required property string userName
- required property string roomTopic
- required property string roomName
- required property string callType
- required property int encryptionError
- required property int relatedEventCacheBuster
- property bool fitsMetadata: (chooser.child && chooser.child.fitsMetadata) ? chooser.child.fitsMetadata : false
- property int metadataWidth
-
- implicitWidth: chooser.child?.implicitWidth
-
- height: chooser.child ? chooser.child.height : Nheko.paddingLarge
-
- DelegateChooser {
- id: chooser
-
- //role: "type" //< not supported in our custom implementation, have to use roleValue
- roleValue: type
- //anchors.fill: parent
-
- width: parent?.width ?? 0 // this should get rid of "cannot read property 'width' of null"
-
- DelegateChoice {
- roleValue: MtxEvent.UnknownEvent
-
- Placeholder {
- typeString: d.typeString
- text: "Unretrieved event"
- }
-
- }
-
- DelegateChoice {
- roleValue: MtxEvent.Tombstone
-
-
- ColumnLayout {
- width: parent.width
-
- NoticeMessage {
- body: formatted
- isOnlyEmoji: false
- isReply: d.isReply
- keepFullText: d.keepFullText
- isStateEvent: d.isStateEvent
- Layout.fillWidth: true
- formatted: qsTr("This room was replaced for the following reason: %1").arg(d.body)
- }
-
- Button {
- Layout.alignment: Qt.AlignHCenter
- text: qsTr("Go to replacement room")
- onClicked: room.joinReplacementRoom(eventId)
- }
-
- }
- }
-
- DelegateChoice {
- roleValue: MtxEvent.TextMessage
-
- TextMessage {
- formatted: d.formattedBody
- body: d.body
- isOnlyEmoji: d.isOnlyEmoji
- isReply: d.isReply
- keepFullText: d.keepFullText
- metadataWidth: d.metadataWidth
- }
-
- }
-
- DelegateChoice {
- roleValue: MtxEvent.UnknownMessage
-
- TextMessage {
- formatted: d.formattedBody
- body: d.body
- isOnlyEmoji: d.isOnlyEmoji
- isReply: d.isReply
- keepFullText: d.keepFullText
- metadataWidth: d.metadataWidth
- }
-
- }
-
- DelegateChoice {
- roleValue: MtxEvent.ElementEffectMessage
-
- TextMessage {
- formatted: d.formattedBody
- body: d.body
- isOnlyEmoji: d.isOnlyEmoji
- isReply: d.isReply
- keepFullText: d.keepFullText
- metadataWidth: d.metadataWidth
- }
-
- }
-
- DelegateChoice {
- roleValue: MtxEvent.NoticeMessage
-
- NoticeMessage {
- formatted: d.formattedBody
- body: d.body
- isOnlyEmoji: d.isOnlyEmoji
- isReply: d.isReply
- keepFullText: d.keepFullText
- isStateEvent: d.isStateEvent
- metadataWidth: d.metadataWidth
- }
-
- }
-
- DelegateChoice {
- roleValue: MtxEvent.EmoteMessage
-
- NoticeMessage {
- formatted: TimelineManager.escapeEmoji(d.userName) + " " + d.formattedBody
- color: TimelineManager.userColor(d.userId, palette.base)
- body: d.body
- isOnlyEmoji: d.isOnlyEmoji
- isReply: d.isReply
- keepFullText: d.keepFullText
- isStateEvent: d.isStateEvent
- metadataWidth: d.metadataWidth
- }
-
- }
-
- DelegateChoice {
- roleValue: MtxEvent.ImageMessage
-
- ImageMessage {
- type: d.type
- originalWidth: d.originalWidth
- proportionalHeight: d.proportionalHeight
- url: d.url
- blurhash: d.blurhash
- body: d.body
- filename: d.filename
- isReply: d.isReply
- eventId: d.eventId
- metadataWidth: d.metadataWidth
- }
-
- }
-
- DelegateChoice {
- roleValue: MtxEvent.Sticker
-
- ImageMessage {
- type: d.type
- originalWidth: d.originalWidth
- proportionalHeight: d.proportionalHeight
- url: d.url
- blurhash: d.blurhash
- body: d.body
- filename: d.filename
- isReply: d.isReply
- eventId: d.eventId
- metadataWidth: d.metadataWidth
- }
-
- }
-
- DelegateChoice {
- roleValue: MtxEvent.FileMessage
-
- FileMessage {
- eventId: d.eventId
- filename: d.filename
- filesize: d.filesize
- metadataWidth: d.metadataWidth
- }
-
- }
-
- DelegateChoice {
- roleValue: MtxEvent.VideoMessage
-
- PlayableMediaMessage {
- proportionalHeight: d.proportionalHeight
- type: d.type
- originalWidth: d.originalWidth
- thumbnailUrl: d.thumbnailUrl
- eventId: d.eventId
- url: d.url
- body: d.body
- filesize: d.filesize
- duration: d.duration
- metadataWidth: d.metadataWidth
- }
-
- }
-
- DelegateChoice {
- roleValue: MtxEvent.AudioMessage
-
- PlayableMediaMessage {
- proportionalHeight: d.proportionalHeight
- type: d.type
- originalWidth: d.originalWidth
- thumbnailUrl: d.thumbnailUrl
- eventId: d.eventId
- url: d.url
- body: d.body
- filesize: d.filesize
- duration: d.duration
- metadataWidth: d.metadataWidth
- }
-
- }
-
- DelegateChoice {
- roleValue: MtxEvent.Redacted
-
- Redacted {
- metadataWidth: d.metadataWidth
- }
- }
-
- DelegateChoice {
- roleValue: MtxEvent.Redaction
-
- Pill {
- text: qsTr("%1 removed a message").arg(d.userName)
- isStateEvent: d.isStateEvent
- }
-
- }
-
- DelegateChoice {
- roleValue: MtxEvent.Encryption
-
- EncryptionEnabled {
- username: d.userName
- }
-
- }
-
- DelegateChoice {
- roleValue: MtxEvent.Encrypted
-
- Encrypted {
- encryptionError: d.encryptionError
- eventId: d.eventId
- }
-
- }
-
- DelegateChoice {
- roleValue: MtxEvent.ServerAcl
-
- NoticeMessage {
- body: formatted
- isOnlyEmoji: false
- isReply: d.isReply
- keepFullText: d.keepFullText
- isStateEvent: d.isStateEvent
- formatted: qsTr("%1 changed which servers are allowed in this room.").arg(d.userName)
- }
-
- }
-
- DelegateChoice {
- roleValue: MtxEvent.Name
-
- NoticeMessage {
- body: formatted
- isOnlyEmoji: false
- isReply: d.isReply
- keepFullText: d.keepFullText
- isStateEvent: d.isStateEvent
- formatted: d.roomName ? qsTr("%2 changed the room name to: %1").arg(d.roomName).arg(d.userName) : qsTr("%1 removed the room name").arg(d.userName)
- }
-
- }
-
- DelegateChoice {
- roleValue: MtxEvent.Topic
-
- NoticeMessage {
- body: formatted
- isOnlyEmoji: false
- isReply: d.isReply
- keepFullText: d.keepFullText
- isStateEvent: d.isStateEvent
- formatted: d.roomTopic ? qsTr("%2 changed the topic to: %1").arg(d.roomTopic).arg(d.userName): qsTr("%1 removed the topic").arg(d.userName)
- }
-
- }
-
- DelegateChoice {
- roleValue: MtxEvent.Avatar
-
- NoticeMessage {
- body: formatted
- isOnlyEmoji: false
- isReply: d.isReply
- keepFullText: d.keepFullText
- isStateEvent: d.isStateEvent
- formatted: qsTr("%1 changed the room avatar").arg(d.userName)
- }
-
- }
-
- DelegateChoice {
- roleValue: MtxEvent.PinnedEvents
-
- NoticeMessage {
- body: formatted
- isOnlyEmoji: false
- isReply: d.isReply
- keepFullText: d.keepFullText
- isStateEvent: d.isStateEvent
- formatted: qsTr("%1 changed the pinned messages.").arg(d.userName)
- }
-
- }
-
- DelegateChoice {
- roleValue: MtxEvent.ImagePackInRoom
-
- NoticeMessage {
- body: formatted
- isOnlyEmoji: false
- isReply: d.isReply
- keepFullText: d.keepFullText
- isStateEvent: d.isStateEvent
- formatted: d.relatedEventCacheBuster, room.formatImagePackEvent(d.eventId)
- }
-
- }
-
-
- DelegateChoice {
- roleValue: MtxEvent.CanonicalAlias
-
- NoticeMessage {
- body: formatted
- isOnlyEmoji: false
- isReply: d.isReply
- keepFullText: d.keepFullText
- isStateEvent: d.isStateEvent
- formatted: qsTr("%1 changed the addresses for this room.").arg(d.userName)
- }
-
- }
-
- DelegateChoice {
- roleValue: MtxEvent.SpaceParent
-
- NoticeMessage {
- body: formatted
- isOnlyEmoji: false
- isReply: d.isReply
- keepFullText: d.keepFullText
- isStateEvent: d.isStateEvent
- formatted: qsTr("%1 changed the parent communities for this room.").arg(d.userName)
- }
-
- }
-
- DelegateChoice {
- roleValue: MtxEvent.RoomCreate
-
- NoticeMessage {
- body: formatted
- isOnlyEmoji: false
- isReply: d.isReply
- keepFullText: d.keepFullText
- isStateEvent: d.isStateEvent
- formatted: qsTr("%1 created and configured room: %2").arg(d.userName).arg(room.roomId)
- }
-
- }
-
- DelegateChoice {
- roleValue: MtxEvent.CallInvite
-
- NoticeMessage {
- body: formatted
- isOnlyEmoji: false
- isReply: d.isReply
- keepFullText: d.keepFullText
- isStateEvent: d.isStateEvent
- formatted: {
- switch (d.callType) {
- case "voice":
- return qsTr("%1 placed a voice call.").arg(d.userName);
- case "video":
- return qsTr("%1 placed a video call.").arg(d.userName);
- default:
- return qsTr("%1 placed a call.").arg(d.userName);
- }
- }
- }
-
- }
-
- DelegateChoice {
- roleValue: MtxEvent.CallAnswer
-
- NoticeMessage {
- body: formatted
- isOnlyEmoji: false
- isReply: d.isReply
- keepFullText: d.keepFullText
- isStateEvent: d.isStateEvent
- formatted: qsTr("%1 answered the call.").arg(d.userName)
- }
-
- }
-
- DelegateChoice {
- roleValue: MtxEvent.CallReject
-
- NoticeMessage {
- body: formatted
- isOnlyEmoji: false
- isReply: d.isReply
- keepFullText: d.keepFullText
- isStateEvent: d.isStateEvent
- formatted: qsTr("%1 rejected the call.").arg(d.userName)
- }
-
- }
-
- DelegateChoice {
- roleValue: MtxEvent.CallSelectAnswer
-
- NoticeMessage {
- body: formatted
- isOnlyEmoji: false
- isReply: d.isReply
- keepFullText: d.keepFullText
- isStateEvent: d.isStateEvent
- formatted: qsTr("%1 select answer").arg(d.userName)
- // formatted: qsTr("Call answered elsewhere")
- }
- }
-
- DelegateChoice {
- roleValue: MtxEvent.CallHangUp
-
- NoticeMessage {
- body: formatted
- isOnlyEmoji: false
- isReply: d.isReply
- keepFullText: d.keepFullText
- isStateEvent: d.isStateEvent
- formatted: qsTr("%1 ended the call.").arg(d.userName)
- }
-
- }
-
- DelegateChoice {
- roleValue: MtxEvent.CallCandidates
-
- NoticeMessage {
- body: formatted
- isOnlyEmoji: false
- isReply: d.isReply
- keepFullText: d.keepFullText
- isStateEvent: d.isStateEvent
- formatted: qsTr("%1 is negotiating the call...").arg(d.userName)
- }
-
- }
-
- DelegateChoice {
- roleValue: MtxEvent.CallNegotiate
-
- NoticeMessage {
- body: formatted
- isOnlyEmoji: false
- isReply: d.isReply
- keepFullText: d.keepFullText
- isStateEvent: d.isStateEvent
- formatted: qsTr("%1 is negotiating the call...").arg(d.userName)
- }
-
- }
-
- DelegateChoice {
- roleValue: MtxEvent.PowerLevels
-
- NoticeMessage {
- body: formatted
- isOnlyEmoji: false
- isReply: d.isReply
- keepFullText: d.keepFullText
- isStateEvent: d.isStateEvent
- formatted: d.relatedEventCacheBuster, room.formatPowerLevelEvent(d.eventId)
- }
-
- }
-
- DelegateChoice {
- roleValue: MtxEvent.PolicyRuleUser
-
- NoticeMessage {
- body: formatted
- isOnlyEmoji: false
- isReply: d.isReply
- keepFullText: d.keepFullText
- isStateEvent: d.isStateEvent
- formatted: d.relatedEventCacheBuster, room.formatPolicyRule(d.eventId)
- }
-
- }
-
- DelegateChoice {
- roleValue: MtxEvent.PolicyRuleRoom
-
- NoticeMessage {
- body: formatted
- isOnlyEmoji: false
- isReply: d.isReply
- keepFullText: d.keepFullText
- isStateEvent: d.isStateEvent
- formatted: d.relatedEventCacheBuster, room.formatPolicyRule(d.eventId)
- }
-
- }
-
- DelegateChoice {
- roleValue: MtxEvent.PolicyRuleServer
-
- NoticeMessage {
- body: formatted
- isOnlyEmoji: false
- isReply: d.isReply
- keepFullText: d.keepFullText
- isStateEvent: d.isStateEvent
- formatted: d.relatedEventCacheBuster, room.formatPolicyRule(d.eventId)
- }
-
- }
-
- DelegateChoice {
- roleValue: MtxEvent.RoomJoinRules
-
- NoticeMessage {
- body: formatted
- isOnlyEmoji: false
- isReply: d.isReply
- keepFullText: d.keepFullText
- isStateEvent: d.isStateEvent
- formatted: d.relatedEventCacheBuster, room.formatJoinRuleEvent(d.eventId)
- }
-
- }
-
- DelegateChoice {
- roleValue: MtxEvent.RoomHistoryVisibility
-
- NoticeMessage {
- body: formatted
- isOnlyEmoji: false
- isReply: d.isReply
- keepFullText: d.keepFullText
- isStateEvent: d.isStateEvent
- formatted: d.relatedEventCacheBuster, room.formatHistoryVisibilityEvent(d.eventId)
- }
-
- }
-
- DelegateChoice {
- roleValue: MtxEvent.RoomGuestAccess
-
- NoticeMessage {
- body: formatted
- isOnlyEmoji: false
- isReply: d.isReply
- keepFullText: d.keepFullText
- isStateEvent: d.isStateEvent
- formatted: d.relatedEventCacheBuster, room.formatGuestAccessEvent(d.eventId)
- }
-
- }
-
- DelegateChoice {
- roleValue: MtxEvent.Member
-
- ColumnLayout {
- width: parent?.width ?? 100
-
- NoticeMessage {
- body: formatted
- isOnlyEmoji: false
- isReply: d.isReply
- keepFullText: d.keepFullText
- isStateEvent: d.isStateEvent
- Layout.fillWidth: true
- formatted: d.relatedEventCacheBuster, room.formatMemberEvent(d.eventId)
- }
-
- Button {
- visible: d.relatedEventCacheBuster, room.showAcceptKnockButton(d.eventId)
- Layout.alignment: Qt.AlignHCenter
- text: qsTr("Allow them in")
- onClicked: room.acceptKnock(eventId)
- }
-
- }
-
- }
-
- DelegateChoice {
- roleValue: MtxEvent.KeyVerificationRequest
-
- NoticeMessage {
- body: formatted
- isOnlyEmoji: false
- isReply: d.isReply
- keepFullText: d.keepFullText
- isStateEvent: d.isStateEvent
- formatted: "KeyVerificationRequest"
- }
-
- }
-
- DelegateChoice {
- roleValue: MtxEvent.KeyVerificationStart
-
- NoticeMessage {
- body: formatted
- isOnlyEmoji: false
- isReply: d.isReply
- keepFullText: d.keepFullText
- isStateEvent: d.isStateEvent
- formatted: "KeyVerificationStart"
- }
-
- }
-
- DelegateChoice {
- roleValue: MtxEvent.KeyVerificationReady
-
- NoticeMessage {
- body: formatted
- isOnlyEmoji: false
- isReply: d.isReply
- keepFullText: d.keepFullText
- isStateEvent: d.isStateEvent
- formatted: "KeyVerificationReady"
- }
-
- }
-
- DelegateChoice {
- roleValue: MtxEvent.KeyVerificationCancel
-
- NoticeMessage {
- body: formatted
- isOnlyEmoji: false
- isReply: d.isReply
- keepFullText: d.keepFullText
- isStateEvent: d.isStateEvent
- formatted: "KeyVerificationCancel"
- }
-
- }
-
- DelegateChoice {
- roleValue: MtxEvent.KeyVerificationKey
-
- NoticeMessage {
- body: formatted
- isOnlyEmoji: false
- isReply: d.isReply
- keepFullText: d.keepFullText
- isStateEvent: d.isStateEvent
- formatted: "KeyVerificationKey"
- }
-
- }
-
- DelegateChoice {
- roleValue: MtxEvent.KeyVerificationMac
-
- NoticeMessage {
- body: formatted
- isOnlyEmoji: false
- isReply: d.isReply
- keepFullText: d.keepFullText
- isStateEvent: d.isStateEvent
- formatted: "KeyVerificationMac"
- }
-
- }
-
- DelegateChoice {
- roleValue: MtxEvent.KeyVerificationDone
-
- NoticeMessage {
- body: formatted
- isOnlyEmoji: false
- isReply: d.isReply
- keepFullText: d.keepFullText
- isStateEvent: d.isStateEvent
- formatted: "KeyVerificationDone"
- }
-
- }
-
- DelegateChoice {
- roleValue: MtxEvent.KeyVerificationDone
-
- NoticeMessage {
- body: formatted
- isOnlyEmoji: false
- isReply: d.isReply
- keepFullText: d.keepFullText
- isStateEvent: d.isStateEvent
- formatted: "KeyVerificationDone"
- }
-
- }
-
- DelegateChoice {
- roleValue: MtxEvent.KeyVerificationAccept
-
- NoticeMessage {
- body: formatted
- isOnlyEmoji: false
- isReply: d.isReply
- keepFullText: d.keepFullText
- isStateEvent: d.isStateEvent
- formatted: "KeyVerificationAccept"
- }
-
- }
-
- DelegateChoice {
- Placeholder {
- typeString: d.typeString
- }
-
- }
-
- }
-
-}
diff --git a/resources/qml/delegates/PlayableMediaMessage.qml b/resources/qml/delegates/PlayableMediaMessage.qml
index fb7bf0cc..99928369 100644
--- a/resources/qml/delegates/PlayableMediaMessage.qml
+++ b/resources/qml/delegates/PlayableMediaMessage.qml
@@ -22,7 +22,7 @@ Item {
required property string url
required property string body
required property string filesize
- property double divisor: isReply ? 4 : 2
+ property double divisor: EventDelegateChooser.isReply ? 10 : 4
property int tempWidth: originalWidth < 1? 400: originalWidth
implicitWidth: type == MtxEvent.VideoMessage ? Math.round(tempWidth*Math.min((timelineView.height/divisor)/(tempWidth*proportionalHeight), 1)) : 500
width: Math.min(parent?.width ?? implicitWidth, implicitWidth)
diff --git a/resources/qml/delegates/Redacted.qml b/resources/qml/delegates/Redacted.qml
index 4a9700dc..3c496f08 100644
--- a/resources/qml/delegates/Redacted.qml
+++ b/resources/qml/delegates/Redacted.qml
@@ -2,25 +2,22 @@
//
// SPDX-License-Identifier: GPL-3.0-or-later
-import QtQuick 2.15
-import QtQuick.Controls 2.15
-import QtQuick.Layouts 1.15
-import im.nheko 1.0
-
-Rectangle{
-
- height: redactedLayout.implicitHeight + Nheko.paddingSmall
- implicitWidth: redactedLayout.implicitWidth + 2 * Nheko.paddingMedium
- width: Math.min(parent.width,implicitWidth+1)
- radius: fontMetrics.lineSpacing / 2 + 2 * Nheko.paddingSmall
- color: palette.alternateBase
- property int metadataWidth
- property bool fitsMetadata: parent.width - redactedLayout.width > metadataWidth + 4
-
- RowLayout {
+import QtQuick
+import QtQuick.Controls
+import QtQuick.Layouts
+import im.nheko
+
+Control {
+ id: msgRoot
+
+ property int metadataWidth: 0
+ property bool fitsMetadata: false //parent.width - redactedLayout.width > metadataWidth + 4
+
+ required property string eventId
+ required property Room room
+
+ contentItem: RowLayout {
id: redactedLayout
- anchors.centerIn: parent
- width: parent.width - 2 * Nheko.paddingMedium
spacing: Nheko.paddingSmall
Image {
@@ -34,12 +31,11 @@ Rectangle{
id: redactedLabel
Layout.margins: 0
Layout.alignment: Qt.AlignVCenter | Qt.AlignRight
- Layout.preferredWidth: implicitWidth
+ Layout.maximumWidth: implicitWidth + 1
Layout.fillWidth: true
- property var redactedPair: room.formatRedactedEvent(eventId)
+ property var redactedPair: room.formatRedactedEvent(msgRoot.eventId)
text: redactedPair["first"]
wrapMode: Label.WordWrap
- color: palette.text
ToolTip.text: redactedPair["second"]
ToolTip.visible: hh.hovered
@@ -48,4 +44,13 @@ Rectangle{
}
}
}
+
+ padding: Nheko.paddingSmall
+
+ Layout.maximumWidth: redactedLayout.Layout.maximumWidth + padding * 2
+
+ background: Rectangle {
+ color: palette.alternateBase
+ radius: fontMetrics.lineSpacing / 2 + 2 * Nheko.paddingSmall
+ }
}
diff --git a/resources/qml/delegates/Reply.qml b/resources/qml/delegates/Reply.qml
index 4d4983ac..ece838b7 100644
--- a/resources/qml/delegates/Reply.qml
+++ b/resources/qml/delegates/Reply.qml
@@ -14,128 +14,88 @@ AbstractButton {
id: r
property color userColor: "red"
- property double proportionalHeight
- property int type
- property string typeString
- property int originalWidth
- property string blurhash
- property string body
- property string formattedBody
- property string eventId
- property string filename
- property string filesize
- property string url
- property bool isOnlyEmoji
- property bool isStateEvent
- property string userId
- property string userName
- property string thumbnailUrl
- property string roomTopic
- property string roomName
- property string callType
- property int duration
- property int encryptionError
- property int relatedEventCacheBuster
- property int maxWidth
property bool keepFullText: false
- height: replyContainer.height
- implicitHeight: replyContainer.height
- implicitWidth: visible? colorLine.width+Math.max(replyContainer.implicitWidth,userName_.fullTextWidth) : 0 // visible? seems to be causing issues
+ required property string eventId
+
+ property var room_: room
+
+ property string userId: eventId ? room.dataById(eventId, Room.UserId, "") : ""
+ property string userName: eventId ? room.dataById(eventId, Room.UserName, "") : ""
+ implicitHeight: replyContainer.implicitHeight
+ implicitWidth: replyContainer.implicitWidth
+ required property int maxWidth
NhekoCursorShape {
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
}
- Rectangle {
- id: colorLine
-
- anchors.top: replyContainer.top
- anchors.bottom: replyContainer.bottom
- width: 4
- color: TimelineManager.userColor(userId, palette.base)
- }
-
onClicked: {
- let link = reply.child.linkAt != undefined && reply.child.linkAt(pressX-colorLine.width, pressY - userName_.implicitHeight);
+ let link = reply.child.linkAt != undefined && reply.child.linkAt(pressX-colorline.width, pressY - userName_.implicitHeight);
if (link) {
Nheko.openLink(link)
} else {
room.showEvent(r.eventId)
}
}
- onPressAndHold: replyContextMenu.show(reply.child.copyText, reply.child.linkAt(pressX-colorLine.width, pressY - userName_.implicitHeight), r.eventId)
+ onPressAndHold: replyContextMenu.show(reply.child.copyText, reply.child.linkAt(pressX-colorline.width, pressY - userName_.implicitHeight), r.eventId)
- ColumnLayout {
- id: replyContainer
+ contentItem: TimelineEvent {
+ id: timelineEvent
- anchors.left: colorLine.right
- width: parent.width - 4
- spacing: 0
+ isStateEvent: false
+ room: room_
+ eventId: r.eventId
+ replyTo: ""
+ mainInset: 4 + Nheko.paddingMedium
+ maxWidth: r.maxWidth
- TapHandler {
- acceptedButtons: Qt.RightButton
- onSingleTapped: replyContextMenu.show(reply.child.copyText, reply.child.linkAt(eventPoint.position.x, eventPoint.position.y - userName_.implicitHeight), r.eventId)
- gesturePolicy: TapHandler.ReleaseWithinBounds
- acceptedDevices: PointerDevice.Mouse | PointerDevice.Stylus | PointerDevice.TouchPad
- }
+ //height: replyContainer.implicitHeight
+ data: Row {
+ id: replyContainer
+
+ spacing: Nheko.paddingSmall
- AbstractButton {
- Layout.leftMargin: 4
- Layout.fillWidth: true
- contentItem: ElidedLabel {
- id: userName_
- fullText: userName
- color: r.userColor
- textFormat: Text.RichText
- width: parent.width
- elideWidth: width
+ Rectangle {
+ id: colorline
+
+ width: 4
+ height: content.height
+
+ color: TimelineManager.userColor(r.userId, palette.base)
}
- onClicked: room.openUserProfile(userId)
- }
- MessageDelegate {
- Layout.leftMargin: 4
- Layout.preferredHeight: height
- id: reply
- blurhash: r.blurhash
- body: r.body
- formattedBody: r.formattedBody
- eventId: r.eventId
- filename: r.filename
- filesize: r.filesize
- proportionalHeight: r.proportionalHeight
- type: r.type
- typeString: r.typeString ?? ""
- url: r.url
- thumbnailUrl: r.thumbnailUrl
- duration: r.duration
- originalWidth: r.originalWidth
- isOnlyEmoji: r.isOnlyEmoji
- isStateEvent: r.isStateEvent
- userId: r.userId
- userName: r.userName
- roomTopic: r.roomTopic
- roomName: r.roomName
- callType: r.callType
- relatedEventCacheBuster: r.relatedEventCacheBuster
- encryptionError: r.encryptionError
- // This is disabled so that left clicking the reply goes to its location
- enabled: false
- Layout.fillWidth: true
- isReply: true
- keepFullText: r.keepFullText
- }
+ Column {
+ id: content
+ spacing: 0
+
+ AbstractButton {
+ id: usernameBtn
+
+ contentItem: Label {
+ id: userName_
+ text: r.userName
+ color: r.userColor
+ textFormat: Text.RichText
+ width: timelineEvent.main?.width
+ }
+ onClicked: room.openUserProfile(r.userId)
+ }
+
+ data: [
+ usernameBtn, timelineEvent.main,
+ ]
+ }
+ }
}
- Rectangle {
+ background: Rectangle {
id: backgroundItem
z: -1
- anchors.fill: replyContainer
- property color userColor: TimelineManager.userColor(userId, palette.base)
+ property color userColor: TimelineManager.userColor(r.userId, palette.base)
property color bgColor: palette.base
color: Qt.tint(bgColor, Qt.hsla(userColor.hslHue, 0.5, userColor.hslLightness, 0.1))
}
diff --git a/resources/qml/delegates/TextMessage.qml b/resources/qml/delegates/TextMessage.qml
index aabb7136..d17e61d2 100644
--- a/resources/qml/delegates/TextMessage.qml
+++ b/resources/qml/delegates/TextMessage.qml
@@ -9,11 +9,12 @@ import im.nheko
MatrixText {
required property string body
required property bool isOnlyEmoji
- required property bool isReply
+ property bool isReply: EventDelegateChooser.isReply
required property bool keepFullText
required property string formatted
+
property string copyText: selectedText ? getText(selectionStart, selectionEnd) : body
- property int metadataWidth
+ property int metadataWidth: 100
property bool fitsMetadata: false //positionAt(width,height-4) == positionAt(width-metadataWidth-10, height-4)
// table border-collapse doesn't seem to work
@@ -39,11 +40,8 @@ MatrixText {
}" : "") + // TODO(Nico): Figure out how to support mobile
"</style>
" + formatted.replace(/<del>/g, "<s>").replace(/<\/del>/g, "</s>").replace(/<strike>/g, "<s>").replace(/<\/strike>/g, "</s>")
- width: parent?.width ?? 0
- height: !keepFullText ? Math.round(Math.min(timelineView.height / 8, implicitHeight)) : implicitHeight
- clip: !keepFullText
- selectByMouse: !isReply
-// enabled: !Settings.mobileMode
+
+ enabled: !isReply
font.pointSize: (Settings.enlargeEmojiOnlyMessages && isOnlyEmoji > 0 && isOnlyEmoji < 4) ? Settings.fontSize * 3 : Settings.fontSize
NhekoCursorShape {
|