summary refs log tree commit diff
path: root/resources/qml/delegates
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2019-10-08 20:55:09 +0200
committerNicolas Werner <nicolas.werner@hotmail.de>2019-11-23 20:06:15 +0100
commitb9076c5c4d1beb7ff4cb4a2db8e6eb4e7f5b0dcd (patch)
tree8634fb6e105b083aef4339ad96f8f3ada2deb660 /resources/qml/delegates
parentfix: add missing quickcontrols2 dep (diff)
downloadnheko-b9076c5c4d1beb7ff4cb4a2db8e6eb4e7f5b0dcd.tar.xz
Try out DelegateChooser
requires Qt5.12+
Diffstat (limited to 'resources/qml/delegates')
-rw-r--r--resources/qml/delegates/FileMessage.qml6
-rw-r--r--resources/qml/delegates/ImageMessage.qml8
-rw-r--r--resources/qml/delegates/NoticeMessage.qml2
-rw-r--r--resources/qml/delegates/PlayableMediaMessage.qml10
-rw-r--r--resources/qml/delegates/TextMessage.qml2
-rw-r--r--resources/qml/delegates/TimelineRow.qml139
-rw-r--r--resources/qml/delegates/placeholder.qml2
7 files changed, 154 insertions, 15 deletions
diff --git a/resources/qml/delegates/FileMessage.qml b/resources/qml/delegates/FileMessage.qml

index 6dd552ab..ad2c695d 100644 --- a/resources/qml/delegates/FileMessage.qml +++ b/resources/qml/delegates/FileMessage.qml
@@ -31,7 +31,7 @@ Rectangle { } MouseArea { anchors.fill: parent - onClicked: timelineManager.saveMedia(eventData.url, eventData.filename, eventData.mimetype, eventData.type) + onClicked: timelineManager.saveMedia(model.url, model.filename, model.mimetype, model.type) cursorShape: Qt.PointingHandCursor } } @@ -40,14 +40,14 @@ Rectangle { Text { Layout.fillWidth: true - text: eventData.body + text: model.body textFormat: Text.PlainText elide: Text.ElideRight color: colors.text } Text { Layout.fillWidth: true - text: eventData.filesize + text: model.filesize textFormat: Text.PlainText elide: Text.ElideRight color: colors.text diff --git a/resources/qml/delegates/ImageMessage.qml b/resources/qml/delegates/ImageMessage.qml
index 2ed41a17..70d2debe 100644 --- a/resources/qml/delegates/ImageMessage.qml +++ b/resources/qml/delegates/ImageMessage.qml
@@ -4,20 +4,20 @@ import com.github.nheko 1.0 Item { width: 300 - height: 300 * eventData.proportionalHeight + height: 300 * model.proportionalHeight Image { id: img anchors.fill: parent - source: eventData.url.replace("mxc://", "image://MxcImage/") + source: model.url.replace("mxc://", "image://MxcImage/") asynchronous: true fillMode: Image.PreserveAspectFit MouseArea { - enabled: eventData.type == MtxEvent.ImageMessage + enabled: model.type == MtxEvent.ImageMessage anchors.fill: parent - onClicked: timelineManager.openImageOverlay(eventData.url, eventData.filename, eventData.mimetype, eventData.type) + onClicked: timelineManager.openImageOverlay(model.url, model.filename, model.mimetype, model.type) } } } diff --git a/resources/qml/delegates/NoticeMessage.qml b/resources/qml/delegates/NoticeMessage.qml
index 5f04d235..b916d65a 100644 --- a/resources/qml/delegates/NoticeMessage.qml +++ b/resources/qml/delegates/NoticeMessage.qml
@@ -1,7 +1,7 @@ import QtQuick 2.5 TextEdit { - text: eventData.formattedBody + text: model.formattedBody textFormat: TextEdit.RichText readOnly: true wrapMode: Text.Wrap diff --git a/resources/qml/delegates/PlayableMediaMessage.qml b/resources/qml/delegates/PlayableMediaMessage.qml
index 2385c750..c716d21d 100644 --- a/resources/qml/delegates/PlayableMediaMessage.qml +++ b/resources/qml/delegates/PlayableMediaMessage.qml
@@ -17,7 +17,7 @@ Rectangle { anchors.centerIn: parent VideoOutput { - visible: eventData.type == MtxEvent.VideoMessage + visible: model.type == MtxEvent.VideoMessage Layout.maximumHeight: 300 Layout.minimumHeight: 300 Layout.maximumWidth: 500 @@ -85,7 +85,7 @@ Rectangle { anchors.fill: parent onClicked: { switch (button.state) { - case "": timelineManager.cacheMedia(eventData.url, eventData.mimetype); break; + case "": timelineManager.cacheMedia(model.url, model.mimetype); break; case "stopped": media.play(); console.log("play"); button.state = "playing" @@ -107,7 +107,7 @@ Rectangle { Connections { target: timelineManager onMediaCached: { - if (mxcUrl == eventData.url) { + if (mxcUrl == model.url) { media.source = "file://" + cacheUrl button.state = "stopped" console.log("media loaded: " + mxcUrl + " at " + cacheUrl) @@ -132,14 +132,14 @@ Rectangle { Text { Layout.fillWidth: true - text: eventData.body + text: model.body textFormat: Text.PlainText elide: Text.ElideRight color: colors.text } Text { Layout.fillWidth: true - text: eventData.filesize + text: model.filesize textFormat: Text.PlainText elide: Text.ElideRight color: colors.text diff --git a/resources/qml/delegates/TextMessage.qml b/resources/qml/delegates/TextMessage.qml
index f7dba618..3a3492ed 100644 --- a/resources/qml/delegates/TextMessage.qml +++ b/resources/qml/delegates/TextMessage.qml
@@ -1,7 +1,7 @@ import QtQuick 2.5 TextEdit { - text: eventData.formattedBody + text: model.formattedBody textFormat: TextEdit.RichText readOnly: true wrapMode: Text.Wrap diff --git a/resources/qml/delegates/TimelineRow.qml b/resources/qml/delegates/TimelineRow.qml new file mode 100644
index 00000000..28a2ec8c --- /dev/null +++ b/resources/qml/delegates/TimelineRow.qml
@@ -0,0 +1,139 @@ +import QtQuick 2.6 +import QtQuick.Controls 2.1 +import QtQuick.Layouts 1.2 +import QtGraphicalEffects 1.0 +import QtQuick.Window 2.2 + +import com.github.nheko 1.0 + +import ".." + +RowLayout { + property var view: undefined + default property alias data: contentItem.data + + height: kid.height // TODO: fix this, we shouldn't need to give the child of contentItem this id! + anchors.leftMargin: avatarSize + 4 + anchors.left: parent.left + anchors.right: parent.right + anchors.rightMargin: scrollbar.width + + function isFullyVisible() { + return (y - view.contentY - 1) + height < view.height + } + function getIndex() { + return index; + } + + Item { + id: contentItem + Layout.fillWidth: true + Layout.alignment: Qt.AlignTop + } + + StatusIndicator { + state: model.state + Layout.alignment: Qt.AlignRight | Qt.AlignTop + Layout.preferredHeight: 16 + } + + EncryptionIndicator { + visible: model.isEncrypted + Layout.alignment: Qt.AlignRight | Qt.AlignTop + Layout.preferredHeight: 16 + } + + Button { + Layout.alignment: Qt.AlignRight | Qt.AlignTop + id: replyButton + flat: true + Layout.preferredHeight: 16 + ToolTip.visible: hovered + ToolTip.text: qsTr("Reply") + + // disable background, because we don't want a border on hover + background: Item { + } + + Image { + id: replyButtonImg + // Workaround, can't get icon.source working for now... + anchors.fill: parent + source: "qrc:/icons/icons/ui/mail-reply.png" + } + ColorOverlay { + anchors.fill: replyButtonImg + source: replyButtonImg + color: replyButton.hovered ? colors.highlight : colors.buttonText + } + + onClicked: view.model.replyAction(model.id) + } + Button { + Layout.alignment: Qt.AlignRight | Qt.AlignTop + id: optionsButton + flat: true + Layout.preferredHeight: 16 + ToolTip.visible: hovered + ToolTip.text: qsTr("Options") + + // disable background, because we don't want a border on hover + background: Item { + } + + Image { + id: optionsButtonImg + // Workaround, can't get icon.source working for now... + anchors.fill: parent + source: "qrc:/icons/icons/ui/vertical-ellipsis.png" + } + ColorOverlay { + anchors.fill: optionsButtonImg + source: optionsButtonImg + color: optionsButton.hovered ? colors.highlight : colors.buttonText + } + + onClicked: contextMenu.open() + + Menu { + y: optionsButton.height + id: contextMenu + + MenuItem { + text: qsTr("Read receipts") + onTriggered: view.model.readReceiptsAction(model.id) + } + MenuItem { + text: qsTr("Mark as read") + } + MenuItem { + text: qsTr("View raw message") + onTriggered: view.model.viewRawMessage(model.id) + } + MenuItem { + text: qsTr("Redact message") + onTriggered: view.model.redactEvent(model.id) + } + MenuItem { + visible: model.type == MtxEvent.ImageMessage || model.type == MtxEvent.VideoMessage || model.type == MtxEvent.AudioMessage || model.type == MtxEvent.FileMessage || model.type == MtxEvent.Sticker + text: qsTr("Save as") + onTriggered: timelineManager.saveMedia(model.url, model.filename, model.mimetype, model.type) + } + } + } + + Text { + Layout.alignment: Qt.AlignRight | Qt.AlignTop + text: model.timestamp.toLocaleTimeString("HH:mm") + color: inactiveColors.text + + ToolTip.visible: ma.containsMouse + ToolTip.text: Qt.formatDateTime(model.timestamp, Qt.DefaultLocaleLongDate) + + MouseArea{ + id: ma + anchors.fill: parent + hoverEnabled: true + } + } +} diff --git a/resources/qml/delegates/placeholder.qml b/resources/qml/delegates/placeholder.qml
index e64bc368..462af2db 100644 --- a/resources/qml/delegates/placeholder.qml +++ b/resources/qml/delegates/placeholder.qml
@@ -2,7 +2,7 @@ import QtQuick 2.5 import QtQuick.Controls 2.1 Label { - text: qsTr("unimplemented event: ") + eventData.type + text: qsTr("unimplemented event: ") + model.type textFormat: Text.PlainText wrapMode: Text.Wrap width: parent.width