mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 18:30:06 +00:00
Position manager updates for tracking
This commit is contained in:
parent
400db66f09
commit
18f500fe5f
3 changed files with 29 additions and 17 deletions
|
|
@ -35,7 +35,6 @@
|
||||||
|
|
||||||
#include <boost/asio/post.hpp>
|
#include <boost/asio/post.hpp>
|
||||||
#include <boost/asio/thread_pool.hpp>
|
#include <boost/asio/thread_pool.hpp>
|
||||||
#include <boost/uuid/random_generator.hpp>
|
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
|
@ -63,7 +62,6 @@ class MainWindowImpl : public QObject
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit MainWindowImpl(MainWindow* mainWindow) :
|
explicit MainWindowImpl(MainWindow* mainWindow) :
|
||||||
uuid_ {boost::uuids::random_generator()()},
|
|
||||||
mainWindow_ {mainWindow},
|
mainWindow_ {mainWindow},
|
||||||
settings_ {},
|
settings_ {},
|
||||||
activeMap_ {nullptr},
|
activeMap_ {nullptr},
|
||||||
|
|
@ -124,7 +122,7 @@ public:
|
||||||
|
|
||||||
if (settings::GeneralSettings::Instance().track_location().GetValue())
|
if (settings::GeneralSettings::Instance().track_location().GetValue())
|
||||||
{
|
{
|
||||||
positionManager_->TrackLocation(uuid_, true);
|
positionManager_->TrackLocation(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
~MainWindowImpl() { threadPool_.join(); }
|
~MainWindowImpl() { threadPool_.join(); }
|
||||||
|
|
@ -155,8 +153,6 @@ public:
|
||||||
|
|
||||||
boost::asio::thread_pool threadPool_ {1u};
|
boost::asio::thread_pool threadPool_ {1u};
|
||||||
|
|
||||||
boost::uuids::uuid uuid_;
|
|
||||||
|
|
||||||
MainWindow* mainWindow_;
|
MainWindow* mainWindow_;
|
||||||
QMapLibreGL::Settings settings_;
|
QMapLibreGL::Settings settings_;
|
||||||
map::MapProvider mapProvider_;
|
map::MapProvider mapProvider_;
|
||||||
|
|
@ -872,13 +868,8 @@ void MainWindowImpl::ConnectOtherSignals()
|
||||||
settings::GeneralSettings::Instance().track_location().StageValue(
|
settings::GeneralSettings::Instance().track_location().StageValue(
|
||||||
trackingEnabled);
|
trackingEnabled);
|
||||||
|
|
||||||
for (std::size_t i = 0; i < maps_.size(); ++i)
|
// Turn on location tracking
|
||||||
{
|
positionManager_->TrackLocation(trackingEnabled);
|
||||||
// maps_[i]->SetTrackLocation(trackingEnabled);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Turn on location tracking (location manager)
|
|
||||||
positionManager_->TrackLocation(uuid_, trackingEnabled);
|
|
||||||
});
|
});
|
||||||
connect(level2ProductsWidget_,
|
connect(level2ProductsWidget_,
|
||||||
&ui::Level2ProductsWidget::RadarProductSelected,
|
&ui::Level2ProductsWidget::RadarProductSelected,
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
|
#include <boost/uuid/random_generator.hpp>
|
||||||
#include <QGeoPositionInfoSource>
|
#include <QGeoPositionInfoSource>
|
||||||
|
|
||||||
namespace scwx
|
namespace scwx
|
||||||
|
|
@ -19,7 +20,8 @@ static const auto logger_ = scwx::util::Logger::Create(logPrefix_);
|
||||||
class PositionManager::Impl
|
class PositionManager::Impl
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit Impl(PositionManager* self) : self_ {self}
|
explicit Impl(PositionManager* self) :
|
||||||
|
self_ {self}, trackingUuid_ {boost::uuids::random_generator()()}
|
||||||
{
|
{
|
||||||
// TODO: macOS requires permission
|
// TODO: macOS requires permission
|
||||||
geoPositionInfoSource_ =
|
geoPositionInfoSource_ =
|
||||||
|
|
@ -55,6 +57,9 @@ public:
|
||||||
|
|
||||||
PositionManager* self_;
|
PositionManager* self_;
|
||||||
|
|
||||||
|
boost::uuids::uuid trackingUuid_;
|
||||||
|
bool trackingEnabled_ {false};
|
||||||
|
|
||||||
std::set<boost::uuids::uuid> uuids_ {};
|
std::set<boost::uuids::uuid> uuids_ {};
|
||||||
|
|
||||||
QGeoPositionInfoSource* geoPositionInfoSource_ {};
|
QGeoPositionInfoSource* geoPositionInfoSource_ {};
|
||||||
|
|
@ -69,15 +74,20 @@ QGeoPositionInfo PositionManager::position() const
|
||||||
return p->position_;
|
return p->position_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PositionManager::TrackLocation(boost::uuids::uuid uuid,
|
bool PositionManager::IsLocationTracked()
|
||||||
bool trackingEnabled)
|
{
|
||||||
|
return p->trackingEnabled_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PositionManager::EnablePositionUpdates(boost::uuids::uuid uuid,
|
||||||
|
bool enabled)
|
||||||
{
|
{
|
||||||
if (p->geoPositionInfoSource_ == nullptr)
|
if (p->geoPositionInfoSource_ == nullptr)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (trackingEnabled)
|
if (enabled)
|
||||||
{
|
{
|
||||||
if (p->uuids_.empty())
|
if (p->uuids_.empty())
|
||||||
{
|
{
|
||||||
|
|
@ -97,6 +107,13 @@ void PositionManager::TrackLocation(boost::uuids::uuid uuid,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PositionManager::TrackLocation(bool trackingEnabled)
|
||||||
|
{
|
||||||
|
p->trackingEnabled_ = trackingEnabled;
|
||||||
|
EnablePositionUpdates(p->trackingUuid_, trackingEnabled);
|
||||||
|
Q_EMIT LocationTrackingChanged(trackingEnabled);
|
||||||
|
}
|
||||||
|
|
||||||
std::shared_ptr<PositionManager> PositionManager::Instance()
|
std::shared_ptr<PositionManager> PositionManager::Instance()
|
||||||
{
|
{
|
||||||
static std::weak_ptr<PositionManager> positionManagerReference_ {};
|
static std::weak_ptr<PositionManager> positionManagerReference_ {};
|
||||||
|
|
|
||||||
|
|
@ -25,11 +25,15 @@ public:
|
||||||
|
|
||||||
QGeoPositionInfo position() const;
|
QGeoPositionInfo position() const;
|
||||||
|
|
||||||
void TrackLocation(boost::uuids::uuid uuid, bool trackingEnabled);
|
bool IsLocationTracked();
|
||||||
|
|
||||||
|
void EnablePositionUpdates(boost::uuids::uuid uuid, bool enabled);
|
||||||
|
void TrackLocation(bool trackingEnabled);
|
||||||
|
|
||||||
static std::shared_ptr<PositionManager> Instance();
|
static std::shared_ptr<PositionManager> Instance();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
void LocationTrackingChanged(bool trackingEnabled);
|
||||||
void PositionUpdated(const QGeoPositionInfo& info);
|
void PositionUpdated(const QGeoPositionInfo& info);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue