From 36f6f73baa41bfbe509c1ac39a9bf52a8b362061 Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Wed, 16 Jun 2021 16:09:31 +0300 Subject: [PATCH] layout:do not store homepath for schemes --- app/layout/abstractlayout.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/app/layout/abstractlayout.cpp b/app/layout/abstractlayout.cpp index e80dc7f3f..9b5323a9e 100644 --- a/app/layout/abstractlayout.cpp +++ b/app/layout/abstractlayout.cpp @@ -383,7 +383,13 @@ void AbstractLayout::loadConfig() m_backgroundStyle = static_cast(m_layoutGroup.readEntry("backgroundStyle", (int)ColorBackgroundStyle)); m_schemeFile = m_layoutGroup.readEntry("schemeFile", QString(Data::Layout::DEFAULTSCHEMEFILE)); - m_schemeFile = m_schemeFile.isEmpty() ? Data::Layout::DEFAULTSCHEMEFILE : m_schemeFile; + + if (m_schemeFile.startsWith("~")) { + m_schemeFile.remove(0, 1); + m_schemeFile = QDir::homePath() + m_schemeFile; + } + + m_schemeFile = m_schemeFile.isEmpty() || !QFileInfo(m_schemeFile).exists() ? Data::Layout::DEFAULTSCHEMEFILE : m_schemeFile; QString deprecatedTextColor = m_layoutGroup.readEntry("textColor", QString()); QString deprecatedBackground = m_layoutGroup.readEntry("background", QString()); @@ -418,7 +424,14 @@ void AbstractLayout::saveConfig() m_layoutGroup.writeEntry("lastUsedActivity", m_lastUsedActivity); m_layoutGroup.writeEntry("popUpMargin", m_popUpMargin); m_layoutGroup.writeEntry("preferredForShortcutsTouched", m_preferredForShortcutsTouched); - m_layoutGroup.writeEntry("schemeFile", m_schemeFile == Data::Layout::DEFAULTSCHEMEFILE ? "" : m_schemeFile); + + QString scmfile = m_schemeFile; + + if (scmfile.startsWith(QDir::homePath())) { + scmfile.remove(0, QDir::homePath().size()); + scmfile = "~" + scmfile; + } + m_layoutGroup.writeEntry("schemeFile", scmfile == Data::Layout::DEFAULTSCHEMEFILE ? "" : scmfile); m_layoutGroup.sync(); }