Index: common/control.h =================================================================== --- common/control.h +++ common/control.h @@ -14,8 +14,8 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . *********************************************************************/ -#ifndef KDED_CONTROL_H -#define KDED_CONTROL_H +#ifndef COMMON_CONTROL_H +#define COMMON_CONTROL_H #include Index: common/control.cpp =================================================================== --- common/control.cpp +++ common/control.cpp @@ -15,26 +15,17 @@ along with this program. If not, see . *********************************************************************/ #include "control.h" -#include "config.h" +#include "globals.h" -#include "kscreen_daemon_debug.h" -#include "generator.h" - -#include #include -#include #include #include -#include - -#include -#include QString Control::s_dirName = QStringLiteral("control/"); QString Control::dirPath() { - return Config::dirPath() % s_dirName; + return Globals::dirPath() % s_dirName; } QString Control::outputFilePath(const QString &hash) @@ -74,7 +65,8 @@ // qDebug() << "Looking for control file:" << configId; QFile file(configFilePath(configId)); if (!file.open(QIODevice::ReadOnly)) { - qCDebug(KSCREEN_KDED) << "Failed to open file" << file.fileName(); + // TODO: have a logging category +// qCDebug(KSCREEN_COMMON) << "Failed to open file" << file.fileName(); return QMap(); } Index: common/globals.h =================================================================== --- common/globals.h +++ common/globals.h @@ -1,5 +1,5 @@ /******************************************************************** -Copyright 2019 Roman Gilg +Copyright 2018 Roman Gilg This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -14,33 +14,19 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . *********************************************************************/ -#ifndef KDED_CONTROL_H -#define KDED_CONTROL_H +#ifndef COMMON_GLOBALS_H +#define COMMON_GLOBALS_H -#include +#include -#include - -class Control +class Globals { public: - enum class OutputRetention { - Undefined = -1, - Global = 0, - Individual = 1, - }; - - static QMap readInOutputRetentionValues(const QString &configId); - static OutputRetention getOutputRetention(const QString &outputId, const QMap &retentions); - - static QString configFilePath(const QString &hash); - static QString outputFilePath(const QString &hash); - -private: + static void setDirPath(const QString &path); static QString dirPath(); - static OutputRetention convertVariantToOutputRetention(QVariant variant); - static QString s_dirName; +private: + static QString s_dirPath; }; #endif Index: common/globals.cpp =================================================================== --- /dev/null +++ common/globals.cpp @@ -0,0 +1,35 @@ +/******************************************************************** +Copyright 2018 Roman Gilg + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*********************************************************************/ +#include "globals.h" + +#include +#include +#include + +QString Globals::s_dirPath = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) % QStringLiteral("/kscreen/"); + +QString Globals::dirPath() { + return s_dirPath; +} + +void Globals::setDirPath(const QString &path) +{ + s_dirPath = path; + if (!s_dirPath.endsWith(QLatin1Char('/'))) { + s_dirPath += QLatin1Char('/'); + } +} Index: kded/CMakeLists.txt =================================================================== --- kded/CMakeLists.txt +++ kded/CMakeLists.txt @@ -6,12 +6,13 @@ daemon.cpp config.cpp output.cpp - control.cpp generator.cpp device.cpp osd.cpp osdmanager.cpp osdaction.cpp + ${CMAKE_SOURCE_DIR}/common/globals.cpp + ${CMAKE_SOURCE_DIR}/common/control.cpp ${CMAKE_SOURCE_DIR}/kcm/src/utils.cpp ) Index: kded/config.h =================================================================== --- kded/config.h +++ kded/config.h @@ -30,11 +30,6 @@ explicit Config(KScreen::ConfigPtr config); ~Config() = default; - static void setDirPath(const QString &path); - static QString dirPath() { - return s_dirPath; - } - QString id() const; bool fileExists() const; @@ -67,7 +62,6 @@ KScreen::ConfigPtr m_data; KScreen::Config::ValidityFlags m_validityFlags; - static QString s_dirPath; static QString s_configsDirName; static QString s_fixedConfigFileName; Index: kded/config.cpp =================================================================== --- kded/config.cpp +++ kded/config.cpp @@ -17,7 +17,8 @@ *********************************************************************/ #include "config.h" #include "output.h" -#include "control.h" +#include "../common/globals.h" +#include "../common/control.h" #include "kscreen_daemon_debug.h" #include "device.h" @@ -32,27 +33,18 @@ #include 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; + return Globals::dirPath() % s_configsDirName; } Config::Config(KScreen::ConfigPtr config) : m_data(config) { } -void Config::setDirPath(const QString &path) -{ - s_dirPath = path; - if (!s_dirPath.endsWith(QLatin1Char('/'))) { - s_dirPath += QLatin1Char('/'); - } -} - QString Config::filePath() { if (!QDir().mkpath(configsDirPath())) { Index: kded/output.h =================================================================== --- kded/output.h +++ kded/output.h @@ -17,7 +17,7 @@ #ifndef KDED_OUTPUT_H #define KDED_OUTPUT_H -#include "control.h" +#include "../common/control.h" #include Index: kded/output.cpp =================================================================== --- kded/output.cpp +++ kded/output.cpp @@ -16,6 +16,7 @@ *********************************************************************/ #include "output.h" #include "config.h" +#include "../common/globals.h" #include "kscreen_daemon_debug.h" #include "generator.h" @@ -34,7 +35,7 @@ QString Output::dirPath() { - return Config::dirPath() % s_dirName; + return Globals::dirPath() % s_dirName; } QString Output::globalFileName(const QString &hash) Index: tests/kded/CMakeLists.txt =================================================================== --- tests/kded/CMakeLists.txt +++ tests/kded/CMakeLists.txt @@ -9,7 +9,8 @@ ${CMAKE_SOURCE_DIR}/kded/device.cpp ${CMAKE_SOURCE_DIR}/kded/config.cpp ${CMAKE_SOURCE_DIR}/kded/output.cpp - ${CMAKE_SOURCE_DIR}/kded/control.cpp + ${CMAKE_SOURCE_DIR}/common/globals.cpp + ${CMAKE_SOURCE_DIR}/common/control.cpp #${CMAKE_SOURCE_DIR}/kded/daemon.cpp ) ecm_qt_declare_logging_category(test_SRCS HEADER kscreen_daemon_debug.h IDENTIFIER KSCREEN_KDED CATEGORY_NAME kscreen.kded) Index: tests/kded/configtest.cpp =================================================================== --- tests/kded/configtest.cpp +++ tests/kded/configtest.cpp @@ -16,6 +16,7 @@ along with this program. If not, see . *********************************************************************/ #include "../../kded/config.h" +#include "../../common/globals.h" #include #include @@ -103,7 +104,7 @@ void TestConfig::initTestCase() { qputenv("KSCREEN_LOGGING", "false"); - Config::setDirPath(QStringLiteral(TEST_DATA "serializerdata/")); + Globals::setDirPath(QStringLiteral(TEST_DATA "serializerdata/")); } void TestConfig::testSimpleConfig() @@ -366,7 +367,6 @@ config->addOutput(output1); Config configWrapper(config); - configWrapper.setDirPath(QStringLiteral(TEST_DATA "serializerdata/")); QHash positions; positions[QStringLiteral("DisplayPort-0")] = QPoint(0, 1080); @@ -407,7 +407,7 @@ // Make sure we don't write into TEST_DATA QStandardPaths::setTestModeEnabled(true); - configWrapper->setDirPath(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) % QStringLiteral("/kscreen/")); + Globals::setDirPath(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) % QStringLiteral("/kscreen/")); // TODO: this needs setup of the control directory // Basic assumptions for the remainder of our tests, this is the situation where the lid is opened @@ -482,7 +482,7 @@ QCOMPARE(output2->isEnabled(), true); QCOMPARE(output2->isPrimary(), false); - Config::setDirPath(QStringLiteral(TEST_DATA "/serializerdata/")); + Globals::setDirPath(QStringLiteral(TEST_DATA "/serializerdata/")); } void TestConfig::testFixedConfig() @@ -495,7 +495,7 @@ // Make sure we don't write into TEST_DATA QStandardPaths::setTestModeEnabled(true); - Config::setDirPath(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) % QStringLiteral("/kscreen/")); + Globals::setDirPath(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) % QStringLiteral("/kscreen/")); // TODO: this needs setup of the control directory const QString fixedCfgPath = Config::configsDirPath() % Config::s_fixedConfigFileName; @@ -506,7 +506,7 @@ QFile fixedCfg(fixedCfgPath); QVERIFY(fixedCfg.exists()); - Config::setDirPath(QStringLiteral(TEST_DATA "/serializerdata/")); + Globals::setDirPath(QStringLiteral(TEST_DATA "/serializerdata/")); }