diff --git a/kded/daemon.h b/kded/daemon.h --- a/kded/daemon.h +++ b/kded/daemon.h @@ -1,5 +1,6 @@ -/************************************************************************************* +/************************************************************************************ * Copyright (C) 2012 by Alejandro Fiestas Olivares * +* Copyright 2018 Roman Gilg * * * * This program is free software; you can redistribute it and/or * * modify it under the terms of the GNU General Public License * @@ -15,72 +16,72 @@ * along with this program; if not, write to the Free Software * * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * *************************************************************************************/ - #ifndef KSCREEN_DAEMON_H #define KSCREEN_DAEMON_H -#include - -#include - +#include "osdaction.h" #include -#include "generator.h" -#include "osdmanager.h" +#include -class QTimer; +#include namespace KScreen { class ConfigOperation; +class OsdManager; } -class Q_DECL_EXPORT KScreenDaemon : public KDEDModule +class QTimer; + +class KScreenDaemon : public KDEDModule { Q_OBJECT Q_CLASSINFO("D-Bus Interface", "org.kde.KScreen") - public: - KScreenDaemon(QObject *parent, const QList&); - ~KScreenDaemon() override; - - public Q_SLOTS: - virtual void requestConfig(); - - void init(); - void applyConfig(); - void applyKnownConfig(); - void applyIdealConfig(); - void configChanged(); - void saveCurrentConfig(); - void displayButton(); - void lidClosedChanged(bool lidIsClosed); - void lidClosedTimeout(); - void setMonitorForChanges(bool enabled); - void outputConnectedChanged(); - void showOutputIdentifier(); - void applyOsdAction(KScreen::OsdAction::Action action); - - // DBus - void applyLayoutPreset(const QString &presetName); - Q_SIGNALS: - // DBus - void outputConnected(const QString &outputName); - void unknownOutputConnected(const QString &outputName); - - protected: - virtual void doApplyConfig(const KScreen::ConfigPtr &config); - - void monitorConnectedChange(); - void disableOutput(KScreen::ConfigPtr &config, KScreen::OutputPtr &output); - void showOsd(const QString &icon, const QString &text); - - KScreen::ConfigPtr m_monitoredConfig; - bool m_monitoring; - QTimer* m_changeCompressor; - QTimer* m_saveTimer; - QTimer* m_lidClosedTimer; - KScreen::OsdManager *m_osdManager; +public: + KScreenDaemon(QObject *parent, const QList&); + ~KScreenDaemon() override; + +public Q_SLOTS: + // DBus + void applyLayoutPreset(const QString &presetName); + +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); + void lidClosedTimeout(); + void setMonitorForChanges(bool enabled); + + void outputConnectedChanged(); + void showOutputIdentifier(); + void applyOsdAction(KScreen::OsdAction::Action action); + + void doApplyConfig(const KScreen::ConfigPtr &config); + + void monitorConnectedChange(); + void disableOutput(KScreen::ConfigPtr &config, KScreen::OutputPtr &output); + void showOsd(const QString &icon, const QString &text); + + KScreen::ConfigPtr m_monitoredConfig; + bool m_monitoring; + QTimer* m_changeCompressor; + QTimer* m_saveTimer; + QTimer* m_lidClosedTimer; + KScreen::OsdManager *m_osdManager; }; #endif /*KSCREEN_DAEMON_H*/ diff --git a/kded/daemon.cpp b/kded/daemon.cpp --- a/kded/daemon.cpp +++ b/kded/daemon.cpp @@ -19,31 +19,28 @@ * along with this program; if not, write to the Free Software * * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * *************************************************************************************/ - #include "daemon.h" #include "serializer.h" #include "generator.h" #include "device.h" #include "kscreenadaptor.h" #include "kscreen_daemon_debug.h" #include "osdmanager.h" -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include #include #include -#include -#include -#include -#include -#include -#include +#include +#include +#include K_PLUGIN_FACTORY_WITH_JSON(KScreenDaemonFactory, "kscreen.json", @@ -59,10 +56,10 @@ { KScreen::Log::instance(); - QMetaObject::invokeMethod(this, "requestConfig", Qt::QueuedConnection); + QMetaObject::invokeMethod(this, "getInitialConfig", Qt::QueuedConnection); } -void KScreenDaemon::requestConfig() +void KScreenDaemon::getInitialConfig() { connect(new KScreen::GetConfigOperation, &KScreen::GetConfigOperation::finished, this, [this](KScreen::ConfigOperation* op) { @@ -105,7 +102,6 @@ m_lidClosedTimer->setSingleShot(true); connect(m_lidClosedTimer, &QTimer::timeout, this, &KScreenDaemon::lidClosedTimeout); - connect(Device::self(), &Device::lidClosedChanged, this, &KScreenDaemon::lidClosedChanged); connect(Device::self(), &Device::resumingFromSuspend, this, [&]() { @@ -122,7 +118,6 @@ m_lidClosedTimer->stop(); }); - connect(Generator::self(), &Generator::ready, this, &KScreenDaemon::applyConfig); @@ -215,7 +210,6 @@ doApplyConfig(Generator::self()->displaySwitch(Generator::Clone)); return; } - Q_UNREACHABLE(); } @@ -232,7 +226,8 @@ } } -void logConfig(const KScreen::ConfigPtr &config) { +void logConfig(const KScreen::ConfigPtr &config) +{ if (config) { foreach (auto o, config->outputs()) { if (o->isConnected()) {