mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-25 20:48:52 +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 {
|
TapHandler {
|
||||||
acceptedButtons: Qt.RightButton
|
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 {
|
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
|
onDoubleTapped: chat.model.reply = model.id
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ import "./delegates"
|
||||||
import "./device-verification"
|
import "./device-verification"
|
||||||
import "./emoji"
|
import "./emoji"
|
||||||
import "./voip"
|
import "./voip"
|
||||||
|
import Qt.labs.platform 1.1 as Platform
|
||||||
import QtGraphicalEffects 1.0
|
import QtGraphicalEffects 1.0
|
||||||
import QtQuick 2.9
|
import QtQuick 2.9
|
||||||
import QtQuick.Controls 2.3
|
import QtQuick.Controls 2.3
|
||||||
|
@ -89,7 +90,7 @@ Page {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Menu {
|
Platform.Menu {
|
||||||
id: messageContextMenu
|
id: messageContextMenu
|
||||||
|
|
||||||
property string eventId
|
property string eventId
|
||||||
|
@ -102,67 +103,68 @@ Page {
|
||||||
eventType = eventType_;
|
eventType = eventType_;
|
||||||
isEncrypted = isEncrypted_;
|
isEncrypted = isEncrypted_;
|
||||||
isEditable = isEditable_;
|
isEditable = isEditable_;
|
||||||
popup(showAt_);
|
if (showAt_)
|
||||||
|
open(showAt_);
|
||||||
|
else
|
||||||
|
open();
|
||||||
}
|
}
|
||||||
|
|
||||||
modal: true
|
Platform.MenuItem {
|
||||||
|
|
||||||
MenuItem {
|
|
||||||
text: qsTr("React")
|
text: qsTr("React")
|
||||||
onClicked: emojiPopup.show(messageContextMenu.parent, function(emoji) {
|
onTriggered: emojiPopup.show(messageContextMenu.parent, function(emoji) {
|
||||||
TimelineManager.queueReactionMessage(messageContextMenu.eventId, emoji);
|
TimelineManager.queueReactionMessage(messageContextMenu.eventId, emoji);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
MenuItem {
|
Platform.MenuItem {
|
||||||
text: qsTr("Reply")
|
text: qsTr("Reply")
|
||||||
onClicked: TimelineManager.timeline.replyAction(messageContextMenu.eventId)
|
onTriggered: TimelineManager.timeline.replyAction(messageContextMenu.eventId)
|
||||||
}
|
}
|
||||||
|
|
||||||
MenuItem {
|
Platform.MenuItem {
|
||||||
visible: messageContextMenu.isEditable
|
visible: messageContextMenu.isEditable
|
||||||
height: visible ? implicitHeight : 0
|
enabled: visible
|
||||||
text: qsTr("Edit")
|
text: qsTr("Edit")
|
||||||
onClicked: TimelineManager.timeline.editAction(messageContextMenu.eventId)
|
onTriggered: TimelineManager.timeline.editAction(messageContextMenu.eventId)
|
||||||
}
|
}
|
||||||
|
|
||||||
MenuItem {
|
Platform.MenuItem {
|
||||||
text: qsTr("Read receipts")
|
text: qsTr("Read receipts")
|
||||||
onTriggered: TimelineManager.timeline.readReceiptsAction(messageContextMenu.eventId)
|
onTriggered: TimelineManager.timeline.readReceiptsAction(messageContextMenu.eventId)
|
||||||
}
|
}
|
||||||
|
|
||||||
MenuItem {
|
Platform.MenuItem {
|
||||||
text: qsTr("Mark as read")
|
text: qsTr("Mark as read")
|
||||||
}
|
}
|
||||||
|
|
||||||
MenuItem {
|
Platform.MenuItem {
|
||||||
text: qsTr("View raw message")
|
text: qsTr("View raw message")
|
||||||
onTriggered: TimelineManager.timeline.viewRawMessage(messageContextMenu.eventId)
|
onTriggered: TimelineManager.timeline.viewRawMessage(messageContextMenu.eventId)
|
||||||
}
|
}
|
||||||
|
|
||||||
MenuItem {
|
Platform.MenuItem {
|
||||||
// TODO(Nico): Fix this still being iterated over, when using keyboard to select options
|
// TODO(Nico): Fix this still being iterated over, when using keyboard to select options
|
||||||
visible: messageContextMenu.isEncrypted
|
visible: messageContextMenu.isEncrypted
|
||||||
height: visible ? implicitHeight : 0
|
enabled: visible
|
||||||
text: qsTr("View decrypted raw message")
|
text: qsTr("View decrypted raw message")
|
||||||
onTriggered: TimelineManager.timeline.viewDecryptedRawMessage(messageContextMenu.eventId)
|
onTriggered: TimelineManager.timeline.viewDecryptedRawMessage(messageContextMenu.eventId)
|
||||||
}
|
}
|
||||||
|
|
||||||
MenuItem {
|
Platform.MenuItem {
|
||||||
text: qsTr("Remove message")
|
text: qsTr("Remove message")
|
||||||
onTriggered: TimelineManager.timeline.redactEvent(messageContextMenu.eventId)
|
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
|
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")
|
text: qsTr("Save as")
|
||||||
onTriggered: TimelineManager.timeline.saveMedia(messageContextMenu.eventId)
|
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
|
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")
|
text: qsTr("Open in external program")
|
||||||
onTriggered: TimelineManager.timeline.openMedia(messageContextMenu.eventId)
|
onTriggered: TimelineManager.timeline.openMedia(messageContextMenu.eventId)
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,9 @@
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
import QtQuick 2.9
|
import Qt.labs.platform 1.1 as Platform
|
||||||
import QtQuick.Controls 2.3
|
import QtQuick 2.12
|
||||||
|
import QtQuick.Controls 2.12
|
||||||
import QtQuick.Layouts 1.2
|
import QtQuick.Layouts 1.2
|
||||||
import im.nheko 1.0
|
import im.nheko 1.0
|
||||||
|
|
||||||
|
@ -17,9 +18,8 @@ Rectangle {
|
||||||
z: 3
|
z: 3
|
||||||
color: colors.window
|
color: colors.window
|
||||||
|
|
||||||
MouseArea {
|
TapHandler {
|
||||||
anchors.fill: parent
|
onSingleTapped: TimelineManager.timeline.openRoomSettings()
|
||||||
onClicked: TimelineManager.timeline.openRoomSettings()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GridLayout {
|
GridLayout {
|
||||||
|
@ -70,9 +70,8 @@ Rectangle {
|
||||||
maximumLineCount: 1
|
maximumLineCount: 1
|
||||||
elide: Text.ElideRight
|
elide: Text.ElideRight
|
||||||
|
|
||||||
MouseArea {
|
TapHandler {
|
||||||
anchors.fill: parent
|
onSingleTapped: TimelineManager.timeline.openRoomSettings()
|
||||||
onClicked: TimelineManager.timeline.openRoomSettings()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -96,27 +95,27 @@ Rectangle {
|
||||||
image: ":/icons/icons/ui/vertical-ellipsis.png"
|
image: ":/icons/icons/ui/vertical-ellipsis.png"
|
||||||
ToolTip.visible: hovered
|
ToolTip.visible: hovered
|
||||||
ToolTip.text: qsTr("Room options")
|
ToolTip.text: qsTr("Room options")
|
||||||
onClicked: roomOptionsMenu.popup(roomOptionsButton)
|
onClicked: roomOptionsMenu.open(roomOptionsButton)
|
||||||
|
|
||||||
Menu {
|
Platform.Menu {
|
||||||
id: roomOptionsMenu
|
id: roomOptionsMenu
|
||||||
|
|
||||||
MenuItem {
|
Platform.MenuItem {
|
||||||
text: qsTr("Invite users")
|
text: qsTr("Invite users")
|
||||||
onTriggered: TimelineManager.openInviteUsersDialog()
|
onTriggered: TimelineManager.openInviteUsersDialog()
|
||||||
}
|
}
|
||||||
|
|
||||||
MenuItem {
|
Platform.MenuItem {
|
||||||
text: qsTr("Members")
|
text: qsTr("Members")
|
||||||
onTriggered: TimelineManager.openMemberListDialog()
|
onTriggered: TimelineManager.openMemberListDialog()
|
||||||
}
|
}
|
||||||
|
|
||||||
MenuItem {
|
Platform.MenuItem {
|
||||||
text: qsTr("Leave room")
|
text: qsTr("Leave room")
|
||||||
onTriggered: TimelineManager.openLeaveRoomDialog()
|
onTriggered: TimelineManager.openLeaveRoomDialog()
|
||||||
}
|
}
|
||||||
|
|
||||||
MenuItem {
|
Platform.MenuItem {
|
||||||
text: qsTr("Settings")
|
text: qsTr("Settings")
|
||||||
onTriggered: TimelineManager.timeline.openRoomSettings()
|
onTriggered: TimelineManager.timeline.openRoomSettings()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue