File indexing completed on 2024-04-28 16:45:08

0001 /*
0002     SPDX-FileCopyrightText: 2019 Roman Gilg <subdiff@gmail.com>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 #ifndef KDED_CONFIG_H
0007 #define KDED_CONFIG_H
0008 
0009 #include <kscreen/config.h>
0010 
0011 #include <QOrientationReading>
0012 
0013 #include <memory>
0014 
0015 class ControlConfig;
0016 
0017 class Config : public QObject
0018 {
0019     Q_OBJECT
0020 public:
0021     explicit Config(KScreen::ConfigPtr config, QObject *parent = nullptr);
0022     ~Config() = default;
0023 
0024     QString id() const;
0025 
0026     bool fileExists() const;
0027     std::unique_ptr<Config> readFile();
0028     std::unique_ptr<Config> readOpenLidFile();
0029     bool writeFile();
0030     bool writeOpenLidFile();
0031     static QString configsDirPath();
0032 
0033     KScreen::ConfigPtr data() const
0034     {
0035         return m_data;
0036     }
0037 
0038     void activateControlWatching();
0039     bool autoRotationRequested() const;
0040     void setDeviceOrientation(QOrientationReading::Orientation orientation);
0041     bool getAutoRotate() const;
0042     void setAutoRotate(bool value);
0043     void log();
0044 
0045     void setValidityFlags(KScreen::Config::ValidityFlags flags)
0046     {
0047         m_validityFlags = flags;
0048     }
0049 
0050     bool canBeApplied() const;
0051 
0052 Q_SIGNALS:
0053     void controlChanged();
0054 
0055 private:
0056     friend class TestConfig;
0057 
0058     QString filePath() const;
0059     std::unique_ptr<Config> readFile(const QString &fileName);
0060     bool writeFile(const QString &filePath);
0061 
0062     bool canBeApplied(KScreen::ConfigPtr config) const;
0063 
0064     KScreen::ConfigPtr m_data;
0065     KScreen::Config::ValidityFlags m_validityFlags;
0066     ControlConfig *m_control;
0067 
0068     static QString s_configsDirName;
0069     static QString s_fixedConfigFileName;
0070 
0071 };
0072 
0073 #endif