summary refs log tree commit diff
path: root/resources/qml/delegates
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2019-10-27 22:01:40 +0100
committerNicolas Werner <nicolas.werner@hotmail.de>2019-11-23 20:06:15 +0100
commit2055c75f8ba710e8950a55aa3c41a9cec9f26ad7 (patch)
tree173665c5059b4c878b8c4dd451fd632275d96f36 /resources/qml/delegates
parentRemove unused Qt Module (diff)
downloadnheko-2055c75f8ba710e8950a55aa3c41a9cec9f26ad7.tar.xz
Organize qml files a bit
Diffstat (limited to 'resources/qml/delegates')
-rw-r--r--resources/qml/delegates/FileMessage.qml2
-rw-r--r--resources/qml/delegates/ImageMessage.qml2
-rw-r--r--resources/qml/delegates/MessageDelegate.qml50
-rw-r--r--resources/qml/delegates/NoticeMessage.qml2
-rw-r--r--resources/qml/delegates/Placeholder.qml2
-rw-r--r--resources/qml/delegates/PlayableMediaMessage.qml2
-rw-r--r--resources/qml/delegates/TextMessage.qml2
-rw-r--r--resources/qml/delegates/TimelineRow.qml151
8 files changed, 56 insertions, 157 deletions
diff --git a/resources/qml/delegates/FileMessage.qml b/resources/qml/delegates/FileMessage.qml
index ad2c695d..f4cf3f15 100644
--- a/resources/qml/delegates/FileMessage.qml
+++ b/resources/qml/delegates/FileMessage.qml
@@ -5,7 +5,7 @@ Rectangle {
 	radius: 10
 	color: colors.dark
 	height: row.height + 24
-	width: parent.width
+	width: parent ? parent.width : undefined
 
 	RowLayout {
 		id: row
diff --git a/resources/qml/delegates/ImageMessage.qml b/resources/qml/delegates/ImageMessage.qml
index f1e95e3d..802ef721 100644
--- a/resources/qml/delegates/ImageMessage.qml
+++ b/resources/qml/delegates/ImageMessage.qml
@@ -3,7 +3,7 @@ import QtQuick 2.6
 import com.github.nheko 1.0
 
 Item {
-	width: Math.min(parent.width, model.width)
+	width: Math.min(parent ? parent.width : undefined, model.width)
 	height: width * model.proportionalHeight
 
 	Image {
diff --git a/resources/qml/delegates/MessageDelegate.qml b/resources/qml/delegates/MessageDelegate.qml
new file mode 100644
index 00000000..3d342a02
--- /dev/null
+++ b/resources/qml/delegates/MessageDelegate.qml
@@ -0,0 +1,50 @@
+import QtQuick 2.6
+import Qt.labs.qmlmodels 1.0
+import com.github.nheko 1.0
+
+DelegateChooser {
+	//role: "type" //< not supported in our custom implementation, have to use roleValue
+	roleValue: model.type
+
+	width: parent.width
+
+	DelegateChoice {
+		roleValue: MtxEvent.TextMessage
+		TextMessage {}
+	}
+	DelegateChoice {
+		roleValue: MtxEvent.NoticeMessage
+		NoticeMessage {}
+	}
+	DelegateChoice {
+		roleValue: MtxEvent.EmoteMessage
+		TextMessage {}
+	}
+	DelegateChoice {
+		roleValue: MtxEvent.ImageMessage
+		ImageMessage {}
+	}
+	DelegateChoice {
+		roleValue: MtxEvent.Sticker
+		ImageMessage {}
+	}
+	DelegateChoice {
+		roleValue: MtxEvent.FileMessage
+		FileMessage {}
+	}
+	DelegateChoice {
+		roleValue: MtxEvent.VideoMessage
+		PlayableMediaMessage {}
+	}
+	DelegateChoice {
+		roleValue: MtxEvent.AudioMessage
+		PlayableMediaMessage {}
+	}
+	DelegateChoice {
+		roleValue: MtxEvent.Redacted
+		Redacted {}
+	}
+	DelegateChoice {
+		Placeholder {}
+	}
+}
diff --git a/resources/qml/delegates/NoticeMessage.qml b/resources/qml/delegates/NoticeMessage.qml
index b916d65a..59e051be 100644
--- a/resources/qml/delegates/NoticeMessage.qml
+++ b/resources/qml/delegates/NoticeMessage.qml
@@ -5,7 +5,7 @@ TextEdit {
 	textFormat: TextEdit.RichText
 	readOnly: true
 	wrapMode: Text.Wrap
-	width: parent.width
+	width: parent ? parent.width : undefined
 	selectByMouse: true
 	font.italic: true
 	color: inactiveColors.text
diff --git a/resources/qml/delegates/Placeholder.qml b/resources/qml/delegates/Placeholder.qml
index 462af2db..171bf18d 100644
--- a/resources/qml/delegates/Placeholder.qml
+++ b/resources/qml/delegates/Placeholder.qml
@@ -5,6 +5,6 @@ Label {
 	text: qsTr("unimplemented event: ") + model.type
 	textFormat: Text.PlainText
 	wrapMode: Text.Wrap
-	width: parent.width
+	width: parent ? parent.width : undefined
 	color: inactiveColors.text
 }
diff --git a/resources/qml/delegates/PlayableMediaMessage.qml b/resources/qml/delegates/PlayableMediaMessage.qml
index 3a518617..68b09f7b 100644
--- a/resources/qml/delegates/PlayableMediaMessage.qml
+++ b/resources/qml/delegates/PlayableMediaMessage.qml
@@ -10,7 +10,7 @@ Rectangle {
 	radius: 10
 	color: colors.dark
 	height: content.height + 24
-	width: parent.width
+	width: parent ? parent.width : undefined
 
 	Column { 
 		id: content
diff --git a/resources/qml/delegates/TextMessage.qml b/resources/qml/delegates/TextMessage.qml
index 3a3492ed..713be868 100644
--- a/resources/qml/delegates/TextMessage.qml
+++ b/resources/qml/delegates/TextMessage.qml
@@ -5,7 +5,7 @@ TextEdit {
 	textFormat: TextEdit.RichText
 	readOnly: true
 	wrapMode: Text.Wrap
-	width: parent.width
+	width: parent ? parent.width : undefined
 	selectByMouse: true
 	color: colors.text
 }
diff --git a/resources/qml/delegates/TimelineRow.qml b/resources/qml/delegates/TimelineRow.qml
deleted file mode 100644
index 3019deb1..00000000
--- a/resources/qml/delegates/TimelineRow.qml
+++ /dev/null
@@ -1,151 +0,0 @@
-import QtQuick 2.6
-import QtQuick.Controls 2.3
-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: replyButton.hovered
-			text: qsTr("Reply")
-			palette: colors
-		}
-
-		// 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: optionsButton.hovered
-			text: qsTr("Options")
-			palette: colors
-		}
-
-		// 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
-			palette: colors
-
-			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
-
-		MouseArea{
-			id: ma
-			anchors.fill: parent
-			hoverEnabled: true
-		}
-
-		ToolTip {
-			visible: ma.containsMouse
-			text: Qt.formatDateTime(model.timestamp, Qt.DefaultLocaleLongDate)
-			palette: colors
-		}
-	}
-}