2018-07-12 01:44:41 +00:00
|
|
|
import QtQuick 2.9
|
|
|
|
import QtQuick.Controls 2.2
|
|
|
|
import QtQuick.Layouts 1.3
|
2018-02-23 14:39:14 +00:00
|
|
|
import QtGraphicalEffects 1.0
|
2018-07-12 01:44:41 +00:00
|
|
|
import QtQuick.Controls.Material 2.2
|
|
|
|
import QtQml.Models 2.3
|
2018-07-07 09:38:20 +00:00
|
|
|
import Matrique 0.1
|
2018-07-13 04:06:27 +00:00
|
|
|
import SortFilterProxyModel 0.2
|
2018-08-21 14:57:15 +00:00
|
|
|
import MatriqueSettings 0.1
|
2018-07-07 09:38:20 +00:00
|
|
|
|
2018-02-23 14:39:14 +00:00
|
|
|
import "qrc:/qml/component"
|
|
|
|
|
|
|
|
Item {
|
2018-07-13 04:06:27 +00:00
|
|
|
property alias listModel: roomListProxyModel.sourceModel
|
2018-08-22 15:21:39 +00:00
|
|
|
property alias rawCurrentIndex: listView.currentIndex
|
2018-07-22 04:09:15 +00:00
|
|
|
readonly property int currentIndex: roomListProxyModel.mapToSource(listView.currentIndex)
|
|
|
|
readonly property var currentRoom: currentIndex != -1 ? listModel.roomAt(currentIndex) : null
|
2018-08-21 14:57:15 +00:00
|
|
|
readonly property bool mini: MatriqueSettings.miniMode // Used as an indicator of whether the listform should be displayed as "Mini mode".
|
2018-08-06 16:17:58 +00:00
|
|
|
signal enterRoom()
|
2018-07-07 09:38:20 +00:00
|
|
|
|
2018-02-23 14:39:14 +00:00
|
|
|
ColumnLayout {
|
|
|
|
anchors.fill: parent
|
|
|
|
spacing: 0
|
|
|
|
|
2018-08-09 11:58:19 +00:00
|
|
|
Rectangle {
|
2018-02-23 14:39:14 +00:00
|
|
|
z: 10
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.preferredHeight: 80
|
2018-08-09 11:58:19 +00:00
|
|
|
color: Qt.tint(Material.accent, "#20FFFFFF")
|
2018-02-23 14:39:14 +00:00
|
|
|
|
|
|
|
TextField {
|
2018-07-07 09:38:20 +00:00
|
|
|
id: searchField
|
2018-08-09 11:58:19 +00:00
|
|
|
width: parent.width - 18
|
2018-02-23 14:39:14 +00:00
|
|
|
height: 36
|
2018-08-19 06:32:18 +00:00
|
|
|
color: "white"
|
|
|
|
leftPadding: mini ? 4 : 32
|
2018-02-23 14:39:14 +00:00
|
|
|
topPadding: 0
|
|
|
|
bottomPadding: 0
|
2018-08-09 11:58:19 +00:00
|
|
|
anchors.centerIn: parent
|
2018-02-23 14:39:14 +00:00
|
|
|
|
2018-08-09 11:58:19 +00:00
|
|
|
background: Row {
|
2018-08-19 06:32:18 +00:00
|
|
|
visible: !parent.text
|
|
|
|
|
2018-08-09 11:58:19 +00:00
|
|
|
MaterialIcon {
|
|
|
|
icon: "\ue8b6"
|
|
|
|
color: "white"
|
2018-02-23 14:39:14 +00:00
|
|
|
|
2018-08-09 11:58:19 +00:00
|
|
|
width: mini ? parent.width : parent.height
|
|
|
|
height: parent.height
|
2018-02-23 14:39:14 +00:00
|
|
|
}
|
|
|
|
|
2018-08-09 11:58:19 +00:00
|
|
|
Label {
|
2018-02-23 14:39:14 +00:00
|
|
|
height: parent.height
|
2018-08-09 11:58:19 +00:00
|
|
|
visible: !mini
|
|
|
|
text: "Search"
|
2018-02-23 14:39:14 +00:00
|
|
|
color: "white"
|
2018-08-09 11:58:19 +00:00
|
|
|
font.pointSize: 12
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
verticalAlignment: Text.AlignVCenter
|
|
|
|
}
|
|
|
|
}
|
2018-02-23 14:39:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-09 11:58:19 +00:00
|
|
|
Rectangle {
|
2018-02-23 14:39:14 +00:00
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
|
|
|
|
2018-08-09 11:58:19 +00:00
|
|
|
color: Material.theme == Material.Light ? "#eaeaea" : "#242424"
|
2018-03-01 11:56:02 +00:00
|
|
|
|
2018-08-09 11:58:19 +00:00
|
|
|
Label {
|
|
|
|
z: 10
|
|
|
|
text: mini ? "Empty" : "Here? No, not here."
|
|
|
|
anchors.centerIn: parent
|
|
|
|
visible: listView.count === 0
|
2018-02-23 14:39:14 +00:00
|
|
|
}
|
|
|
|
|
2018-07-13 04:06:27 +00:00
|
|
|
SortFilterProxyModel {
|
|
|
|
id: roomListProxyModel
|
|
|
|
filters: RegExpFilter {
|
|
|
|
roleName: "name"
|
|
|
|
pattern: searchField.text
|
|
|
|
caseSensitivity: Qt.CaseInsensitive
|
|
|
|
}
|
2018-08-17 04:55:57 +00:00
|
|
|
proxyRoles: ExpressionRole {
|
|
|
|
name: "display"
|
|
|
|
expression: {
|
|
|
|
switch (category) {
|
|
|
|
case 1: return "Invited"
|
|
|
|
case 2: return "Favorites"
|
|
|
|
case 3: return "Rooms"
|
|
|
|
case 4: return "People"
|
|
|
|
case 5: return "Low Priorities"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-13 04:06:27 +00:00
|
|
|
sorters: [
|
2018-08-17 07:58:08 +00:00
|
|
|
RoleSorter { roleName: "category" },
|
2018-08-22 15:21:39 +00:00
|
|
|
RoleSorter {
|
|
|
|
roleName: "unreadCount"
|
|
|
|
sortOrder: Qt.DescendingOrder
|
|
|
|
},
|
2018-07-13 04:06:27 +00:00
|
|
|
StringSorter { roleName: "name" }
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
2018-02-23 14:39:14 +00:00
|
|
|
ListView {
|
|
|
|
id: listView
|
2018-08-09 11:58:19 +00:00
|
|
|
anchors.fill: parent
|
2018-02-23 14:39:14 +00:00
|
|
|
|
2018-07-13 04:06:27 +00:00
|
|
|
model: roomListProxyModel
|
|
|
|
|
2018-02-23 14:39:14 +00:00
|
|
|
highlight: Rectangle {
|
|
|
|
color: Material.accent
|
|
|
|
opacity: 0.2
|
|
|
|
}
|
2018-07-07 09:38:20 +00:00
|
|
|
highlightMoveDuration: 250
|
2018-08-04 20:14:45 +00:00
|
|
|
highlightResizeDuration: 0
|
2018-02-23 14:39:14 +00:00
|
|
|
|
2018-07-08 12:54:06 +00:00
|
|
|
currentIndex: -1
|
|
|
|
|
2018-08-04 12:40:23 +00:00
|
|
|
boundsBehavior: Flickable.DragOverBounds
|
|
|
|
|
2018-02-23 14:39:14 +00:00
|
|
|
ScrollBar.vertical: ScrollBar { id: scrollBar }
|
|
|
|
|
2018-08-22 15:28:59 +00:00
|
|
|
delegate: Item {
|
2018-07-13 04:06:27 +00:00
|
|
|
width: parent.width
|
|
|
|
height: 80
|
2018-08-21 14:57:15 +00:00
|
|
|
|
|
|
|
AutoMouseArea {
|
|
|
|
anchors.fill: parent
|
|
|
|
|
|
|
|
onPressed: listView.currentIndex = index
|
|
|
|
onSecondaryClicked: roomListMenu.popup()
|
|
|
|
onPrimaryClicked: category === RoomType.Invited ? inviteDialog.open() : enterRoom()
|
|
|
|
}
|
2018-07-13 04:06:27 +00:00
|
|
|
|
|
|
|
ToolTip.visible: mini && hovered
|
|
|
|
ToolTip.text: name
|
|
|
|
|
2018-08-06 15:51:22 +00:00
|
|
|
Rectangle {
|
|
|
|
width: 4
|
|
|
|
height: parent.height
|
|
|
|
color: Qt.tint(Material.accent, "#20FFFFFF")
|
|
|
|
visible: unreadCount > 0
|
|
|
|
}
|
|
|
|
|
2018-08-22 15:28:59 +00:00
|
|
|
RowLayout {
|
2018-07-13 04:06:27 +00:00
|
|
|
anchors.fill: parent
|
|
|
|
anchors.margins: 16
|
|
|
|
spacing: 16
|
|
|
|
|
|
|
|
ImageStatus {
|
|
|
|
Layout.preferredWidth: height
|
|
|
|
Layout.fillHeight: true
|
|
|
|
|
|
|
|
source: avatar ? "image://mxc/" + avatar : ""
|
|
|
|
displayText: name
|
|
|
|
}
|
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
|
|
|
Layout.alignment: Qt.AlignHCenter
|
|
|
|
|
|
|
|
visible: parent.width > 80
|
|
|
|
|
|
|
|
Label {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
|
|
|
|
2018-08-22 15:21:39 +00:00
|
|
|
text: name || "No Name"
|
2018-07-13 04:06:27 +00:00
|
|
|
font.pointSize: 16
|
|
|
|
elide: Text.ElideRight
|
|
|
|
wrapMode: Text.NoWrap
|
|
|
|
}
|
|
|
|
|
|
|
|
Label {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
|
|
|
|
2018-08-22 15:21:39 +00:00
|
|
|
text: lastEvent || topic
|
2018-07-13 04:06:27 +00:00
|
|
|
elide: Text.ElideRight
|
|
|
|
wrapMode: Text.NoWrap
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-17 04:55:57 +00:00
|
|
|
section.property: "display"
|
2018-07-13 04:06:27 +00:00
|
|
|
section.criteria: ViewSection.FullString
|
2018-07-13 04:41:21 +00:00
|
|
|
section.delegate: Label {
|
2018-07-13 04:06:27 +00:00
|
|
|
width: parent.width
|
2018-07-13 04:41:21 +00:00
|
|
|
height: 24
|
|
|
|
text: section
|
|
|
|
color: "grey"
|
2018-07-20 04:14:02 +00:00
|
|
|
leftPadding: mini ? undefined : 16
|
2018-07-14 11:24:20 +00:00
|
|
|
elide: Text.ElideRight
|
2018-07-13 04:41:21 +00:00
|
|
|
verticalAlignment: Text.AlignVCenter
|
2018-07-20 04:14:02 +00:00
|
|
|
horizontalAlignment: mini ? Text.AlignHCenter : undefined
|
|
|
|
background: Rectangle {
|
2018-08-17 04:55:57 +00:00
|
|
|
anchors.fill: parent
|
2018-07-20 04:14:02 +00:00
|
|
|
color: Material.theme == Material.Light ? "#dbdbdb" : "#363636"
|
|
|
|
}
|
2018-07-13 04:06:27 +00:00
|
|
|
}
|
2018-08-07 15:41:18 +00:00
|
|
|
|
2018-08-17 04:55:57 +00:00
|
|
|
Dialog {
|
|
|
|
id: inviteDialog
|
|
|
|
parent: ApplicationWindow.overlay
|
|
|
|
|
|
|
|
x: (window.width - width) / 2
|
|
|
|
y: (window.height - height) / 2
|
|
|
|
width: 360
|
|
|
|
|
|
|
|
title: "Action Required"
|
|
|
|
modal: true
|
|
|
|
standardButtons: Dialog.Ok | Dialog.Cancel
|
|
|
|
|
|
|
|
contentItem: Label { text: "Accept this invitation?" }
|
|
|
|
|
2018-08-18 08:02:47 +00:00
|
|
|
onAccepted: currentRoom.acceptInvitation()
|
2018-08-21 14:57:15 +00:00
|
|
|
onRejected: currentRoom.forget()
|
2018-08-17 04:55:57 +00:00
|
|
|
}
|
|
|
|
|
2018-08-07 15:41:18 +00:00
|
|
|
Menu {
|
|
|
|
id: roomListMenu
|
|
|
|
|
|
|
|
MenuItem {
|
|
|
|
text: "Favourite"
|
|
|
|
checkable: true
|
|
|
|
checked: currentRoom && currentRoom.isFavourite
|
|
|
|
onTriggered: currentRoom.isFavourite ? currentRoom.removeTag("m.favourite") : currentRoom.addTag("m.favourite", "1")
|
|
|
|
}
|
|
|
|
MenuItem {
|
|
|
|
text: "Deprioritize"
|
|
|
|
checkable: true
|
|
|
|
checked: currentRoom && currentRoom.isLowPriority
|
|
|
|
onTriggered: currentRoom.isLowPriority ? currentRoom.removeTag("m.lowpriority") : currentRoom.addTag("m.lowpriority", "1")
|
|
|
|
}
|
|
|
|
MenuSeparator {}
|
|
|
|
MenuItem {
|
|
|
|
text: "Mark as Read"
|
|
|
|
onTriggered: currentRoom.markAllMessagesAsRead()
|
|
|
|
}
|
|
|
|
MenuItem {
|
|
|
|
text: "Leave Room"
|
2018-08-18 08:02:47 +00:00
|
|
|
onTriggered: currentRoom.forget()
|
2018-08-07 15:41:18 +00:00
|
|
|
}
|
|
|
|
}
|
2018-02-23 14:39:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|