From 2d2d35fcf502bd57e0f09247097bc12d9d0975f7 Mon Sep 17 00:00:00 2001 From: Black Hat Date: Wed, 12 Sep 2018 08:27:34 +0800 Subject: [PATCH] Simplify menu code and tweak UI. --- qml/MatriqueSettings.qml | 2 +- qml/Setting.qml | 9 +++++---- qml/component/GenericBubble.qml | 6 +----- qml/form/RoomForm.qml | 2 +- qml/form/RoomListForm.qml | 11 +++++++---- qml/menu/MessageContextMenu.qml | 18 +++++++----------- qml/menu/RoomContextMenu.qml | 15 ++++++++------- 7 files changed, 30 insertions(+), 33 deletions(-) diff --git a/qml/MatriqueSettings.qml b/qml/MatriqueSettings.qml index 1c8ead1..60d4509 100644 --- a/qml/MatriqueSettings.qml +++ b/qml/MatriqueSettings.qml @@ -4,7 +4,7 @@ import Qt.labs.settings 1.0 Settings { property bool lazyLoad: true - property bool richText + property bool richText: true property bool pressAndHold property bool rearrangeByActivity diff --git a/qml/Setting.qml b/qml/Setting.qml index 81787e4..9a76d99 100644 --- a/qml/Setting.qml +++ b/qml/Setting.qml @@ -35,7 +35,7 @@ Page { delegate: Column { property bool expanded: false - spacing: 16 + spacing: 8 SwipeDelegate { width: accountSettingsListView.width @@ -99,15 +99,18 @@ Page { ListView { Layout.fillWidth: true - Layout.preferredHeight: 32 + Layout.preferredHeight: 24 orientation: ListView.Horizontal + spacing: 8 + model: ["#498882", "#42a5f5", "#5c6bc0", "#7e57c2", "#ab47bc", "#ff7043"] delegate: Rectangle { width: parent.height height: parent.height + radius: width / 2 color: modelData @@ -122,8 +125,6 @@ Page { RowLayout { Layout.fillWidth: true - spacing: 16 - Label { text: "Homeserver:" } TextField { Layout.fillWidth: true diff --git a/qml/component/GenericBubble.qml b/qml/component/GenericBubble.qml index 917108a..5d8e3b9 100644 --- a/qml/component/GenericBubble.qml +++ b/qml/component/GenericBubble.qml @@ -17,11 +17,7 @@ Control { onSecondaryClicked: { messageContextMenu.row = messageRow - messageContextMenu.plainText = plainText - messageContextMenu.toolTip = toolTip - messageContextMenu.eventId = eventId - messageContextMenu.eventType = eventType - messageContextMenu.canRedact = sentByMe + messageContextMenu.model = model messageContextMenu.popup() } } diff --git a/qml/form/RoomForm.qml b/qml/form/RoomForm.qml index 9b48cc8..fdd0094 100644 --- a/qml/form/RoomForm.qml +++ b/qml/form/RoomForm.qml @@ -89,7 +89,7 @@ Item { Layout.fillWidth: true Layout.fillHeight: true - text: currentRoom ? currentRoom.topic : "" + text: currentRoom ? (currentRoom.topic).replace(/(\r\n\t|\n|\r\t)/gm,"") : "" color: "white" elide: Text.ElideRight wrapMode: Text.NoWrap diff --git a/qml/form/RoomListForm.qml b/qml/form/RoomListForm.qml index 98f209f..58d9c91 100644 --- a/qml/form/RoomListForm.qml +++ b/qml/form/RoomListForm.qml @@ -116,7 +116,7 @@ Item { hoverEnabled: MSettings.miniMode onSecondaryClicked: { - roomContextMenu.room = currentRoom + roomContextMenu.model = model roomContextMenu.popup() } onPrimaryClicked: { @@ -141,11 +141,14 @@ Item { } Rectangle { - width: 4 + width: unreadCount > 0 || highlighted ? 4 : 0 height: parent.height color: Material.accent - visible: unreadCount > 0 || highlighted + + Behavior on width { + PropertyAnimation { easing.type: Easing.InOutCubic; duration: 200 } + } } RowLayout { @@ -187,7 +190,7 @@ Item { Layout.fillWidth: true Layout.fillHeight: true - text: (lastEvent == "" ? topic : lastEvent).replace(/(\r\n\t|\n|\r\t)/gm,""); + text: (lastEvent == "" ? topic : lastEvent).replace(/(\r\n\t|\n|\r\t)/gm,"") elide: Text.ElideRight wrapMode: Text.NoWrap } diff --git a/qml/menu/MessageContextMenu.qml b/qml/menu/MessageContextMenu.qml index a8c93d3..a5354e6 100644 --- a/qml/menu/MessageContextMenu.qml +++ b/qml/menu/MessageContextMenu.qml @@ -2,27 +2,23 @@ import QtQuick 2.9 import QtQuick.Controls 2.2 Menu { - property var row - property bool canRedact - property string eventType - property string plainText - property string toolTip - property string eventId + property var row: null + property var model: null - readonly property bool isFile: eventType === "video" || eventType === "audio" || eventType === "file" || eventType === "image" + readonly property bool isFile: model && (model.eventType === "video" || model.eventType === "audio" || model.eventType === "file" || model.eventType === "image") id: messageContextMenu MenuItem { text: "Copy" - onTriggered: matriqueController.copyToClipboard(plainText) + onTriggered: matriqueController.copyToClipboard(model.plainText) } MenuItem { text: "View Source" onTriggered: { - sourceDialog.sourceText = toolTip + sourceDialog.sourceText = model.toolTip sourceDialog.open() } } @@ -41,10 +37,10 @@ Menu { onTriggered: row.saveFileAs() } MenuItem { - visible: canRedact + visible: model && model.author === currentRoom.localUser height: visible ? undefined : 0 text: "Redact" - onTriggered: currentRoom.redactEvent(eventId) + onTriggered: currentRoom.redactEvent(model.eventId) } } diff --git a/qml/menu/RoomContextMenu.qml b/qml/menu/RoomContextMenu.qml index ee81ca2..451a990 100644 --- a/qml/menu/RoomContextMenu.qml +++ b/qml/menu/RoomContextMenu.qml @@ -1,34 +1,35 @@ import QtQuick 2.9 import QtQuick.Controls 2.2 +import Matrique 0.1 Menu { - property var room: null + property var model: null id: roomListMenu MenuItem { text: "Favourite" checkable: true - checked: room && room.isFavourite + checked: model && model.category === RoomType.Favorite - onTriggered: room.isFavourite ? room.removeTag("m.favourite") : room.addTag("m.favourite", "1") + onTriggered: model.category === RoomType.Favorite ? model.currentRoom.removeTag("m.favourite") : model.currentRoom.addTag("m.favourite", "1") } MenuItem { text: "Deprioritize" checkable: true - checked: room && room.isLowPriority + checked: model && model.category === RoomType.Deprioritized - onTriggered: room.isLowPriority ? room.removeTag("m.lowpriority") : room.addTag("m.lowpriority", "1") + onTriggered: model.category === RoomType.Deprioritized ? model.currentRoom.removeTag("m.lowpriority") : model.currentRoom.addTag("m.lowpriority", "1") } MenuSeparator {} MenuItem { text: "Mark as Read" - onTriggered: room.markAllMessagesAsRead() + onTriggered: model.currentRoom.markAllMessagesAsRead() } MenuItem { text: "Leave Room" - onTriggered: room.forget() + onTriggered: model.currentRoom.forget() } }