Prepare for adding proxy before chat.model
This commit is contained in:
parent
78784babd1
commit
570d7b8b30
@ -91,7 +91,7 @@ Item {
|
|||||||
delegate: TextButton {
|
delegate: TextButton {
|
||||||
required property string modelData
|
required property string modelData
|
||||||
|
|
||||||
visible: chat.model ? chat.model.permissions.canSend(MtxEvent.Reaction) : false
|
visible: room ? room.permissions.canSend(MtxEvent.Reaction) : false
|
||||||
|
|
||||||
Layout.preferredHeight: fontMetrics.height
|
Layout.preferredHeight: fontMetrics.height
|
||||||
font.family: Settings.emojiFont
|
font.family: Settings.emojiFont
|
||||||
@ -116,14 +116,14 @@ Item {
|
|||||||
ToolTip.delay: Nheko.tooltipDelay
|
ToolTip.delay: Nheko.tooltipDelay
|
||||||
ToolTip.text: qsTr("Edit")
|
ToolTip.text: qsTr("Edit")
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (row.model.isEditable) chat.model.edit = row.model.eventId;
|
if (row.model.isEditable) room.edit = row.model.eventId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ImageButton {
|
ImageButton {
|
||||||
id: reactButton
|
id: reactButton
|
||||||
|
|
||||||
visible: chat.model ? chat.model.permissions.canSend(MtxEvent.Reaction) : false
|
visible: room ? room.permissions.canSend(MtxEvent.Reaction) : false
|
||||||
width: 16
|
width: 16
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
image: ":/icons/icons/ui/smile.svg"
|
image: ":/icons/icons/ui/smile.svg"
|
||||||
@ -140,27 +140,27 @@ Item {
|
|||||||
ImageButton {
|
ImageButton {
|
||||||
id: threadButton
|
id: threadButton
|
||||||
|
|
||||||
visible: chat.model ? chat.model.permissions.canSend(MtxEvent.TextMessage) : false
|
visible: room ? room.permissions.canSend(MtxEvent.TextMessage) : false
|
||||||
width: 16
|
width: 16
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
image: row.model.threadId ? ":/icons/icons/ui/thread.svg" : ":/icons/icons/ui/new-thread.svg"
|
image: (row.model && row.model.threadId) ? ":/icons/icons/ui/thread.svg" : ":/icons/icons/ui/new-thread.svg"
|
||||||
ToolTip.visible: hovered
|
ToolTip.visible: hovered
|
||||||
ToolTip.delay: Nheko.tooltipDelay
|
ToolTip.delay: Nheko.tooltipDelay
|
||||||
ToolTip.text: row.model.threadId ? qsTr("Reply in thread") : qsTr("New thread")
|
ToolTip.text: (row.model && row.model.threadId) ? qsTr("Reply in thread") : qsTr("New thread")
|
||||||
onClicked: chat.model.thread = (row.model.threadId || row.model.eventId)
|
onClicked: room.thread = (row.model.threadId || row.model.eventId)
|
||||||
}
|
}
|
||||||
|
|
||||||
ImageButton {
|
ImageButton {
|
||||||
id: replyButton
|
id: replyButton
|
||||||
|
|
||||||
visible: chat.model ? chat.model.permissions.canSend(MtxEvent.TextMessage) : false
|
visible: room ? room.permissions.canSend(MtxEvent.TextMessage) : false
|
||||||
width: 16
|
width: 16
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
image: ":/icons/icons/ui/reply.svg"
|
image: ":/icons/icons/ui/reply.svg"
|
||||||
ToolTip.visible: hovered
|
ToolTip.visible: hovered
|
||||||
ToolTip.delay: Nheko.tooltipDelay
|
ToolTip.delay: Nheko.tooltipDelay
|
||||||
ToolTip.text: qsTr("Reply")
|
ToolTip.text: qsTr("Reply")
|
||||||
onClicked: chat.model.reply = row.model.eventId
|
onClicked: room.reply = row.model.eventId
|
||||||
}
|
}
|
||||||
|
|
||||||
ImageButton {
|
ImageButton {
|
||||||
@ -205,37 +205,37 @@ Item {
|
|||||||
onActivated: {
|
onActivated: {
|
||||||
if(room.input.uploads.length > 0)
|
if(room.input.uploads.length > 0)
|
||||||
room.input.declineUploads();
|
room.input.declineUploads();
|
||||||
else if(chat.model.reply)
|
else if(room.reply)
|
||||||
chat.model.reply = undefined;
|
room.reply = undefined;
|
||||||
else if (chat.model.edit)
|
else if (room.edit)
|
||||||
chat.model.edit = undefined;
|
room.edit = undefined;
|
||||||
else
|
else
|
||||||
chat.model.thread = undefined
|
room.thread = undefined
|
||||||
TimelineManager.focusMessageInput();
|
TimelineManager.focusMessageInput();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Shortcut {
|
Shortcut {
|
||||||
sequence: "Alt+Up"
|
sequence: "Alt+Up"
|
||||||
onActivated: chat.model.reply = chat.model.indexToId(chat.model.reply ? chat.model.idToIndex(chat.model.reply) + 1 : 0)
|
onActivated: room.reply = chat.model.indexToId(room.reply ? chat.model.idToIndex(room.reply) + 1 : 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
Shortcut {
|
Shortcut {
|
||||||
sequence: "Alt+Down"
|
sequence: "Alt+Down"
|
||||||
onActivated: {
|
onActivated: {
|
||||||
var idx = chat.model.reply ? chat.model.idToIndex(chat.model.reply) - 1 : -1;
|
var idx = room.reply ? chat.model.idToIndex(room.reply) - 1 : -1;
|
||||||
chat.model.reply = idx >= 0 ? chat.model.indexToId(idx) : null;
|
room.reply = idx >= 0 ? chat.model.indexToId(idx) : null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Shortcut {
|
Shortcut {
|
||||||
sequence: "Alt+F"
|
sequence: "Alt+F"
|
||||||
onActivated: {
|
onActivated: {
|
||||||
if (chat.model.reply) {
|
if (room.reply) {
|
||||||
var forwardMess = forwardCompleterComponent.createObject(timelineRoot);
|
var forwardMess = forwardCompleterComponent.createObject(timelineRoot);
|
||||||
forwardMess.setMessageEventId(chat.model.reply);
|
forwardMess.setMessageEventId(room.reply);
|
||||||
forwardMess.open();
|
forwardMess.open();
|
||||||
chat.model.reply = null;
|
room.reply = null;
|
||||||
timelineRoot.destroyOnClose(forwardMess);
|
timelineRoot.destroyOnClose(forwardMess);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -244,7 +244,7 @@ Item {
|
|||||||
Shortcut {
|
Shortcut {
|
||||||
sequence: "Ctrl+E"
|
sequence: "Ctrl+E"
|
||||||
onActivated: {
|
onActivated: {
|
||||||
chat.model.edit = chat.model.reply;
|
room.edit = room.reply;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -255,8 +255,8 @@ Item {
|
|||||||
|
|
||||||
// force current read index to update
|
// force current read index to update
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
if (chat.model)
|
if (room)
|
||||||
chat.model.setCurrentIndex(chat.model.currentIndex);
|
room.setCurrentIndex(room.currentIndex);
|
||||||
|
|
||||||
}
|
}
|
||||||
interval: 1000
|
interval: 1000
|
||||||
@ -314,14 +314,14 @@ Item {
|
|||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
function onRoomAvatarUrlChanged() {
|
function onRoomAvatarUrlChanged() {
|
||||||
messageUserAvatar.url = chat.model.avatarUrl(userId).replace("mxc://", "image://MxcImage/");
|
messageUserAvatar.url = room.avatarUrl(userId).replace("mxc://", "image://MxcImage/");
|
||||||
}
|
}
|
||||||
|
|
||||||
function onScrollToIndex(index) {
|
function onScrollToIndex(index) {
|
||||||
chat.positionViewAtIndex(index, ListView.Center);
|
chat.positionViewAtIndex(index, ListView.Center);
|
||||||
}
|
}
|
||||||
|
|
||||||
target: chat.model
|
target: room
|
||||||
}
|
}
|
||||||
property int remainingWidth: chat.delegateMaxWidth - spacing - messageUserAvatar.width
|
property int remainingWidth: chat.delegateMaxWidth - spacing - messageUserAvatar.width
|
||||||
AbstractButton {
|
AbstractButton {
|
||||||
@ -335,7 +335,7 @@ Item {
|
|||||||
ToolTip.visible: hovered
|
ToolTip.visible: hovered
|
||||||
ToolTip.delay: Nheko.tooltipDelay
|
ToolTip.delay: Nheko.tooltipDelay
|
||||||
ToolTip.text: userId
|
ToolTip.text: userId
|
||||||
onClicked: chat.model.openUserProfile(userId)
|
onClicked: room.openUserProfile(userId)
|
||||||
leftInset: 0
|
leftInset: 0
|
||||||
rightInset: 0
|
rightInset: 0
|
||||||
leftPadding: 0
|
leftPadding: 0
|
||||||
@ -412,7 +412,7 @@ Item {
|
|||||||
required property string day
|
required property string day
|
||||||
required property string previousMessageDay
|
required property string previousMessageDay
|
||||||
required property string userName
|
required property string userName
|
||||||
property bool scrolledToThis: eventId === chat.model.scrollTarget && (y + height > chat.y + chat.contentY && y < chat.y + chat.height + chat.contentY)
|
property bool scrolledToThis: eventId === room.scrollTarget && (y + height > chat.y + chat.contentY && y < chat.y + chat.height + chat.contentY)
|
||||||
|
|
||||||
anchors.horizontalCenter: parent ? parent.horizontalCenter : undefined
|
anchors.horizontalCenter: parent ? parent.horizontalCenter : undefined
|
||||||
width: chat.delegateMaxWidth
|
width: chat.delegateMaxWidth
|
||||||
@ -523,7 +523,7 @@ Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ScriptAction {
|
ScriptAction {
|
||||||
script: chat.model.eventShown()
|
script: room.eventShown()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -548,7 +548,7 @@ Item {
|
|||||||
footer: Item {
|
footer: Item {
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
anchors.margins: Nheko.paddingLarge
|
anchors.margins: Nheko.paddingLarge
|
||||||
visible: chat.model && chat.model.paginationInProgress
|
visible: room && room.paginationInProgress
|
||||||
// hacky, but works
|
// hacky, but works
|
||||||
height: loadingSpinner.height + 2 * Nheko.paddingLarge
|
height: loadingSpinner.height + 2 * Nheko.paddingLarge
|
||||||
|
|
||||||
@ -557,7 +557,7 @@ Item {
|
|||||||
|
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
anchors.margins: Nheko.paddingLarge
|
anchors.margins: Nheko.paddingLarge
|
||||||
running: chat.model && chat.model.paginationInProgress
|
running: room && room.paginationInProgress
|
||||||
foreground: Nheko.colors.mid
|
foreground: Nheko.colors.mid
|
||||||
z: 3
|
z: 3
|
||||||
}
|
}
|
||||||
@ -772,7 +772,7 @@ Item {
|
|||||||
visible: true
|
visible: true
|
||||||
enabled: visible
|
enabled: visible
|
||||||
text: qsTr("&Go to quoted message")
|
text: qsTr("&Go to quoted message")
|
||||||
onTriggered: chat.model.showEvent(replyContextMenu.eventId)
|
onTriggered: room.showEvent(replyContextMenu.eventId)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,7 @@ Rectangle {
|
|||||||
anchors.margins: 8
|
anchors.margins: 8
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
buttonTextColor: TimelineManager.userColor(room.thread, Nheko.colors.base)
|
buttonTextColor: room ? TimelineManager.userColor(room.thread, Nheko.colors.base) : undefined
|
||||||
image: ":/icons/icons/ui/dismiss_thread.svg"
|
image: ":/icons/icons/ui/dismiss_thread.svg"
|
||||||
width: 22
|
width: 22
|
||||||
height: 22
|
height: 22
|
||||||
|
@ -67,7 +67,7 @@ AbstractButton {
|
|||||||
|
|
||||||
|
|
||||||
onPressAndHold: messageContextMenu.show(eventId, threadId, type, isSender, isEncrypted, isEditable, contentItem.child.hoveredLink, contentItem.child.copyText)
|
onPressAndHold: messageContextMenu.show(eventId, threadId, type, isSender, isEncrypted, isEditable, contentItem.child.hoveredLink, contentItem.child.copyText)
|
||||||
onDoubleClicked: chat.model.reply = eventId
|
onDoubleClicked: room.reply = eventId
|
||||||
|
|
||||||
DragHandler {
|
DragHandler {
|
||||||
id: draghandler
|
id: draghandler
|
||||||
@ -76,7 +76,7 @@ AbstractButton {
|
|||||||
xAxis.minimum: -100
|
xAxis.minimum: -100
|
||||||
onActiveChanged: {
|
onActiveChanged: {
|
||||||
if(!active && (x < -70 || x > 70))
|
if(!active && (x < -70 || x > 70))
|
||||||
chat.model.reply = eventId
|
room.reply = eventId
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
states: State {
|
states: State {
|
||||||
@ -245,13 +245,13 @@ AbstractButton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Image {
|
Image {
|
||||||
visible: isEdited || eventId == chat.model.edit
|
visible: isEdited || eventId == room.edit
|
||||||
Layout.alignment: Qt.AlignRight | Qt.AlignTop
|
Layout.alignment: Qt.AlignRight | Qt.AlignTop
|
||||||
height: parent.iconSize
|
height: parent.iconSize
|
||||||
width: parent.iconSize
|
width: parent.iconSize
|
||||||
sourceSize.width: parent.iconSize * Screen.devicePixelRatio
|
sourceSize.width: parent.iconSize * Screen.devicePixelRatio
|
||||||
sourceSize.height: parent.iconSize * Screen.devicePixelRatio
|
sourceSize.height: parent.iconSize * Screen.devicePixelRatio
|
||||||
source: "image://colorimage/:/icons/icons/ui/edit.svg?" + ((eventId == chat.model.edit) ? Nheko.colors.highlight : Nheko.colors.buttonText)
|
source: "image://colorimage/:/icons/icons/ui/edit.svg?" + ((eventId == room.edit) ? Nheko.colors.highlight : Nheko.colors.buttonText)
|
||||||
ToolTip.visible: editHovered.hovered
|
ToolTip.visible: editHovered.hovered
|
||||||
ToolTip.delay: Nheko.tooltipDelay
|
ToolTip.delay: Nheko.tooltipDelay
|
||||||
ToolTip.text: qsTr("Edited")
|
ToolTip.text: qsTr("Edited")
|
||||||
@ -318,7 +318,7 @@ AbstractButton {
|
|||||||
}
|
}
|
||||||
color: Nheko.colors.highlight
|
color: Nheko.colors.highlight
|
||||||
width: row.maxWidth
|
width: row.maxWidth
|
||||||
visible: (r.index > 0 && (chat.model.fullyReadEventId == r.eventId))
|
visible: (r.index > 0 && (room.fullyReadEventId == r.eventId))
|
||||||
height: visible ? 3 : 0
|
height: visible ? 3 : 0
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user