File indexing completed on 2024-04-28 16:45:06
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 <KQuickAddons/ManagedConfigModule> 0009 0010 #include "output_model.h" 0011 0012 namespace KScreen 0013 { 0014 class ConfigOperation; 0015 } 0016 0017 class ConfigHandler; 0018 class OrientationSensor; 0019 class OutputIdentifier; 0020 0021 class KCMKScreen : public KQuickAddons::ManagedConfigModule 0022 { 0023 Q_OBJECT 0024 0025 Q_PROPERTY(OutputModel *outputModel READ outputModel NOTIFY outputModelChanged) 0026 Q_PROPERTY(bool backendReady READ backendReady NOTIFY backendReadyChanged) 0027 Q_PROPERTY(bool screenNormalized READ screenNormalized NOTIFY screenNormalizedChanged) 0028 Q_PROPERTY(bool perOutputScaling READ perOutputScaling NOTIFY perOutputScalingChanged) 0029 Q_PROPERTY(bool xwaylandClientsScaleSupported READ xwaylandClientsScaleSupported NOTIFY xwaylandClientsScaleSupportedChanged) 0030 Q_PROPERTY(bool primaryOutputSupported READ primaryOutputSupported NOTIFY primaryOutputSupportedChanged) 0031 Q_PROPERTY(bool outputReplicationSupported READ outputReplicationSupported NOTIFY outputReplicationSupportedChanged) 0032 Q_PROPERTY(qreal globalScale READ globalScale WRITE setGlobalScale NOTIFY globalScaleChanged) 0033 Q_PROPERTY(int outputRetention READ outputRetention WRITE setOutputRetention NOTIFY outputRetentionChanged) 0034 Q_PROPERTY(bool autoRotationSupported READ autoRotationSupported NOTIFY autoRotationSupportedChanged) 0035 Q_PROPERTY(bool orientationSensorAvailable READ orientationSensorAvailable NOTIFY orientationSensorAvailableChanged) 0036 Q_PROPERTY(bool tabletModeAvailable READ tabletModeAvailable NOTIFY tabletModeAvailableChanged) 0037 Q_PROPERTY(bool xwaylandClientsScale READ xwaylandClientsScale WRITE setXwaylandClientsScale NOTIFY xwaylandClientsScaleChanged) 0038 0039 public: 0040 enum InvalidConfigReason { 0041 NoEnabledOutputs, 0042 ConfigHasGaps, 0043 }; 0044 Q_ENUM(InvalidConfigReason) 0045 0046 explicit KCMKScreen(QObject *parent, const KPluginMetaData &data, const QVariantList &args); 0047 ~KCMKScreen() override = default; 0048 0049 void load() override; 0050 void save() override; 0051 void defaults() override; 0052 0053 bool isSaveNeeded() const override; 0054 0055 OutputModel *outputModel() const; 0056 0057 Q_INVOKABLE void identifyOutputs(); 0058 0059 bool backendReady() const; 0060 0061 Q_INVOKABLE QSize normalizeScreen() const; 0062 bool screenNormalized() const; 0063 0064 bool perOutputScaling() const; 0065 bool primaryOutputSupported() const; 0066 bool outputReplicationSupported() const; 0067 0068 qreal globalScale() const; 0069 void setGlobalScale(qreal scale); 0070 0071 bool xwaylandClientsScale() const; 0072 void setXwaylandClientsScale(bool scale); 0073 bool xwaylandClientsScaleSupported() const; 0074 0075 int outputRetention() const; 0076 void setOutputRetention(int retention); 0077 0078 bool autoRotationSupported() const; 0079 bool orientationSensorAvailable() const; 0080 bool tabletModeAvailable() const; 0081 0082 void doSave(); 0083 Q_INVOKABLE void revertSettings(); 0084 Q_INVOKABLE void requestReboot(); 0085 0086 Q_INVOKABLE void setStopUpdatesFromBackend(bool value); 0087 Q_INVOKABLE void updateFromBackend(); 0088 0089 Q_SIGNALS: 0090 void backendReadyChanged(); 0091 void backendError(); 0092 void outputModelChanged(); 0093 void changed(); 0094 void screenNormalizedChanged(); 0095 void perOutputScalingChanged(); 0096 void primaryOutputSupportedChanged(); 0097 void outputReplicationSupportedChanged(); 0098 void globalScaleChanged(); 0099 void outputRetentionChanged(); 0100 void autoRotationSupportedChanged(); 0101 void orientationSensorAvailableChanged(); 0102 void tabletModeAvailableChanged(); 0103 void invalidConfig(InvalidConfigReason reason); 0104 void errorOnSave(); 0105 void globalScaleWritten(); 0106 void outputConnect(bool connected); 0107 void settingsReverted(); 0108 void showRevertWarning(); 0109 void xwaylandClientsScaleChanged(); 0110 void xwaylandClientsScaleSupportedChanged(); 0111 0112 private: 0113 void setBackendReady(bool error); 0114 void setScreenNormalized(bool normalized); 0115 0116 void exportGlobalScale(); 0117 0118 void configReady(KScreen::ConfigOperation *op); 0119 void continueNeedsSaveCheck(bool needs); 0120 void checkConfig(); 0121 0122 std::unique_ptr<ConfigHandler> m_configHandler; 0123 OrientationSensor *m_orientationSensor; 0124 bool m_backendReady = false; 0125 bool m_screenNormalized = true; 0126 bool m_settingsReverted = false; 0127 bool m_stopUpdatesFromBackend = false; 0128 bool m_configNeedsSave = false; 0129 0130 QTimer *m_loadCompressor; 0131 };