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-09-17 13:01:02 +00:00
|
|
|
import Spectral 0.1
|
2018-07-13 04:06:27 +00:00
|
|
|
import SortFilterProxyModel 0.2
|
2018-09-17 13:01:02 +00:00
|
|
|
import Spectral.Settings 0.1
|
2018-07-07 09:38:20 +00:00
|
|
|
|
2018-09-11 05:14:56 +00:00
|
|
|
import "qrc:/qml/component"
|
|
|
|
import "qrc:/qml/menu"
|
2018-09-10 00:06:32 +00:00
|
|
|
import "qrc:/js/util.js" as Util
|
2018-02-23 14:39:14 +00:00
|
|
|
|
|
|
|
Item {
|
2018-07-13 04:06:27 +00:00
|
|
|
property alias listModel: roomListProxyModel.sourceModel
|
2018-08-24 05:25:41 +00:00
|
|
|
property var enteredRoom: null
|
2018-07-07 09:38:20 +00:00
|
|
|
|
2018-09-02 13:26:42 +00:00
|
|
|
Label {
|
|
|
|
z: 10
|
2018-09-04 13:13:14 +00:00
|
|
|
|
2018-09-02 13:26:42 +00:00
|
|
|
text: MSettings.miniMode ? "Empty" : "Here? No, not here."
|
|
|
|
anchors.centerIn: parent
|
|
|
|
visible: listView.count === 0
|
|
|
|
}
|
|
|
|
|
2018-02-23 14:39:14 +00:00
|
|
|
ColumnLayout {
|
|
|
|
anchors.fill: parent
|
|
|
|
spacing: 0
|
|
|
|
|
2018-09-02 13:26:42 +00:00
|
|
|
TextField {
|
2018-02-23 14:39:14 +00:00
|
|
|
Layout.fillWidth: true
|
2018-09-02 13:26:42 +00:00
|
|
|
Layout.preferredHeight: 40
|
|
|
|
Layout.margins: 12
|
2018-09-04 13:13:14 +00:00
|
|
|
|
|
|
|
id: searchField
|
|
|
|
|
2018-09-02 13:26:42 +00:00
|
|
|
leftPadding: MSettings.miniMode ? 4 : 32
|
|
|
|
topPadding: 0
|
|
|
|
bottomPadding: 0
|
|
|
|
placeholderText: "Search..."
|
|
|
|
|
2018-09-10 10:29:41 +00:00
|
|
|
background: Rectangle { color: MSettings.darkTheme ? "#303030" : "#fafafa" }
|
2018-02-23 14:39:14 +00:00
|
|
|
|
2018-09-02 13:26:42 +00:00
|
|
|
Shortcut {
|
|
|
|
sequence: StandardKey.Find
|
|
|
|
onActivated: searchField.forceActiveFocus()
|
|
|
|
}
|
|
|
|
}
|
2018-08-26 07:42:37 +00:00
|
|
|
|
2018-09-02 13:26:42 +00:00
|
|
|
SortFilterProxyModel {
|
|
|
|
id: roomListProxyModel
|
2018-09-04 13:13:14 +00:00
|
|
|
|
2018-09-02 13:26:42 +00:00
|
|
|
filters: RegExpFilter {
|
|
|
|
roleName: "name"
|
|
|
|
pattern: searchField.text
|
|
|
|
caseSensitivity: Qt.CaseInsensitive
|
|
|
|
}
|
|
|
|
proxyRoles: ExpressionRole {
|
|
|
|
name: "display"
|
|
|
|
expression: {
|
|
|
|
switch (category) {
|
|
|
|
case 1: return "Invited"
|
|
|
|
case 2: return "Favorites"
|
|
|
|
case 3: return "Rooms"
|
|
|
|
case 4: return "People"
|
2018-09-18 10:06:46 +00:00
|
|
|
case 5: return "Low Priority"
|
2018-09-02 13:26:42 +00:00
|
|
|
}
|
2018-08-26 07:42:37 +00:00
|
|
|
}
|
2018-02-23 14:39:14 +00:00
|
|
|
}
|
2018-09-02 13:26:42 +00:00
|
|
|
|
|
|
|
sorters: [
|
|
|
|
RoleSorter { roleName: "category" },
|
|
|
|
RoleSorter {
|
|
|
|
enabled: MSettings.rearrangeByActivity
|
2018-09-18 12:57:38 +00:00
|
|
|
roleName: "lastActiveTime"
|
2018-09-02 13:26:42 +00:00
|
|
|
sortOrder: Qt.DescendingOrder
|
|
|
|
},
|
|
|
|
StringSorter { roleName: "name" }
|
|
|
|
]
|
2018-02-23 14:39:14 +00:00
|
|
|
}
|
|
|
|
|
2018-09-02 13:26:42 +00:00
|
|
|
ListView {
|
2018-02-23 14:39:14 +00:00
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
|
|
|
|
2018-09-02 13:26:42 +00:00
|
|
|
id: listView
|
2018-03-01 11:56:02 +00:00
|
|
|
|
2018-09-02 13:26:42 +00:00
|
|
|
spacing: 1
|
|
|
|
clip: true
|
2018-02-23 14:39:14 +00:00
|
|
|
|
2018-09-02 13:26:42 +00:00
|
|
|
model: roomListProxyModel
|
2018-08-17 04:55:57 +00:00
|
|
|
|
2018-09-02 13:26:42 +00:00
|
|
|
currentIndex: -1
|
2018-07-13 04:06:27 +00:00
|
|
|
|
2018-09-02 23:13:39 +00:00
|
|
|
highlightFollowsCurrentItem: true
|
|
|
|
|
|
|
|
highlightMoveDuration: 200
|
|
|
|
highlightResizeDuration: 0
|
|
|
|
|
2018-09-02 13:26:42 +00:00
|
|
|
boundsBehavior: Flickable.DragOverBounds
|
2018-02-23 14:39:14 +00:00
|
|
|
|
2018-09-02 13:26:42 +00:00
|
|
|
ScrollBar.vertical: ScrollBar {}
|
2018-07-13 04:06:27 +00:00
|
|
|
|
2018-09-02 13:26:42 +00:00
|
|
|
delegate: Rectangle {
|
|
|
|
readonly property bool highlighted: currentRoom === enteredRoom
|
2018-07-08 12:54:06 +00:00
|
|
|
|
2018-09-02 13:26:42 +00:00
|
|
|
width: parent.width
|
|
|
|
height: 64
|
2018-08-04 12:40:23 +00:00
|
|
|
|
2018-09-10 10:29:41 +00:00
|
|
|
color: MSettings.darkTheme ? "#303030" : "#fafafa"
|
2018-02-23 14:39:14 +00:00
|
|
|
|
2018-09-02 13:26:42 +00:00
|
|
|
AutoMouseArea {
|
|
|
|
anchors.fill: parent
|
2018-08-26 05:17:12 +00:00
|
|
|
|
2018-09-02 13:26:42 +00:00
|
|
|
hoverEnabled: MSettings.miniMode
|
2018-08-21 14:57:15 +00:00
|
|
|
|
2018-09-11 05:14:56 +00:00
|
|
|
onSecondaryClicked: {
|
2018-09-12 00:27:34 +00:00
|
|
|
roomContextMenu.model = model
|
2018-09-11 05:14:56 +00:00
|
|
|
roomContextMenu.popup()
|
|
|
|
}
|
2018-09-11 06:58:07 +00:00
|
|
|
onPrimaryClicked: {
|
|
|
|
if (category === RoomType.Invited) {
|
|
|
|
inviteDialog.currentRoom = currentRoom
|
|
|
|
inviteDialog.open()
|
|
|
|
} else {
|
|
|
|
enteredRoom = currentRoom
|
|
|
|
}
|
|
|
|
}
|
2018-08-24 05:25:41 +00:00
|
|
|
|
2018-09-02 13:26:42 +00:00
|
|
|
ToolTip.visible: MSettings.miniMode && containsMouse
|
|
|
|
ToolTip.text: name
|
|
|
|
}
|
2018-08-21 14:57:15 +00:00
|
|
|
|
2018-09-02 23:13:39 +00:00
|
|
|
Rectangle {
|
|
|
|
anchors.fill: parent
|
2018-09-04 13:13:14 +00:00
|
|
|
|
2018-09-06 04:34:15 +00:00
|
|
|
visible: highlightCount > 0 || highlighted
|
2018-09-02 23:13:39 +00:00
|
|
|
color: Material.accent
|
|
|
|
opacity: 0.1
|
|
|
|
}
|
|
|
|
|
2018-09-02 13:26:42 +00:00
|
|
|
Rectangle {
|
2018-09-12 00:27:34 +00:00
|
|
|
width: unreadCount > 0 || highlighted ? 4 : 0
|
2018-09-02 13:26:42 +00:00
|
|
|
height: parent.height
|
2018-09-04 13:13:14 +00:00
|
|
|
|
2018-09-02 13:26:42 +00:00
|
|
|
color: Material.accent
|
2018-09-12 00:27:34 +00:00
|
|
|
|
|
|
|
Behavior on width {
|
|
|
|
PropertyAnimation { easing.type: Easing.InOutCubic; duration: 200 }
|
|
|
|
}
|
2018-09-02 13:26:42 +00:00
|
|
|
}
|
2018-08-24 05:31:17 +00:00
|
|
|
|
2018-09-02 13:26:42 +00:00
|
|
|
RowLayout {
|
|
|
|
anchors.fill: parent
|
|
|
|
anchors.margins: 12
|
2018-09-04 13:13:14 +00:00
|
|
|
|
2018-09-02 13:26:42 +00:00
|
|
|
spacing: 12
|
2018-08-24 05:31:17 +00:00
|
|
|
|
2018-09-06 08:22:00 +00:00
|
|
|
ImageItem {
|
|
|
|
id: imageItem
|
|
|
|
|
2018-09-02 13:26:42 +00:00
|
|
|
Layout.preferredWidth: height
|
|
|
|
Layout.fillHeight: true
|
2018-07-13 04:06:27 +00:00
|
|
|
|
2018-09-06 08:22:00 +00:00
|
|
|
hint: name || "No Name"
|
|
|
|
|
|
|
|
image: avatar
|
2018-08-06 15:51:22 +00:00
|
|
|
}
|
|
|
|
|
2018-09-02 13:26:42 +00:00
|
|
|
ColumnLayout {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
|
|
|
Layout.alignment: Qt.AlignHCenter
|
2018-07-13 04:06:27 +00:00
|
|
|
|
2018-09-02 13:26:42 +00:00
|
|
|
visible: parent.width > 64
|
|
|
|
|
|
|
|
Label {
|
|
|
|
Layout.fillWidth: true
|
2018-07-13 04:06:27 +00:00
|
|
|
Layout.fillHeight: true
|
|
|
|
|
2018-09-02 13:26:42 +00:00
|
|
|
text: name || "No Name"
|
|
|
|
font.pointSize: 12
|
|
|
|
elide: Text.ElideRight
|
|
|
|
wrapMode: Text.NoWrap
|
2018-07-13 04:06:27 +00:00
|
|
|
}
|
|
|
|
|
2018-09-02 13:26:42 +00:00
|
|
|
Label {
|
2018-07-13 04:06:27 +00:00
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
|
|
|
|
2018-09-12 00:27:34 +00:00
|
|
|
text: (lastEvent == "" ? topic : lastEvent).replace(/(\r\n\t|\n|\r\t)/gm,"")
|
2018-09-02 13:26:42 +00:00
|
|
|
elide: Text.ElideRight
|
|
|
|
wrapMode: Text.NoWrap
|
2018-07-13 04:06:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-09-02 13:26:42 +00:00
|
|
|
}
|
2018-07-13 04:06:27 +00:00
|
|
|
|
2018-09-02 13:26:42 +00:00
|
|
|
section.property: "display"
|
|
|
|
section.criteria: ViewSection.FullString
|
|
|
|
section.delegate: Label {
|
|
|
|
width: parent.width
|
|
|
|
height: 24
|
2018-09-04 13:13:14 +00:00
|
|
|
|
2018-09-02 13:26:42 +00:00
|
|
|
text: section
|
|
|
|
color: "grey"
|
|
|
|
leftPadding: MSettings.miniMode ? undefined : 16
|
|
|
|
elide: Text.ElideRight
|
|
|
|
verticalAlignment: Text.AlignVCenter
|
|
|
|
horizontalAlignment: MSettings.miniMode ? Text.AlignHCenter : undefined
|
|
|
|
}
|
2018-08-07 15:41:18 +00:00
|
|
|
|
2018-09-11 05:14:56 +00:00
|
|
|
RoomContextMenu { id: roomContextMenu }
|
|
|
|
|
2018-09-02 13:26:42 +00:00
|
|
|
Dialog {
|
2018-09-11 06:58:07 +00:00
|
|
|
property var currentRoom
|
|
|
|
|
2018-09-02 13:26:42 +00:00
|
|
|
id: inviteDialog
|
|
|
|
parent: ApplicationWindow.overlay
|
2018-08-17 04:55:57 +00:00
|
|
|
|
2018-09-02 13:26:42 +00:00
|
|
|
x: (window.width - width) / 2
|
|
|
|
y: (window.height - height) / 2
|
|
|
|
width: 360
|
2018-08-17 04:55:57 +00:00
|
|
|
|
2018-09-02 13:26:42 +00:00
|
|
|
title: "Action Required"
|
|
|
|
modal: true
|
|
|
|
standardButtons: Dialog.Ok | Dialog.Cancel
|
2018-08-17 04:55:57 +00:00
|
|
|
|
2018-09-02 13:26:42 +00:00
|
|
|
contentItem: Label { text: "Accept this invitation?" }
|
2018-08-17 04:55:57 +00:00
|
|
|
|
2018-09-02 13:26:42 +00:00
|
|
|
onAccepted: currentRoom.acceptInvitation()
|
|
|
|
onRejected: currentRoom.forget()
|
2018-02-23 14:39:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|