1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 18:56:34 +01:00

SessionManager: Use relative paths for session files in settings

See #2331
This commit is contained in:
David Rosca 2018-01-02 20:56:08 +01:00
parent da3e16d7c4
commit a8763bee06

View File

@ -310,11 +310,17 @@ void SessionManager::fillSessionsMetaDataListIfNeeded()
void SessionManager::loadSettings() void SessionManager::loadSettings()
{ {
QDir sessionsDir(DataPaths::path(DataPaths::Sessions));
Settings settings; Settings settings;
settings.beginGroup("Web-Browser-Settings"); settings.beginGroup("Web-Browser-Settings");
m_lastActiveSessionPath = settings.value("lastActiveSessionPath", defaultSessionPath()).toString(); m_lastActiveSessionPath = settings.value("lastActiveSessionPath", defaultSessionPath()).toString();
settings.endGroup(); settings.endGroup();
if (QDir::isRelativePath(m_lastActiveSessionPath)) {
m_lastActiveSessionPath = sessionsDir.absoluteFilePath(m_lastActiveSessionPath);
}
// fallback to default session // fallback to default session
if (!QFile::exists(m_lastActiveSessionPath)) if (!QFile::exists(m_lastActiveSessionPath))
m_lastActiveSessionPath = defaultSessionPath(); m_lastActiveSessionPath = defaultSessionPath();
@ -322,9 +328,11 @@ void SessionManager::loadSettings()
void SessionManager::saveSettings() void SessionManager::saveSettings()
{ {
QDir sessionsDir(DataPaths::path(DataPaths::Sessions));
Settings settings; Settings settings;
settings.beginGroup("Web-Browser-Settings"); settings.beginGroup("Web-Browser-Settings");
settings.setValue("lastActiveSessionPath", m_lastActiveSessionPath); settings.setValue("lastActiveSessionPath", sessionsDir.relativeFilePath(m_lastActiveSessionPath));
settings.endGroup(); settings.endGroup();
} }