Move most context menu into dir.

This commit is contained in:
Black Hat 2019-04-30 11:05:35 +08:00
parent b062d62954
commit 5fe8bafbf3
14 changed files with 269 additions and 185 deletions

View File

@ -10,6 +10,7 @@ import Spectral.Setting 0.1
import Spectral.Component 2.0
import Spectral.Dialog 2.0
import Spectral.Menu.Timeline 2.0
import Spectral.Font 0.1
import Spectral.Effect 2.0
@ -125,7 +126,25 @@ ColumnLayout {
id: messageMouseArea
onSecondaryClicked: messageContextMenu.popup()
onSecondaryClicked: {
var contextMenu = fileDelegateContextMenu.createObject(ApplicationWindow.overlay)
contextMenu.viewSource.connect(function() {
messageSourceDialog.createObject(ApplicationWindow.overlay, {"sourceText": toolTip}).open()
})
contextMenu.downloadAndOpen.connect(downloadAndOpen)
contextMenu.saveFileAs.connect(saveFileAs)
contextMenu.reply.connect(function() {
roomPanelInput.replyUser = author
roomPanelInput.replyEventID = eventId
roomPanelInput.replyContent = message
roomPanelInput.isReply = true
roomPanelInput.focus()
})
contextMenu.redact.connect(function() {
currentRoom.redactEvent(eventId)
})
contextMenu.popup()
}
Component {
id: messageSourceDialog
@ -133,40 +152,10 @@ ColumnLayout {
MessageSourceDialog {}
}
Menu {
id: messageContextMenu
Component {
id: fileDelegateContextMenu
MenuItem {
text: "View Source"
onTriggered: messageSourceDialog.createObject(ApplicationWindow.overlay, {"sourceText": toolTip}).open()
}
MenuItem {
text: "Open Externally"
onTriggered: downloadAndOpen()
}
MenuItem {
text: "Save As"
onTriggered: saveFileAs()
}
MenuItem {
text: "Reply"
onTriggered: {
roomPanelInput.replyUser = author
roomPanelInput.replyEventID = eventId
roomPanelInput.replyContent = message
roomPanelInput.isReply = true
roomPanelInput.focus()
}
}
MenuItem {
text: "Redact"
onTriggered: currentRoom.redactEvent(eventId)
}
FileDelegateContextMenu {}
}
}
}

View File

@ -10,6 +10,7 @@ import Spectral.Setting 0.1
import Spectral.Component 2.0
import Spectral.Dialog 2.0
import Spectral.Menu.Timeline 2.0
import Spectral.Effect 2.0
import Spectral.Font 0.1
@ -141,12 +142,27 @@ ColumnLayout {
id: messageMouseArea
onPrimaryClicked: {
var window = fullScreenImage.createObject()
window.show()
}
onPrimaryClicked: fullScreenImage.createObject().show()
onSecondaryClicked: messageContextMenu.popup()
onSecondaryClicked: {
var contextMenu = imageDelegateContextMenu.createObject(ApplicationWindow.overlay)
contextMenu.viewSource.connect(function() {
messageSourceDialog.createObject(ApplicationWindow.overlay, {"sourceText": toolTip}).open()
})
contextMenu.downloadAndOpen.connect(downloadAndOpen)
contextMenu.saveFileAs.connect(saveFileAs)
contextMenu.reply.connect(function() {
roomPanelInput.replyUser = author
roomPanelInput.replyEventID = eventId
roomPanelInput.replyContent = message
roomPanelInput.isReply = true
roomPanelInput.focus()
})
contextMenu.redact.connect(function() {
currentRoom.redactEvent(eventId)
})
contextMenu.popup()
}
Component {
id: messageSourceDialog
@ -154,44 +170,10 @@ ColumnLayout {
MessageSourceDialog {}
}
Menu {
id: messageContextMenu
Component {
id: imageDelegateContextMenu
MenuItem {
text: "View Source"
onTriggered: messageSourceDialog.createObject(ApplicationWindow.overlay, {"sourceText": toolTip}).open()
}
MenuItem {
text: "Open Externally"
onTriggered: downloadAndOpen()
}
MenuItem {
text: "Save As"
onTriggered: saveFileAs()
}
MenuItem {
text: "Reply"
onTriggered: {
roomPanelInput.replyUser = author
roomPanelInput.replyEventID = eventId
roomPanelInput.replyContent = message
roomPanelInput.isReply = true
roomPanelInput.focus()
}
}
MenuItem {
text: "Redact"
onTriggered: currentRoom.redactEvent(eventId)
}
FileDelegateContextMenu {}
}
}
}

View File

@ -8,6 +8,7 @@ import Spectral.Setting 0.1
import Spectral.Component 2.0
import Spectral.Dialog 2.0
import Spectral.Menu.Timeline 2.0
import Spectral.Effect 2.0
import Spectral.Font 0.1
@ -97,41 +98,36 @@ ColumnLayout {
id: messageMouseArea
onSecondaryClicked: messageContextMenu.popup()
onSecondaryClicked: {
var contextMenu = messageDelegateContextMenu.createObject(ApplicationWindow.overlay)
contextMenu.viewSource.connect(function() {
messageSourceDialog.createObject(ApplicationWindow.overlay, {"sourceText": toolTip}).open()
})
contextMenu.reply.connect(function() {
roomPanelInput.replyUser = author
roomPanelInput.replyEventID = eventId
roomPanelInput.replyContent = contentLabel.selectedText || message
roomPanelInput.isReply = true
roomPanelInput.focus()
})
contextMenu.redact.connect(function() {
currentRoom.redactEvent(eventId)
})
contextMenu.popup()
}
Component {
id: messageDelegateContextMenu
MessageDelegateContextMenu {}
}
Component {
id: messageSourceDialog
MessageSourceDialog {}
}
Menu {
readonly property string selectedText: contentLabel.selectedText
id: messageContextMenu
MenuItem {
text: "View Source"
onTriggered: messageSourceDialog.createObject(ApplicationWindow.overlay, {"sourceText": toolTip}).open()
}
MenuItem {
text: "Reply"
onTriggered: {
roomPanelInput.replyUser = author
roomPanelInput.replyEventID = eventId
roomPanelInput.replyContent = messageContextMenu.selectedText || message
roomPanelInput.isReply = true
roomPanelInput.focus()
}
}
MenuItem {
text: "Redact"
onTriggered: currentRoom.redactEvent(eventId)
}
}
}
}

View File

@ -0,0 +1,50 @@
import QtQuick 2.12
import QtQuick.Controls 2.12
Dialog {
property var room
anchors.centerIn: parent
width: 360
id: root
title: "Invitation Received"
modal: true
contentItem: Label {
text: "Accept this invitation?"
}
footer: DialogButtonBox {
Button {
text: "Accept"
flat: true
onClicked: {
room.acceptInvitation()
close()
}
}
Button {
text: "Reject"
flat: true
onClicked: {
room.forget()
close()
}
}
Button {
text: "Cancel"
flat: true
onClicked: close()
}
}
onClosed: destroy()
}

View File

@ -44,7 +44,7 @@ Dialog {
placeholderText: "Password"
echoMode: TextInput.Password
onAccepted: root.doLogin()
onAccepted: root.accept()
}
}
@ -52,5 +52,5 @@ Dialog {
spectralController.loginWithCredentials(serverField.text, usernameField.text, passwordField.text)
}
onClosed: root.destroy()
onClosed: destroy()
}

