support XDG_CONFIG_PATH for app code

BUG:428210
work/spdx
Michail Vourlakos 4 years ago
parent a24f6b85c2
commit f27f938042

@ -27,6 +27,7 @@
#include "../screenpool.h"
#include "../layout/abstractlayout.h"
#include "../settings/universalsettings.h"
#include "../tools/commontools.h"
// Qt
#include <QFile>
@ -63,17 +64,17 @@ Importer::~Importer()
bool Importer::updateOldConfiguration()
{
QFile oldAppletsFile(QDir::homePath() + "/.config/lattedock-appletsrc");
QFile oldAppletsFile(Latte::configPath() + "/lattedock-appletsrc");
if (!oldAppletsFile.exists()) {
return false;
}
//! import standard old configuration and create the relevant layouts
importOldLayout(QDir::homePath() + "/.config/lattedock-appletsrc", i18n("My Layout"));
importOldLayout(QDir::homePath() + "/.config/lattedock-appletsrc", i18n("Alternative"), true);
importOldLayout(Latte::configPath() + "/lattedock-appletsrc", i18n("My Layout"));
importOldLayout(Latte::configPath() + "/lattedock-appletsrc", i18n("Alternative"), true);
QFile extFile(QDir::homePath() + "/.config/lattedockextrc");
QFile extFile(Latte::configPath() + "/lattedockextrc");
//! import also the old user layouts into the new architecture
if (extFile.exists()) {
@ -268,7 +269,7 @@ QString Importer::layoutCanBeImported(QString oldAppletsPath, QString newName, Q
QDir layoutDir(exportDirectory.isNull() ? layoutUserDir() : exportDirectory);
if (!layoutDir.exists() && exportDirectory.isNull()) {
QDir(QDir::homePath() + "/.config").mkdir("latte");
QDir(Latte::configPath()).mkdir("latte");
}
//! set up the new layout name
@ -397,7 +398,7 @@ bool Importer::exportFullConfiguration(QString file)
return false;
}
archive.addLocalFile(QString(QDir::homePath() + "/.config/lattedockrc"), QStringLiteral("lattedockrc"));
archive.addLocalFile(QString(Latte::configPath() + "/lattedockrc"), QStringLiteral("lattedockrc"));
for(const auto &layoutName : availableLayouts()) {
archive.addLocalFile(layoutUserFilePath(layoutName), QString("latte/" + layoutName + ".layout.latte"));
@ -515,7 +516,7 @@ bool Importer::importHelper(QString fileName)
latteDir.removeRecursively();
}
archive.directory()->copyTo(QString(QDir::homePath() + "/.config"));
archive.directory()->copyTo(Latte::configPath());
return true;
}
@ -591,7 +592,7 @@ bool Importer::layoutExists(QString layoutName)
QString Importer::layoutUserDir()
{
return QString(QDir::homePath() + "/.config/latte");
return QString(Latte::configPath() + "/latte");
}
QString Importer::layoutUserFilePath(QString layoutName)

@ -33,6 +33,7 @@
#include "../settings/dialogs/settingsdialog.h"
#include "../settings/universalsettings.h"
#include "../templates/templatesmanager.h"
#include "../tools/commontools.h"
// Qt
#include <QDir>
@ -87,7 +88,7 @@ void Manager::init()
//startup create what is necessary....
if (!layoutsDir.exists()) {
QDir(QDir::homePath() + "/.config").mkdir("latte");
QDir(Latte::configPath()).mkdir("latte");
}
QString defpath = m_corona->templatesManager()->newLayout(i18n("My Layout"), i18n(Templates::DEFAULTLAYOUTTEMPLATENAME));

@ -19,6 +19,9 @@
#include "screenpool.h"
// local
#include "../../tools/commontools.h"
// Qt
#include <QDebug>
#include <QDir>
@ -43,7 +46,7 @@ ScreenPool::ScreenPool(QObject *parent)
load();
QString plasmaSettingsFile = QDir::homePath() + "/.config/" + PLASMARC;
QString plasmaSettingsFile = Latte::configPath() + "/" + PLASMARC;
KDirWatch::self()->addFile(plasmaSettingsFile);

@ -377,7 +377,7 @@ void Theme::loadThemePaths()
} else {
//! when plasma theme uses the kde colors
//! we track when kde color scheme is changing
QString kdeSettingsFile = QDir::homePath() + "/.config/kdeglobals";
QString kdeSettingsFile = Latte::configPath() + "/kdeglobals";
KDirWatch::self()->addFile(kdeSettingsFile);

@ -25,6 +25,7 @@
#include "../layout/centrallayout.h"
#include "../layouts/importer.h"
#include "../layouts/manager.h"
#include "../tools/commontools.h"
// Qt
#include <QDebug>
@ -40,7 +41,7 @@
#define KWINMETAFORWARDTOPLASMASTRING "org.kde.plasmashell,/PlasmaShell,org.kde.PlasmaShell,activateLauncherMenu"
#define KWINCOLORSSCRIPT "kwin/scripts/lattewindowcolors"
#define KWINRC "/.config/kwinrc"
#define KWINRC "kwinrc"
#define KWINRCTRACKERINTERVAL 2500
@ -101,7 +102,7 @@ void UniversalSettings::load()
}
//! Track KWin rc options
const QString kwinrcFilePath = QDir::homePath() + KWINRC;
const QString kwinrcFilePath = Latte::configPath() + "/" + KWINRC;
KDirWatch::self()->addFile(kwinrcFilePath);
recoverKWinOptions();
@ -212,14 +213,14 @@ void UniversalSettings::setLaunchers(QStringList launcherList)
bool UniversalSettings::autostart() const
{
QFile autostartFile(QDir::homePath() + "/.config/autostart/org.kde.latte-dock.desktop");
QFile autostartFile(Latte::configPath() + "/autostart/org.kde.latte-dock.desktop");
return autostartFile.exists();
}
void UniversalSettings::setAutostart(bool state)
{
//! remove old autostart file
QFile oldAutostartFile(QDir::homePath() + "/.config/autostart/latte-dock.desktop");
QFile oldAutostartFile(Latte::configPath() + "/autostart/latte-dock.desktop");
if (oldAutostartFile.exists()) {
oldAutostartFile.remove();
@ -227,7 +228,7 @@ void UniversalSettings::setAutostart(bool state)
//! end of removal of old autostart file
QFile autostartFile(QDir::homePath() + "/.config/autostart/org.kde.latte-dock.desktop");
QFile autostartFile(Latte::configPath() + "/autostart/org.kde.latte-dock.desktop");
QFile metaFile(Layouts::Importer::standardPath("applications/org.kde.latte-dock.desktop", false));
if (!state && autostartFile.exists()) {
@ -241,9 +242,9 @@ void UniversalSettings::setAutostart(bool state)
emit autostartChanged();
} else if (state && metaFile.exists()) {
//! check if autostart folder exists and create otherwise
QDir autostartDir(QDir::homePath() + "/.config/autostart");
QDir autostartDir(Latte::configPath() + "/autostart");
if (!autostartDir.exists()) {
QDir configDir(QDir::homePath() + "/.config");
QDir configDir(Latte::configPath());
configDir.mkdir("autostart");
}

@ -19,6 +19,7 @@
// local
#include "shortcutstracker.h"
#include "../tools/commontools.h"
// Qt
#include <QAction>
@ -56,7 +57,7 @@ void ShortcutsTracker::initGlobalShortcutsWatcher()
m_badgesForActivate << QString();
}
const QString globalShortcutsFilePath = QDir::homePath() + "/.config/" + GLOBALSHORTCUTSCONFIG;
const QString globalShortcutsFilePath = Latte::configPath() + "/" + GLOBALSHORTCUTSCONFIG;
m_shortcutsConfigPtr = KSharedConfig::openConfig(globalShortcutsFilePath);
KDirWatch::self()->addFile(globalShortcutsFilePath);

@ -21,6 +21,7 @@
#include "commontools.h"
// Qt
#include <QDir>
#include <QFileInfo>
#include <QStandardPaths>
#include <QtMath>
@ -101,4 +102,16 @@ QString standardPath(QString subPath, bool localfirst)
return "";
}
QString configPath()
{
QStringList configPaths = QStandardPaths::standardLocations(QStandardPaths::ConfigLocation);
if (configPaths.count() == 0) {
return QDir::homePath() + "/.config";
}
return configPaths[0];
}
}

