Minor improvements

- Rename TextDelegate to RichLabel since it's not actually a delegate
- Allow web search for whole messages
This commit is contained in:
Tobias Fella
2021-12-15 00:53:43 +01:00
parent 91f3f64bb5
commit 332d6c9782
6 changed files with 19 additions and 25 deletions

View File

@@ -19,9 +19,18 @@ TimelineContainer {
onReplyClicked: ListView.view.goToEvent(eventID) onReplyClicked: ListView.view.goToEvent(eventID)
hoverComponent: hoverActions hoverComponent: hoverActions
innerObject: TextDelegate { innerObject: RichLabel {
isEmote: messageDelegate.isEmote isEmote: messageDelegate.isEmote
Layout.maximumWidth: messageDelegate.bubbleMaxWidth Layout.maximumWidth: messageDelegate.bubbleMaxWidth
onRequestOpenMessageContext: openMessageContext(model, parent.selectedText)
TapHandler {
acceptedButtons: Qt.RightButton
onTapped: openMessageContext(model, parent.selectedText)
}
TapHandler {
acceptedButtons: Qt.LeftButton
onLongPressed: openMessageContext(model, parent.selectedText)
}
} }
} }

View File

@@ -75,11 +75,10 @@ MouseArea {
Component { Component {
id: textComponent id: textComponent
TextDelegate { RichLabel {
id: replyText id: replyText
textMessage: reply.display textMessage: reply.display
textFormat: Text.RichText textFormat: Text.RichText
hasContextMenu: false
width: Math.min(implicitWidth, bubbleMaxWidth - Kirigami.Units.largeSpacing * 3) width: Math.min(implicitWidth, bubbleMaxWidth - Kirigami.Units.largeSpacing * 3)
x: Kirigami.Units.smallSpacing * 3 + replyAvatar.width x: Kirigami.Units.smallSpacing * 3 + replyAvatar.width
} }

View File

@@ -18,10 +18,6 @@ TextEdit {
property string textMessage: model.display property string textMessage: model.display
property bool spoilerRevealed: !hasSpoiler.test(textMessage) property bool spoilerRevealed: !hasSpoiler.test(textMessage)
property bool hasContextMenu: true
signal requestOpenMessageContext()
ListView.onReused: Qt.binding(() => !hasSpoiler.test(textMessage)) ListView.onReused: Qt.binding(() => !hasSpoiler.test(textMessage))
Layout.fillWidth: Config.compactLayout Layout.fillWidth: Config.compactLayout
@@ -77,16 +73,4 @@ a{
enabled: !parent.hoveredLink && !spoilerRevealed enabled: !parent.hoveredLink && !spoilerRevealed
onTapped: spoilerRevealed = true onTapped: spoilerRevealed = true
} }
TapHandler {
acceptedButtons: Qt.RightButton
onTapped: openMessageContext(model, parent.selectedText)
enabled: hasContextMenu
}
TapHandler {
acceptedButtons: Qt.LeftButton
onLongPressed: requestOpenMessageContext()
enabled: hasContextMenu
}
} }

View File

@@ -1,6 +1,6 @@
module NeoChat.Component.Timeline module NeoChat.Component.Timeline
RichLabel 1.0 RichLabel.qml
TimelineContainer 1.0 TimelineContainer.qml TimelineContainer 1.0 TimelineContainer.qml
TextDelegate 1.0 TextDelegate.qml
StateDelegate 1.0 StateDelegate.qml StateDelegate 1.0 StateDelegate.qml
SectionDelegate 1.0 SectionDelegate.qml SectionDelegate 1.0 SectionDelegate.qml
ImageDelegate 1.0 ImageDelegate.qml ImageDelegate 1.0 ImageDelegate.qml

View File

@@ -74,13 +74,15 @@ Loader {
QQC2.Menu { QQC2.Menu {
id: webshortcutmenu id: webshortcutmenu
title: i18n("Search for '%1'", webshortcutmodel.trunkatedSearchText) title: i18n("Search for '%1'", webshortcutmodel.trunkatedSearchText)
property bool isVisible: selectedText && selectedText.length > 0 && webshortcutmodel.enabled property bool isVisible: webshortcutmodel.enabled
Component.onCompleted: webshortcutmenu.parent.visible = isVisible Component.onCompleted: {
webshortcutmenu.parent.visible = isVisible
}
onIsVisibleChanged: webshortcutmenu.parent.visible = isVisible onIsVisibleChanged: webshortcutmenu.parent.visible = isVisible
Instantiator { Instantiator {
model: WebShortcutModel { model: WebShortcutModel {
id: webshortcutmodel id: webshortcutmodel
selectedText: loadRoot.selectedText selectedText: loadRoot.selectedText ? loadRoot.selectedText : loadRoot.message
onOpenUrl: RoomManager.visitNonMatrix(url) onOpenUrl: RoomManager.visitNonMatrix(url)
} }
delegate: QQC2.MenuItem { delegate: QQC2.MenuItem {

View File

@@ -33,7 +33,7 @@
<file>imports/NeoChat/Component/Timeline/qmldir</file> <file>imports/NeoChat/Component/Timeline/qmldir</file>
<file>imports/NeoChat/Component/Timeline/ReplyComponent.qml</file> <file>imports/NeoChat/Component/Timeline/ReplyComponent.qml</file>
<file>imports/NeoChat/Component/Timeline/StateDelegate.qml</file> <file>imports/NeoChat/Component/Timeline/StateDelegate.qml</file>
<file>imports/NeoChat/Component/Timeline/TextDelegate.qml</file> <file>imports/NeoChat/Component/Timeline/RichLabel.qml</file>
<file>imports/NeoChat/Component/Timeline/TimelineContainer.qml</file> <file>imports/NeoChat/Component/Timeline/TimelineContainer.qml</file>
<file>imports/NeoChat/Component/Timeline/SectionDelegate.qml</file> <file>imports/NeoChat/Component/Timeline/SectionDelegate.qml</file>
<file>imports/NeoChat/Component/Timeline/VideoDelegate.qml</file> <file>imports/NeoChat/Component/Timeline/VideoDelegate.qml</file>