@@ -48,6 +48,11 @@ endif()
|
|||||||
|
|
||||||
set(QUOTIENT_FORCE_NAMESPACED_INCLUDES TRUE)
|
set(QUOTIENT_FORCE_NAMESPACED_INCLUDES TRUE)
|
||||||
|
|
||||||
|
set(RECOMMENDED_SPACE_ID "" CACHE STRING "The matrix ID of a space that will be recommended to the user. Only relevant to distros")
|
||||||
|
set(RECOMMENDED_SPACE_DISPLAYNAME "" CACHE STRING "The displayname of a space that will be recommended to the user. Only relevant to distros")
|
||||||
|
set(RECOMMENDED_SPACE_AVATAR "" CACHE STRING "mxc url of a space that will be recommended to the user. Only relevant to distros")
|
||||||
|
set(RECOMMENDED_SPACE_DESCRIPTION "" CACHE STRING "Description of a space that will be recommended to the user. Only relevant to distros")
|
||||||
|
|
||||||
ecm_setup_version(${PROJECT_VERSION}
|
ecm_setup_version(${PROJECT_VERSION}
|
||||||
VARIABLE_PREFIX NEOCHAT
|
VARIABLE_PREFIX NEOCHAT
|
||||||
VERSION_HEADER ${CMAKE_CURRENT_BINARY_DIR}/neochat-version.h
|
VERSION_HEADER ${CMAKE_CURRENT_BINARY_DIR}/neochat-version.h
|
||||||
|
|||||||
@@ -307,11 +307,17 @@ qt_add_qml_module(neochat URI org.kde.neochat NO_PLUGIN
|
|||||||
qml/ServerComboBox.qml
|
qml/ServerComboBox.qml
|
||||||
qml/UserSearchPage.qml
|
qml/UserSearchPage.qml
|
||||||
qml/ManualUserDialog.qml
|
qml/ManualUserDialog.qml
|
||||||
|
qml/RecommendedSpaceDialog.qml
|
||||||
RESOURCES
|
RESOURCES
|
||||||
qml/confetti.png
|
qml/confetti.png
|
||||||
qml/glowdot.png
|
qml/glowdot.png
|
||||||
)
|
)
|
||||||
|
|
||||||
|
target_compile_definitions(neochat PRIVATE "RECOMMENDED_SPACE_ID=\"${RECOMMENDED_SPACE_ID}\"")
|
||||||
|
target_compile_definitions(neochat PRIVATE "RECOMMENDED_SPACE_AVATAR=\"${RECOMMENDED_SPACE_AVATAR}\"")
|
||||||
|
target_compile_definitions(neochat PRIVATE "RECOMMENDED_SPACE_DESCRIPTION=\"${RECOMMENDED_SPACE_DESCRIPTION}\"")
|
||||||
|
target_compile_definitions(neochat PRIVATE "RECOMMENDED_SPACE_DISPLAYNAME=\"${RECOMMENDED_SPACE_DISPLAYNAME}\"")
|
||||||
|
|
||||||
configure_file(config-neochat.h.in ${CMAKE_CURRENT_BINARY_DIR}/config-neochat.h)
|
configure_file(config-neochat.h.in ${CMAKE_CURRENT_BINARY_DIR}/config-neochat.h)
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
|
|||||||
62
src/qml/RecommendedSpaceDialog.qml
Normal file
62
src/qml/RecommendedSpaceDialog.qml
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
// 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
|
||||||
|
|
||||||
|
FormCard.FormCardPage {
|
||||||
|
id: root
|
||||||
|
|
||||||
|
property var connection
|
||||||
|
|
||||||
|
title: i18nc("@title Join <name of a space>", "Join %1", SpaceHierarchyCache.recommendedSpaceDisplayName)
|
||||||
|
|
||||||
|
FormCard.FormHeader {
|
||||||
|
title: i18nc("@title", "Your distro recommends you join this space")
|
||||||
|
}
|
||||||
|
FormCard.FormCard {
|
||||||
|
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.closeDialog()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
FormCard.FormButtonDelegate {
|
||||||
|
text: i18nc("@action:button", "Ignore")
|
||||||
|
onClicked: {
|
||||||
|
SpaceHierarchyCache.recommendedSpaceHidden = true
|
||||||
|
root.closeDialog()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -176,6 +176,41 @@ 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: {
|
||||||
|
let dialog = pageStack.pushDialogLayer(Qt.resolvedUrl("qrc:/org/kde/neochat/qml/RecommendedSpaceDialog.qml"), {
|
||||||
|
connection: root.connection
|
||||||
|
}, {
|
||||||
|
title: i18nc("@title Join <name of a space>", "Join %1", SpaceHierarchyCache.recommendedSpaceDisplayName)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
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 {
|
Kirigami.Separator {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.topMargin: Kirigami.Units.smallSpacing / 2
|
Layout.topMargin: Kirigami.Units.smallSpacing / 2
|
||||||
|
|||||||
@@ -6,6 +6,9 @@
|
|||||||
#include <Quotient/csapi/space_hierarchy.h>
|
#include <Quotient/csapi/space_hierarchy.h>
|
||||||
#include <Quotient/qt_connection_util.h>
|
#include <Quotient/qt_connection_util.h>
|
||||||
|
|
||||||
|
#include <KConfigGroup>
|
||||||
|
#include <KSharedConfig>
|
||||||
|
|
||||||
#include "neochatroom.h"
|
#include "neochatroom.h"
|
||||||
|
|
||||||
using namespace Quotient;
|
using namespace Quotient;
|
||||||
@@ -111,4 +114,38 @@ void SpaceHierarchyCache::setConnection(NeoChatConnection *connection)
|
|||||||
connect(connection, &Connection::aboutToDeleteRoom, this, &SpaceHierarchyCache::removeSpaceFromHierarchy);
|
connect(connection, &Connection::aboutToDeleteRoom, this, &SpaceHierarchyCache::removeSpaceFromHierarchy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString SpaceHierarchyCache::recommendedSpaceId() const
|
||||||
|
{
|
||||||
|
return QStringLiteral(RECOMMENDED_SPACE_ID);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString SpaceHierarchyCache::recommendedSpaceAvatar() const
|
||||||
|
{
|
||||||
|
return QStringLiteral(RECOMMENDED_SPACE_AVATAR);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString SpaceHierarchyCache::recommendedSpaceDisplayName() const
|
||||||
|
{
|
||||||
|
return QStringLiteral(RECOMMENDED_SPACE_DISPLAYNAME);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString SpaceHierarchyCache::recommendedSpaceDescription() const
|
||||||
|
{
|
||||||
|
return QStringLiteral(RECOMMENDED_SPACE_DESCRIPTION);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SpaceHierarchyCache::recommendedSpaceHidden() const
|
||||||
|
{
|
||||||
|
KConfigGroup group(KSharedConfig::openStateConfig(), QStringLiteral("recommendedSpace"));
|
||||||
|
return group.readEntry<bool>(QStringLiteral("hidden"), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SpaceHierarchyCache::setRecommendedSpaceHidden(bool hidden)
|
||||||
|
{
|
||||||
|
KConfigGroup group(KSharedConfig::openStateConfig(), QStringLiteral("recommendedSpace"));
|
||||||
|
group.writeEntry(QStringLiteral("hidden"), hidden);
|
||||||
|
group.sync();
|
||||||
|
Q_EMIT recommendedSpaceHiddenChanged();
|
||||||
|
}
|
||||||
|
|
||||||
#include "moc_spacehierarchycache.cpp"
|
#include "moc_spacehierarchycache.cpp"
|
||||||
|
|||||||
@@ -31,6 +31,11 @@ class SpaceHierarchyCache : public QObject
|
|||||||
QML_SINGLETON
|
QML_SINGLETON
|
||||||
|
|
||||||
Q_PROPERTY(NeoChatConnection *connection READ connection WRITE setConnection NOTIFY connectionChanged)
|
Q_PROPERTY(NeoChatConnection *connection READ connection WRITE setConnection NOTIFY connectionChanged)
|
||||||
|
Q_PROPERTY(QString recommendedSpaceId READ recommendedSpaceId CONSTANT)
|
||||||
|
Q_PROPERTY(QString recommendedSpaceAvatar READ recommendedSpaceAvatar CONSTANT)
|
||||||
|
Q_PROPERTY(QString recommendedSpaceDisplayName READ recommendedSpaceDisplayName CONSTANT)
|
||||||
|
Q_PROPERTY(QString recommendedSpaceDescription READ recommendedSpaceDescription CONSTANT)
|
||||||
|
Q_PROPERTY(bool recommendedSpaceHidden READ recommendedSpaceHidden WRITE setRecommendedSpaceHidden NOTIFY recommendedSpaceHiddenChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static SpaceHierarchyCache &instance()
|
static SpaceHierarchyCache &instance()
|
||||||
@@ -57,9 +62,18 @@ public:
|
|||||||
NeoChatConnection *connection() const;
|
NeoChatConnection *connection() const;
|
||||||
void setConnection(NeoChatConnection *connection);
|
void setConnection(NeoChatConnection *connection);
|
||||||
|
|
||||||
|
QString recommendedSpaceId() const;
|
||||||
|
QString recommendedSpaceAvatar() const;
|
||||||
|
QString recommendedSpaceDisplayName() const;
|
||||||
|
QString recommendedSpaceDescription() const;
|
||||||
|
|
||||||
|
bool recommendedSpaceHidden() const;
|
||||||
|
void setRecommendedSpaceHidden(bool hidden);
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void spaceHierarchyChanged();
|
void spaceHierarchyChanged();
|
||||||
void connectionChanged();
|
void connectionChanged();
|
||||||
|
void recommendedSpaceHiddenChanged();
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void addSpaceToHierarchy(Quotient::Room *room);
|
void addSpaceToHierarchy(Quotient::Room *room);
|
||||||
|
|||||||
Reference in New Issue
Block a user