Compare commits

..

9 Commits

Author SHA1 Message Date
Tobias Fella
217f9e2e02 Set OUTPUT_DIRECTORY for qml modules
This fixes some cmake warning and might make qmlls happier
2024-03-29 20:06:26 +01:00
Tobias Fella
f40a0a6f5f Remove unused property 2024-03-29 16:43:06 +01:00
Tobias Fella
9bd67acc2f Remove leftover signal 2024-03-29 16:05:07 +01:00
James Graham
e87da0feb0 Add pagination to space hierarchy cache
Add pagination to space hierarchy cache to ensure all rooms get cached.
2024-03-29 15:03:50 +00:00
Tobias Fella
2608d879fa Add "Leave room" button to sidebar
BUG: 484425
2024-03-29 13:53:59 +01:00
Tobias Fella
6ab61fd41f Fix opening the last room active room if it's not in a space
At the moment, the saved room was effectively always overridden by the first room in the list
2024-03-29 13:29:41 +01:00
Tobias Fella
30dd6297ee Make sure we're switching out of the space home page when leaving the currently opened space 2024-03-29 11:57:06 +01:00
Tobias Fella
ce02183f82 Fix plural handling in space member strings 2024-03-29 11:56:29 +01:00
Tobias Fella
7c74a6cbe1 Improve space management strings 2024-03-29 11:56:06 +01:00
13 changed files with 96 additions and 29 deletions

View File

