2023-02-22 01:48:49 +03:00
|
|
|
// SPDX-FileCopyrightText: Nheko Contributors
|
2021-06-11 14:12:43 +03:00
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2022-04-22 01:26:14 +03:00
|
|
|
import "./components"
|
2021-06-11 14:12:43 +03:00
|
|
|
import "./dialogs"
|
|
|
|
import Qt.labs.platform 1.1 as Platform
|
2021-06-13 02:48:11 +03:00
|
|
|
import QtQml 2.12
|
|
|
|
import QtQuick 2.12
|
|
|
|
import QtQuick.Controls 2.5
|
2021-06-11 14:12:43 +03:00
|
|
|
import QtQuick.Layouts 1.3
|
|
|
|
import im.nheko 1.0
|
|
|
|
|
|
|
|
Page {
|
2021-12-01 02:02:41 +03:00
|
|
|
id: communitySidebar
|
2021-06-11 14:12:43 +03:00
|
|
|
//leftPadding: Nheko.paddingSmall
|
|
|
|
//rightPadding: Nheko.paddingSmall
|
|
|
|
property int avatarSize: Math.ceil(fontMetrics.lineSpacing * 1.6)
|
|
|
|
property bool collapsed: false
|
|
|
|
|
2023-01-31 21:34:26 +03:00
|
|
|
// HACK: https://bugreports.qt.io/browse/QTBUG-83972, qtwayland cannot auto hide menu
|
|
|
|
Connections {
|
|
|
|
function onHideMenu() {
|
|
|
|
communityContextMenu.close()
|
|
|
|
}
|
|
|
|
target: MainWindow
|
|
|
|
}
|
|
|
|
|
2021-06-11 14:12:43 +03:00
|
|
|
ListView {
|
|
|
|
id: communitiesList
|
|
|
|
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
|
|
|
height: parent.height
|
2021-12-01 02:02:41 +03:00
|
|
|
model: Communities.filtered()
|
2021-06-11 14:12:43 +03:00
|
|
|
|
2023-02-16 02:39:47 +03:00
|
|
|
ScrollBar.vertical: ScrollBar {
|
2023-02-15 00:00:05 +03:00
|
|
|
id: scrollbar
|
2023-02-16 02:39:47 +03:00
|
|
|
parent: !collapsed && Settings.scrollbarsInRoomlist ? communitiesList : null
|
2023-02-15 00:00:05 +03:00
|
|
|
}
|
|
|
|
|
2021-06-11 14:12:43 +03:00
|
|
|
ScrollHelper {
|
|
|
|
flickable: parent
|
|
|
|
anchors.fill: parent
|
|
|
|
enabled: !Settings.mobileMode
|
|
|
|
}
|
|
|
|
|
|
|
|
Platform.Menu {
|
|
|
|
id: communityContextMenu
|
|
|
|
|
2021-06-11 18:54:05 +03:00
|
|
|
property string tagId
|
2022-04-29 00:00:12 +03:00
|
|
|
property bool hidden
|
|
|
|
property bool muted
|
2021-06-11 14:12:43 +03:00
|
|
|
|
2022-04-29 00:00:12 +03:00
|
|
|
function show(id_, hidden_, muted_) {
|
2021-06-11 18:54:05 +03:00
|
|
|
tagId = id_;
|
2022-04-29 00:00:12 +03:00
|
|
|
hidden = hidden_;
|
|
|
|
muted = muted_;
|
2021-06-11 14:12:43 +03:00
|
|
|
open();
|
|
|
|
}
|
|
|
|
|
2022-04-29 00:00:12 +03:00
|
|
|
Platform.MenuItem {
|
2022-10-01 16:20:38 +03:00
|
|
|
text: qsTr("Do not show notification counts for this community or tag.")
|
2022-04-29 00:00:12 +03:00
|
|
|
checkable: true
|
|
|
|
checked: communityContextMenu.muted
|
|
|
|
onTriggered: Communities.toggleTagMute(communityContextMenu.tagId)
|
|
|
|
}
|
|
|
|
|
2021-06-11 14:12:43 +03:00
|
|
|
Platform.MenuItem {
|
2022-10-01 16:20:38 +03:00
|
|
|
text: qsTr("Hide rooms with this tag or from this community by default.")
|
2022-04-29 00:00:12 +03:00
|
|
|
checkable: true
|
|
|
|
checked: communityContextMenu.hidden
|
2021-06-11 18:54:05 +03:00
|
|
|
onTriggered: Communities.toggleTagId(communityContextMenu.tagId)
|
2021-06-11 14:12:43 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2021-11-04 01:20:28 +03:00
|
|
|
delegate: ItemDelegate {
|
2021-06-11 14:12:43 +03:00
|
|
|
id: communityItem
|
|
|
|
|
2021-11-04 01:20:28 +03:00
|
|
|
property color backgroundColor: Nheko.colors.window
|
2021-06-11 14:12:43 +03:00
|
|
|
property color importantText: Nheko.colors.text
|
|
|
|
property color unimportantText: Nheko.colors.buttonText
|
|
|
|
property color bubbleBackground: Nheko.colors.highlight
|
|
|
|
property color bubbleText: Nheko.colors.highlightedText
|
2022-07-16 04:07:00 +03:00
|
|
|
required property var model
|
2021-06-11 14:12:43 +03:00
|
|
|
|
|
|
|
height: avatarSize + 2 * Nheko.paddingMedium
|
2023-02-16 02:39:47 +03:00
|
|
|
width: ListView.view.width - ((scrollbar.interactive && scrollbar.visible && scrollbar.parent) ? scrollbar.width : 0)
|
2021-06-11 14:12:43 +03:00
|
|
|
state: "normal"
|
2021-11-04 01:20:28 +03:00
|
|
|
ToolTip.visible: hovered && collapsed
|
2022-07-16 04:07:00 +03:00
|
|
|
ToolTip.text: model.tooltip
|
2021-12-31 02:47:14 +03:00
|
|
|
ToolTip.delay: Nheko.tooltipDelay
|
2022-07-16 04:07:00 +03:00
|
|
|
onClicked: Communities.setCurrentTagId(model.id)
|
|
|
|
onPressAndHold: communityContextMenu.show(model.id, model.hidden, model.muted)
|
2021-06-11 14:12:43 +03:00
|
|
|
states: [
|
|
|
|
State {
|
|
|
|
name: "highlight"
|
2022-07-16 04:07:00 +03:00
|
|
|
when: (communityItem.hovered || model.hidden) && !(Communities.currentTagId === model.id)
|
2021-06-11 14:12:43 +03:00
|
|
|
|
|
|
|
PropertyChanges {
|
|
|
|
target: communityItem
|
2021-11-04 01:20:28 +03:00
|
|
|
backgroundColor: Nheko.colors.dark
|
2021-06-11 14:12:43 +03:00
|
|
|
importantText: Nheko.colors.brightText
|
|
|
|
unimportantText: Nheko.colors.brightText
|
|
|
|
bubbleBackground: Nheko.colors.highlight
|
|
|
|
bubbleText: Nheko.colors.highlightedText
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
State {
|
|
|
|
name: "selected"
|
2022-07-16 04:07:00 +03:00
|
|
|
when: Communities.currentTagId == model.id
|
2021-06-11 14:12:43 +03:00
|
|
|
|
|
|
|
PropertyChanges {
|
|
|
|
target: communityItem
|
2021-11-04 01:20:28 +03:00
|
|
|
backgroundColor: Nheko.colors.highlight
|
2021-06-11 14:12:43 +03:00
|
|
|
importantText: Nheko.colors.highlightedText
|
|
|
|
unimportantText: Nheko.colors.highlightedText
|
|
|
|
bubbleBackground: Nheko.colors.highlightedText
|
|
|
|
bubbleText: Nheko.colors.highlight
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
2021-11-04 01:20:28 +03:00
|
|
|
Item {
|
|
|
|
anchors.fill: parent
|
2021-06-11 14:12:43 +03:00
|
|
|
|
2021-11-04 01:20:28 +03:00
|
|
|
TapHandler {
|
|
|
|
acceptedButtons: Qt.RightButton
|
2022-07-16 04:07:00 +03:00
|
|
|
onSingleTapped: communityContextMenu.show(model.id, model.hidden, model.muted)
|
2021-11-04 01:20:28 +03:00
|
|
|
gesturePolicy: TapHandler.ReleaseWithinBounds
|
|
|
|
acceptedDevices: PointerDevice.Mouse | PointerDevice.Stylus | PointerDevice.TouchPad
|
|
|
|
}
|
2021-06-11 14:12:43 +03:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
RowLayout {
|
2021-12-01 02:02:41 +03:00
|
|
|
id: r
|
2021-06-11 14:12:43 +03:00
|
|
|
spacing: Nheko.paddingMedium
|
|
|
|
anchors.fill: parent
|
|
|
|
anchors.margins: Nheko.paddingMedium
|
2022-07-16 04:07:00 +03:00
|
|
|
anchors.leftMargin: Nheko.paddingMedium + (communitySidebar.collapsed ? 0 : (fontMetrics.lineSpacing * model.depth))
|
2021-12-01 02:02:41 +03:00
|
|
|
|
|
|
|
ImageButton {
|
2022-07-16 04:07:00 +03:00
|
|
|
visible: !communitySidebar.collapsed && model.collapsible
|
2021-12-01 02:02:41 +03:00
|
|
|
Layout.preferredHeight: fontMetrics.lineSpacing
|
|
|
|
Layout.preferredWidth: fontMetrics.lineSpacing
|
|
|
|
Layout.alignment: Qt.AlignVCenter
|
|
|
|
height: fontMetrics.lineSpacing
|
|
|
|
width: fontMetrics.lineSpacing
|
2022-07-16 04:07:00 +03:00
|
|
|
image: model.collapsed ? ":/icons/icons/ui/collapsed.svg" : ":/icons/icons/ui/expanded.svg"
|
2021-12-01 02:02:41 +03:00
|
|
|
ToolTip.visible: hovered
|
2021-12-31 02:47:14 +03:00
|
|
|
ToolTip.delay: Nheko.tooltipDelay
|
2022-07-16 04:07:00 +03:00
|
|
|
ToolTip.text: model.collapsed ? qsTr("Expand") : qsTr("Collapse")
|
2021-12-01 02:02:41 +03:00
|
|
|
hoverEnabled: true
|
|
|
|
|
2022-07-16 04:07:00 +03:00
|
|
|
onClicked: model.collapsed = !model.collapsed
|
2021-12-01 02:02:41 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
Item {
|
|
|
|
Layout.preferredWidth: fontMetrics.lineSpacing
|
2022-07-16 04:07:00 +03:00
|
|
|
visible: !communitySidebar.collapsed && !model.collapsible && Communities.containsSubspaces
|
2021-12-01 02:02:41 +03:00
|
|
|
}
|
2021-06-11 14:12:43 +03:00
|
|
|
|
|
|
|
Avatar {
|
|
|
|
id: avatar
|
|
|
|
|
|
|
|
enabled: false
|
|
|
|
Layout.alignment: Qt.AlignVCenter
|
|
|
|
height: avatarSize
|
|
|
|
width: avatarSize
|
|
|
|
url: {
|
2022-07-16 04:07:00 +03:00
|
|
|
if (model.avatarUrl.startsWith("mxc://"))
|
|
|
|
return model.avatarUrl.replace("mxc://", "image://MxcImage/");
|
2021-06-11 15:51:29 +03:00
|
|
|
else
|
2022-07-16 04:07:00 +03:00
|
|
|
return "image://colorimage/" + model.avatarUrl + "?" + communityItem.unimportantText;
|
2021-06-11 14:12:43 +03:00
|
|
|
}
|
2022-07-16 04:07:00 +03:00
|
|
|
roomid: model.id
|
|
|
|
displayName: model.displayName
|
2021-11-04 01:20:28 +03:00
|
|
|
color: communityItem.backgroundColor
|
2022-04-13 04:49:21 +03:00
|
|
|
|
2022-04-22 01:26:14 +03:00
|
|
|
NotificationBubble {
|
2022-07-16 04:07:00 +03:00
|
|
|
notificationCount: model.unreadMessages
|
|
|
|
hasLoudNotification: model.hasLoudNotification
|
2022-04-22 01:26:14 +03:00
|
|
|
bubbleBackgroundColor: communityItem.bubbleBackground
|
|
|
|
bubbleTextColor: communityItem.bubbleText
|
|
|
|
font.pixelSize: fontMetrics.font.pixelSize * 0.6
|
2022-07-16 04:07:00 +03:00
|
|
|
mayBeVisible: communitySidebar.collapsed && !model.muted && Settings.spaceNotifications
|
2022-04-13 04:49:21 +03:00
|
|
|
anchors.right: avatar.right
|
|
|
|
anchors.bottom: avatar.bottom
|
|
|
|
anchors.margins: -Nheko.paddingSmall
|
|
|
|
}
|
|
|
|
|
2021-06-11 15:51:29 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
ElidedLabel {
|
2021-12-01 02:02:41 +03:00
|
|
|
visible: !communitySidebar.collapsed
|
2021-06-11 15:51:29 +03:00
|
|
|
Layout.alignment: Qt.AlignVCenter
|
|
|
|
color: communityItem.importantText
|
2021-12-01 02:33:22 +03:00
|
|
|
Layout.fillWidth: true
|
|
|
|
elideWidth: width
|
2022-07-16 04:07:00 +03:00
|
|
|
fullText: model.displayName
|
2021-06-11 15:51:29 +03:00
|
|
|
textFormat: Text.PlainText
|
|
|
|
}
|
2021-06-11 14:12:43 +03:00
|
|
|
|
2021-06-11 15:51:29 +03:00
|
|
|
Item {
|
|
|
|
Layout.fillWidth: true
|
2021-06-11 14:12:43 +03:00
|
|
|
}
|
|
|
|
|
2022-04-22 01:26:14 +03:00
|
|
|
NotificationBubble {
|
2022-07-16 04:07:00 +03:00
|
|
|
notificationCount: model.unreadMessages
|
|
|
|
hasLoudNotification: model.hasLoudNotification
|
2022-04-22 01:26:14 +03:00
|
|
|
bubbleBackgroundColor: communityItem.bubbleBackground
|
|
|
|
bubbleTextColor: communityItem.bubbleText
|
2022-07-16 04:07:00 +03:00
|
|
|
mayBeVisible: !communitySidebar.collapsed && !model.muted && Settings.spaceNotifications
|
2022-04-13 04:49:21 +03:00
|
|
|
Layout.alignment: Qt.AlignRight
|
|
|
|
Layout.leftMargin: Nheko.paddingSmall
|
|
|
|
}
|
|
|
|
|
2021-06-11 14:12:43 +03:00
|
|
|
}
|
|
|
|
|
2021-11-11 23:32:38 +03:00
|
|
|
background: Rectangle {
|
2022-04-22 01:26:14 +03:00
|
|
|
color: communityItem.backgroundColor
|
2021-11-11 23:32:38 +03:00
|
|
|
}
|
|
|
|
|
2021-06-11 14:12:43 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
background: Rectangle {
|
|
|
|
color: Nheko.theme.sidebarBackground
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|