2021-05-15 00:35:34 +03:00
|
|
|
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
2022-01-01 06:57:53 +03:00
|
|
|
// SPDX-FileCopyrightText: 2022 Nheko Contributors
|
2021-05-15 00:35:34 +03:00
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2022-04-22 01:26:25 +03:00
|
|
|
import "./components"
|
2021-05-28 18:25:46 +03:00
|
|
|
import "./dialogs"
|
2022-01-02 08:22:27 +03:00
|
|
|
import "./ui"
|
2021-05-22 16:19:44 +03:00
|
|
|
import Qt.labs.platform 1.1 as Platform
|
2021-06-13 02:48:11 +03:00
|
|
|
import QtQml 2.12
|
2021-07-10 21:28:46 +03:00
|
|
|
import QtQuick 2.15
|
|
|
|
import QtQuick.Controls 2.15
|
2021-05-15 00:35:34 +03:00
|
|
|
import QtQuick.Layouts 1.3
|
|
|
|
import im.nheko 1.0
|
|
|
|
|
|
|
|
Page {
|
2021-06-06 00:36:08 +03:00
|
|
|
//leftPadding: Nheko.paddingSmall
|
|
|
|
//rightPadding: Nheko.paddingSmall
|
2021-06-08 23:18:51 +03:00
|
|
|
property int avatarSize: Math.ceil(fontMetrics.lineSpacing * 2.3)
|
|
|
|
property bool collapsed: false
|
2021-06-06 00:36:08 +03:00
|
|
|
|
2021-08-18 00:31:25 +03:00
|
|
|
Component {
|
2021-07-29 05:31:31 +03:00
|
|
|
id: roomDirectoryComponent
|
|
|
|
|
|
|
|
RoomDirectory {
|
|
|
|
}
|
2021-08-18 00:31:25 +03:00
|
|
|
|
|
|
|
}
|
2021-07-29 05:31:31 +03:00
|
|
|
|
2022-03-26 00:30:19 +03:00
|
|
|
Component {
|
|
|
|
id: createRoomComponent
|
|
|
|
|
|
|
|
CreateRoom {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-26 19:28:44 +03:00
|
|
|
Component {
|
|
|
|
id: createDirectComponent
|
|
|
|
|
|
|
|
CreateDirect {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-19 20:34:10 +03:00
|
|
|
ListView {
|
2021-05-21 22:19:03 +03:00
|
|
|
id: roomlist
|
|
|
|
|
2021-05-19 20:34:10 +03:00
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
|
|
|
height: parent.height
|
|
|
|
model: Rooms
|
2021-12-14 06:07:59 +03:00
|
|
|
reuseItems: true
|
2021-05-19 20:34:10 +03:00
|
|
|
|
|
|
|
ScrollHelper {
|
|
|
|
flickable: parent
|
|
|
|
anchors.fill: parent
|
|
|
|
}
|
|
|
|
|
2021-05-21 22:19:03 +03:00
|
|
|
Connections {
|
2021-07-27 23:35:38 +03:00
|
|
|
function onCurrentRoomChanged() {
|
2021-08-11 05:16:27 +03:00
|
|
|
if (Rooms.currentRoom)
|
|
|
|
roomlist.positionViewAtIndex(Rooms.roomidToIndex(Rooms.currentRoom.roomId), ListView.Contain);
|
2021-08-14 00:13:09 +03:00
|
|
|
|
2021-05-21 22:19:03 +03:00
|
|
|
}
|
2021-07-27 23:35:38 +03:00
|
|
|
|
|
|
|
target: Rooms
|
2021-05-21 22:19:03 +03:00
|
|
|
}
|
|
|
|
|
2022-05-06 01:36:38 +03:00
|
|
|
Component {
|
|
|
|
id: roomWindowComponent
|
|
|
|
|
|
|
|
ApplicationWindow {
|
|
|
|
id: roomWindowW
|
|
|
|
|
|
|
|
property var room: null
|
|
|
|
property var roomPreview: null
|
|
|
|
|
2022-08-31 21:44:21 +03:00
|
|
|
Component.onCompleted: {
|
|
|
|
MainWindow.addPerRoomWindow(room.roomId || roomPreview.roomid, roomWindowW);
|
|
|
|
Nheko.setTransientParent(roomWindowW, null);
|
|
|
|
}
|
2022-05-07 19:53:16 +03:00
|
|
|
Component.onDestruction: MainWindow.removePerRoomWindow(room.roomId || roomPreview.roomid, roomWindowW)
|
2022-05-06 01:36:38 +03:00
|
|
|
|
|
|
|
height: 650
|
|
|
|
width: 420
|
|
|
|
minimumWidth: 150
|
|
|
|
minimumHeight: 150
|
|
|
|
palette: Nheko.colors
|
|
|
|
color: Nheko.colors.window
|
2022-05-07 20:03:58 +03:00
|
|
|
title: room.plainRoomName
|
2022-08-31 21:44:21 +03:00
|
|
|
//flags: Qt.Window | Qt.WindowCloseButtonHint | Qt.WindowTitleHint
|
2022-05-06 01:36:38 +03:00
|
|
|
|
|
|
|
Shortcut {
|
|
|
|
sequence: StandardKey.Cancel
|
|
|
|
onActivated: roomWindowW.close()
|
|
|
|
}
|
|
|
|
|
|
|
|
TimelineView {
|
2022-05-12 21:56:22 +03:00
|
|
|
id: timelineView
|
2022-05-06 01:36:38 +03:00
|
|
|
anchors.fill: parent
|
|
|
|
room: roomWindowW.room
|
|
|
|
roomPreview: roomWindowW.roomPreview.roomid ? roomWindowW.roomPreview : null
|
|
|
|
}
|
2022-05-12 21:56:22 +03:00
|
|
|
|
|
|
|
PrivacyScreen {
|
|
|
|
anchors.fill: parent
|
|
|
|
visible: Settings.privacyScreen
|
|
|
|
screenTimeout: Settings.privacyScreenTimeout
|
|
|
|
timelineRoot: timelineView
|
|
|
|
windowTarget: roomWindowW
|
|
|
|
}
|
2022-09-12 02:05:20 +03:00
|
|
|
|
|
|
|
onActiveChanged: { room.lastReadIdOnWindowFocus(); }
|
2022-05-06 01:36:38 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-08-10 01:20:44 +03:00
|
|
|
|
|
|
|
Component {
|
|
|
|
id: nestedSpaceMenuLevel
|
|
|
|
|
|
|
|
SpaceMenuLevel {
|
|
|
|
roomid: roomContextMenu.roomid
|
|
|
|
childMenu: rootSpaceMenu.childMenu
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-05-28 18:25:46 +03:00
|
|
|
Platform.Menu {
|
|
|
|
id: roomContextMenu
|
|
|
|
|
|
|
|
property string roomid
|
|
|
|
property var tags
|
|
|
|
|
|
|
|
function show(roomid_, tags_) {
|
|
|
|
roomid = roomid_;
|
|
|
|
tags = tags_;
|
|
|
|
open();
|
|
|
|
}
|
|
|
|
|
|
|
|
InputDialog {
|
|
|
|
id: newTag
|
|
|
|
|
|
|
|
title: qsTr("New tag")
|
|
|
|
prompt: qsTr("Enter the tag you want to use:")
|
|
|
|
onAccepted: function(text) {
|
|
|
|
Rooms.toggleTag(roomContextMenu.roomid, "u." + text, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-06 01:36:38 +03:00
|
|
|
Platform.MenuItem {
|
|
|
|
text: qsTr("Open separately")
|
|
|
|
onTriggered: {
|
|
|
|
var roomWindow = roomWindowComponent.createObject(null, {
|
|
|
|
"room": Rooms.getRoomById(roomContextMenu.roomid),
|
|
|
|
"roomPreview": Rooms.getRoomPreviewById(roomContextMenu.roomid)
|
|
|
|
});
|
|
|
|
roomWindow.showNormal();
|
|
|
|
destroyOnClose(roomWindow);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-30 14:22:11 +03:00
|
|
|
Platform.MenuItem {
|
|
|
|
text: qsTr("Leave room")
|
2021-09-24 04:18:48 +03:00
|
|
|
onTriggered: TimelineManager.openLeaveRoomDialog(roomContextMenu.roomid)
|
2021-05-28 18:25:46 +03:00
|
|
|
}
|
|
|
|
|
2022-06-24 02:44:50 +03:00
|
|
|
Platform.MenuItem {
|
|
|
|
text: qsTr("Copy room link")
|
|
|
|
onTriggered: Rooms.copyLink(roomContextMenu.roomid)
|
|
|
|
}
|
|
|
|
|
2022-08-10 01:20:44 +03:00
|
|
|
Platform.Menu {
|
|
|
|
id: tagsMenu
|
|
|
|
title: qsTr("Tag room as:")
|
|
|
|
|
|
|
|
Instantiator {
|
|
|
|
model: Communities.tagsWithDefault
|
|
|
|
onObjectAdded: tagsMenu.insertItem(index, object)
|
|
|
|
onObjectRemoved: tagsMenu.removeItem(object)
|
|
|
|
|
|
|
|
delegate: Platform.MenuItem {
|
|
|
|
property string t: modelData
|
|
|
|
|
|
|
|
text: {
|
|
|
|
switch (t) {
|
|
|
|
case "m.favourite":
|
|
|
|
return qsTr("Favourite");
|
|
|
|
case "m.lowpriority":
|
|
|
|
return qsTr("Low priority");
|
|
|
|
case "m.server_notice":
|
|
|
|
return qsTr("Server notice");
|
|
|
|
default:
|
|
|
|
return t.substring(2);
|
|
|
|
}
|
2021-05-28 18:25:46 +03:00
|
|
|
}
|
2022-08-10 01:20:44 +03:00
|
|
|
checkable: true
|
|
|
|
checked: roomContextMenu.tags !== undefined && roomContextMenu.tags.includes(t)
|
|
|
|
onTriggered: Rooms.toggleTag(roomContextMenu.roomid, t, checked)
|
2021-05-28 18:25:46 +03:00
|
|
|
}
|
2022-08-10 01:20:44 +03:00
|
|
|
|
2021-05-28 18:25:46 +03:00
|
|
|
}
|
|
|
|
|
2022-08-10 01:20:44 +03:00
|
|
|
Platform.MenuItem {
|
|
|
|
text: qsTr("Create new tag...")
|
|
|
|
onTriggered: newTag.show()
|
|
|
|
}
|
2021-05-28 18:25:46 +03:00
|
|
|
}
|
|
|
|
|
2022-08-10 01:20:44 +03:00
|
|
|
SpaceMenuLevel {
|
|
|
|
id: rootSpaceMenu
|
2021-05-28 18:25:46 +03:00
|
|
|
|
2022-08-10 01:20:44 +03:00
|
|
|
roomid: roomContextMenu.roomid
|
|
|
|
position: -1
|
2022-10-01 16:20:38 +03:00
|
|
|
title: qsTr("Add or remove from community...")
|
2022-08-10 01:20:44 +03:00
|
|
|
childMenu: nestedSpaceMenuLevel
|
|
|
|
}
|
2021-05-28 18:25:46 +03:00
|
|
|
}
|
|
|
|
|
2021-11-04 01:01:36 +03:00
|
|
|
delegate: ItemDelegate {
|
2021-05-21 22:19:03 +03:00
|
|
|
id: roomItem
|
|
|
|
|
2021-11-04 01:01:36 +03:00
|
|
|
property color backgroundColor: Nheko.colors.window
|
2021-05-21 22:19:03 +03:00
|
|
|
property color importantText: Nheko.colors.text
|
|
|
|
property color unimportantText: Nheko.colors.buttonText
|
|
|
|
property color bubbleBackground: Nheko.colors.highlight
|
|
|
|
property color bubbleText: Nheko.colors.highlightedText
|
2021-07-10 21:28:46 +03:00
|
|
|
required property string roomName
|
|
|
|
required property string roomId
|
|
|
|
required property string avatarUrl
|
|
|
|
required property string time
|
|
|
|
required property string lastMessage
|
|
|
|
required property var tags
|
|
|
|
required property bool isInvite
|
|
|
|
required property bool isSpace
|
|
|
|
required property int notificationCount
|
|
|
|
required property bool hasLoudNotification
|
|
|
|
required property bool hasUnreadMessages
|
2021-08-31 03:08:47 +03:00
|
|
|
required property bool isDirect
|
2021-09-05 03:53:33 +03:00
|
|
|
required property string directChatOtherUserId
|
2021-05-21 22:19:03 +03:00
|
|
|
|
2022-01-02 08:22:27 +03:00
|
|
|
Ripple {
|
|
|
|
color: Qt.rgba(Nheko.colors.dark.r, Nheko.colors.dark.g, Nheko.colors.dark.b, 0.5)
|
|
|
|
}
|
|
|
|
|
2021-06-08 23:18:51 +03:00
|
|
|
height: avatarSize + 2 * Nheko.paddingMedium
|
2021-05-19 20:34:10 +03:00
|
|
|
width: ListView.view.width
|
2021-05-21 22:19:03 +03:00
|
|
|
state: "normal"
|
2021-12-14 06:07:59 +03:00
|
|
|
ToolTip.visible: hovered && collapsed
|
2021-12-31 02:47:14 +03:00
|
|
|
ToolTip.delay: Nheko.tooltipDelay
|
2021-07-10 21:28:46 +03:00
|
|
|
ToolTip.text: roomName
|
2021-11-04 01:01:36 +03:00
|
|
|
onClicked: {
|
|
|
|
console.log("tapped " + roomId);
|
2021-12-02 05:52:48 +03:00
|
|
|
|
|
|
|
if (isSpace && Communities.currentTagId != "space:"+roomId)
|
|
|
|
Communities.currentTagId = "space:"+roomId;
|
|
|
|
|
2021-11-04 01:01:36 +03:00
|
|
|
if (!Rooms.currentRoom || Rooms.currentRoom.roomId !== roomId)
|
|
|
|
Rooms.setCurrentRoom(roomId);
|
|
|
|
else
|
|
|
|
Rooms.resetCurrentRoom();
|
|
|
|
}
|
|
|
|
onPressAndHold: {
|
|
|
|
if (!isInvite)
|
|
|
|
roomContextMenu.show(roomId, tags);
|
|
|
|
|
|
|
|
}
|
2021-05-21 22:19:03 +03:00
|
|
|
states: [
|
|
|
|
State {
|
|
|
|
name: "highlight"
|
2021-11-04 01:01:36 +03:00
|
|
|
when: roomItem.hovered && !((Rooms.currentRoom && roomId == Rooms.currentRoom.roomId) || Rooms.currentRoomPreview.roomid == roomId)
|
2021-05-21 22:19:03 +03:00
|
|
|
|
|
|
|
PropertyChanges {
|
|
|
|
target: roomItem
|
2021-11-04 01:01:36 +03:00
|
|
|
backgroundColor: Nheko.colors.dark
|
2021-05-21 22:19:03 +03:00
|
|
|
importantText: Nheko.colors.brightText
|
|
|
|
unimportantText: Nheko.colors.brightText
|
|
|
|
bubbleBackground: Nheko.colors.highlight
|
|
|
|
bubbleText: Nheko.colors.highlightedText
|
|
|
|
}
|
2021-05-19 20:34:10 +03:00
|
|
|
|
2021-05-21 22:19:03 +03:00
|
|
|
},
|
|
|
|
State {
|
|
|
|
name: "selected"
|
2021-07-17 23:16:02 +03:00
|
|
|
when: (Rooms.currentRoom && roomId == Rooms.currentRoom.roomId) || Rooms.currentRoomPreview.roomid == roomId
|
2021-05-21 22:19:03 +03:00
|
|
|
|
|
|
|
PropertyChanges {
|
|
|
|
target: roomItem
|
2021-11-04 01:01:36 +03:00
|
|
|
backgroundColor: Nheko.colors.highlight
|
2021-05-21 22:19:03 +03:00
|
|
|
importantText: Nheko.colors.highlightedText
|
|
|
|
unimportantText: Nheko.colors.highlightedText
|
|
|
|
bubbleBackground: Nheko.colors.highlightedText
|
|
|
|
bubbleText: Nheko.colors.highlight
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
]
|
2021-05-19 20:34:10 +03:00
|
|
|
|
2021-07-31 12:04:47 +03:00
|
|
|
// NOTE(Nico): We want to prevent the touch areas from overlapping. For some reason we need to add 1px of padding for that...
|
|
|
|
Item {
|
|
|
|
anchors.fill: parent
|
|
|
|
anchors.margins: 1
|
|
|
|
|
|
|
|
TapHandler {
|
|
|
|
acceptedButtons: Qt.RightButton
|
|
|
|
onSingleTapped: {
|
|
|
|
if (!TimelineManager.isInvite)
|
|
|
|
roomContextMenu.show(roomId, tags);
|
2021-05-30 14:22:11 +03:00
|
|
|
|
2021-07-31 12:04:47 +03:00
|
|
|
}
|
|
|
|
gesturePolicy: TapHandler.ReleaseWithinBounds
|
2021-07-31 16:59:19 +03:00
|
|
|
acceptedDevices: PointerDevice.Mouse | PointerDevice.Stylus | PointerDevice.TouchPad
|
2021-05-28 23:14:59 +03:00
|
|
|
}
|
2021-05-28 18:25:46 +03:00
|
|
|
|
2021-05-21 22:19:03 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
RowLayout {
|
2021-05-19 20:34:10 +03:00
|
|
|
spacing: Nheko.paddingMedium
|
|
|
|
anchors.fill: parent
|
|
|
|
anchors.margins: Nheko.paddingMedium
|
|
|
|
|
|
|
|
Avatar {
|
|
|
|
id: avatar
|
|
|
|
|
2021-05-28 18:25:46 +03:00
|
|
|
enabled: false
|
2021-05-19 20:34:10 +03:00
|
|
|
Layout.alignment: Qt.AlignVCenter
|
2021-06-08 23:18:51 +03:00
|
|
|
height: avatarSize
|
|
|
|
width: avatarSize
|
2021-07-10 21:28:46 +03:00
|
|
|
url: avatarUrl.replace("mxc://", "image://MxcImage/")
|
|
|
|
displayName: roomName
|
2021-09-05 03:53:33 +03:00
|
|
|
userid: isDirect ? directChatOtherUserId : ""
|
2021-08-31 03:08:47 +03:00
|
|
|
roomid: roomId
|
2021-06-08 23:18:51 +03:00
|
|
|
|
2022-04-22 01:26:25 +03:00
|
|
|
NotificationBubble {
|
2021-06-08 23:18:51 +03:00
|
|
|
id: collapsedNotificationBubble
|
|
|
|
|
2022-04-22 01:26:25 +03:00
|
|
|
notificationCount: roomItem.notificationCount
|
|
|
|
hasLoudNotification: roomItem.hasLoudNotification
|
|
|
|
bubbleBackgroundColor: roomItem.bubbleBackground
|
|
|
|
bubbleTextColor: roomItem.bubbleText
|
2021-06-08 23:18:51 +03:00
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
anchors.margins: -Nheko.paddingSmall
|
2022-06-06 19:07:25 +03:00
|
|
|
mayBeVisible: collapsed && (isSpace ? Settings.spaceNotifications : true)
|
2021-06-08 23:18:51 +03:00
|
|
|
}
|
|
|
|
|
2021-05-19 20:34:10 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
id: textContent
|
|
|
|
|
2021-06-08 23:18:51 +03:00
|
|
|
visible: !collapsed
|
2021-05-19 20:34:10 +03:00
|
|
|
Layout.alignment: Qt.AlignLeft
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.minimumWidth: 100
|
|
|
|
width: parent.width - avatar.width
|
|
|
|
Layout.preferredWidth: parent.width - avatar.width
|
2022-02-26 18:06:20 +03:00
|
|
|
height: avatar.height
|
|
|
|
spacing: Nheko.paddingSmall
|
2021-05-19 20:34:10 +03:00
|
|
|
|
2022-04-22 01:26:25 +03:00
|
|
|
NotificationBubble {
|
2022-04-20 06:18:11 +03:00
|
|
|
id: notificationBubble
|
|
|
|
|
2022-04-22 01:26:25 +03:00
|
|
|
parent: isSpace ? titleRow : subtextRow
|
|
|
|
notificationCount: roomItem.notificationCount
|
|
|
|
hasLoudNotification: roomItem.hasLoudNotification
|
|
|
|
bubbleBackgroundColor: roomItem.bubbleBackground
|
|
|
|
bubbleTextColor: roomItem.bubbleText
|
|
|
|
Layout.alignment: Qt.AlignRight
|
|
|
|
Layout.leftMargin: Nheko.paddingSmall
|
|
|
|
Layout.preferredWidth: implicitWidth
|
|
|
|
Layout.preferredHeight: implicitHeight
|
2022-06-06 19:07:25 +03:00
|
|
|
mayBeVisible: !collapsed && (isSpace ? Settings.spaceNotifications : true)
|
2022-04-20 06:18:11 +03:00
|
|
|
}
|
|
|
|
|
2021-05-19 20:34:10 +03:00
|
|
|
RowLayout {
|
2022-04-20 06:18:11 +03:00
|
|
|
id: titleRow
|
|
|
|
|
2022-02-26 18:06:20 +03:00
|
|
|
Layout.alignment: Qt.AlignTop
|
2021-05-19 20:34:10 +03:00
|
|
|
Layout.fillWidth: true
|
2022-03-09 20:36:01 +03:00
|
|
|
spacing: Nheko.paddingSmall
|
2021-05-19 20:34:10 +03:00
|
|
|
|
|
|
|
ElidedLabel {
|
2022-03-09 20:36:01 +03:00
|
|
|
id: rN
|
|
|
|
Layout.alignment: Qt.AlignBaseline
|
2021-05-21 22:19:03 +03:00
|
|
|
color: roomItem.importantText
|
2022-02-26 00:57:13 +03:00
|
|
|
elideWidth: width
|
2021-07-10 21:28:46 +03:00
|
|
|
fullText: roomName
|
2021-05-22 11:16:42 +03:00
|
|
|
textFormat: Text.RichText
|
2021-05-19 20:34:10 +03:00
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
|
|
|
|
|
|
|
Label {
|
|
|
|
id: timestamp
|
2021-06-18 17:22:06 +03:00
|
|
|
|
2021-07-10 21:28:46 +03:00
|
|
|
visible: !isInvite && !isSpace
|
2021-06-18 15:10:45 +03:00
|
|
|
width: visible ? 0 : undefined
|
2022-03-09 20:36:01 +03:00
|
|
|
Layout.alignment: Qt.AlignRight | Qt.AlignBaseline
|
2021-05-19 20:34:10 +03:00
|
|
|
font.pixelSize: fontMetrics.font.pixelSize * 0.9
|
2021-05-21 22:19:03 +03:00
|
|
|
color: roomItem.unimportantText
|
2021-07-10 21:28:46 +03:00
|
|
|
text: time
|
2021-05-19 20:34:10 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
RowLayout {
|
2022-04-20 06:18:11 +03:00
|
|
|
id: subtextRow
|
|
|
|
|
2021-05-19 20:34:10 +03:00
|
|
|
Layout.fillWidth: true
|
|
|
|
spacing: 0
|
2021-07-10 21:28:46 +03:00
|
|
|
visible: !isSpace
|
2021-05-24 15:04:07 +03:00
|
|
|
height: visible ? 0 : undefined
|
2022-02-26 18:06:20 +03:00
|
|
|
Layout.alignment: Qt.AlignBottom
|
2021-05-19 20:34:10 +03:00
|
|
|
|
|
|
|
ElidedLabel {
|
2021-05-21 22:19:03 +03:00
|
|
|
color: roomItem.unimportantText
|
2021-05-19 20:34:10 +03:00
|
|
|
font.pixelSize: fontMetrics.font.pixelSize * 0.9
|
2022-02-26 00:57:13 +03:00
|
|
|
elideWidth: width
|
2021-07-10 21:28:46 +03:00
|
|
|
fullText: lastMessage
|
2021-05-22 11:16:42 +03:00
|
|
|
textFormat: Text.RichText
|
2021-05-19 20:34:10 +03:00
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
height: parent.height - Nheko.paddingSmall * 2
|
|
|
|
width: 3
|
|
|
|
color: Nheko.colors.highlight
|
2021-07-10 21:28:46 +03:00
|
|
|
visible: hasUnreadMessages
|
2021-05-19 20:34:10 +03:00
|
|
|
}
|
|
|
|
|
2021-11-04 01:01:36 +03:00
|
|
|
background: Rectangle {
|
|
|
|
color: backgroundColor
|
|
|
|
}
|
|
|
|
|
2021-05-19 20:34:10 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2021-05-15 00:35:34 +03:00
|
|
|
|
|
|
|
background: Rectangle {
|
|
|
|
color: Nheko.theme.sidebarBackground
|
|
|
|
}
|
|
|
|
|
|
|
|
header: ColumnLayout {
|
|
|
|
spacing: 0
|
|
|
|
|
2022-01-30 22:09:58 +03:00
|
|
|
Pane {
|
2021-05-22 16:19:44 +03:00
|
|
|
id: userInfoPanel
|
|
|
|
|
|
|
|
function openUserProfile() {
|
|
|
|
Nheko.updateUserProfile();
|
2022-10-05 18:25:01 +03:00
|
|
|
var userProfile = Qt.createComponent("qrc:/qml/dialogs/UserProfile.qml").createObject(timelineRoot, {
|
2021-05-22 16:19:44 +03:00
|
|
|
"profile": Nheko.currentUser
|
|
|
|
});
|
|
|
|
userProfile.show();
|
2022-02-21 07:01:01 +03:00
|
|
|
timelineRoot.destroyOnClose(userProfile);
|
2021-05-22 16:19:44 +03:00
|
|
|
}
|
|
|
|
|
2022-01-30 22:09:58 +03:00
|
|
|
|
2021-05-15 00:35:34 +03:00
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.alignment: Qt.AlignBottom
|
2022-01-30 22:09:58 +03:00
|
|
|
//Layout.preferredHeight: userInfoGrid.implicitHeight + 2 * Nheko.paddingMedium
|
|
|
|
padding: Nheko.paddingMedium
|
2021-05-15 00:35:34 +03:00
|
|
|
Layout.minimumHeight: 40
|
|
|
|
|
2022-01-30 22:09:58 +03:00
|
|
|
background: Rectangle {color: Nheko.colors.window}
|
|
|
|
|
2021-05-28 18:25:46 +03:00
|
|
|
InputDialog {
|
2021-05-22 16:19:44 +03:00
|
|
|
id: statusDialog
|
|
|
|
|
|
|
|
title: qsTr("Status Message")
|
2021-05-28 18:25:46 +03:00
|
|
|
prompt: qsTr("Enter your status message:")
|
|
|
|
onAccepted: function(text) {
|
|
|
|
Nheko.setStatusMessage(text);
|
2021-05-22 16:19:44 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Platform.Menu {
|
|
|
|
id: userInfoMenu
|
|
|
|
|
|
|
|
Platform.MenuItem {
|
|
|
|
text: qsTr("Profile settings")
|
|
|
|
onTriggered: userInfoPanel.openUserProfile()
|
|
|
|
}
|
|
|
|
|
|
|
|
Platform.MenuItem {
|
|
|
|
text: qsTr("Set status message")
|
|
|
|
onTriggered: statusDialog.show()
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
TapHandler {
|
2021-06-08 23:18:51 +03:00
|
|
|
margin: -Nheko.paddingSmall
|
2021-05-22 16:19:44 +03:00
|
|
|
acceptedButtons: Qt.LeftButton
|
|
|
|
onSingleTapped: userInfoPanel.openUserProfile()
|
|
|
|
onLongPressed: userInfoMenu.open()
|
|
|
|
gesturePolicy: TapHandler.ReleaseWithinBounds
|
|
|
|
}
|
|
|
|
|
|
|
|
TapHandler {
|
2021-06-08 23:18:51 +03:00
|
|
|
margin: -Nheko.paddingSmall
|
2021-05-22 16:19:44 +03:00
|
|
|
acceptedButtons: Qt.RightButton
|
|
|
|
onSingleTapped: userInfoMenu.open()
|
|
|
|
gesturePolicy: TapHandler.ReleaseWithinBounds
|
2021-05-22 15:31:38 +03:00
|
|
|
}
|
|
|
|
|
2022-01-30 22:09:58 +03:00
|
|
|
contentItem: RowLayout {
|
2021-05-15 00:35:34 +03:00
|
|
|
id: userInfoGrid
|
|
|
|
|
2021-06-12 17:05:45 +03:00
|
|
|
property var profile: Nheko.currentUser
|
|
|
|
|
2021-05-15 00:35:34 +03:00
|
|
|
spacing: Nheko.paddingMedium
|
|
|
|
|
|
|
|
Avatar {
|
|
|
|
id: avatar
|
|
|
|
|
|
|
|
Layout.alignment: Qt.AlignVCenter
|
2021-05-19 20:34:10 +03:00
|
|
|
Layout.preferredWidth: fontMetrics.lineSpacing * 2
|
|
|
|
Layout.preferredHeight: fontMetrics.lineSpacing * 2
|
2021-06-12 17:05:45 +03:00
|
|
|
url: (userInfoGrid.profile ? userInfoGrid.profile.avatarUrl : "").replace("mxc://", "image://MxcImage/")
|
|
|
|
displayName: userInfoGrid.profile ? userInfoGrid.profile.displayName : ""
|
|
|
|
userid: userInfoGrid.profile ? userInfoGrid.profile.userid : ""
|
2021-08-03 14:20:36 +03:00
|
|
|
enabled: false
|
2021-05-15 00:35:34 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
id: col
|
|
|
|
|
2021-06-08 23:18:51 +03:00
|
|
|
visible: !collapsed
|
2021-05-15 00:35:34 +03:00
|
|
|
Layout.alignment: Qt.AlignLeft
|
|
|
|
Layout.fillWidth: true
|
2021-05-19 20:34:10 +03:00
|
|
|
width: parent.width - avatar.width - logoutButton.width - Nheko.paddingMedium * 2
|
|
|
|
Layout.preferredWidth: parent.width - avatar.width - logoutButton.width - Nheko.paddingMedium * 2
|
2021-05-15 00:35:34 +03:00
|
|
|
spacing: 0
|
|
|
|
|
2021-05-19 20:34:10 +03:00
|
|
|
ElidedLabel {
|
2021-05-15 00:35:34 +03:00
|
|
|
Layout.alignment: Qt.AlignBottom
|
|
|
|
font.pointSize: fontMetrics.font.pointSize * 1.1
|
|
|
|
font.weight: Font.DemiBold
|
2021-06-12 17:05:45 +03:00
|
|
|
fullText: userInfoGrid.profile ? userInfoGrid.profile.displayName : ""
|
2021-05-19 20:34:10 +03:00
|
|
|
elideWidth: col.width
|
2021-05-15 00:35:34 +03:00
|
|
|
}
|
|
|
|
|
2021-05-19 20:34:10 +03:00
|
|
|
ElidedLabel {
|
2021-05-15 00:35:34 +03:00
|
|
|
Layout.alignment: Qt.AlignTop
|
|
|
|
color: Nheko.colors.buttonText
|
|
|
|
font.pointSize: fontMetrics.font.pointSize * 0.9
|
2021-05-19 20:34:10 +03:00
|
|
|
elideWidth: col.width
|
2021-06-12 17:05:45 +03:00
|
|
|
fullText: userInfoGrid.profile ? userInfoGrid.profile.userid : ""
|
2021-05-15 00:35:34 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Item {
|
|
|
|
}
|
|
|
|
|
|
|
|
ImageButton {
|
|
|
|
id: logoutButton
|
|
|
|
|
2021-06-08 23:18:51 +03:00
|
|
|
visible: !collapsed
|
2021-05-15 00:35:34 +03:00
|
|
|
Layout.alignment: Qt.AlignVCenter
|
2021-11-11 06:29:50 +03:00
|
|
|
Layout.preferredWidth: fontMetrics.lineSpacing * 2
|
|
|
|
Layout.preferredHeight: fontMetrics.lineSpacing * 2
|
2021-11-14 04:23:10 +03:00
|
|
|
image: ":/icons/icons/ui/power-off.svg"
|
2021-05-15 00:35:34 +03:00
|
|
|
ToolTip.visible: hovered
|
2021-12-31 02:47:14 +03:00
|
|
|
ToolTip.delay: Nheko.tooltipDelay
|
2021-05-15 00:35:34 +03:00
|
|
|
ToolTip.text: qsTr("Logout")
|
2021-05-30 13:41:44 +03:00
|
|
|
onClicked: Nheko.openLogoutDialog()
|
2021-05-15 00:35:34 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
color: Nheko.theme.separator
|
|
|
|
height: 2
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
|
|
|
|
2021-11-02 00:20:15 +03:00
|
|
|
Rectangle {
|
|
|
|
id: unverifiedStuffBubble
|
2021-11-04 01:01:36 +03:00
|
|
|
|
|
|
|
color: Qt.lighter(Nheko.theme.orange, verifyButtonHovered.hovered ? 1.2 : 1)
|
2021-11-02 00:20:15 +03:00
|
|
|
Layout.fillWidth: true
|
|
|
|
implicitHeight: explanation.height + Nheko.paddingMedium * 2
|
|
|
|
visible: SelfVerificationStatus.status != SelfVerificationStatus.AllVerified
|
|
|
|
|
|
|
|
RowLayout {
|
|
|
|
id: unverifiedStuffBubbleContainer
|
2021-11-04 01:01:36 +03:00
|
|
|
|
2021-11-02 00:20:15 +03:00
|
|
|
width: parent.width
|
|
|
|
height: explanation.height + Nheko.paddingMedium * 2
|
|
|
|
spacing: 0
|
|
|
|
|
|
|
|
Label {
|
|
|
|
id: explanation
|
2021-11-04 01:01:36 +03:00
|
|
|
|
2021-11-02 00:20:15 +03:00
|
|
|
Layout.margins: Nheko.paddingMedium
|
|
|
|
Layout.rightMargin: Nheko.paddingSmall
|
|
|
|
color: Nheko.colors.buttonText
|
|
|
|
Layout.fillWidth: true
|
2021-11-04 01:01:36 +03:00
|
|
|
text: {
|
|
|
|
switch (SelfVerificationStatus.status) {
|
2021-11-02 00:20:15 +03:00
|
|
|
case SelfVerificationStatus.NoMasterKey:
|
2021-11-04 01:01:36 +03:00
|
|
|
//: Cross-signing setup has not run yet.
|
|
|
|
return qsTr("Encryption not set up");
|
2021-11-02 00:20:15 +03:00
|
|
|
case SelfVerificationStatus.UnverifiedMasterKey:
|
2021-11-04 01:01:36 +03:00
|
|
|
//: The user just signed in with this device and hasn't verified their master key.
|
|
|
|
return qsTr("Unverified login");
|
2021-11-02 00:20:15 +03:00
|
|
|
case SelfVerificationStatus.UnverifiedDevices:
|
2021-11-04 01:01:36 +03:00
|
|
|
//: There are unverified devices signed in to this account.
|
|
|
|
return qsTr("Please verify your other devices");
|
2021-11-02 00:20:15 +03:00
|
|
|
default:
|
2021-11-04 01:01:36 +03:00
|
|
|
return "";
|
|
|
|
}
|
2021-11-02 00:20:15 +03:00
|
|
|
}
|
|
|
|
textFormat: Text.PlainText
|
|
|
|
wrapMode: Text.Wrap
|
|
|
|
}
|
|
|
|
|
|
|
|
ImageButton {
|
|
|
|
id: closeUnverifiedBubble
|
|
|
|
|
|
|
|
Layout.rightMargin: Nheko.paddingMedium
|
2021-11-17 04:35:10 +03:00
|
|
|
Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
|
2021-11-02 00:20:15 +03:00
|
|
|
hoverEnabled: true
|
|
|
|
width: fontMetrics.font.pixelSize
|
|
|
|
height: fontMetrics.font.pixelSize
|
2021-11-14 04:23:10 +03:00
|
|
|
image: ":/icons/icons/ui/dismiss.svg"
|
2021-11-02 00:20:15 +03:00
|
|
|
ToolTip.visible: closeUnverifiedBubble.hovered
|
2021-12-31 02:47:14 +03:00
|
|
|
ToolTip.delay: Nheko.tooltipDelay
|
2021-11-02 00:20:15 +03:00
|
|
|
ToolTip.text: qsTr("Close")
|
|
|
|
onClicked: unverifiedStuffBubble.visible = false
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
HoverHandler {
|
|
|
|
id: verifyButtonHovered
|
|
|
|
|
2021-11-04 01:01:36 +03:00
|
|
|
enabled: !closeUnverifiedBubble.hovered
|
2021-11-02 00:20:15 +03:00
|
|
|
acceptedDevices: PointerDevice.Mouse | PointerDevice.Stylus | PointerDevice.TouchPad
|
|
|
|
}
|
|
|
|
|
|
|
|
TapHandler {
|
|
|
|
enabled: !closeUnverifiedBubble.hovered
|
|
|
|
acceptedButtons: Qt.LeftButton
|
|
|
|
onSingleTapped: {
|
2021-11-04 01:01:36 +03:00
|
|
|
if (SelfVerificationStatus.status == SelfVerificationStatus.UnverifiedDevices)
|
2021-11-02 00:20:15 +03:00
|
|
|
SelfVerificationStatus.verifyUnverifiedDevices();
|
2021-11-04 01:01:36 +03:00
|
|
|
else
|
2021-11-02 00:20:15 +03:00
|
|
|
SelfVerificationStatus.statusChanged();
|
|
|
|
}
|
|
|
|
}
|
2021-11-04 01:01:36 +03:00
|
|
|
|
2021-11-02 00:20:15 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
color: Nheko.theme.separator
|
|
|
|
height: 1
|
|
|
|
Layout.fillWidth: true
|
|
|
|
visible: unverifiedStuffBubble.visible
|
|
|
|
}
|
|
|
|
|
2021-05-15 00:35:34 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
footer: ColumnLayout {
|
|
|
|
spacing: 0
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
color: Nheko.theme.separator
|
|
|
|
height: 1
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
|
|
|
|
2022-01-30 22:09:58 +03:00
|
|
|
Pane {
|
2021-05-15 00:35:34 +03:00
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.alignment: Qt.AlignBottom
|
|
|
|
Layout.minimumHeight: 40
|
|
|
|
|
2022-01-30 22:09:58 +03:00
|
|
|
horizontalPadding: Nheko.paddingMedium
|
|
|
|
verticalPadding: 0
|
2021-05-15 00:35:34 +03:00
|
|
|
|
2022-01-30 22:09:58 +03:00
|
|
|
background: Rectangle {color: Nheko.colors.window}
|
|
|
|
contentItem: RowLayout {
|
|
|
|
id: buttonRow
|
2021-05-15 00:35:34 +03:00
|
|
|
|
|
|
|
ImageButton {
|
2021-06-13 04:18:31 +03:00
|
|
|
Layout.fillWidth: true
|
2021-05-15 00:35:34 +03:00
|
|
|
hoverEnabled: true
|
|
|
|
width: 22
|
|
|
|
height: 22
|
2021-11-14 04:23:10 +03:00
|
|
|
image: ":/icons/icons/ui/add-square-button.svg"
|
2021-05-15 00:35:34 +03:00
|
|
|
ToolTip.visible: hovered
|
2021-12-31 02:47:14 +03:00
|
|
|
ToolTip.delay: Nheko.tooltipDelay
|
2021-05-15 00:35:34 +03:00
|
|
|
ToolTip.text: qsTr("Start a new chat")
|
|
|
|
Layout.margins: Nheko.paddingMedium
|
2021-05-30 13:41:44 +03:00
|
|
|
onClicked: roomJoinCreateMenu.open(parent)
|
|
|
|
|
|
|
|
Platform.Menu {
|
|
|
|
id: roomJoinCreateMenu
|
|
|
|
|
|
|
|
Platform.MenuItem {
|
|
|
|
text: qsTr("Join a room")
|
|
|
|
onTriggered: Nheko.openJoinRoomDialog()
|
|
|
|
}
|
|
|
|
|
|
|
|
Platform.MenuItem {
|
|
|
|
text: qsTr("Create a new room")
|
2022-03-26 00:30:19 +03:00
|
|
|
onTriggered: {
|
|
|
|
var createRoom = createRoomComponent.createObject(timelineRoot);
|
|
|
|
createRoom.show();
|
|
|
|
timelineRoot.destroyOnClose(createRoom);
|
|
|
|
}
|
2021-05-30 13:41:44 +03:00
|
|
|
}
|
|
|
|
|
2022-03-26 19:28:44 +03:00
|
|
|
Platform.MenuItem {
|
|
|
|
text: qsTr("Start a direct chat")
|
|
|
|
onTriggered: {
|
|
|
|
var createDirect = createDirectComponent.createObject(timelineRoot);
|
|
|
|
createDirect.show();
|
|
|
|
timelineRoot.destroyOnClose(createDirect);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-05 03:00:20 +03:00
|
|
|
Platform.MenuItem {
|
|
|
|
text: qsTr("Create a new community")
|
|
|
|
onTriggered: {
|
|
|
|
var createRoom = createRoomComponent.createObject(timelineRoot, { "space": true });
|
|
|
|
createRoom.show();
|
|
|
|
timelineRoot.destroyOnClose(createRoom);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-30 13:41:44 +03:00
|
|
|
}
|
2021-05-30 14:22:11 +03:00
|
|
|
|
2021-05-15 00:35:34 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
ImageButton {
|
2021-06-08 23:18:51 +03:00
|
|
|
visible: !collapsed
|
2021-06-13 04:18:31 +03:00
|
|
|
Layout.fillWidth: true
|
2021-05-15 00:35:34 +03:00
|
|
|
hoverEnabled: true
|
|
|
|
width: 22
|
|
|
|
height: 22
|
2022-07-08 18:28:28 +03:00
|
|
|
image: ":/icons/icons/ui/room-directory.svg"
|
2021-05-15 00:35:34 +03:00
|
|
|
ToolTip.visible: hovered
|
2021-12-31 02:47:14 +03:00
|
|
|
ToolTip.delay: Nheko.tooltipDelay
|
2021-05-15 00:35:34 +03:00
|
|
|
ToolTip.text: qsTr("Room directory")
|
|
|
|
Layout.margins: Nheko.paddingMedium
|
2021-08-18 00:31:25 +03:00
|
|
|
onClicked: {
|
2021-07-29 05:31:31 +03:00
|
|
|
var win = roomDirectoryComponent.createObject(timelineRoot);
|
|
|
|
win.show();
|
2022-02-21 07:01:01 +03:00
|
|
|
timelineRoot.destroyOnClose(win);
|
2021-08-18 00:31:25 +03:00
|
|
|
}
|
2021-05-15 00:35:34 +03:00
|
|
|
}
|
|
|
|
|
2022-02-18 23:06:28 +03:00
|
|
|
ImageButton {
|
|
|
|
visible: !collapsed
|
|
|
|
Layout.fillWidth: true
|
|
|
|
hoverEnabled: true
|
|
|
|
ripple: false
|
|
|
|
width: 22
|
|
|
|
height: 22
|
|
|
|
image: ":/icons/icons/ui/search.svg"
|
|
|
|
ToolTip.visible: hovered
|
|
|
|
ToolTip.delay: Nheko.tooltipDelay
|
|
|
|
ToolTip.text: qsTr("Search rooms (Ctrl+K)")
|
|
|
|
Layout.margins: Nheko.paddingMedium
|
|
|
|
onClicked: {
|
2022-11-01 16:56:23 +03:00
|
|
|
var quickSwitch = Qt.createComponent("qrc:/qml/QuickSwitcher.qml").createObject(timelineRoot);
|
2022-02-18 23:06:28 +03:00
|
|
|
quickSwitch.open();
|
2022-11-01 16:56:23 +03:00
|
|
|
destroyOnClosed(quickSwitch);
|
2022-02-18 23:06:28 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-15 00:35:34 +03:00
|
|
|
ImageButton {
|
2021-06-08 23:18:51 +03:00
|
|
|
visible: !collapsed
|
2021-06-13 04:18:31 +03:00
|
|
|
Layout.fillWidth: true
|
2021-05-15 00:35:34 +03:00
|
|
|
hoverEnabled: true
|
2022-01-09 02:28:03 +03:00
|
|
|
ripple: false
|
2021-05-15 00:35:34 +03:00
|
|
|
width: 22
|
|
|
|
height: 22
|
2021-11-14 04:23:10 +03:00
|
|
|
image: ":/icons/icons/ui/settings.svg"
|
2021-05-15 00:35:34 +03:00
|
|
|
ToolTip.visible: hovered
|
2021-12-31 02:47:14 +03:00
|
|
|
ToolTip.delay: Nheko.tooltipDelay
|
2021-05-15 00:35:34 +03:00
|
|
|
ToolTip.text: qsTr("User settings")
|
|
|
|
Layout.margins: Nheko.paddingMedium
|
2022-01-09 02:28:03 +03:00
|
|
|
onClicked: mainWindow.push(userSettingsPage);
|
2021-05-15 00:35:34 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|