Don't recreate config group when saving last room
Instead have the group as a member of the room manager
This commit is contained in:
@@ -19,6 +19,7 @@ RoomManager::RoomManager(QObject *parent)
|
|||||||
, m_lastCurrentRoom(nullptr)
|
, m_lastCurrentRoom(nullptr)
|
||||||
, m_config(KConfig("data", KConfig::SimpleConfig, QStandardPaths::AppDataLocation))
|
, m_config(KConfig("data", KConfig::SimpleConfig, QStandardPaths::AppDataLocation))
|
||||||
{
|
{
|
||||||
|
m_lastRoomConfig = m_config.group("LastOpenRoom");
|
||||||
}
|
}
|
||||||
|
|
||||||
RoomManager::~RoomManager()
|
RoomManager::~RoomManager()
|
||||||
@@ -97,8 +98,7 @@ void RoomManager::openRoomForActiveConnection()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Read from last open room
|
// Read from last open room
|
||||||
KConfigGroup lastOpenRoomGroup(&m_config, "LastOpenRoom");
|
QString roomId = m_lastRoomConfig.readEntry(Controller::instance().activeConnection()->userId(), QString());
|
||||||
QString roomId = lastOpenRoomGroup.readEntry(Controller::instance().activeConnection()->userId(), QString());
|
|
||||||
|
|
||||||
// TODO remove legacy check at some point.
|
// TODO remove legacy check at some point.
|
||||||
if (roomId.isEmpty()) {
|
if (roomId.isEmpty()) {
|
||||||
@@ -130,9 +130,7 @@ void RoomManager::enterRoom(NeoChatRoom *room)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Save last open room
|
// Save last open room
|
||||||
KConfigGroup lastOpenRoomGroup(&m_config, "LastOpenRoom");
|
m_lastRoomConfig.writeEntry(Controller::instance().activeConnection()->userId(), room->id());
|
||||||
lastOpenRoomGroup.writeEntry(Controller::instance().activeConnection()->userId(), room->id());
|
|
||||||
lastOpenRoomGroup.config()->sync();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RoomManager::openWindow(NeoChatRoom *room)
|
void RoomManager::openWindow(NeoChatRoom *room)
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <KConfig>
|
#include <KConfig>
|
||||||
|
#include <KConfigGroup>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <uriresolver.h>
|
#include <uriresolver.h>
|
||||||
|
|
||||||
@@ -104,4 +105,5 @@ private:
|
|||||||
NeoChatRoom *m_lastCurrentRoom;
|
NeoChatRoom *m_lastCurrentRoom;
|
||||||
QString m_arg;
|
QString m_arg;
|
||||||
KConfig m_config;
|
KConfig m_config;
|
||||||
|
KConfigGroup m_lastRoomConfig;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user