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-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-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-07-20 05:50:25 +00:00
|
|
|
readonly property bool mini: setting.miniMode // Used as an indicator of whether the listform should be displayed as "Mini mode".
|
2018-07-07 09:38:20 +00:00
|
|
|
|
2018-02-23 14:39:14 +00:00
|
|
|
ColumnLayout {
|
|
|
|
anchors.fill: parent
|
|
|
|
spacing: 0
|
|
|
|
|
|
|
|
Pane {
|
|
|
|
z: 10
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.preferredHeight: 80
|
|
|
|
background: Rectangle {
|
|
|
|
color: Qt.tint(Material.accent, "#20FFFFFF")
|
|
|
|
}
|
|
|
|
|
|
|
|
TextField {
|
2018-07-07 09:38:20 +00:00
|
|
|
id: searchField
|
2018-02-23 14:39:14 +00:00
|
|
|
width: parent.width
|
|
|
|
height: 36
|
2018-07-07 09:38:20 +00:00
|
|
|
leftPadding: mini ? 4 : 16
|
2018-02-23 14:39:14 +00:00
|
|
|
topPadding: 0
|
|
|
|
bottomPadding: 0
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
|
|
|
|
background: Item {
|
|
|
|
Row {
|
|
|
|
anchors.fill: parent
|
|
|
|
|
2018-07-07 09:38:20 +00:00
|
|
|
MaterialIcon {
|
|
|
|
icon: "\ue8b6"
|
2018-02-23 14:39:14 +00:00
|
|
|
color: "white"
|
2018-07-07 09:38:20 +00:00
|
|
|
|
|
|
|
width: mini ? parent.width : parent.height
|
|
|
|
height: parent.height
|
2018-02-23 14:39:14 +00:00
|
|
|
}
|
|
|
|
|
2018-07-10 04:18:21 +00:00
|
|
|
Label {
|
2018-02-23 14:39:14 +00:00
|
|
|
height: parent.height
|
2018-07-07 09:38:20 +00:00
|
|
|
visible: !mini
|
2018-02-23 14:39:14 +00:00
|
|
|
text: "Search"
|
|
|
|
color: "white"
|
|
|
|
font.pointSize: 12
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
verticalAlignment: Text.AlignVCenter
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Rectangle {
|
2018-07-09 02:45:26 +00:00
|
|
|
width: searchField.activeFocus || searchField.text ? parent.width : 0
|
2018-02-23 14:39:14 +00:00
|
|
|
height: parent.height
|
|
|
|
color: "white"
|
|
|
|
|
|
|
|
Behavior on width {
|
2018-07-07 09:38:20 +00:00
|
|
|
PropertyAnimation { easing.type: Easing.InOutCubic; duration: 200 }
|
2018-02-23 14:39:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Pane {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
|
|
|
padding: 0
|
|
|
|
|
2018-03-01 11:56:02 +00:00
|
|
|
background: Item {
|
|
|
|
anchors.fill: parent
|
|
|
|
Rectangle {
|
|
|
|
anchors.fill: parent
|
2018-07-07 09:38:20 +00:00
|
|
|
color: Material.theme == Material.Light ? "#eaeaea" : "#242424"
|
2018-03-01 11:56:02 +00:00
|
|
|
}
|
|
|
|
|
2018-07-07 09:38:20 +00:00
|
|
|
Label {
|
2018-03-01 11:56:02 +00:00
|
|
|
z: 10
|
2018-07-07 09:38:20 +00:00
|
|
|
text: mini ? "Empty" : "Here? No, not here."
|
2018-03-01 11:56:02 +00:00
|
|
|
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
|
|
|
|
}
|
|
|
|
proxyRoles: [
|
|
|
|
ExpressionRole { name: "isFavorite"; expression: category === "Favorites" },
|
2018-07-18 14:16:03 +00:00
|
|
|
ExpressionRole { name: "isDirectChat"; expression: category === "People" },
|
2018-07-13 04:06:27 +00:00
|
|
|
ExpressionRole { name: "isLowPriority"; expression: category === "Low Priorities" }
|
|
|
|
]
|
|
|
|
sorters: [
|
|
|
|
RoleSorter { roleName: "isFavorite"; sortOrder: Qt.DescendingOrder },
|
|
|
|
RoleSorter { roleName: "isLowPriority" },
|
2018-07-18 14:16:03 +00:00
|
|
|
RoleSorter { roleName: "isDirectChat" },
|
2018-07-13 04:06:27 +00:00
|
|
|
StringSorter { roleName: "name" }
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-02-23 14:39:14 +00:00
|
|
|
ListView {
|
|
|
|
id: listView
|
|
|
|
width: parent.width
|
|
|
|
height: parent.height
|
|
|
|
|
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-07-22 04:09:15 +00:00
|
|
|
maximumFlickVelocity: 2048
|
2018-02-23 14:39:14 +00:00
|
|
|
|
2018-07-08 12:54:06 +00:00
|
|
|
currentIndex: -1
|
|
|
|
|
2018-02-23 14:39:14 +00:00
|
|
|
ScrollBar.vertical: ScrollBar { id: scrollBar }
|
|
|
|
|
2018-07-13 04:06:27 +00:00
|
|
|
delegate: ItemDelegate {
|
|
|
|
width: parent.width
|
|
|
|
height: 80
|
|
|
|
onClicked: listView.currentIndex = index
|
2018-07-22 04:09:15 +00:00
|
|
|
onPressAndHold: {
|
|
|
|
roomListMenu.roomIndex = index
|
|
|
|
roomListMenu.popup()
|
|
|
|
}
|
2018-07-13 04:06:27 +00:00
|
|
|
|
|
|
|
ToolTip.visible: mini && hovered
|
|
|
|
ToolTip.text: name
|
|
|
|
|
|
|
|
contentItem: RowLayout {
|
|
|
|
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-07-20 04:14:02 +00:00
|
|
|
text: name ? 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
|
|
|
|
|
|
|
|
text: topic ? topic : "No topic yet."
|
|
|
|
elide: Text.ElideRight
|
|
|
|
wrapMode: Text.NoWrap
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
section.property: "category"
|
|
|
|
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 {
|
|
|
|
anchors.fill:parent
|
|
|
|
color: Material.theme == Material.Light ? "#dbdbdb" : "#363636"
|
|
|
|
}
|
2018-07-13 04:06:27 +00:00
|
|
|
}
|
2018-07-22 04:09:15 +00:00
|
|
|
|
|
|
|
Menu {
|
|
|
|
property int roomIndex: -1
|
|
|
|
readonly property int roomProxyIndex: roomListProxyModel.mapToSource(roomIndex)
|
|
|
|
readonly property var room: roomProxyIndex != -1 ? listModel.roomAt(roomProxyIndex) : null
|
|
|
|
|
|
|
|
id: roomListMenu
|
|
|
|
|
|
|
|
MenuItem {
|
2018-08-01 18:04:45 +00:00
|
|
|
text: "Favourite" + (roomListMenu.room && roomListMenu.room.isFavourite ? " \u2713" : "")
|
2018-07-23 14:41:18 +00:00
|
|
|
onTriggered: roomListMenu.room.isFavourite ? roomListMenu.room.removeTag("m.favourite") : roomListMenu.room.addTag("m.favourite", "1")
|
2018-07-22 04:09:15 +00:00
|
|
|
}
|
|
|
|
MenuItem {
|
2018-08-01 18:04:45 +00:00
|
|
|
text: "Deprioritize" + (roomListMenu.room && roomListMenu.room.isLowPriority ? " \u2713" : "")
|
2018-07-23 14:41:18 +00:00
|
|
|
onTriggered: roomListMenu.room.isLowPriority ? roomListMenu.room.removeTag("m.lowpriority") : roomListMenu.room.addTag("m.lowpriority", "1")
|
2018-07-22 04:09:15 +00:00
|
|
|
}
|
2018-07-30 14:42:27 +00:00
|
|
|
MenuItem {
|
|
|
|
text: "Leave Room"
|
2018-08-01 12:26:29 +00:00
|
|
|
onTriggered: matriqueController.forgetRoom(roomListMenu.room.id)
|
2018-07-30 14:42:27 +00:00
|
|
|
}
|
2018-07-22 04:09:15 +00:00
|
|
|
}
|
2018-02-23 14:39:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|