@@ -175,6 +175,7 @@ add_library(neochat STATIC
)
qt_add_qml_module(neochat URI org.kde.neochat NO_PLUGIN
OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/src/org/kde/neochat
QML_FILES
qml/main.qml
qml/AccountMenu.qml
@@ -288,6 +289,7 @@ qt_add_qml_module(neochat URI org.kde.neochat NO_PLUGIN
qml/JoinRoomDialog.qml
qml/ConfirmUrlDialog.qml
qml/AccountSwitchDialog.qml
qml/ConfirmLeaveDialog.qml
RESOURCES
qml/confetti.png
qml/glowdot.png

View File

@@ -0,0 +1,32 @@
// 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 org.kde.kirigami as Kirigami
import org.kde.kirigamiaddons.formcard as FormCard
import org.kde.neochat
Kirigami.Dialog {
id: root
required property NeoChatRoom room
width: Kirigami.Units.gridUnit * 24
title: i18nc("@title:dialog", "Confirm Leaving Room")
contentItem: FormCard.FormTextDelegate {
text: root.room ? i18nc("Do you really want to leave <room name>?", "Do you really want to leave %1?", root.room.displayName) : ""
}
customFooterActions: [
Kirigami.Action {
text: i18nc("@action:button", "Leave Room")
icon.name: "arrow-left"
onTriggered: RoomManager.leaveRoom(root.room)
}
]
}

View File

@@ -115,6 +115,20 @@ QQC2.ScrollView {
Layout.fillWidth: true
}
Delegates.RoundedItemDelegate {
id: leaveButton
icon.name: "arrow-left"
text: i18nc("@action:button", "Leave this room")
Layout.fillWidth: true
onClicked: {
Qt.createComponent('org.kde.neochat', 'ConfirmLeaveDialog.qml').createObject(root.QQC2.ApplicationWindow.window, {
room: root.room
}).open();
}
}
Kirigami.ListSectionHeader {
label: i18n("Members")
activeFocusOnTab: false

View File

@@ -32,7 +32,7 @@ Kirigami.Page {
readonly property RoomTreeModel roomTreeModel: RoomTreeModel {
connection: root.connection
}
property bool spaceChanging: true
property bool spaceChanging: false
readonly property bool collapsed: Config.collapsed
@@ -128,12 +128,11 @@ Kirigami.Page {
reuseItems: false
onLayoutChanged: {
treeView.expandRecursively();
if (sortFilterRoomTreeModel.filterTextJustChanged) {
treeView.expandRecursively();
sortFilterRoomTreeModel.filterTextJustChanged = false;
}
if (root.spaceChanging) {
treeView.expandRecursively();
if (spaceDrawer.showDirectChats || spaceDrawer.selectedSpaceId.length < 1) {
const item = treeView.itemAtIndex(treeView.index(1, 0))
if (!item) {

View File

@@ -97,7 +97,7 @@ Item {
Layout.fillWidth: true
Layout.alignment: Qt.AlignLeft | Qt.AlignTop
text: root.memberCount + (root.topic !== "" ? i18nc("number of room members", " members - ") + root.topic : i18nc("number of room members", " members"))
text: root.topic.length > 0 ? i18ncp("number of room members", "%1 member - ", "%1 members - ", root.memberCount) + root.topic : i18ncp("number of room members", "%1 member", "%1 members", root.memberCount)
elide: Text.ElideRight
font: Kirigami.Theme.smallFont
textFormat: Text.PlainText
@@ -106,7 +106,7 @@ Item {
}
QQC2.ToolButton {
visible: root.isSpace && root.canAddChildren
text: i18nc("@button", "Add new child")
text: i18nc("@button", "Add new room")
icon.name: "list-add"
display: QQC2.AbstractButton.IconOnly
onClicked: root.createRoom()

View File

@@ -55,7 +55,7 @@ Kirigami.Page {
}
QQC2.Button {
visible: root.currentRoom.canSendState("m.space.child")
text: i18nc("@button", "Add new child")
text: i18nc("@button", "Add new room")
icon.name: "list-add"
onClicked: _private.createRoom(root.currentRoom.id)
}

View File

@@ -18,7 +18,6 @@ Kirigami.ApplicationWindow {
property int columnWidth: Kirigami.Units.gridUnit * 13
property RoomListPage roomListPage
property bool roomListLoaded: false
property RoomPage roomPage
property SpaceHomePage spaceHomePage
@@ -36,7 +35,6 @@ Kirigami.ApplicationWindow {
showExisting: true
onConnectionChosen: {
pageStack.replace(roomListComponent);
roomListLoaded = true;
roomListPage = pageStack.currentItem;
RoomManager.loadInitialRoom();
}
@@ -63,7 +61,6 @@ Kirigami.ApplicationWindow {
target: LoginHelper
function onLoaded() {
pageStack.replace(roomListComponent);
roomListLoaded = true;
roomListPage = pageStack.currentItem;
RoomManager.loadInitialRoom();
}
@@ -321,7 +318,6 @@ Kirigami.ApplicationWindow {
if (AccountRegistry.rowCount() === 0) {
RoomManager.reset();
pageStack.clear();
roomListLoaded = false;
pageStack.push(Qt.createComponent('org.kde.neochat', '.qml'));
}
}

View File

@@ -375,6 +375,11 @@ void RoomManager::leaveRoom(NeoChatRoom *room)
m_currentRoom = m_lastCurrentRoom;
m_lastCurrentRoom = nullptr;
Q_EMIT currentRoomChanged();
if (m_currentRoom->isSpace()) {
Q_EMIT replaceSpaceHome(m_currentRoom);
} else {
Q_EMIT replaceRoom(m_currentRoom, {});
}
}
room->forget();

View File

@@ -259,13 +259,6 @@ Q_SIGNALS:
*/
void goToEvent(const QString &event);
/**
* @brief Open room in a new window.
*
* Signal triggered when a room needs to be opened in a new window.
*/
void openRoomInNewWindow(NeoChatRoom *room);
/**
* @brief Show details for the given user.
*

View File

@@ -4,6 +4,7 @@
qt_add_library(settings STATIC)
qt_add_qml_module(settings
URI org.kde.neochat.settings
OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/src/org/kde/neochat/settings
QML_FILES
NeoChatSettings.qml
RoomSettings.qml

View File

@@ -3,7 +3,6 @@
#include "spacehierarchycache.h"
#include <Quotient/csapi/space_hierarchy.h>
#include <Quotient/qt_connection_util.h>
#include <KConfigGroup>
@@ -55,24 +54,44 @@ void SpaceHierarchyCache::populateSpaceHierarchy(const QString &spaceId)
if (!m_connection) {
return;
}
auto job = m_connection->callApi<GetSpaceHierarchyJob>(spaceId);
m_nextBatchTokens[spaceId] = QString();
auto job = m_connection->callApi<GetSpaceHierarchyJob>(spaceId, none, none, none, *m_nextBatchTokens[spaceId]);
auto group = KConfigGroup(KSharedConfig::openStateConfig("SpaceHierarchy"_ls), "Cache"_ls);
m_spaceHierarchy.insert(spaceId, group.readEntry(spaceId, QStringList()));
connect(job, &BaseJob::success, this, [this, job, spaceId]() {
const auto rooms = job->rooms();
QList<QString> roomList;
for (unsigned long i = 0; i < rooms.size(); ++i) {
for (const auto &state : rooms[i].childrenState) {
addBatch(spaceId, job);
});
}
void SpaceHierarchyCache::addBatch(const QString &spaceId, Quotient::GetSpaceHierarchyJob *job)
{
const auto rooms = job->rooms();
QStringList roomList = m_spaceHierarchy[spaceId];
for (unsigned long i = 0; i < rooms.size(); ++i) {
for (const auto &state : rooms[i].childrenState) {
if (!roomList.contains(state->stateKey())) {
roomList.push_back(state->stateKey());
}
}
m_spaceHierarchy.insert(spaceId, roomList);
Q_EMIT spaceHierarchyChanged();
auto group = KConfigGroup(KSharedConfig::openStateConfig("SpaceHierarchy"_ls), "Cache"_ls);
group.writeEntry(spaceId, roomList);
group.sync();
});
}
m_spaceHierarchy.insert(spaceId, roomList);
Q_EMIT spaceHierarchyChanged();
auto group = KConfigGroup(KSharedConfig::openStateConfig("SpaceHierarchy"_ls), "Cache"_ls);
group.writeEntry(spaceId, roomList);
group.sync();
const auto nextBatchToken = job->nextBatch();
if (!nextBatchToken.isEmpty() && nextBatchToken != *m_nextBatchTokens[spaceId]) {
*m_nextBatchTokens[spaceId] = nextBatchToken;
auto nextJob = m_connection->callApi<GetSpaceHierarchyJob>(spaceId, none, none, none, *m_nextBatchTokens[spaceId]);
connect(nextJob, &BaseJob::success, this, [this, nextJob, spaceId]() {
addBatch(spaceId, nextJob);
});
} else {
m_nextBatchTokens[spaceId].reset();
}
}
void SpaceHierarchyCache::addSpaceToHierarchy(Quotient::Room *room)

View File

@@ -10,6 +10,8 @@
#include <QQmlEngine>
#include <QString>
#include <Quotient/csapi/space_hierarchy.h>
#include "neochatconnection.h"
namespace Quotient
@@ -110,6 +112,9 @@ private:
QList<QString> m_activeSpaceRooms;
QHash<QString, QList<QString>> m_spaceHierarchy;
void cacheSpaceHierarchy();
QHash<QString, Quotient::Omittable<QString>> m_nextBatchTokens;
void populateSpaceHierarchy(const QString &spaceId);
void addBatch(const QString &spaceId, Quotient::GetSpaceHierarchyJob *job);
NeoChatConnection *m_connection;
};

View File

@@ -4,6 +4,7 @@
qt_add_library(timeline STATIC)
qt_add_qml_module(timeline
URI org.kde.neochat.timeline
OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/src/org/kde/neochat/timeline
QML_FILES
EventDelegate.qml
TimelineDelegate.qml