Add minimal room management
This commit is contained in:
@@ -1,14 +1,21 @@
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2019 Black Hat <bhat@encom.eu.org>
|
||||
* SPDX-FileCopyrightText: 2020 Carl Schwan <carl@carlschwan.eu>
|
||||
*
|
||||
* SPDX-LicenseIdentifier: GPL-3.0-only
|
||||
*/
|
||||
import QtQuick 2.12
|
||||
import QtQuick.Controls 2.12
|
||||
import QtQuick.Controls.Material 2.12
|
||||
|
||||
/**
|
||||
* Context menu when clicking on a room in the room list
|
||||
*/
|
||||
Menu {
|
||||
id: root
|
||||
property var room
|
||||
|
||||
id: root
|
||||
|
||||
MenuItem {
|
||||
text: "Favourite"
|
||||
text: i18n("Favourite")
|
||||
checkable: true
|
||||
checked: room.isFavourite
|
||||
|
||||
@@ -16,7 +23,7 @@ Menu {
|
||||
}
|
||||
|
||||
MenuItem {
|
||||
text: "Deprioritize"
|
||||
text: i18n("Deprioritize")
|
||||
checkable: true
|
||||
checked: room.isLowPriority
|
||||
|
||||
@@ -26,15 +33,13 @@ Menu {
|
||||
MenuSeparator {}
|
||||
|
||||
MenuItem {
|
||||
text: "Mark as Read"
|
||||
text: i18n("Mark as Read")
|
||||
|
||||
onTriggered: room.markAllMessagesAsRead()
|
||||
}
|
||||
|
||||
MenuItem {
|
||||
text: "Leave Room"
|
||||
Material.foreground: Material.Red
|
||||
|
||||
text: i18n("Leave Room")
|
||||
onTriggered: room.forget()
|
||||
}
|
||||
|
||||
@@ -37,8 +37,6 @@ Kirigami.ScrollablePage {
|
||||
}
|
||||
|
||||
ListView {
|
||||
id: messageListView
|
||||
|
||||
model: KSortFilterProxyModel {
|
||||
id: sortedFilteredRoomListModel
|
||||
sourceModel: roomListModel
|
||||
@@ -59,56 +57,73 @@ Kirigami.ScrollablePage {
|
||||
topPadding: Kirigami.Units.largeSpacing
|
||||
bottomPadding: Kirigami.Units.largeSpacing
|
||||
|
||||
contentItem: RowLayout {
|
||||
spacing: Kirigami.Units.largeSpacing
|
||||
contentItem: Item {
|
||||
implicitHeight: roomLayout.implicitHeight
|
||||
RowLayout {
|
||||
id: roomLayout
|
||||
spacing: Kirigami.Units.largeSpacing
|
||||
anchors.fill: parent
|
||||
|
||||
Kirigami.Avatar {
|
||||
Layout.preferredWidth: height
|
||||
Layout.fillHeight: true
|
||||
|
||||
source: avatar ? "image://mxc/" + avatar : ""
|
||||
name: model.name || "No Name"
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
|
||||
spacing: Kirigami.Units.smallSpacing
|
||||
|
||||
QQC2.Label {
|
||||
Layout.fillWidth: true
|
||||
Kirigami.Avatar {
|
||||
Layout.preferredWidth: height
|
||||
Layout.fillHeight: true
|
||||
text: name ?? ""
|
||||
font.pixelSize: 15
|
||||
font.bold: unreadCount >= 0
|
||||
elide: Text.ElideRight
|
||||
wrapMode: Text.NoWrap
|
||||
|
||||
source: avatar ? "image://mxc/" + avatar : ""
|
||||
name: model.name || i18n("No Name")
|
||||
}
|
||||
|
||||
QQC2.Label {
|
||||
ColumnLayout {
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
|
||||
text: (lastEvent == "" ? topic : lastEvent).replace(/(\r\n\t|\n|\r\t)/gm," ")
|
||||
font.pixelSize: 12
|
||||
elide: Text.ElideRight
|
||||
wrapMode: Text.NoWrap
|
||||
spacing: Kirigami.Units.smallSpacing
|
||||
|
||||
QQC2.Label {
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
text: name ?? ""
|
||||
font.pixelSize: 15
|
||||
font.bold: unreadCount >= 0
|
||||
elide: Text.ElideRight
|
||||
wrapMode: Text.NoWrap
|
||||
}
|
||||
|
||||
QQC2.Label {
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
|
||||
text: (lastEvent == "" ? topic : lastEvent).replace(/(\r\n\t|\n|\r\t)/gm," ")
|
||||
font.pixelSize: 12
|
||||
elide: Text.ElideRight
|
||||
wrapMode: Text.NoWrap
|
||||
}
|
||||
}
|
||||
}
|
||||
MouseArea {
|
||||
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
||||
anchors.fill: parent
|
||||
onClicked: {
|
||||
console.log(mouse.button)
|
||||
if (mouse.button == Qt.RightButton) {
|
||||
roomListContextMenu.createObject(parent, {"room": currentRoom}).popup()
|
||||
} else {
|
||||
if (enteredRoom) {
|
||||
leaveRoom(enteredRoom)
|
||||
}
|
||||
|
||||
enteredRoom = currentRoom
|
||||
|
||||
enterRoom(enteredRoom)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onClicked: {
|
||||
if (enteredRoom) {
|
||||
leaveRoom(enteredRoom)
|
||||
}
|
||||
|
||||
enteredRoom = currentRoom
|
||||
|
||||
enterRoom(enteredRoom)
|
||||
}
|
||||
}
|
||||
Component {
|
||||
id: roomListContextMenu
|
||||
RoomListContextMenu {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@ import org.kde.kirigami 2.12 as Kirigami
|
||||
|
||||
import Spectral 0.1
|
||||
import Spectral.Component 2.0
|
||||
import Spectral.Dialog 2.0
|
||||
import Spectral.Panel 2.0
|
||||
|
||||
Kirigami.ApplicationWindow {
|
||||
@@ -21,7 +20,7 @@ Kirigami.ApplicationWindow {
|
||||
|
||||
contextDrawer: RoomDrawer {
|
||||
id: contextDrawer
|
||||
enabled: roomList.enteredRoom !== null
|
||||
enabled: root.currentRoomm !== null
|
||||
room: root.currentRoom
|
||||
handleVisible: enabled && (pageStack.currentItem instanceof RoomPage)
|
||||
}
|
||||
|
||||
2
res.qrc
2
res.qrc
@@ -6,6 +6,7 @@
|
||||
<file>qml/RoomListPage.qml</file>
|
||||
<file>qml/RoomPage.qml</file>
|
||||
<file>qml/ChatTextInput.qml</file>
|
||||
<file>qml/RoomListContextMenu.qml</file>
|
||||
<file>imports/Spectral/Component/Emoji/EmojiPicker.qml</file>
|
||||
<file>imports/Spectral/Component/Emoji/qmldir</file>
|
||||
<file>imports/Spectral/Component/Timeline/MessageDelegate.qml</file>
|
||||
@@ -45,7 +46,6 @@
|
||||
<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>
|
||||
|
||||
Reference in New Issue
Block a user