diff options
author | Nicolas Werner <nicolas.werner@hotmail.de> | 2021-03-14 22:22:52 +0100 |
---|---|---|
committer | Nicolas Werner <nicolas.werner@hotmail.de> | 2021-03-14 22:22:52 +0100 |
commit | e490ef953f22e753f631719b7e2624ff3e146812 (patch) | |
tree | f37a8dc83d17650f4549c256b18a426cab49b1a7 | |
parent | Use readonly properties where possible (diff) | |
download | nheko-e490ef953f22e753f631719b7e2624ff3e146812.tar.xz |
Use native menus
-rw-r--r-- | resources/qml/TimelineRow.qml | 4 | ||||
-rw-r--r-- | resources/qml/TimelineView.qml | 44 | ||||
-rw-r--r-- | resources/qml/TopBar.qml | 27 |
3 files changed, 38 insertions, 37 deletions
diff --git a/resources/qml/TimelineRow.qml b/resources/qml/TimelineRow.qml index 0f815f6f..a66b994a 100644 --- a/resources/qml/TimelineRow.qml +++ b/resources/qml/TimelineRow.qml @@ -28,11 +28,11 @@ Item { TapHandler { acceptedButtons: Qt.RightButton - onSingleTapped: messageContextMenu.show(model.id, model.type, model.isEncrypted, model.isEditable, row) + onSingleTapped: messageContextMenu.show(model.id, model.type, model.isEncrypted, model.isEditable) } TapHandler { - onLongPressed: messageContextMenu.show(model.id, model.type, model.isEncrypted, model.isEditable, row) + onLongPressed: messageContextMenu.show(model.id, model.type, model.isEncrypted, model.isEditable) onDoubleTapped: chat.model.reply = model.id } diff --git a/resources/qml/TimelineView.qml b/resources/qml/TimelineView.qml index 02f6d5f4..5732dc73 100644 --- a/resources/qml/TimelineView.qml +++ b/resources/qml/TimelineView.qml @@ -6,6 +6,7 @@ import "./delegates" import "./device-verification" import "./emoji" import "./voip" +import Qt.labs.platform 1.1 as Platform import QtGraphicalEffects 1.0 import QtQuick 2.9 import QtQuick.Controls 2.3 @@ -89,7 +90,7 @@ Page { } } - Menu { + Platform.Menu { id: messageContextMenu property string eventId @@ -102,67 +103,68 @@ Page { eventType = eventType_; isEncrypted = isEncrypted_; isEditable = isEditable_; - popup(showAt_); + if (showAt_) + open(showAt_); + else + open(); } - modal: true - - MenuItem { + Platform.MenuItem { text: qsTr("React") - onClicked: emojiPopup.show(messageContextMenu.parent, function(emoji) { + onTriggered: emojiPopup.show(messageContextMenu.parent, function(emoji) { TimelineManager.queueReactionMessage(messageContextMenu.eventId, emoji); }) } - MenuItem { + Platform.MenuItem { text: qsTr("Reply") - onClicked: TimelineManager.timeline.replyAction(messageContextMenu.eventId) + onTriggered: TimelineManager.timeline.replyAction(messageContextMenu.eventId) } - MenuItem { + Platform.MenuItem { visible: messageContextMenu.isEditable - height: visible ? implicitHeight : 0 + enabled: visible text: qsTr("Edit") - onClicked: TimelineManager.timeline.editAction(messageContextMenu.eventId) + onTriggered: TimelineManager.timeline.editAction(messageContextMenu.eventId) } - MenuItem { + Platform.MenuItem { text: qsTr("Read receipts") onTriggered: TimelineManager.timeline.readReceiptsAction(messageContextMenu.eventId) } - MenuItem { + Platform.MenuItem { text: qsTr("Mark as read") } - MenuItem { + Platform.MenuItem { text: qsTr("View raw message") onTriggered: TimelineManager.timeline.viewRawMessage(messageContextMenu.eventId) } - MenuItem { + Platform.MenuItem { // TODO(Nico): Fix this still being iterated over, when using keyboard to select options visible: messageContextMenu.isEncrypted - height: visible ? implicitHeight : 0 + enabled: visible text: qsTr("View decrypted raw message") onTriggered: TimelineManager.timeline.viewDecryptedRawMessage(messageContextMenu.eventId) } - MenuItem { + Platform.MenuItem { text: qsTr("Remove message") onTriggered: TimelineManager.timeline.redactEvent(messageContextMenu.eventId) } - MenuItem { + Platform.MenuItem { visible: messageContextMenu.eventType == MtxEvent.ImageMessage || messageContextMenu.eventType == MtxEvent.VideoMessage || messageContextMenu.eventType == MtxEvent.AudioMessage || messageContextMenu.eventType == MtxEvent.FileMessage || messageContextMenu.eventType == MtxEvent.Sticker - height: visible ? implicitHeight : 0 + enabled: visible text: qsTr("Save as") onTriggered: TimelineManager.timeline.saveMedia(messageContextMenu.eventId) } - MenuItem { + Platform.MenuItem { visible: messageContextMenu.eventType == MtxEvent.ImageMessage || messageContextMenu.eventType == MtxEvent.VideoMessage || messageContextMenu.eventType == MtxEvent.AudioMessage || messageContextMenu.eventType == MtxEvent.FileMessage || messageContextMenu.eventType == MtxEvent.Sticker - height: visible ? implicitHeight : 0 + enabled: visible text: qsTr("Open in external program") onTriggered: TimelineManager.timeline.openMedia(messageContextMenu.eventId) } diff --git a/resources/qml/TopBar.qml b/resources/qml/TopBar.qml index 444a4572..048a76a1 100644 --- a/resources/qml/TopBar.qml +++ b/resources/qml/TopBar.qml @@ -2,8 +2,9 @@ // // SPDX-License-Identifier: GPL-3.0-or-later -import QtQuick 2.9 -import QtQuick.Controls 2.3 +import Qt.labs.platform 1.1 as Platform +import QtQuick 2.12 +import QtQuick.Controls 2.12 import QtQuick.Layouts 1.2 import im.nheko 1.0 @@ -17,9 +18,8 @@ Rectangle { z: 3 color: colors.window - MouseArea { - anchors.fill: parent - onClicked: TimelineManager.timeline.openRoomSettings() + TapHandler { + onSingleTapped: TimelineManager.timeline.openRoomSettings() } GridLayout { @@ -70,9 +70,8 @@ Rectangle { maximumLineCount: 1 elide: Text.ElideRight - MouseArea { - anchors.fill: parent - onClicked: TimelineManager.timeline.openRoomSettings() + TapHandler { + onSingleTapped: TimelineManager.timeline.openRoomSettings() } } @@ -96,27 +95,27 @@ Rectangle { image: ":/icons/icons/ui/vertical-ellipsis.png" ToolTip.visible: hovered ToolTip.text: qsTr("Room options") - onClicked: roomOptionsMenu.popup(roomOptionsButton) + onClicked: roomOptionsMenu.open(roomOptionsButton) - Menu { + Platform.Menu { id: roomOptionsMenu - MenuItem { + Platform.MenuItem { text: qsTr("Invite users") onTriggered: TimelineManager.openInviteUsersDialog() } - MenuItem { + Platform.MenuItem { text: qsTr("Members") onTriggered: TimelineManager.openMemberListDialog() } - MenuItem { + Platform.MenuItem { text: qsTr("Leave room") onTriggered: TimelineManager.openLeaveRoomDialog() } - MenuItem { + Platform.MenuItem { text: qsTr("Settings") onTriggered: TimelineManager.timeline.openRoomSettings() } |