Fix Space Saving
This handles the following non-functioning cases from the space saving mr: - Selecting home or friends - Switching space that has the same room selected
This commit is contained in:
@@ -30,7 +30,7 @@ QQC2.Control {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
property bool showDirectChats: false
|
property bool showDirectChats: RoomManager.directChatsActive
|
||||||
|
|
||||||
signal selectionChanged
|
signal selectionChanged
|
||||||
signal spacesUpdated
|
signal spacesUpdated
|
||||||
@@ -103,7 +103,9 @@ QQC2.Control {
|
|||||||
checked: root.selectedSpaceId === "" && root.showDirectChats === false
|
checked: root.selectedSpaceId === "" && root.showDirectChats === false
|
||||||
onClicked: {
|
onClicked: {
|
||||||
root.showDirectChats = false;
|
root.showDirectChats = false;
|
||||||
|
RoomManager.directChatsActive = false;
|
||||||
root.selectedSpaceId = "";
|
root.selectedSpaceId = "";
|
||||||
|
RoomManager.lastSpaceId = "";
|
||||||
root.selectionChanged();
|
root.selectionChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -123,7 +125,9 @@ QQC2.Control {
|
|||||||
checked: root.showDirectChats === true
|
checked: root.showDirectChats === true
|
||||||
onClicked: {
|
onClicked: {
|
||||||
root.showDirectChats = true;
|
root.showDirectChats = true;
|
||||||
|
RoomManager.directChatsActive = true;
|
||||||
root.selectedSpaceId = "";
|
root.selectedSpaceId = "";
|
||||||
|
RoomManager.lastSpaceId = "";
|
||||||
root.selectionChanged();
|
root.selectionChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -184,8 +188,11 @@ QQC2.Control {
|
|||||||
|
|
||||||
onSelected: {
|
onSelected: {
|
||||||
root.showDirectChats = false;
|
root.showDirectChats = false;
|
||||||
|
RoomManager.directChatsActive = false;
|
||||||
if (!SpaceHierarchyCache.isSpaceChild(roomId, RoomManager.currentRoom.id) || root.selectedSpaceId == roomId) {
|
if (!SpaceHierarchyCache.isSpaceChild(roomId, RoomManager.currentRoom.id) || root.selectedSpaceId == roomId) {
|
||||||
RoomManager.resolveResource(currentRoom.id);
|
RoomManager.resolveResource(currentRoom.id);
|
||||||
|
} else {
|
||||||
|
RoomManager.lastSpaceId = currentRoom.id;
|
||||||
}
|
}
|
||||||
root.selectedSpaceId = roomId;
|
root.selectedSpaceId = roomId;
|
||||||
root.selectionChanged();
|
root.selectionChanged();
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ RoomManager::RoomManager(QObject *parent)
|
|||||||
{
|
{
|
||||||
m_lastRoomConfig = m_config->group(QStringLiteral("LastOpenRoom"));
|
m_lastRoomConfig = m_config->group(QStringLiteral("LastOpenRoom"));
|
||||||
m_lastSpaceConfig = m_config->group(QStringLiteral("LastOpenSpace"));
|
m_lastSpaceConfig = m_config->group(QStringLiteral("LastOpenSpace"));
|
||||||
|
m_directChatsConfig = m_config->group(QStringLiteral("DirectChatsActive"));
|
||||||
|
|
||||||
connect(this, &RoomManager::currentRoomChanged, this, [this]() {
|
connect(this, &RoomManager::currentRoomChanged, this, [this]() {
|
||||||
m_timelineModel->setRoom(m_currentRoom);
|
m_timelineModel->setRoom(m_currentRoom);
|
||||||
@@ -179,7 +180,7 @@ void RoomManager::loadInitialRoom()
|
|||||||
connect(this, &RoomManager::connectionChanged, this, &RoomManager::openRoomForActiveConnection);
|
connect(this, &RoomManager::connectionChanged, this, &RoomManager::openRoomForActiveConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString RoomManager::lastSpaceId()
|
QString RoomManager::lastSpaceId() const
|
||||||
{
|
{
|
||||||
if (!m_connection) {
|
if (!m_connection) {
|
||||||
return {};
|
return {};
|
||||||
@@ -187,6 +188,40 @@ QString RoomManager::lastSpaceId()
|
|||||||
return m_lastSpaceConfig.readEntry(m_connection->userId(), QString());
|
return m_lastSpaceConfig.readEntry(m_connection->userId(), QString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RoomManager::setLastSpaceId(const QString &lastSpaceId)
|
||||||
|
{
|
||||||
|
if (!m_connection) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto currentLastSpaceId = m_lastSpaceConfig.readEntry(m_connection->userId(), QString());
|
||||||
|
if (lastSpaceId == currentLastSpaceId) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_lastSpaceConfig.writeEntry(m_connection->userId(), lastSpaceId);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool RoomManager::directChatsActive() const
|
||||||
|
{
|
||||||
|
if (!m_connection) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
return m_directChatsConfig.readEntry(m_connection->userId(), bool());
|
||||||
|
}
|
||||||
|
|
||||||
|
void RoomManager::setDirectChatsActive(bool directChatsActive)
|
||||||
|
{
|
||||||
|
if (!m_connection) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto currentDirectChatsActive = m_directChatsConfig.readEntry(m_connection->userId(), bool());
|
||||||
|
if (directChatsActive == currentDirectChatsActive) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_directChatsConfig.writeEntry(m_connection->userId(), directChatsActive);
|
||||||
|
}
|
||||||
|
|
||||||
void RoomManager::openRoomForActiveConnection()
|
void RoomManager::openRoomForActiveConnection()
|
||||||
{
|
{
|
||||||
if (!m_connection) {
|
if (!m_connection) {
|
||||||
|
|||||||
@@ -92,7 +92,12 @@ class RoomManager : public QObject, public UriResolverBase
|
|||||||
/**
|
/**
|
||||||
* @brief The room ID of the last space entered.
|
* @brief The room ID of the last space entered.
|
||||||
*/
|
*/
|
||||||
Q_PROPERTY(QString lastSpaceId READ lastSpaceId CONSTANT)
|
Q_PROPERTY(QString lastSpaceId READ lastSpaceId WRITE setLastSpaceId CONSTANT)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Whether the last SpaceDrawer category selected was direct chats.
|
||||||
|
*/
|
||||||
|
Q_PROPERTY(bool directChatsActive READ directChatsActive WRITE setDirectChatsActive CONSTANT)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The ChatDocumentHandler for the open room.
|
* @brief The ChatDocumentHandler for the open room.
|
||||||
@@ -200,7 +205,11 @@ public:
|
|||||||
*/
|
*/
|
||||||
void setUrlArgument(const QString &arg);
|
void setUrlArgument(const QString &arg);
|
||||||
|
|
||||||
QString lastSpaceId();
|
QString lastSpaceId() const;
|
||||||
|
void setLastSpaceId(const QString &lastSpaceId);
|
||||||
|
|
||||||
|
bool directChatsActive() const;
|
||||||
|
void setDirectChatsActive(bool directChatsActive);
|
||||||
|
|
||||||
NeoChatConnection *connection() const;
|
NeoChatConnection *connection() const;
|
||||||
void setConnection(NeoChatConnection *connection);
|
void setConnection(NeoChatConnection *connection);
|
||||||
@@ -334,6 +343,7 @@ private:
|
|||||||
KSharedConfig::Ptr m_config;
|
KSharedConfig::Ptr m_config;
|
||||||
KConfigGroup m_lastRoomConfig;
|
KConfigGroup m_lastRoomConfig;
|
||||||
KConfigGroup m_lastSpaceConfig;
|
KConfigGroup m_lastSpaceConfig;
|
||||||
|
KConfigGroup m_directChatsConfig;
|
||||||
QPointer<ChatDocumentHandler> m_chatDocumentHandler;
|
QPointer<ChatDocumentHandler> m_chatDocumentHandler;
|
||||||
|
|
||||||
TimelineModel *m_timelineModel;
|
TimelineModel *m_timelineModel;
|
||||||
|
|||||||
Reference in New Issue
Block a user