mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-10-30 09:30:47 +03:00
Use native menus
This commit is contained in:
parent
47a7adf823
commit
e490ef953f
3 changed files with 38 additions and 37 deletions
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue