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

0001 /*
0002     SPDX-FileCopyrightText: 2012 Alejandro Fiestas Olivares <afiestas@kde.org>
0003     SPDX-FileCopyrightText: 2018 Roman Gilg <subdiff@gmail.com>
0004 
0005     SPDX-License-Identifier: GPL-2.0-or-later
0006 */
0007 #ifndef KSCREEN_DAEMON_H
0008 #define KSCREEN_DAEMON_H
0009 
0010 #include "../common/globals.h"
0011 #include "../common/osdaction.h"
0012 #include "config-X11.h"
0013 
0014 #include <kscreen/config.h>
0015 
0016 #include <kdedmodule.h>
0017 
0018 #include <QVariant>
0019 
0020 #include <memory>
0021 
0022 class Config;
0023 class OrientationSensor;
0024 class OrgKdeKscreenOsdServiceInterface;
0025 
0026 namespace KScreen
0027 {
0028 class OsdManager;
0029 }
0030 
0031 class QTimer;
0032 
0033 class KScreenDaemon : public KDEDModule
0034 {
0035     Q_OBJECT
0036     Q_CLASSINFO("D-Bus Interface", "org.kde.KScreen")
0037 
0038 public:
0039     KScreenDaemon(QObject *parent, const QList<QVariant> &);
0040     ~KScreenDaemon() override;
0041 
0042 public Q_SLOTS:
0043     // DBus
0044     void applyLayoutPreset(const QString &presetName);
0045     bool getAutoRotate();
0046     void setAutoRotate(bool value);
0047     bool isAutoRotateAvailable();
0048 
0049 Q_SIGNALS:
0050     // DBus
0051     void outputConnected(const QString &outputName);
0052     void unknownOutputConnected(const QString &outputName);
0053 
0054 private:
0055     Q_INVOKABLE void getInitialConfig();
0056     void init();
0057 
0058     void applyConfig();
0059     void applyKnownConfig();
0060     void applyIdealConfig();
0061     void configChanged();
0062     void saveCurrentConfig();
0063     void displayButton();
0064 #if HAVE_X11
0065     void alignX11TouchScreen();
0066 #endif
0067     void lidClosedChanged(bool lidIsClosed);
0068     void disableLidOutput();
0069     void setMonitorForChanges(bool enabled);
0070 
0071     void outputConnectedChanged();
0072     void showOSD();
0073     void applyOsdAction(KScreen::OsdAction::Action action);
0074 
0075     void doApplyConfig(const KScreen::ConfigPtr &config);
0076     void doApplyConfig(std::unique_ptr<Config> config);
0077     void refreshConfig();
0078 
0079     void monitorConnectedChange();
0080     void disableOutput(const KScreen::OutputPtr &output);
0081 
0082     void updateOrientation();
0083 
0084     std::unique_ptr<Config> m_monitoredConfig;
0085     bool m_monitoring;
0086     bool m_configDirty = true;
0087     QTimer *m_changeCompressor;
0088     QTimer *m_saveTimer;
0089     QTimer *m_lidClosedTimer;
0090     OrgKdeKscreenOsdServiceInterface *m_osdServiceInterface;
0091     OrientationSensor *m_orientationSensor;
0092 
0093     bool m_startingUp = true;
0094 };
0095 
0096 #endif /*KSCREEN_DAEMON_H*/