File indexing completed on 2024-04-28 05:27:38
0001 /* 0002 SPDX-FileCopyrightText: 2019 Roman Gilg <subdiff@gmail.com> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 #pragma once 0007 0008 #include "../common/control.h" 0009 0010 #include <kscreen/config.h> 0011 0012 #include <memory> 0013 0014 class OutputModel; 0015 0016 class ConfigHandler : public QObject 0017 { 0018 Q_OBJECT 0019 public: 0020 explicit ConfigHandler(QObject *parent = nullptr); 0021 ~ConfigHandler() override = default; 0022 0023 void setConfig(KScreen::ConfigPtr config); 0024 void updateInitialData(); 0025 0026 OutputModel *outputModel() const 0027 { 0028 return m_outputModel; 0029 } 0030 0031 QSize normalizeScreen(); 0032 0033 KScreen::ConfigPtr config() const 0034 { 0035 return m_config; 0036 } 0037 0038 KScreen::ConfigPtr initialConfig() const 0039 { 0040 return m_initialConfig; 0041 } 0042 0043 void revertConfig() 0044 { 0045 m_config = (m_previousConfig ? m_previousConfig : m_initialConfig)->clone(); 0046 } 0047 0048 KScreen::OutputPtr replicationSource(const KScreen::OutputPtr &output) const; 0049 void setReplicationSource(KScreen::OutputPtr &output, const KScreen::OutputPtr &source); 0050 0051 uint32_t overscan(const KScreen::OutputPtr &output) const; 0052 void setOverscan(const KScreen::OutputPtr &output, uint32_t value); 0053 0054 KScreen::Output::VrrPolicy vrrPolicy(const KScreen::OutputPtr &output) const; 0055 void setVrrPolicy(const KScreen::OutputPtr &output, KScreen::Output::VrrPolicy value); 0056 0057 KScreen::Output::RgbRange rgbRange(const KScreen::OutputPtr &output) const; 0058 void setRgbRange(const KScreen::OutputPtr &output, KScreen::Output::RgbRange value); 0059 0060 void writeControl(); 0061 0062 void checkNeedsSave(); 0063 bool shouldTestNewSettings(); 0064 0065 Q_SIGNALS: 0066 void outputModelChanged(); 0067 void changed(); 0068 void screenNormalizationUpdate(bool normalized); 0069 void needsSaveChecked(bool need); 0070 void outputConnect(bool connected); 0071 0072 private: 0073 void checkScreenNormalization(); 0074 QSize screenSize() const; 0075 void outputPrioritiesChanged(); 0076 void initOutput(const KScreen::OutputPtr &output); 0077 /** 0078 * @brief checkSaveandTestCommon - compairs common config changes that would make the config dirty and needed to have the config checked when applied. 0079 * @param isSaveCheck - True if your checking to see if the changes should request a save. 0080 * False if you want to check if you should test the config when applied. 0081 * @return true, if you should check for a save or test the new configuration 0082 */ 0083 bool checkSaveandTestCommon(bool isSaveCheck); 0084 bool checkPrioritiesNeedSave(); 0085 0086 KScreen::ConfigPtr m_config = nullptr; 0087 KScreen::ConfigPtr m_initialConfig; 0088 KScreen::ConfigPtr m_previousConfig = nullptr; 0089 OutputModel *m_outputModel = nullptr; 0090 0091 std::unique_ptr<ControlConfig> m_control; 0092 std::unique_ptr<ControlConfig> m_initialControl; 0093 QSize m_lastNormalizedScreenSize; 0094 };