Add a way for distros to recommend joining a space

Implements #137
This commit is contained in:
Tobias Fella
2024-01-29 23:12:51 +01:00
parent 292cfb0d3d
commit 4ebcc36fb3
5 changed files with 158 additions and 0 deletions

View File

@@ -0,0 +1,69 @@
// SPDX-FileCopyrightText: 2024 Tobias Fella <tobias.fella@kde.org>
// SPDX-License-Identifier: GPL-2.0-or-later
import QtQuick
import QtQuick.Controls as QQC2
import QtQuick.Layouts
import org.kde.kirigami as Kirigami
import org.kde.kirigamiaddons.formcard as FormCard
import org.kde.kirigamiaddons.components
import org.kde.neochat
Kirigami.Dialog {
id: root
property var connection
parent: applicationWindow().overlay
leftPadding: 0
rightPadding: 0
topPadding: 0
bottomPadding: 0
title: i18nc("@title Join <name of a space>", "Join %1", SpaceHierarchyCache.recommendedSpaceDisplayName)
width: Math.min(applicationWindow().width, Kirigami.Units.gridUnit * 24)
contentItem: ColumnLayout {
FormCard.AbstractFormDelegate {
background: null
contentItem: RowLayout {
spacing: Kirigami.Units.largeSpacing * 4
Avatar {
source: root.connection.makeMediaUrl(SpaceHierarchyCache.recommendedSpaceAvatar)
}
ColumnLayout {
Layout.fillWidth: true
Kirigami.Heading {
Layout.fillWidth: true
text: SpaceHierarchyCache.recommendedSpaceDisplayName
}
QQC2.Label {
Layout.fillWidth: true
text: SpaceHierarchyCache.recommendedSpaceDescription
}
}
}
}
FormCard.FormDelegateSeparator {}
FormCard.FormButtonDelegate {
text: i18nc("@action:button", "Join")
onClicked: {
SpaceHierarchyCache.recommendedSpaceHidden = true
RoomManager.resolveResource(SpaceHierarchyCache.recommendedSpaceId, "join")
root.close()
}
}
FormCard.FormButtonDelegate {
text: i18nc("@action:button", "Ignore")
onClicked: {
SpaceHierarchyCache.recommendedSpaceHidden = true
root.close()
}
}
}
}

View File

@@ -254,6 +254,43 @@ QQC2.Control {
}
}
AvatarTabButton {
id: recommendedSpaceButton
Layout.fillWidth: true
Layout.preferredHeight: width - Kirigami.Units.smallSpacing
Layout.maximumHeight: width - Kirigami.Units.smallSpacing
visible: SpaceHierarchyCache.recommendedSpaceId.length > 0 && !root.connection.room(SpaceHierarchyCache.recommendedSpaceId) && !SpaceHierarchyCache.recommendedSpaceHidden
text: i18nc("Join <name of a space>", "Join %1", SpaceHierarchyCache.recommendedSpaceDisplayName)
source: root.connection.makeMediaUrl(SpaceHierarchyCache.recommendedSpaceAvatar)
onClicked: {
recommendedSpaceDialogComponent.createObject(QQC2.ApplicationWindow.overlay, {
connection: root.connection
}).open()
}
Component {
id: recommendedSpaceDialogComponent
RecommendedSpaceDialog {}
}
Rectangle {
color: Kirigami.Theme.backgroundColor
width: Kirigami.Units.gridUnit * 1.5
height: width
anchors.bottom: parent.bottom
anchors.bottomMargin: Kirigami.Units.smallSpacing
anchors.rightMargin: Kirigami.Units.smallSpacing * 2
anchors.right: parent.right
radius: width / 2
z: parent.z + 1
Kirigami.Icon {
anchors.fill: parent
z: parent + 1
source: "list-add"
}
}
}
Kirigami.Separator {
Layout.fillWidth: true
Layout.topMargin: Kirigami.Units.smallSpacing / 2