Remember Space
Save the last space entered so it can be recalled on startup
This commit is contained in:
@@ -21,7 +21,14 @@ QQC2.Control {
|
|||||||
topPadding: 0
|
topPadding: 0
|
||||||
bottomPadding: 0
|
bottomPadding: 0
|
||||||
|
|
||||||
property string selectedSpaceId
|
property string selectedSpaceId: RoomManager.lastSpaceId
|
||||||
|
Connections {
|
||||||
|
target: RoomManager
|
||||||
|
function onConnectionChanged() {
|
||||||
|
// We need to rebind as any previous change will have been overwritten.
|
||||||
|
selectedSpaceId = RoomManager.lastSpaceId
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
property bool showDirectChats: false
|
property bool showDirectChats: false
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ RoomManager::RoomManager(QObject *parent)
|
|||||||
, m_mediaMessageFilterModel(new MediaMessageFilterModel(this, m_messageFilterModel))
|
, m_mediaMessageFilterModel(new MediaMessageFilterModel(this, m_messageFilterModel))
|
||||||
{
|
{
|
||||||
m_lastRoomConfig = m_config->group(QStringLiteral("LastOpenRoom"));
|
m_lastRoomConfig = m_config->group(QStringLiteral("LastOpenRoom"));
|
||||||
|
m_lastSpaceConfig = m_config->group(QStringLiteral("LastOpenSpace"));
|
||||||
|
|
||||||
connect(this, &RoomManager::currentRoomChanged, this, [this]() {
|
connect(this, &RoomManager::currentRoomChanged, this, [this]() {
|
||||||
m_timelineModel->setRoom(m_currentRoom);
|
m_timelineModel->setRoom(m_currentRoom);
|
||||||
@@ -172,6 +173,14 @@ void RoomManager::loadInitialRoom()
|
|||||||
connect(this, &RoomManager::connectionChanged, this, &RoomManager::openRoomForActiveConnection);
|
connect(this, &RoomManager::connectionChanged, this, &RoomManager::openRoomForActiveConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString RoomManager::lastSpaceId()
|
||||||
|
{
|
||||||
|
if (!m_connection) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
return m_lastSpaceConfig.readEntry(m_connection->userId(), QString());
|
||||||
|
}
|
||||||
|
|
||||||
void RoomManager::openRoomForActiveConnection()
|
void RoomManager::openRoomForActiveConnection()
|
||||||
{
|
{
|
||||||
if (!m_connection) {
|
if (!m_connection) {
|
||||||
@@ -248,6 +257,7 @@ void RoomManager::visitRoom(Room *room, const QString &eventId)
|
|||||||
Q_EMIT currentRoomChanged();
|
Q_EMIT currentRoomChanged();
|
||||||
|
|
||||||
if (neoChatRoom->isSpace()) {
|
if (neoChatRoom->isSpace()) {
|
||||||
|
m_lastSpaceConfig.writeEntry(m_connection->userId(), room->id());
|
||||||
Q_EMIT replaceSpaceHome(neoChatRoom);
|
Q_EMIT replaceSpaceHome(neoChatRoom);
|
||||||
} else {
|
} else {
|
||||||
Q_EMIT replaceRoom(neoChatRoom, eventId);
|
Q_EMIT replaceRoom(neoChatRoom, eventId);
|
||||||
@@ -257,6 +267,7 @@ void RoomManager::visitRoom(Room *room, const QString &eventId)
|
|||||||
m_lastCurrentRoom = std::exchange(m_currentRoom, neoChatRoom);
|
m_lastCurrentRoom = std::exchange(m_currentRoom, neoChatRoom);
|
||||||
Q_EMIT currentRoomChanged();
|
Q_EMIT currentRoomChanged();
|
||||||
if (neoChatRoom->isSpace()) {
|
if (neoChatRoom->isSpace()) {
|
||||||
|
m_lastSpaceConfig.writeEntry(m_connection->userId(), room->id());
|
||||||
Q_EMIT pushSpaceHome(neoChatRoom);
|
Q_EMIT pushSpaceHome(neoChatRoom);
|
||||||
} else {
|
} else {
|
||||||
Q_EMIT pushRoom(neoChatRoom, eventId);
|
Q_EMIT pushRoom(neoChatRoom, eventId);
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#include <QQmlEngine>
|
#include <QQmlEngine>
|
||||||
#include <Quotient/room.h>
|
#include <Quotient/room.h>
|
||||||
#include <Quotient/uriresolver.h>
|
#include <Quotient/uriresolver.h>
|
||||||
|
#include <KConfigGroup>
|
||||||
|
|
||||||
#include "chatdocumenthandler.h"
|
#include "chatdocumenthandler.h"
|
||||||
#include "enums/delegatetype.h"
|
#include "enums/delegatetype.h"
|
||||||
@@ -87,6 +88,11 @@ class RoomManager : public QObject, public UriResolverBase
|
|||||||
*/
|
*/
|
||||||
Q_PROPERTY(bool hasOpenRoom READ hasOpenRoom NOTIFY currentRoomChanged)
|
Q_PROPERTY(bool hasOpenRoom READ hasOpenRoom NOTIFY currentRoomChanged)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief The room ID of the last space entered.
|
||||||
|
*/
|
||||||
|
Q_PROPERTY(QString lastSpaceId READ lastSpaceId CONSTANT)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The ChatDocumentHandler for the open room.
|
* @brief The ChatDocumentHandler for the open room.
|
||||||
*
|
*
|
||||||
@@ -200,6 +206,8 @@ public:
|
|||||||
*/
|
*/
|
||||||
void setUrlArgument(const QString &arg);
|
void setUrlArgument(const QString &arg);
|
||||||
|
|
||||||
|
QString lastSpaceId();
|
||||||
|
|
||||||
NeoChatConnection *connection() const;
|
NeoChatConnection *connection() const;
|
||||||
void setConnection(NeoChatConnection *connection);
|
void setConnection(NeoChatConnection *connection);
|
||||||
|
|
||||||
@@ -331,6 +339,7 @@ private:
|
|||||||
QString m_arg;
|
QString m_arg;
|
||||||
KSharedConfig::Ptr m_config;
|
KSharedConfig::Ptr m_config;
|
||||||
KConfigGroup m_lastRoomConfig;
|
KConfigGroup m_lastRoomConfig;
|
||||||
|
KConfigGroup m_lastSpaceConfig;
|
||||||
QPointer<ChatDocumentHandler> m_chatDocumentHandler;
|
QPointer<ChatDocumentHandler> m_chatDocumentHandler;
|
||||||
|
|
||||||
TimelineModel *m_timelineModel;
|
TimelineModel *m_timelineModel;
|
||||||
|
|||||||
Reference in New Issue
Block a user