diff --git a/libcolorcorrect/compositorcoloradaptor.h b/libcolorcorrect/compositorcoloradaptor.h --- a/libcolorcorrect/compositorcoloradaptor.h +++ b/libcolorcorrect/compositorcoloradaptor.h @@ -46,6 +46,8 @@ Q_PROPERTY(bool activeStaged READ activeStaged WRITE setActiveStaged NOTIFY activeStagedChanged) Q_PROPERTY(bool activeDefault READ activeDefault CONSTANT) + Q_PROPERTY(bool running READ running NOTIFY runningChanged) + Q_PROPERTY(bool modeEnabled READ modeEnabled NOTIFY modeEnabledChanged) Q_PROPERTY(int mode READ mode NOTIFY modeChanged) Q_PROPERTY(int modeStaged READ modeStaged WRITE setModeStaged NOTIFY modeStagedChanged) @@ -146,6 +148,10 @@ return true; } + bool running() { + return m_running; + } + bool modeEnabled() const { return m_modeEnabled; } @@ -387,6 +393,9 @@ void activeEnabledChanged(); void activeChanged(); void activeStagedChanged(); + + void runningChanged(); + void modeEnabledChanged(); void modeChanged(); void modeStagedChanged(); @@ -434,6 +443,8 @@ bool m_active = false; bool m_activeStaged = false; + bool m_running = false; + bool m_modeEnabled = true; Mode m_mode = Mode::ModeAutomatic; Mode m_modeStaged = Mode::ModeAutomatic; diff --git a/libcolorcorrect/compositorcoloradaptor.cpp b/libcolorcorrect/compositorcoloradaptor.cpp --- a/libcolorcorrect/compositorcoloradaptor.cpp +++ b/libcolorcorrect/compositorcoloradaptor.cpp @@ -122,6 +122,8 @@ SETTER(m_activeEnabled, data["ActiveEnabled"].toBool(), activeEnabledChanged()) SETTER(m_active, data["Active"].toBool(), activeChanged()) + + SETTER(m_running, data["Running"].toBool(), runningChanged()) SETTER(m_mode, (Mode)data["Mode"].toInt(), modeChanged()) SETTER(m_nightTemperatureEnabled, data["NightTemperatureEnabled"].toBool(), nightTemperatureEnabledChanged()) diff --git a/libcolorcorrect/kded/locationupdater.h b/libcolorcorrect/kded/locationupdater.h --- a/libcolorcorrect/kded/locationupdater.h +++ b/libcolorcorrect/kded/locationupdater.h @@ -35,8 +35,10 @@ void sendLocation(double latitude, double longitude); private: - ColorCorrect::CompositorAdaptor *m_adaptor; - ColorCorrect::Geolocator *m_locator; + void resetLocator(); + + ColorCorrect::CompositorAdaptor *m_adaptor = nullptr; + ColorCorrect::Geolocator *m_locator = nullptr; }; #endif diff --git a/libcolorcorrect/kded/locationupdater.cpp b/libcolorcorrect/kded/locationupdater.cpp --- a/libcolorcorrect/kded/locationupdater.cpp +++ b/libcolorcorrect/kded/locationupdater.cpp @@ -30,8 +30,23 @@ : KDEDModule(parent) { m_adaptor = new ColorCorrect::CompositorAdaptor(this); - m_locator = new ColorCorrect::Geolocator(this); - connect(m_locator, &ColorCorrect::Geolocator::locationChanged, this, &LocationUpdater::sendLocation); + connect(m_adaptor, &ColorCorrect::CompositorAdaptor::dataUpdated, this, + &LocationUpdater::resetLocator); + resetLocator(); +} + +void LocationUpdater::resetLocator() +{ + if (m_adaptor->running() && m_adaptor->mode() == 0) { + if (!m_locator) { + m_locator = new ColorCorrect::Geolocator(this); + connect(m_locator, &ColorCorrect::Geolocator::locationChanged, this, + &LocationUpdater::sendLocation); + } + } else { + delete m_locator; + m_locator = nullptr; + } } void LocationUpdater::sendLocation(double latitude, double longitude)