View File

@ -22,6 +22,6 @@ Popup {
}
}
onClosed: root.destroy()
onClosed: destroy()
}

View File

@ -6,3 +6,4 @@ LoginDialog 2.0 LoginDialog.qml
CreateRoomDialog 2.0 CreateRoomDialog.qml
JoinRoomDialog 2.0 JoinRoomDialog.qml
InviteUserDialog 2.0 InviteUserDialog.qml
AcceptInvitationDialog 2.0 AcceptInvitationDialog.qml

View File

@ -0,0 +1,42 @@
import QtQuick 2.12
import QtQuick.Controls 2.12
import QtQuick.Controls.Material 2.12
Menu {
property var room
id: root
MenuItem {
text: "Favourite"
checkable: true
checked: room.isFavourite
onTriggered: room.isFavourite ? room.removeTag("m.favourite") : room.addTag("m.favourite", 1.0)
}
MenuItem {
text: "Deprioritize"
checkable: true
checked: room.isLowPriority
onTriggered: room.isLowPriority ? room.removeTag("m.lowpriority") : room.addTag("m.lowpriority", 1.0)
}
MenuSeparator {}
MenuItem {
text: "Mark as Read"
onTriggered: room.markAllMessagesAsRead()
}
MenuItem {
text: "Leave Room"
Material.foreground: Material.Red
onTriggered: room.forget()
}
onClosed: destroy()
}

View File

@ -0,0 +1,46 @@
import QtQuick 2.12
import QtQuick.Controls 2.12
import Spectral.Dialog 2.0
Menu {
signal viewSource()
signal downloadAndOpen()
signal saveFileAs()
signal reply()
signal redact()
id: root
MenuItem {
text: "View Source"
onTriggered: viewSource()
}
MenuItem {
text: "Open Externally"
onTriggered: downloadAndOpen()
}
MenuItem {
text: "Save As"
onTriggered: saveFileAs()
}
MenuItem {
text: "Reply"
onTriggered: reply()
}
MenuItem {
text: "Redact"
onTriggered: redact()
}
onClosed: destroy()
}

View File

@ -0,0 +1,34 @@
import QtQuick 2.12
import QtQuick.Controls 2.12
import Spectral.Dialog 2.0
Menu {
readonly property string selectedText: contentLabel.selectedText
signal viewSource()
signal reply()
signal redact()
id: root
MenuItem {
text: "View Source"
onTriggered: viewSource()
}
MenuItem {
text: "Reply"
onTriggered: reply()
}
MenuItem {
text: "Redact"
onTriggered: redact()
}
onClosed: destroy()
}

View File

@ -0,0 +1,3 @@
module Spectral.Menu.Timeline
MessageDelegateContextMenu 2.0 MessageDelegateContextMenu.qml
FileDelegateContextMenu 2.0 FileDelegateContextMenu.qml

View File

@ -0,0 +1,2 @@
module Spectral.Menu
RoomListContextMenu 2.0 RoomListContextMenu.qml

View File

@ -5,6 +5,8 @@ import QtQuick.Layouts 1.12
import QtQuick.Controls.Material 2.12
import Spectral.Component 2.0
import Spectral.Dialog 2.0
import Spectral.Menu 2.0
import Spectral.Effect 2.0
import Spectral 0.1
@ -363,11 +365,9 @@ Item {
RippleEffect {
anchors.fill: parent
onSecondaryClicked: roomContextMenu.popup()
onPrimaryClicked: {
if (category === RoomType.Invited) {
inviteDialog.currentRoom = currentRoom
inviteDialog.open()
acceptInvitationDialog.createObject(ApplicationWindow.overlay, {"room": currentRoom}).open()
} else {
if (enteredRoom) {
enteredRoom.displayed = false
@ -378,41 +378,13 @@ Item {
enteredRoom = currentRoom
}
}
onSecondaryClicked: roomListContextMenu.createObject(ApplicationWindow.overlay, {"room": currentRoom}).popup()
}
Menu {
id: roomContextMenu
Component {
id: roomListContextMenu
MenuItem {
text: "Favourite"
checkable: true
checked: category === RoomType.Favorite
onTriggered: category === RoomType.Favorite ? currentRoom.removeTag("m.favourite") : currentRoom.addTag("m.favourite", 1.0)
}
MenuItem {
text: "Deprioritize"
checkable: true
checked: category === RoomType.Deprioritized
onTriggered: category === RoomType.Deprioritized ? currentRoom.removeTag("m.lowpriority") : currentRoom.addTag("m.lowpriority", 1.0)
}
MenuSeparator {}
MenuItem {
text: "Mark as Read"
onTriggered: currentRoom.markAllMessagesAsRead()
}
MenuItem {
text: "Leave Room"
Material.foreground: Material.Red
onTriggered: currentRoom.forget()
}
RoomListContextMenu {}
}
}
@ -431,48 +403,9 @@ Item {
}
}
Dialog {
property var currentRoom
Component {
id: acceptInvitationDialog
id: inviteDialog
parent: ApplicationWindow.overlay
x: (window.width - width) / 2
y: (window.height - height) / 2
width: 360
title: "Action Required"
modal: true
contentItem: Label { text: "Accept this invitation?" }
footer: DialogButtonBox {
Button {
text: "Accept"
flat: true
onClicked: {
inviteDialog.currentRoom.acceptInvitation()
inviteDialog.close()
}
}
Button {
text: "Reject"
flat: true
onClicked: {
inviteDialog.currentRoom.forget()
inviteDialog.close()
}
}
Button {
text: "Cancel"
flat: true
onClicked: inviteDialog.close()
}
}
AcceptInvitationDialog {}
}
}

View File

@ -52,5 +52,11 @@
<file>imports/Spectral/Dialog/CreateRoomDialog.qml</file>
<file>imports/Spectral/Dialog/JoinRoomDialog.qml</file>
<file>imports/Spectral/Dialog/InviteUserDialog.qml</file>
<file>imports/Spectral/Dialog/AcceptInvitationDialog.qml</file>
<file>imports/Spectral/Menu/qmldir</file>
<file>imports/Spectral/Menu/RoomListContextMenu.qml</file>
<file>imports/Spectral/Menu/Timeline/qmldir</file>
<file>imports/Spectral/Menu/Timeline/MessageDelegateContextMenu.qml</file>
<file>imports/Spectral/Menu/Timeline/FileDelegateContextMenu.qml</file>
</qresource>
</RCC>