Compare commits
9 Commits
work/tobia
...
work/tobia
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
217f9e2e02 | ||
|
|
f40a0a6f5f | ||
|
|
9bd67acc2f | ||
|
|
e87da0feb0 | ||
|
|
2608d879fa | ||
|
|
6ab61fd41f | ||
|
|
30dd6297ee | ||
|
|
ce02183f82 | ||
|
|
7c74a6cbe1 |
@@ -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
|
||||
|
||||
32
src/qml/ConfirmLeaveDialog.qml
Normal file
32
src/qml/ConfirmLeaveDialog.qml
Normal 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)
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user