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 2.12
|
||||||
import QtQuick.Controls 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 {
|
Menu {
|
||||||
|
id: root
|
||||||
property var room
|
property var room
|
||||||
|
|
||||||
id: root
|
|
||||||
|
|
||||||
MenuItem {
|
MenuItem {
|
||||||
text: "Favourite"
|
text: i18n("Favourite")
|
||||||
checkable: true
|
checkable: true
|
||||||
checked: room.isFavourite
|
checked: room.isFavourite
|
||||||
|
|
||||||
@@ -16,7 +23,7 @@ Menu {
|
|||||||
}
|
}
|
||||||
|
|
||||||
MenuItem {
|
MenuItem {
|
||||||
text: "Deprioritize"
|
text: i18n("Deprioritize")
|
||||||
checkable: true
|
checkable: true
|
||||||
checked: room.isLowPriority
|
checked: room.isLowPriority
|
||||||
|
|
||||||
@@ -26,15 +33,13 @@ Menu {
|
|||||||
MenuSeparator {}
|
MenuSeparator {}
|
||||||
|
|
||||||
MenuItem {
|
MenuItem {
|
||||||
text: "Mark as Read"
|
text: i18n("Mark as Read")
|
||||||
|
|
||||||
onTriggered: room.markAllMessagesAsRead()
|
onTriggered: room.markAllMessagesAsRead()
|
||||||
}
|
}
|
||||||
|
|
||||||
MenuItem {
|
MenuItem {
|
||||||
text: "Leave Room"
|
text: i18n("Leave Room")
|
||||||
Material.foreground: Material.Red
|
|
||||||
|
|
||||||
onTriggered: room.forget()
|
onTriggered: room.forget()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -37,8 +37,6 @@ Kirigami.ScrollablePage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ListView {
|
ListView {
|
||||||
id: messageListView
|
|
||||||
|
|
||||||
model: KSortFilterProxyModel {
|
model: KSortFilterProxyModel {
|
||||||
id: sortedFilteredRoomListModel
|
id: sortedFilteredRoomListModel
|
||||||
sourceModel: roomListModel
|
sourceModel: roomListModel
|
||||||
@@ -59,56 +57,73 @@ Kirigami.ScrollablePage {
|
|||||||
topPadding: Kirigami.Units.largeSpacing
|
topPadding: Kirigami.Units.largeSpacing
|
||||||
bottomPadding: Kirigami.Units.largeSpacing
|
bottomPadding: Kirigami.Units.largeSpacing
|
||||||
|
|
||||||
contentItem: RowLayout {
|
contentItem: Item {
|
||||||
spacing: Kirigami.Units.largeSpacing
|
implicitHeight: roomLayout.implicitHeight
|
||||||
|
RowLayout {
|
||||||
|
id: roomLayout
|
||||||
|
spacing: Kirigami.Units.largeSpacing
|
||||||
|
anchors.fill: parent
|
||||||
|
|
||||||
Kirigami.Avatar {
|
Kirigami.Avatar {
|
||||||
Layout.preferredWidth: height
|
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
|
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
text: name ?? ""
|
|
||||||
font.pixelSize: 15
|
source: avatar ? "image://mxc/" + avatar : ""
|
||||||
font.bold: unreadCount >= 0
|
name: model.name || i18n("No Name")
|
||||||
elide: Text.ElideRight
|
|
||||||
wrapMode: Text.NoWrap
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QQC2.Label {
|
ColumnLayout {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
Layout.alignment: Qt.AlignHCenter
|
Layout.alignment: Qt.AlignHCenter
|
||||||
|
|
||||||
text: (lastEvent == "" ? topic : lastEvent).replace(/(\r\n\t|\n|\r\t)/gm," ")
|
spacing: Kirigami.Units.smallSpacing
|
||||||
font.pixelSize: 12
|
|
||||||
elide: Text.ElideRight
|
QQC2.Label {
|
||||||
wrapMode: Text.NoWrap
|
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: {
|
Component {
|
||||||
if (enteredRoom) {
|
id: roomListContextMenu
|
||||||
leaveRoom(enteredRoom)
|
RoomListContextMenu {}
|
||||||
}
|
|
||||||
|
|
||||||
enteredRoom = currentRoom
|
|
||||||
|
|
||||||
enterRoom(enteredRoom)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import org.kde.kirigami 2.12 as Kirigami
|
|||||||
|
|
||||||
import Spectral 0.1
|
import Spectral 0.1
|
||||||
import Spectral.Component 2.0
|
import Spectral.Component 2.0
|
||||||
import Spectral.Dialog 2.0
|
|
||||||
import Spectral.Panel 2.0
|
import Spectral.Panel 2.0
|
||||||
|
|
||||||
Kirigami.ApplicationWindow {
|
Kirigami.ApplicationWindow {
|
||||||
@@ -21,7 +20,7 @@ Kirigami.ApplicationWindow {
|
|||||||
|
|
||||||
contextDrawer: RoomDrawer {
|
contextDrawer: RoomDrawer {
|
||||||
id: contextDrawer
|
id: contextDrawer
|
||||||
enabled: roomList.enteredRoom !== null
|
enabled: root.currentRoomm !== null
|
||||||
room: root.currentRoom
|
room: root.currentRoom
|
||||||
handleVisible: enabled && (pageStack.currentItem instanceof RoomPage)
|
handleVisible: enabled && (pageStack.currentItem instanceof RoomPage)
|
||||||
}
|
}
|
||||||
|
|||||||
2
res.qrc
2
res.qrc
@@ -6,6 +6,7 @@
|
|||||||
<file>qml/RoomListPage.qml</file>
|
<file>qml/RoomListPage.qml</file>
|
||||||
<file>qml/RoomPage.qml</file>
|
<file>qml/RoomPage.qml</file>
|
||||||
<file>qml/ChatTextInput.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/EmojiPicker.qml</file>
|
||||||
<file>imports/Spectral/Component/Emoji/qmldir</file>
|
<file>imports/Spectral/Component/Emoji/qmldir</file>
|
||||||
<file>imports/Spectral/Component/Timeline/MessageDelegate.qml</file>
|
<file>imports/Spectral/Component/Timeline/MessageDelegate.qml</file>
|
||||||
@@ -45,7 +46,6 @@
|
|||||||
<file>imports/Spectral/Dialog/InviteUserDialog.qml</file>
|
<file>imports/Spectral/Dialog/InviteUserDialog.qml</file>
|
||||||
<file>imports/Spectral/Dialog/AcceptInvitationDialog.qml</file>
|
<file>imports/Spectral/Dialog/AcceptInvitationDialog.qml</file>
|
||||||
<file>imports/Spectral/Menu/qmldir</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/qmldir</file>
|
||||||
<file>imports/Spectral/Menu/Timeline/MessageDelegateContextMenu.qml</file>
|
<file>imports/Spectral/Menu/Timeline/MessageDelegateContextMenu.qml</file>
|
||||||
<file>imports/Spectral/Menu/Timeline/FileDelegateContextMenu.qml</file>
|
<file>imports/Spectral/Menu/Timeline/FileDelegateContextMenu.qml</file>
|
||||||
|
|||||||
Reference in New Issue
Block a user