From 5d513f84fa66052e1f68f1819ec586f101c08d92 Mon Sep 17 00:00:00 2001 From: miruka Date: Sun, 22 Mar 2020 12:50:10 -0400 Subject: [PATCH] Add compact mode for sidepanes + setting --- src/backend/user_files.py | 1 + src/gui/Base/HAvatar.qml | 10 ++++++++-- src/gui/Base/HTile.qml | 13 ++++++++++++- src/gui/MainPane/Account.qml | 1 + src/gui/MainPane/Room.qml | 2 ++ src/gui/Pages/Chat/RoomPane/MemberDelegate.qml | 1 + src/themes/Glass.qpl | 1 + src/themes/Midnight.qpl | 1 + 8 files changed, 27 insertions(+), 3 deletions(-) diff --git a/src/backend/user_files.py b/src/backend/user_files.py index b8cef622..07046582 100644 --- a/src/backend/user_files.py +++ b/src/backend/user_files.py @@ -208,6 +208,7 @@ class UISettings(JSONDataFile): return { "alertOnMessageForMsec": 4000, "alwaysCenterRoomHeader": False, + "alwaysUseCompactMode": False, "clearRoomFilterOnEnter": True, "clearRoomFilterOnEscape": True, "collapseSidePanesUnderWindowWidth": 400, diff --git a/src/gui/Base/HAvatar.qml b/src/gui/Base/HAvatar.qml index 1c418881..7d632b43 100644 --- a/src/gui/Base/HAvatar.qml +++ b/src/gui/Base/HAvatar.qml @@ -6,8 +6,12 @@ import "../Base" Rectangle { id: avatar - implicitWidth: theme.controls.avatar.size - implicitHeight: theme.controls.avatar.size + implicitWidth: implicitHeight + implicitHeight: + compact ? + theme.controls.avatar.compactSize : + theme.controls.avatar.size + radius: theme.controls.avatar.radius color: avatarImage.visible ? "transparent" : utils.hsluv( @@ -18,6 +22,8 @@ Rectangle { ) + property bool compact: false + property string name property alias mxc: avatarImage.mxc property alias title: avatarImage.title diff --git a/src/gui/Base/HTile.qml b/src/gui/Base/HTile.qml index 7e1b3250..cd4c3474 100644 --- a/src/gui/Base/HTile.qml +++ b/src/gui/Base/HTile.qml @@ -11,6 +11,7 @@ HButton { default property alias additionalData: contentItem.data + property bool compact: window.settings.alwaysUseCompactMode property real contentOpacity: 1 readonly property alias title: title @@ -77,7 +78,7 @@ HButton { color: theme.colors.dimText visible: Layout.maximumHeight > 0 - Layout.maximumHeight: text ? implicitWidth : 0 + Layout.maximumHeight: ! compact && text ? implicitHeight : 0 Layout.fillWidth: true Layout.fillHeight: true @@ -87,6 +88,16 @@ HButton { } + Binding on topPadding { + value: spacing / 4 + when: compact + } + + Binding on bottomPadding { + value: spacing / 4 + when: compact + } + TapHandler { acceptedButtons: Qt.LeftButton onTapped: leftClicked() diff --git a/src/gui/MainPane/Account.qml b/src/gui/MainPane/Account.qml index f34fd990..08f70e0e 100644 --- a/src/gui/MainPane/Account.qml +++ b/src/gui/MainPane/Account.qml @@ -23,6 +23,7 @@ HTileDelegate { userId: model.id displayName: model.display_name mxc: model.avatar_url + compact: account.compact radius: mainPane.small ? diff --git a/src/gui/MainPane/Room.qml b/src/gui/MainPane/Room.qml index 80459d13..4dc5d8d4 100644 --- a/src/gui/MainPane/Room.qml +++ b/src/gui/MainPane/Room.qml @@ -7,6 +7,7 @@ import ".." import "../Base" HTileDelegate { + id: room backgroundColor: theme.mainPane.listView.room.background opacity: model.left ? theme.mainPane.listView.room.leftRoomOpacity : 1 @@ -19,6 +20,7 @@ HTileDelegate { roomId: model.id displayName: model.display_name mxc: model.avatar_url + compact: room.compact radius: mainPane.small ? diff --git a/src/gui/Pages/Chat/RoomPane/MemberDelegate.qml b/src/gui/Pages/Chat/RoomPane/MemberDelegate.qml index 3a293d01..bdc8776c 100644 --- a/src/gui/Pages/Chat/RoomPane/MemberDelegate.qml +++ b/src/gui/Pages/Chat/RoomPane/MemberDelegate.qml @@ -17,6 +17,7 @@ HTileDelegate { powerLevel: model.power_level shiftMembershipIconPosition: ! roomPane.collapsed invited: model.invited + compact: memberDelegate.compact } title.text: model.display_name || model.id diff --git a/src/themes/Glass.qpl b/src/themes/Glass.qpl index 0aaa6855..1360c51a 100644 --- a/src/themes/Glass.qpl +++ b/src/themes/Glass.qpl @@ -218,6 +218,7 @@ controls: avatar: int size: baseElementsHeight + int compactSize: baseElementsHeight / 2 int radius: theme.radius hoveredImage: diff --git a/src/themes/Midnight.qpl b/src/themes/Midnight.qpl index fb37a394..a0069664 100644 --- a/src/themes/Midnight.qpl +++ b/src/themes/Midnight.qpl @@ -224,6 +224,7 @@ controls: avatar: int size: baseElementsHeight + int compactSize: baseElementsHeight / 2 int radius: theme.radius hoveredImage: