From 7c833ce7647174a6de2b1677cbb0f7136dbd2524 Mon Sep 17 00:00:00 2001 From: Black Hat Date: Sat, 22 Sep 2018 22:28:47 +0800 Subject: [PATCH] Room filtering. --- qml/Room.qml | 1 + qml/Setting.qml | 7 ---- qml/SpectralSettings.qml | 1 - qml/form/RoomListForm.qml | 29 +++++++++---- qml/main.qml | 87 ++++++++++++++++++++++++++++++++++----- 5 files changed, 98 insertions(+), 27 deletions(-) diff --git a/qml/Room.qml b/qml/Room.qml index 2e38817..4269082 100644 --- a/qml/Room.qml +++ b/qml/Room.qml @@ -9,6 +9,7 @@ import "form" Page { property alias connection: roomListModel.connection + property alias filter: roomListForm.filter id: page diff --git a/qml/Setting.qml b/qml/Setting.qml index 6cc6e15..d5b1ade 100644 --- a/qml/Setting.qml +++ b/qml/Setting.qml @@ -213,13 +213,6 @@ Page { onCheckedChanged: MSettings.miniMode = checked } - - Switch { - text: "Rearrange rooms by activity" - checked: MSettings.rearrangeByActivity - - onCheckedChanged: MSettings.rearrangeByActivity = checked - } } } diff --git a/qml/SpectralSettings.qml b/qml/SpectralSettings.qml index be3aa18..edd9554 100644 --- a/qml/SpectralSettings.qml +++ b/qml/SpectralSettings.qml @@ -4,7 +4,6 @@ import Qt.labs.settings 1.0 Settings { property bool pressAndHold - property bool rearrangeByActivity property bool darkTheme property bool miniMode diff --git a/qml/form/RoomListForm.qml b/qml/form/RoomListForm.qml index 7708b2f..800bf67 100644 --- a/qml/form/RoomListForm.qml +++ b/qml/form/RoomListForm.qml @@ -14,6 +14,7 @@ import "qrc:/js/util.js" as Util Item { property alias listModel: roomListProxyModel.sourceModel + property int filter: 0 property var enteredRoom: null Label { @@ -51,11 +52,25 @@ Item { SortFilterProxyModel { id: roomListProxyModel - filters: RegExpFilter { - roleName: "name" - pattern: searchField.text - caseSensitivity: Qt.CaseInsensitive - } + filters: [ + RegExpFilter { + roleName: "name" + pattern: searchField.text + caseSensitivity: Qt.CaseInsensitive + }, + ExpressionFilter { + enabled: filter === 1 + expression: unreadCount > 0 + }, + ExpressionFilter { + enabled: filter === 2 + expression: category === 1 || category === 2 || category === 4 + }, + ExpressionFilter { + enabled: filter === 3 + expression: category === 3 || category === 5 + } + ] proxyRoles: ExpressionRole { name: "display" expression: { @@ -72,11 +87,9 @@ Item { sorters: [ RoleSorter { roleName: "category" }, RoleSorter { - enabled: MSettings.rearrangeByActivity roleName: "lastActiveTime" sortOrder: Qt.DescendingOrder - }, - StringSorter { roleName: "name" } + } ] } diff --git a/qml/main.qml b/qml/main.qml index 43c382a..69b0b2f 100644 --- a/qml/main.qml +++ b/qml/main.qml @@ -116,25 +116,90 @@ ApplicationWindow { clip: true - delegate: SideNavButton { + delegate: Column { + property bool expanded: accountListView.currentConnection === connection + width: parent.width - height: width - selected: stackView.currentItem === page && currentConnection === connection + spacing: 0 - ImageItem { - anchors.fill: parent - anchors.margins: 12 + SideNavButton { + width: parent.width + height: width - hint: user.displayName - image: user.avatar + selected: stackView.currentItem === page && currentConnection === connection + + ImageItem { + anchors.fill: parent + anchors.margins: 12 + + hint: user.displayName + image: user.avatar + } + + highlightColor: spectralController.color(user.id) + + page: roomPage + + onClicked: { + accountListView.currentConnection = connection + roomPage.filter = 0 + } } - highlightColor: spectralController.color(user.id) + Column { + width: parent.width + height: expanded ? implicitHeight : 0 - page: roomPage + spacing: 0 + clip: true - onClicked: accountListView.currentConnection = connection + SideNavButton { + width: parent.width + height: width + + MaterialIcon { + anchors.fill: parent + + icon: "\ue7f7" + color: "white" + } + + onClicked: roomPage.filter = 1 + } + + SideNavButton { + width: parent.width + height: width + + MaterialIcon { + anchors.fill: parent + + icon: "\ue7fd" + color: "white" + } + + onClicked: roomPage.filter = 2 + } + + SideNavButton { + width: parent.width + height: width + + MaterialIcon { + anchors.fill: parent + + icon: "\ue886" + color: "white" + } + + onClicked: roomPage.filter = 3 + } + + Behavior on height { + PropertyAnimation { easing.type: Easing.InOutCubic; duration: 200 } + } + } } }