Simplify menu code and tweak UI.

This commit is contained in:
Black Hat 2018-09-12 08:27:34 +08:00
parent ebe69fd4c0
commit 2d2d35fcf5
7 changed files with 30 additions and 33 deletions

View File

@ -4,7 +4,7 @@ import Qt.labs.settings 1.0
Settings { Settings {
property bool lazyLoad: true property bool lazyLoad: true
property bool richText property bool richText: true
property bool pressAndHold property bool pressAndHold
property bool rearrangeByActivity property bool rearrangeByActivity

View File

@ -35,7 +35,7 @@ Page {
delegate: Column { delegate: Column {
property bool expanded: false property bool expanded: false
spacing: 16 spacing: 8
SwipeDelegate { SwipeDelegate {
width: accountSettingsListView.width width: accountSettingsListView.width
@ -99,15 +99,18 @@ Page {
ListView { ListView {
Layout.fillWidth: true Layout.fillWidth: true
Layout.preferredHeight: 32 Layout.preferredHeight: 24
orientation: ListView.Horizontal orientation: ListView.Horizontal
spacing: 8
model: ["#498882", "#42a5f5", "#5c6bc0", "#7e57c2", "#ab47bc", "#ff7043"] model: ["#498882", "#42a5f5", "#5c6bc0", "#7e57c2", "#ab47bc", "#ff7043"]
delegate: Rectangle { delegate: Rectangle {
width: parent.height width: parent.height
height: parent.height height: parent.height
radius: width / 2
color: modelData color: modelData
@ -122,8 +125,6 @@ Page {
RowLayout { RowLayout {
Layout.fillWidth: true Layout.fillWidth: true
spacing: 16
Label { text: "Homeserver:" } Label { text: "Homeserver:" }
TextField { TextField {
Layout.fillWidth: true Layout.fillWidth: true

View File

@ -17,11 +17,7 @@ Control {
onSecondaryClicked: { onSecondaryClicked: {
messageContextMenu.row = messageRow messageContextMenu.row = messageRow
messageContextMenu.plainText = plainText messageContextMenu.model = model
messageContextMenu.toolTip = toolTip
messageContextMenu.eventId = eventId
messageContextMenu.eventType = eventType
messageContextMenu.canRedact = sentByMe
messageContextMenu.popup() messageContextMenu.popup()
} }
} }

View File

@ -89,7 +89,7 @@ Item {
Layout.fillWidth: true Layout.fillWidth: true
Layout.fillHeight: true Layout.fillHeight: true
text: currentRoom ? currentRoom.topic : "" text: currentRoom ? (currentRoom.topic).replace(/(\r\n\t|\n|\r\t)/gm,"") : ""
color: "white" color: "white"
elide: Text.ElideRight elide: Text.ElideRight
wrapMode: Text.NoWrap wrapMode: Text.NoWrap

View File

@ -116,7 +116,7 @@ Item {
hoverEnabled: MSettings.miniMode hoverEnabled: MSettings.miniMode
onSecondaryClicked: { onSecondaryClicked: {
roomContextMenu.room = currentRoom roomContextMenu.model = model
roomContextMenu.popup() roomContextMenu.popup()
} }
onPrimaryClicked: { onPrimaryClicked: {
@ -141,11 +141,14 @@ Item {
} }
Rectangle { Rectangle {
width: 4 width: unreadCount > 0 || highlighted ? 4 : 0
height: parent.height height: parent.height
color: Material.accent color: Material.accent
visible: unreadCount > 0 || highlighted
Behavior on width {
PropertyAnimation { easing.type: Easing.InOutCubic; duration: 200 }
}
} }
RowLayout { RowLayout {
@ -187,7 +190,7 @@ Item {
Layout.fillWidth: true Layout.fillWidth: true
Layout.fillHeight: 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 elide: Text.ElideRight
wrapMode: Text.NoWrap wrapMode: Text.NoWrap
} }

View File

@ -2,27 +2,23 @@ import QtQuick 2.9
import QtQuick.Controls 2.2 import QtQuick.Controls 2.2
Menu { Menu {
property var row property var row: null
property bool canRedact property var model: null
property string eventType
property string plainText
property string toolTip
property string eventId
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 id: messageContextMenu
MenuItem { MenuItem {
text: "Copy" text: "Copy"
onTriggered: matriqueController.copyToClipboard(plainText) onTriggered: matriqueController.copyToClipboard(model.plainText)
} }
MenuItem { MenuItem {
text: "View Source" text: "View Source"
onTriggered: { onTriggered: {
sourceDialog.sourceText = toolTip sourceDialog.sourceText = model.toolTip
sourceDialog.open() sourceDialog.open()
} }
} }
@ -41,10 +37,10 @@ Menu {
onTriggered: row.saveFileAs() onTriggered: row.saveFileAs()
} }
MenuItem { MenuItem {
visible: canRedact visible: model && model.author === currentRoom.localUser
height: visible ? undefined : 0 height: visible ? undefined : 0
text: "Redact" text: "Redact"
onTriggered: currentRoom.redactEvent(eventId) onTriggered: currentRoom.redactEvent(model.eventId)
} }
} }

View File

@ -1,34 +1,35 @@
import QtQuick 2.9 import QtQuick 2.9
import QtQuick.Controls 2.2 import QtQuick.Controls 2.2
import Matrique 0.1
Menu { Menu {
property var room: null property var model: null
id: roomListMenu id: roomListMenu
MenuItem { MenuItem {
text: "Favourite" text: "Favourite"
checkable: true 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 { MenuItem {
text: "Deprioritize" text: "Deprioritize"
checkable: true 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 {} MenuSeparator {}
MenuItem { MenuItem {
text: "Mark as Read" text: "Mark as Read"
onTriggered: room.markAllMessagesAsRead() onTriggered: model.currentRoom.markAllMessagesAsRead()
} }
MenuItem { MenuItem {
text: "Leave Room" text: "Leave Room"
onTriggered: room.forget() onTriggered: model.currentRoom.forget()
} }
} }