Add a compact room list option

This commit is contained in:
Gary Wang
2022-12-20 18:06:44 +08:00
committed by Tobias Fella
parent 3c33bea7db
commit 304054a4bb
3 changed files with 23 additions and 6 deletions

View File

@@ -72,7 +72,11 @@
<default>true</default> <default>true</default>
</entry> </entry>
<entry name="CompactLayout" type="bool"> <entry name="CompactLayout" type="bool">
<label>Use a compact layout</label> <label>Use a compact chat layout</label>
<default>false</default>
</entry>
<entry name="CompactRoomList" type="bool">
<label>Use a compact room list layout</label>
<default>false</default> <default>false</default>
</entry> </entry>
<entry name="ShowRename" type="bool"> <entry name="ShowRename" type="bool">

View File

@@ -316,6 +316,7 @@ Kirigami.ScrollablePage {
labelItem.textFormat: Text.PlainText labelItem.textFormat: Text.PlainText
subtitle: subtitleText subtitle: subtitleText
subtitleItem.textFormat: Text.PlainText subtitleItem.textFormat: Text.PlainText
subtitleItem.visible: !Config.compactRoomList
onPressAndHold: { onPressAndHold: {
createRoomListContextMenu() createRoomListContextMenu()
} }
@@ -347,8 +348,8 @@ Kirigami.ScrollablePage {
QQC2.Label { QQC2.Label {
text: notificationCount > 0 ? notificationCount : "●" text: notificationCount > 0 ? notificationCount : "●"
visible: unreadCount > 0 visible: unreadCount > 0
padding: Kirigami.Units.smallSpacing
color: Kirigami.Theme.textColor color: Kirigami.Theme.textColor
Layout.rightMargin: Kirigami.Units.smallSpacing
Layout.minimumWidth: height Layout.minimumWidth: height
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
background: Rectangle { background: Rectangle {
@@ -361,7 +362,7 @@ Kirigami.ScrollablePage {
} }
QQC2.Button { QQC2.Button {
id: configButton id: configButton
visible: roomListItem.hovered && !Kirigami.Settings.isMobile visible: roomListItem.hovered && !Kirigami.Settings.isMobile && !Config.compactRoomList
Accessible.name: i18n("Configure room") Accessible.name: i18n("Configure room")
action: Kirigami.Action { action: Kirigami.Action {
@@ -376,13 +377,13 @@ Kirigami.ScrollablePage {
function createRoomListContextMenu() { function createRoomListContextMenu() {
const menu = roomListContextMenu.createObject(page, {room: currentRoom}) const menu = roomListContextMenu.createObject(page, {room: currentRoom})
if (!Kirigami.Settings.isMobile) { if (!Kirigami.Settings.isMobile && !Config.compactRoomList) {
configButton.visible = true configButton.visible = true
configButton.down = true configButton.down = true
} }
menu.closed.connect(function() { menu.closed.connect(function() {
configButton.down = undefined configButton.down = undefined
configButton.visible = Qt.binding(function() { return roomListItem.hovered && !Kirigami.Settings.isMobile }) configButton.visible = Qt.binding(function() { return roomListItem.hovered && !Kirigami.Settings.isMobile && !Config.compactRoomList })
}) })
menu.open() menu.open()
} }

View File

@@ -200,7 +200,19 @@ Kirigami.ScrollablePage {
} }
} }
MobileForm.FormDelegateSeparator { below: colorSchemeDelegate.item ; visible: colorSchemeDelegate.visible } MobileForm.FormDelegateSeparator { below: compactRoomListDelegate }
MobileForm.FormCheckDelegate {
id: compactRoomListDelegate
text: i18n("Use compact room list")
checked: Config.compactRoomList
onToggled: {
Config.compactRoomList = checked;
Config.save();
}
}
MobileForm.FormDelegateSeparator { above: compactRoomListDelegate ; below: colorSchemeDelegate.item ; visible: colorSchemeDelegate.visible }
Loader { Loader {
id: colorSchemeDelegate id: colorSchemeDelegate