Page MenuHomePhorge

No OneTemporary

Size
9 KB
Referenced Files
None
Subscribers
None
diff --git a/src/contents/ui/Bubble.qml b/src/contents/ui/Bubble.qml
index 1440231..75474ce 100644
--- a/src/contents/ui/Bubble.qml
+++ b/src/contents/ui/Bubble.qml
@@ -1,113 +1,132 @@
/*
* This file is part of kazv.
* SPDX-FileCopyrightText: 2020-2023 tusooa <tusooa@kazv.moe>
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
import QtQuick 2.15
import QtQuick.Layouts 1.15
import QtQuick.Controls 2.15
import org.kde.kirigami 2.13 as Kirigami
import '.' as Kazv
-Kirigami.AbstractCard {
+ItemDelegate {
id: upper
default property var children
property var currentEvent: event
property var menuContent: []
readonly property var bubbleSpacing: leftPadding + rightPadding
- Layout.fillWidth: false
- Layout.minimumWidth: inReplyToLoader.item ? inReplyToLoader.item.width : 0
+ Layout.fillWidth: true
+ Layout.preferredHeight: bubbleRootLayout.implicitHeight
+
+ property var backgroundItem: Rectangle {
+ anchors.fill: parent
+ color: hovered ? Kirigami.Theme.activeBackgroundColor : Kirigami.Theme.backgroundColor
+ }
+ background: compactMode ? null : backgroundItem
TapHandler {
acceptedButtons: Qt.LeftButton | Qt.RightButton
property var menu: Menu {
objectName: 'bubbleContextMenu'
Kirigami.Action {
objectName: 'replyToMenuItem'
text: l10n.get('event-reply-action')
onTriggered: console.log('reply to')
enabled: event && !event.redacted
}
Kirigami.Action {
objectName: 'deleteMenuItem'
text: l10n.get('event-delete')
onTriggered: eventView.redactSelf()
enabled: event && !event.redacted
}
MenuSeparator {}
Kirigami.Action {
text: l10n.get('event-view-source')
onTriggered: eventSourcePopup.open()
}
}
onLongPressed: maybePopup()
onTapped: {
if (eventPoint.event.button === Qt.RightButton) {
maybePopup()
}
}
function shouldPopup() {
return !compactMode
}
function maybePopup() {
if (shouldPopup()) {
menu.popup(parent)
}
}
}
property var eventSourcePopup: Kirigami.OverlaySheet {
title: l10n.get('event-source-popup-title')
Kazv.EventSourceView {
event: upper.currentEvent
}
}
- contentItem: ColumnLayout {
+ ColumnLayout {
+ id: bubbleRootLayout
anchors.left: parent.left
anchors.right: parent.right
-
- property var inReplyTo: Loader {
- id: inReplyToLoader
- source: 'qrc:/EventViewCompact.qml'
- active: currentEvent.replyingToEventId && !compactMode
- asynchronous: true
-
- property var event: room.messageById(currentEvent.replyingToEventId)
- property var props: ({
- event,
- sender: room.member(event.sender || matrixSdk.userId),
- stateKeyUser: event.stateKey ? room.member(event.stateKey) : {},
- isGapped: timeline.gaps.includes(event.eventId),
- })
+ property var inReplyTo: RowLayout {
+ Layout.fillWidth: true
+
+ Loader {
+ id: inReplyToLoader
+ source: 'qrc:/EventViewCompact.qml'
+ active: currentEvent.replyingToEventId && !compactMode
+ asynchronous: true
+ Layout.minimumHeight: inReplyToLoader.item ? inReplyToLoader.item.height : 0
+ Layout.fillWidth: true
+
+ property var event: room.messageById(currentEvent.replyingToEventId)
+ property var props: ({
+ event,
+ sender: room.member(event.sender || matrixSdk.userId),
+ stateKeyUser: event.stateKey ? room.member(event.stateKey) : {},
+ isGapped: timeline.gaps.includes(event.eventId),
+ })
+ }
}
property var eventContent: RowLayout {
+ Layout.fillWidth: true
property var encryptedIcon: Kirigami.Icon {
source: 'emblem-encrypted-locked'
Layout.preferredHeight: inlineBadgeSize
Layout.preferredWidth: inlineBadgeSize
}
data: [
...(event && event.encrypted ? [encryptedIcon] : []),
...(Array.isArray(upper.children) ? upper.children :
upper.children ? [upper.children] : [])
]
}
children: event.replyingToEventId && !compactMode ? [inReplyTo, eventContent] : [eventContent];
}
+
+ Component.onCompleted: {
+ console.log('upper.width=', upper.width);
+ console.log('bubbleRootLayout.width=', bubbleRootLayout.width);
+ console.log('eventContent.width=', bubbleRootLayout.eventContent.width);
+ }
}
diff --git a/src/contents/ui/event-types/Simple.qml b/src/contents/ui/event-types/Simple.qml
index 87ca145..d57b4b8 100644
--- a/src/contents/ui/event-types/Simple.qml
+++ b/src/contents/ui/event-types/Simple.qml
@@ -1,108 +1,109 @@
/*
* This file is part of kazv.
* SPDX-FileCopyrightText: 2020-2021 Tusooa Zhu <tusooa@kazv.moe>
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
import QtQuick 2.15
import QtQuick.Layouts 1.15
import QtQuick.Controls 2.15
import org.kde.kirigami 2.13 as Kirigami
ColumnLayout {
property var event
property var sender
default property var children
property var localEchoIndicator: Kirigami.Icon {
objectName: 'localEchoIndicator'
source: event.isSending ? 'state-sync' : 'state-warning'
Layout.preferredHeight: Kirigami.Units.iconSizes.medium
Layout.preferredWidth: Kirigami.Units.iconSizes.medium
Accessible.role: event.isSending ? Accessible.StaticText : Accessible.Button
Accessible.name: event.isSending ? l10n.get('event-sending') : l10n.get('event-resend')
ToolTip.text: event.isSending ? l10n.get('event-sending') : l10n.get('event-send-failed')
ToolTip.delay: 1000
ToolTip.timeout: 5000
ToolTip.visible: hoverHandler.hovered
HoverHandler { id: hoverHandler }
TapHandler {
objectName: 'resendEventButton'
onTapped: {
room.resendMessage(event.txnId);
}
enabled: event.isFailed
}
}
property var contentMaxWidth: {
(parent.width
// avatar size and margins
- iconSize
- 2 * Kirigami.Units.largeSpacing
- 2 * Kirigami.Units.largeSpacing
// local echo indicator
- (event.isLocalEcho ? Kirigami.Units.iconSizes.medium + Kirigami.Units.largeSpacing : 0)
)
}
id: layout
RowLayout {
- width: parent.width
+ // width: parent.width
+ Layout.fillWidth: true
Layout.leftMargin: Kirigami.Units.largeSpacing
Layout.rightMargin: Kirigami.Units.largeSpacing
Layout.topMargin: Kirigami.Units.largeSpacing
Kirigami.Avatar {
id: avatar
Layout.alignment: Qt.AlignTop
sourceSize.width: iconSize
sourceSize.height: iconSize
source: sender.avatarMxcUri ? matrixSdk.mxcUriToHttp(sender.avatarMxcUri) : ''
name: sender.name || sender.userId
visible: !compactMode
TapHandler {
onTapped: {
console.log('avatar tapped');
pageStack.push(Qt.resolvedUrl("qrc:///UserPage.qml"), {
userId: sender.userId,
user: sender,
})
}
}
}
ColumnLayout {
Layout.fillWidth: true
Layout.leftMargin: Kirigami.Units.largeSpacing
RowLayout {
Kirigami.Avatar {
id: avatarCompact
Layout.preferredWidth: Kirigami.Units.iconSizes.sizeForLabels
Layout.preferredHeight: Kirigami.Units.iconSizes.sizeForLabels
sourceSize.width: Kirigami.Units.iconSizes.sizeForLabels
sourceSize.height: Kirigami.Units.iconSizes.sizeForLabels
source: sender.avatarMxcUri ? matrixSdk.mxcUriToHttp(sender.avatarMxcUri) : ''
name: sender.name || sender.userId
visible: compactMode
}
Label {
text: sender.name || sender.userId
Layout.fillWidth: true
}
}
RowLayout {
id: container
Layout.fillWidth: true
data: (event.isLocalEcho ? [layout.localEchoIndicator] : []).concat(layout.children)
}
}
}
}
diff --git a/src/contents/ui/event-types/TextTemplate.qml b/src/contents/ui/event-types/TextTemplate.qml
index 92736d5..8dd0f19 100644
--- a/src/contents/ui/event-types/TextTemplate.qml
+++ b/src/contents/ui/event-types/TextTemplate.qml
@@ -1,44 +1,39 @@
/*
* This file is part of kazv.
* SPDX-FileCopyrightText: 2020-2023 tusooa <tusooa@kazv.moe>
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
import QtQuick 2.2
import QtQuick.Layouts 1.15
import QtQuick.Controls 2.15
import org.kde.kirigami 2.13 as Kirigami
import '.' as Types
import '..' as Kazv
Types.Simple {
id: upper
property var text
default property var children
- property var innerContentWidth: upper.contentMaxWidth - bubble.bubbleSpacing
Kazv.Bubble {
id: bubble
- Layout.maximumWidth: upper.contentMaxWidth
+ Layout.fillWidth: true
RowLayout {
- //leftPadding: Kirigami.Units.largeSpacing
- //spacing: Kirigami.Units.largeSpacing
- Layout.maximumWidth: innerContentWidth
+ Layout.fillWidth: true
property var label: Kazv.SelectableText {
- Layout.fillWidth: false
- Layout.preferredWidth: implicitWidth
- Layout.maximumWidth: innerContentWidth
+ Layout.fillWidth: true
wrapMode: Text.Wrap
text: upper.text
}
data: [
...(Array.isArray(upper.children) ? upper.children :
upper.children ? [upper.children] : []),
label
]
}
}
}

File Metadata

Mime Type
text/x-diff
Expires
Sun, Jan 19, 11:14 PM (1 d, 18 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
55496
Default Alt Text
(9 KB)

Event Timeline