@ -37,6 +37,8 @@ float colorLumina(float r, float g, float b);
//! returns the standard path found that contains the subPath
//! local paths have higher priority by default
QString standardPath(QString subPath, bool localFirst = true);
QString configPath();
}
#endif

@ -22,6 +22,7 @@
// local
#include "../layouts/importer.h"
#include "../tools/commontools.h"
// Qt
#include <QDebug>
@ -158,7 +159,7 @@ QString SchemeColors::possibleSchemeFile(QString scheme)
QString tempScheme = scheme;
if (scheme == "kdeglobals") {
QString settingsFile = QDir::homePath() + "/.config/kdeglobals";
QString settingsFile = Latte::configPath() + "/kdeglobals";
if (QFileInfo(settingsFile).exists()) {
KSharedConfigPtr filePtr = KSharedConfig::openConfig(settingsFile);

@ -22,6 +22,7 @@
// local
#include "../abstractwindowinterface.h"
#include "../../lattecorona.h"
#include "../../tools/commontools.h"
// Qt
#include <QDir>
@ -65,7 +66,7 @@ void Schemes::init()
});
//! track for changing default scheme
QString kdeSettingsFile = QDir::homePath() + "/.config/kdeglobals";
QString kdeSettingsFile = Latte::configPath() + "/kdeglobals";
KDirWatch::self()->addFile(kdeSettingsFile);

Loading…
Cancel
Save