summaryrefslogtreecommitdiffstats
path: root/resources/qml/CommunitiesList.qml
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2023-06-02 01:45:24 +0200
committerNicolas Werner <nicolas.werner@hotmail.de>2023-06-08 22:32:08 +0200
commit5aee8d609a3fcca63bb9a0f983a77b45eebfefe7 (patch)
tree1f270d525e4e5b5db381d19675467620593368cd /resources/qml/CommunitiesList.qml
parentde8522a185f9d62eaefb37d0f1a5e2e77c73c175 (diff)
Format qml
Diffstat (limited to 'resources/qml/CommunitiesList.qml')
-rw-r--r--resources/qml/CommunitiesList.qml172
1 files changed, 81 insertions, 91 deletions
diff --git a/resources/qml/CommunitiesList.qml b/resources/qml/CommunitiesList.qml
index a210a4bb..62a29a2d 100644
--- a/resources/qml/CommunitiesList.qml
+++ b/resources/qml/CommunitiesList.qml
@@ -13,19 +13,24 @@ import im.nheko 1.0
Page {
id: communitySidebar
+
//leftPadding: Nheko.paddingSmall
//rightPadding: Nheko.paddingSmall
property int avatarSize: Math.ceil(fontMetrics.lineSpacing * 1.6)
property bool collapsed: false
+ background: Rectangle {
+ color: Nheko.theme.sidebarBackground
+ }
+
// HACK: https://bugreports.qt.io/browse/QTBUG-83972, qtwayland cannot auto hide menu
Connections {
function onHideMenu() {
- communityContextMenu.close()
+ communityContextMenu.close();
}
+
target: MainWindow
}
-
ListView {
id: communitiesList
@@ -36,195 +41,180 @@ Page {
ScrollBar.vertical: ScrollBar {
id: scrollbar
- parent: !collapsed && Settings.scrollbarsInRoomlist ? communitiesList : null
- }
-
- Platform.Menu {
- id: communityContextMenu
-
- property string tagId
- property bool hidden
- property bool muted
-
- function show(id_, hidden_, muted_) {
- tagId = id_;
- hidden = hidden_;
- muted = muted_;
- open();
- }
-
- Platform.MenuItem {
- text: qsTr("Do not show notification counts for this community or tag.")
- checkable: true
- checked: communityContextMenu.muted
- onTriggered: Communities.toggleTagMute(communityContextMenu.tagId)
- }
-
- Platform.MenuItem {
- text: qsTr("Hide rooms with this tag or from this community by default.")
- checkable: true
- checked: communityContextMenu.hidden
- onTriggered: Communities.toggleTagId(communityContextMenu.tagId)
- }
+ parent: !collapsed && Settings.scrollbarsInRoomlist ? communitiesList : null
}
-
delegate: ItemDelegate {
id: communityItem
property color backgroundColor: palette.window
- property color importantText: palette.text
- property color unimportantText: palette.buttonText
property color bubbleBackground: palette.highlight
property color bubbleText: palette.highlightedText
+ property color importantText: palette.text
required property var model
+ property color unimportantText: palette.buttonText
+ ToolTip.delay: Nheko.tooltipDelay
+ ToolTip.text: model.tooltip
+ ToolTip.visible: hovered && collapsed
height: avatarSize + 2 * Nheko.paddingMedium
- width: ListView.view.width - ((scrollbar.interactive && scrollbar.visible && scrollbar.parent) ? scrollbar.width : 0)
state: "normal"
- ToolTip.visible: hovered && collapsed
- ToolTip.text: model.tooltip
- ToolTip.delay: Nheko.tooltipDelay
- onClicked: Communities.setCurrentTagId(model.id)
- onPressAndHold: communityContextMenu.show(model.id, model.hidden, model.muted)
+ width: ListView.view.width - ((scrollbar.interactive && scrollbar.visible && scrollbar.parent) ? scrollbar.width : 0)
+
+ background: Rectangle {
+ color: communityItem.backgroundColor
+ }
states: [
State {
name: "highlight"
when: (communityItem.hovered || model.hidden) && !(Communities.currentTagId === model.id)
PropertyChanges {
- target: communityItem
backgroundColor: palette.dark
- importantText: palette.brightText
- unimportantText: palette.brightText
bubbleBackground: palette.highlight
bubbleText: palette.highlightedText
+ importantText: palette.brightText
+ target: communityItem
+ unimportantText: palette.brightText
}
-
},
State {
name: "selected"
when: Communities.currentTagId == model.id
PropertyChanges {
- target: communityItem
backgroundColor: palette.highlight
- importantText: palette.highlightedText
- unimportantText: palette.highlightedText
bubbleBackground: palette.highlightedText
bubbleText: palette.highlight
+ importantText: palette.highlightedText
+ target: communityItem
+ unimportantText: palette.highlightedText
}
-
}
]
+ onClicked: Communities.setCurrentTagId(model.id)
+ onPressAndHold: communityContextMenu.show(model.id, model.hidden, model.muted)
+
Item {
anchors.fill: parent
TapHandler {
acceptedButtons: Qt.RightButton
- onSingleTapped: communityContextMenu.show(model.id, model.hidden, model.muted)
- gesturePolicy: TapHandler.ReleaseWithinBounds
acceptedDevices: PointerDevice.Mouse | PointerDevice.Stylus | PointerDevice.TouchPad
- }
+ gesturePolicy: TapHandler.ReleaseWithinBounds
+ onSingleTapped: communityContextMenu.show(model.id, model.hidden, model.muted)
+ }
}
-
RowLayout {
id: r
- spacing: Nheko.paddingMedium
+
anchors.fill: parent
- anchors.margins: Nheko.paddingMedium
anchors.leftMargin: Nheko.paddingMedium + (communitySidebar.collapsed ? 0 : (fontMetrics.lineSpacing * model.depth))
+ anchors.margins: Nheko.paddingMedium
+ spacing: Nheko.paddingMedium
ImageButton {
- visible: !communitySidebar.collapsed && model.collapsible
+ Layout.alignment: Qt.AlignVCenter
Layout.preferredHeight: fontMetrics.lineSpacing
Layout.preferredWidth: fontMetrics.lineSpacing
- Layout.alignment: Qt.AlignVCenter
- height: fontMetrics.lineSpacing
- width: fontMetrics.lineSpacing
- image: model.collapsed ? ":/icons/icons/ui/collapsed.svg" : ":/icons/icons/ui/expanded.svg"
- ToolTip.visible: hovered
ToolTip.delay: Nheko.tooltipDelay
ToolTip.text: model.collapsed ? qsTr("Expand") : qsTr("Collapse")
+ ToolTip.visible: hovered
+ height: fontMetrics.lineSpacing
hoverEnabled: true
+ image: model.collapsed ? ":/icons/icons/ui/collapsed.svg" : ":/icons/icons/ui/expanded.svg"
+ visible: !communitySidebar.collapsed && model.collapsible
+ width: fontMetrics.lineSpacing
onClicked: model.collapsed = !model.collapsed
}
-
Item {
Layout.preferredWidth: fontMetrics.lineSpacing
visible: !communitySidebar.collapsed && !model.collapsible && Communities.containsSubspaces
}
-
Avatar {
id: avatar
- enabled: false
Layout.alignment: Qt.AlignVCenter
+ color: communityItem.backgroundColor
+ displayName: model.displayName
+ enabled: false
height: avatarSize
- width: avatarSize
+ roomid: model.id
url: {
if (model.avatarUrl.startsWith("mxc://"))
return model.avatarUrl.replace("mxc://", "image://MxcImage/");
else
return "image://colorimage/" + model.avatarUrl + "?" + communityItem.unimportantText;
}
- roomid: model.id
- displayName: model.displayName
- color: communityItem.backgroundColor
+ width: avatarSize
NotificationBubble {
- notificationCount: model.unreadMessages
- hasLoudNotification: model.hasLoudNotification
+ anchors.bottom: avatar.bottom
+ anchors.margins: -Nheko.paddingSmall
+ anchors.right: avatar.right
bubbleBackgroundColor: communityItem.bubbleBackground
bubbleTextColor: communityItem.bubbleText
font.pixelSize: fontMetrics.font.pixelSize * 0.6
+ hasLoudNotification: model.hasLoudNotification
mayBeVisible: communitySidebar.collapsed && !model.muted && Settings.spaceNotifications
- anchors.right: avatar.right
- anchors.bottom: avatar.bottom
- anchors.margins: -Nheko.paddingSmall
+ notificationCount: model.unreadMessages
}
-
}
-
ElidedLabel {
- visible: !communitySidebar.collapsed
Layout.alignment: Qt.AlignVCenter
- color: communityItem.importantText
Layout.fillWidth: true
+ color: communityItem.importantText
elideWidth: width
fullText: model.displayName
textFormat: Text.PlainText
+ visible: !communitySidebar.collapsed
}
-
Item {
Layout.fillWidth: true
}
-
NotificationBubble {
- notificationCount: model.unreadMessages
- hasLoudNotification: model.hasLoudNotification
+ Layout.alignment: Qt.AlignRight
+ Layout.leftMargin: Nheko.paddingSmall
bubbleBackgroundColor: communityItem.bubbleBackground
bubbleTextColor: communityItem.bubbleText
+ hasLoudNotification: model.hasLoudNotification
mayBeVisible: !communitySidebar.collapsed && !model.muted && Settings.spaceNotifications
- Layout.alignment: Qt.AlignRight
- Layout.leftMargin: Nheko.paddingSmall
+ notificationCount: model.unreadMessages
}
-
}
+ }
- background: Rectangle {
- color: communityItem.backgroundColor
+ Platform.Menu {
+ id: communityContextMenu
+
+ property bool hidden
+ property bool muted
+ property string tagId
+
+ function show(id_, hidden_, muted_) {
+ tagId = id_;
+ hidden = hidden_;
+ muted = muted_;
+ open();
}
- }
+ Platform.MenuItem {
+ checkable: true
+ checked: communityContextMenu.muted
+ text: qsTr("Do not show notification counts for this community or tag.")
- }
+ onTriggered: Communities.toggleTagMute(communityContextMenu.tagId)
+ }
+ Platform.MenuItem {
+ checkable: true
+ checked: communityContextMenu.hidden
+ text: qsTr("Hide rooms with this tag or from this community by default.")
- background: Rectangle {
- color: Nheko.theme.sidebarBackground
+ onTriggered: Communities.toggleTagId(communityContextMenu.tagId)
+ }
+ }
}
-
}