Port space menu to ConvergentContextMenu
This commit is contained in:
@@ -283,7 +283,7 @@ QQC2.Control {
|
|||||||
room: room,
|
room: room,
|
||||||
connection: root.connection
|
connection: root.connection
|
||||||
});
|
});
|
||||||
context.open();
|
context.popup();
|
||||||
}
|
}
|
||||||
Component {
|
Component {
|
||||||
id: spaceListContextMenu
|
id: spaceListContextMenu
|
||||||
|
|||||||
@@ -16,146 +16,62 @@ import org.kde.neochat.settings
|
|||||||
/**
|
/**
|
||||||
* Context menu when clicking on a room in the room list
|
* Context menu when clicking on a room in the room list
|
||||||
*/
|
*/
|
||||||
Loader {
|
KirigamiComponents.ConvergentContextMenu {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
property NeoChatRoom room
|
property NeoChatRoom room
|
||||||
required property NeoChatConnection connection
|
required property NeoChatConnection connection
|
||||||
required property Kirigami.ApplicationWindow window
|
required property Kirigami.ApplicationWindow window
|
||||||
|
|
||||||
signal closed
|
headerContentItem: RowLayout {
|
||||||
|
spacing: Kirigami.Units.largeSpacing
|
||||||
|
|
||||||
Component {
|
KirigamiComponents.Avatar {
|
||||||
id: regularMenu
|
id: avatar
|
||||||
QQC2.Menu {
|
source: room.avatarMediaUrl
|
||||||
QQC2.MenuItem {
|
Layout.preferredWidth: Kirigami.Units.gridUnit * 2
|
||||||
text: i18nc("'Space' is a matrix space", "View Space")
|
Layout.preferredHeight: Kirigami.Units.gridUnit * 2
|
||||||
icon.name: "view-list-details"
|
}
|
||||||
onTriggered: RoomManager.resolveResource(room.id)
|
|
||||||
}
|
|
||||||
|
|
||||||
QQC2.MenuItem {
|
Kirigami.Heading {
|
||||||
text: i18nc("@action:inmenu", "Copy Address to Clipboard")
|
level: 2
|
||||||
icon.name: "edit-copy"
|
Layout.fillWidth: true
|
||||||
onTriggered: if (room.canonicalAlias.length === 0) {
|
text: room.displayName
|
||||||
Clipboard.saveText(room.id);
|
wrapMode: Text.WordWrap
|
||||||
} else {
|
|
||||||
Clipboard.saveText(room.canonicalAlias);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QQC2.MenuItem {
|
|
||||||
text: i18nc("'Space' is a matrix space", "Space Settings")
|
|
||||||
icon.name: 'settings-configure-symbolic'
|
|
||||||
onTriggered: {
|
|
||||||
RoomSettingsView.openRoomSettings(root.room, RoomSettingsView.Space);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QQC2.MenuSeparator {}
|
|
||||||
|
|
||||||
QQC2.MenuItem {
|
|
||||||
text: i18nc("'Space' is a matrix space", "Leave Space")
|
|
||||||
icon.name: "go-previous"
|
|
||||||
onTriggered: RoomManager.leaveRoom(room)
|
|
||||||
}
|
|
||||||
|
|
||||||
onClosed: {
|
|
||||||
root.closed();
|
|
||||||
regularMenu.destroy();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Component {
|
QQC2.Action {
|
||||||
id: mobileMenu
|
text: i18nc("'Space' is a matrix space", "View Space")
|
||||||
|
icon.name: "view-list-details"
|
||||||
Kirigami.OverlayDrawer {
|
onTriggered: RoomManager.resolveResource(room.id)
|
||||||
id: drawer
|
|
||||||
height: popupContent.implicitHeight
|
|
||||||
edge: Qt.BottomEdge
|
|
||||||
padding: 0
|
|
||||||
leftPadding: 0
|
|
||||||
rightPadding: 0
|
|
||||||
bottomPadding: 0
|
|
||||||
topPadding: 0
|
|
||||||
|
|
||||||
parent: applicationWindow().overlay
|
|
||||||
|
|
||||||
ColumnLayout {
|
|
||||||
id: popupContent
|
|
||||||
|
|
||||||
width: parent.width
|
|
||||||
spacing: 0
|
|
||||||
|
|
||||||
RowLayout {
|
|
||||||
id: headerLayout
|
|
||||||
Layout.fillWidth: true
|
|
||||||
Layout.margins: Kirigami.Units.largeSpacing
|
|
||||||
spacing: Kirigami.Units.largeSpacing
|
|
||||||
|
|
||||||
KirigamiComponents.Avatar {
|
|
||||||
id: avatar
|
|
||||||
source: room.avatarMediaUrl
|
|
||||||
Layout.preferredWidth: Kirigami.Units.gridUnit * 3
|
|
||||||
Layout.preferredHeight: Kirigami.Units.gridUnit * 3
|
|
||||||
Layout.alignment: Qt.AlignTop
|
|
||||||
}
|
|
||||||
|
|
||||||
Kirigami.Heading {
|
|
||||||
level: 5
|
|
||||||
Layout.fillWidth: true
|
|
||||||
text: room.displayName
|
|
||||||
wrapMode: Text.WordWrap
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
FormCard.FormButtonDelegate {
|
|
||||||
text: i18nc("'Space' is a matrix space", "View Space")
|
|
||||||
icon.name: "view-list-details"
|
|
||||||
onClicked: RoomManager.resolveResource(root.room.id)
|
|
||||||
}
|
|
||||||
|
|
||||||
FormCard.FormButtonDelegate {
|
|
||||||
text: i18nc("@action:inmenu", "Copy Address to Clipboard")
|
|
||||||
icon.name: "edit-copy"
|
|
||||||
onClicked: if (room.canonicalAlias.length === 0) {
|
|
||||||
Clipboard.saveText(room.id);
|
|
||||||
} else {
|
|
||||||
Clipboard.saveText(room.canonicalAlias);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
FormCard.FormButtonDelegate {
|
|
||||||
text: i18nc("'Space' is a matrix space", "Space Settings")
|
|
||||||
icon.name: 'settings-configure-symbolic'
|
|
||||||
onClicked: {
|
|
||||||
RoomSettingsView.openRoomSettings(root.room, RoomSettingsView.Space);
|
|
||||||
drawer.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
FormCard.FormButtonDelegate {
|
|
||||||
text: i18nc("'Space' is a matrix space", "Leave Space")
|
|
||||||
onClicked: RoomManager.leaveRoom(room)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
onClosed: root.closed()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
asynchronous: true
|
QQC2.Action {
|
||||||
sourceComponent: Kirigami.Settings.isMobile ? mobileMenu : regularMenu
|
text: i18nc("@action:inmenu", "Copy Address to Clipboard")
|
||||||
|
icon.name: "edit-copy"
|
||||||
function open() {
|
onTriggered: if (room.canonicalAlias.length === 0) {
|
||||||
active = true;
|
Clipboard.saveText(room.id);
|
||||||
}
|
|
||||||
|
|
||||||
onStatusChanged: if (status == Loader.Ready) {
|
|
||||||
if (Kirigami.Settings.isMobile) {
|
|
||||||
item.open();
|
|
||||||
} else {
|
} else {
|
||||||
item.popup();
|
Clipboard.saveText(room.canonicalAlias);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QQC2.Action {
|
||||||
|
text: i18nc("'Space' is a matrix space", "Space Settings")
|
||||||
|
icon.name: 'settings-configure-symbolic'
|
||||||
|
onTriggered: {
|
||||||
|
RoomSettingsView.openRoomSettings(root.room, RoomSettingsView.Space);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Kirigami.Action {
|
||||||
|
separator: true
|
||||||
|
}
|
||||||
|
|
||||||
|
QQC2.Action {
|
||||||
|
text: i18nc("'Space' is a matrix space", "Leave Space")
|
||||||
|
icon.name: "go-previous"
|
||||||
|
onTriggered: RoomManager.leaveRoom(room)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user