Changeset View
Changeset View
Standalone View
Standalone View
libcolorcorrect/kded/locationupdater.cpp
Show All 24 Lines | |||||
25 | K_PLUGIN_FACTORY_WITH_JSON(LocationUpdaterFactory, | 25 | K_PLUGIN_FACTORY_WITH_JSON(LocationUpdaterFactory, | ||
26 | "colorcorrectlocationupdater.json", | 26 | "colorcorrectlocationupdater.json", | ||
27 | registerPlugin<LocationUpdater>();) | 27 | registerPlugin<LocationUpdater>();) | ||
28 | 28 | | |||
29 | LocationUpdater::LocationUpdater(QObject *parent, const QList<QVariant> &) | 29 | LocationUpdater::LocationUpdater(QObject *parent, const QList<QVariant> &) | ||
30 | : KDEDModule(parent) | 30 | : KDEDModule(parent) | ||
31 | { | 31 | { | ||
32 | m_adaptor = new ColorCorrect::CompositorAdaptor(this); | 32 | m_adaptor = new ColorCorrect::CompositorAdaptor(this); | ||
33 | connect(m_adaptor, &ColorCorrect::CompositorAdaptor::dataUpdated, this, | ||||
34 | &LocationUpdater::resetLocator); | ||||
35 | resetLocator(); | ||||
36 | } | ||||
37 | | ||||
38 | void LocationUpdater::resetLocator() | ||||
39 | { | ||||
40 | if (m_adaptor->running() && m_adaptor->mode() == 0) { | ||||
41 | if (!m_locator) { | ||||
33 | m_locator = new ColorCorrect::Geolocator(this); | 42 | m_locator = new ColorCorrect::Geolocator(this); | ||
34 | connect(m_locator, &ColorCorrect::Geolocator::locationChanged, this, &LocationUpdater::sendLocation); | 43 | connect(m_locator, &ColorCorrect::Geolocator::locationChanged, this, | ||
44 | &LocationUpdater::sendLocation); | ||||
45 | } | ||||
46 | } else { | ||||
47 | delete m_locator; | ||||
48 | m_locator = nullptr; | ||||
49 | } | ||||
35 | } | 50 | } | ||
36 | 51 | | |||
37 | void LocationUpdater::sendLocation(double latitude, double longitude) | 52 | void LocationUpdater::sendLocation(double latitude, double longitude) | ||
38 | { | 53 | { | ||
39 | m_adaptor->sendAutoLocationUpdate(latitude, longitude); | 54 | m_adaptor->sendAutoLocationUpdate(latitude, longitude); | ||
40 | } | 55 | } | ||
41 | 56 | | |||
42 | #include <locationupdater.moc> | 57 | #include <locationupdater.moc> |