1
0
mirror of https://github.com/KDE/latte-dock.git synced 2024-12-23 13:33:50 +03:00

provide universalsettings upgrade path for v0.10

This commit is contained in:
Michail Vourlakos 2020-08-30 14:57:31 +03:00
parent eb627dd070
commit 9428027aff
2 changed files with 33 additions and 0 deletions

View File

@ -21,6 +21,8 @@
#include "universalsettings.h"
// local
#include "../data/layoutdata.h"
#include "../layout/centrallayout.h"
#include "../layouts/importer.h"
#include "../layouts/manager.h"
@ -482,6 +484,32 @@ void UniversalSettings::syncSettings()
m_universalGroup.sync();
}
void UniversalSettings::upgrade_v010()
{
if (m_singleModeLayoutName.isEmpty()) {
//!Upgrading path for v0.9 to v0.10
QString lastNonAssigned = m_universalGroup.readEntry("lastNonAssignedLayout", QString());
QString currentLayout = m_universalGroup.readEntry("currentLayout", QString());
if (!lastNonAssigned.isEmpty()) {
m_singleModeLayoutName = lastNonAssigned;
} else if (!currentLayout.isEmpty()) {
m_singleModeLayoutName = currentLayout;
}
if (!m_singleModeLayoutName.isEmpty() && Layouts::Importer::layoutExists(m_singleModeLayoutName)) {
//! it is executed only after the upgrade path
m_universalGroup.writeEntry("singleModeLayoutName", m_singleModeLayoutName);
CentralLayout storage(this, Layouts::Importer::layoutUserFilePath(m_singleModeLayoutName));
if (m_singleModeLayoutName == lastNonAssigned) {
storage.setActivities(QStringList(Data::Layout::FREEACTIVITIESID));
} else if (storage.activities().isEmpty()) {
storage.setActivities(QStringList(Data::Layout::ALLACTIVITIESID));
}
}
}
}
void UniversalSettings::loadConfig()
{
m_version = m_universalGroup.readEntry("version", 1);
@ -497,6 +525,10 @@ void UniversalSettings::loadConfig()
m_sensitivity = static_cast<Settings::MouseSensitivity>(m_universalGroup.readEntry("mouseSensitivity", (int)Settings::HighMouseSensitivity));
loadScalesConfig();
if (m_singleModeLayoutName.isEmpty()) {
upgrade_v010();
}
}
void UniversalSettings::saveConfig()

View File

@ -160,6 +160,7 @@ private slots:
void updateColorsScriptIsPresent();
void trackedFileChanged(const QString &file);
void upgrade_v010();
private:
void cleanupSettings();