daemon.h 3.39 KB
Newer Older
1
/************************************************************************************
2
*  Copyright (C) 2012 by Alejandro Fiestas Olivares <afiestas@kde.org>              *
3
*  Copyright 2018 Roman Gilg <subdiff@gmail.com>                                    *
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
*                                                                                   *
*  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, write to the Free Software                      *
*  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA   *
*************************************************************************************/
Sebastian Kügler's avatar
Sebastian Kügler committed
19 20
#ifndef KSCREEN_DAEMON_H
#define KSCREEN_DAEMON_H
21

22
#include "../common/globals.h"
23
#include "osdaction.h"
24

Àlex Fiestas's avatar
Àlex Fiestas committed
25
#include <kscreen/config.h>
26

27
#include <kdedmodule.h>
28

29
#include <QVariant>
30

31 32 33
#include <memory>

class Config;
34
class OrientationSensor;
35

36 37
namespace KScreen
{
38
class OsdManager;
39 40
}

41 42 43
class QTimer;

class KScreenDaemon : public KDEDModule
44 45 46 47
{
    Q_OBJECT
    Q_CLASSINFO("D-Bus Interface", "org.kde.KScreen")

48 49 50 51 52 53 54
public:
    KScreenDaemon(QObject *parent, const QList<QVariant>&);
    ~KScreenDaemon() override;

public Q_SLOTS:
    // DBus
    void applyLayoutPreset(const QString &presetName);
55 56
    bool getAutoRotate();
    void setAutoRotate(bool value);
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73

Q_SIGNALS:
    // DBus
    void outputConnected(const QString &outputName);
    void unknownOutputConnected(const QString &outputName);

private:
    Q_INVOKABLE void getInitialConfig();
    void init();

    void applyConfig();
    void applyKnownConfig();
    void applyIdealConfig();
    void configChanged();
    void saveCurrentConfig();
    void displayButton();
    void lidClosedChanged(bool lidIsClosed);
74
    void disableLidOutput();
75 76 77 78 79 80 81
    void setMonitorForChanges(bool enabled);

    void outputConnectedChanged();
    void showOutputIdentifier();
    void applyOsdAction(KScreen::OsdAction::Action action);

    void doApplyConfig(const KScreen::ConfigPtr &config);
82 83
    void doApplyConfig(std::unique_ptr<Config> config);
    void refreshConfig();
84 85

    void monitorConnectedChange();
86
    void disableOutput(KScreen::OutputPtr &output);
87 88
    void showOsd(const QString &icon, const QString &text);

89 90
    void updateOrientation();

91
    std::unique_ptr<Config> m_monitoredConfig;
92
    bool m_monitoring;
93
    bool m_configDirty = true;
94 95 96 97
    QTimer* m_changeCompressor;
    QTimer* m_saveTimer;
    QTimer* m_lidClosedTimer;
    KScreen::OsdManager *m_osdManager;
98
    OrientationSensor *m_orientationSensor;
Kai Uwe Broulik's avatar
Kai Uwe Broulik committed
99
    bool m_startingUp = true;
100 101
};

Sebastian Kügler's avatar
Sebastian Kügler committed
102
#endif /*KSCREEN_DAEMON_H*/