diff --git a/kded/config.h b/kded/config.h --- a/kded/config.h +++ b/kded/config.h @@ -69,7 +69,10 @@ KScreen::Config::ValidityFlags m_validityFlags; static QString s_dirPath; + static QString s_configsDirName; static QString s_fixedConfigFileName; + + static QString configsDirPath(); }; #endif diff --git a/kded/config.cpp b/kded/config.cpp --- a/kded/config.cpp +++ b/kded/config.cpp @@ -36,6 +36,12 @@ QString Config::s_fixedConfigFileName = QStringLiteral("fixed-config"); QString Config::s_dirPath = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) % QStringLiteral("/kscreen/"); +QString Config::s_configsDirName = QStringLiteral("" /*"configs/"*/); // TODO: KDE6 - move these files into the subfolder + +QString Config::configsDirPath() +{ + return s_dirPath % s_configsDirName; +} Config::Config(KScreen::ConfigPtr config) : m_data(config) @@ -52,10 +58,10 @@ QString Config::filePath() { - if (!QDir().mkpath(s_dirPath)) { + if (!QDir().mkpath(configsDirPath())) { return QString(); } - return s_dirPath % id(); + return configsDirPath() % id(); } QString Config::id() const @@ -68,7 +74,7 @@ bool Config::fileExists() const { - return (QFile::exists(s_dirPath % id()) || QFile::exists(s_dirPath % s_fixedConfigFileName)); + return (QFile::exists(configsDirPath() % id()) || QFile::exists(configsDirPath() % s_fixedConfigFileName)); } std::unique_ptr Config::readFile() @@ -105,11 +111,11 @@ KScreen::ConfigPtr config = m_data->clone(); QFile file; - if (QFile::exists(s_dirPath % s_fixedConfigFileName)) { - file.setFileName(s_dirPath % s_fixedConfigFileName); + if (QFile::exists(configsDirPath() % s_fixedConfigFileName)) { + file.setFileName(configsDirPath() % s_fixedConfigFileName); qCDebug(KSCREEN_KDED) << "found a fixed config, will use " << file.fileName(); } else { - file.setFileName(s_dirPath % fileName); + file.setFileName(configsDirPath() % fileName); } if (!file.open(QIODevice::ReadOnly)) { qCDebug(KSCREEN_KDED) << "failed to open file" << file.fileName(); diff --git a/tests/kded/configtest.cpp b/tests/kded/configtest.cpp --- a/tests/kded/configtest.cpp +++ b/tests/kded/configtest.cpp @@ -438,7 +438,7 @@ QCOMPARE(output2->isPrimary(), true); // Check if both files exist - const QString closedPath = configWrapper->s_dirPath % configWrapper->id(); + const QString closedPath = Config::configsDirPath() % configWrapper->id(); const QString openedPath = closedPath % QStringLiteral("_lidOpened"); QFile openCfg(openedPath); @@ -481,7 +481,7 @@ QCOMPARE(output2->isEnabled(), true); QCOMPARE(output2->isPrimary(), false); - configWrapper->setDirPath(QStringLiteral(TEST_DATA "/serializerdata/")); + Config::setDirPath(QStringLiteral(TEST_DATA "/serializerdata/")); } void TestConfig::testFixedConfig() @@ -495,14 +495,16 @@ // Make sure we don't write into TEST_DATA QStandardPaths::setTestModeEnabled(true); - configWrapper->setDirPath(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) % QStringLiteral("/kscreen/")); - const auto fixedCfgPath = configWrapper->s_dirPath % configWrapper->s_fixedConfigFileName; + Config::setDirPath(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) % QStringLiteral("/kscreen/")); + const QString fixedCfgPath = Config::configsDirPath() % Config::s_fixedConfigFileName; // save config as the current one, this is the config we don't want restored, and which we'll overwrite configWrapper->writeFile(fixedCfgPath); // Check if both files exist QFile fixedCfg(fixedCfgPath); QVERIFY(fixedCfg.exists()); + + Config::setDirPath(QStringLiteral(TEST_DATA "/serializerdata/")); }