mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 20:40:04 +00:00
Create alert manager to handle audio alert location method
- Will also manage receipt of alerts for playing audio
This commit is contained in:
parent
212f2700b7
commit
6ec594144d
4 changed files with 116 additions and 2 deletions
|
|
@ -78,7 +78,8 @@ set(SRC_GL_DRAW source/scwx/qt/gl/draw/draw_item.cpp
|
|||
source/scwx/qt/gl/draw/placefile_text.cpp
|
||||
source/scwx/qt/gl/draw/placefile_triangles.cpp
|
||||
source/scwx/qt/gl/draw/rectangle.cpp)
|
||||
set(HDR_MANAGER source/scwx/qt/manager/font_manager.hpp
|
||||
set(HDR_MANAGER source/scwx/qt/manager/alert_manager.hpp
|
||||
source/scwx/qt/manager/font_manager.hpp
|
||||
source/scwx/qt/manager/media_manager.hpp
|
||||
source/scwx/qt/manager/placefile_manager.hpp
|
||||
source/scwx/qt/manager/position_manager.hpp
|
||||
|
|
@ -89,7 +90,8 @@ set(HDR_MANAGER source/scwx/qt/manager/font_manager.hpp
|
|||
source/scwx/qt/manager/text_event_manager.hpp
|
||||
source/scwx/qt/manager/timeline_manager.hpp
|
||||
source/scwx/qt/manager/update_manager.hpp)
|
||||
set(SRC_MANAGER source/scwx/qt/manager/font_manager.cpp
|
||||
set(SRC_MANAGER source/scwx/qt/manager/alert_manager.cpp
|
||||
source/scwx/qt/manager/font_manager.cpp
|
||||
source/scwx/qt/manager/media_manager.cpp
|
||||
source/scwx/qt/manager/placefile_manager.cpp
|
||||
source/scwx/qt/manager/position_manager.cpp
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include <scwx/qt/main/application.hpp>
|
||||
#include <scwx/qt/main/versions.hpp>
|
||||
#include <scwx/qt/manager/alert_manager.hpp>
|
||||
#include <scwx/qt/manager/placefile_manager.hpp>
|
||||
#include <scwx/qt/manager/position_manager.hpp>
|
||||
#include <scwx/qt/manager/radar_product_manager.hpp>
|
||||
|
|
@ -82,6 +83,7 @@ public:
|
|||
radarSiteDialog_ {nullptr},
|
||||
settingsDialog_ {nullptr},
|
||||
updateDialog_ {nullptr},
|
||||
alertManager_ {manager::AlertManager::Instance()},
|
||||
placefileManager_ {manager::PlacefileManager::Instance()},
|
||||
positionManager_ {manager::PositionManager::Instance()},
|
||||
textEventManager_ {manager::TextEventManager::Instance()},
|
||||
|
|
@ -178,6 +180,7 @@ public:
|
|||
ui::SettingsDialog* settingsDialog_;
|
||||
ui::UpdateDialog* updateDialog_;
|
||||
|
||||
std::shared_ptr<manager::AlertManager> alertManager_;
|
||||
std::shared_ptr<manager::PlacefileManager> placefileManager_;
|
||||
std::shared_ptr<manager::PositionManager> positionManager_;
|
||||
std::shared_ptr<manager::TextEventManager> textEventManager_;
|
||||
|
|
|
|||
77
scwx-qt/source/scwx/qt/manager/alert_manager.cpp
Normal file
77
scwx-qt/source/scwx/qt/manager/alert_manager.cpp
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
#include <scwx/qt/manager/alert_manager.hpp>
|
||||
#include <scwx/qt/manager/position_manager.hpp>
|
||||
#include <scwx/qt/settings/audio_settings.hpp>
|
||||
#include <scwx/qt/types/location_types.hpp>
|
||||
#include <scwx/util/logger.hpp>
|
||||
|
||||
#include <boost/uuid/random_generator.hpp>
|
||||
|
||||
namespace scwx
|
||||
{
|
||||
namespace qt
|
||||
{
|
||||
namespace manager
|
||||
{
|
||||
|
||||
static const std::string logPrefix_ = "scwx::qt::manager::alert_manager";
|
||||
static const auto logger_ = scwx::util::Logger::Create(logPrefix_);
|
||||
|
||||
class AlertManager::Impl
|
||||
{
|
||||
public:
|
||||
explicit Impl(AlertManager* self) : self_ {self}
|
||||
{
|
||||
settings::AudioSettings& audioSettings =
|
||||
settings::AudioSettings::Instance();
|
||||
|
||||
UpdateLocationTracking(audioSettings.alert_location_method().GetValue());
|
||||
|
||||
audioSettings.alert_location_method().RegisterValueChangedCallback(
|
||||
[this](const std::string& value) { UpdateLocationTracking(value); });
|
||||
}
|
||||
|
||||
~Impl() {}
|
||||
|
||||
void UpdateLocationTracking(const std::string& value) const;
|
||||
|
||||
AlertManager* self_;
|
||||
|
||||
boost::uuids::uuid uuid_ {boost::uuids::random_generator()()};
|
||||
|
||||
std::shared_ptr<PositionManager> positionManager_ {
|
||||
PositionManager::Instance()};
|
||||
};
|
||||
|
||||
AlertManager::AlertManager() : p(std::make_unique<Impl>(this)) {}
|
||||
AlertManager::~AlertManager() = default;
|
||||
|
||||
void AlertManager::Impl::UpdateLocationTracking(
|
||||
const std::string& locationMethodName) const
|
||||
{
|
||||
types::LocationMethod locationMethod =
|
||||
types::GetLocationMethod(locationMethodName);
|
||||
bool locationEnabled = locationMethod == types::LocationMethod::Track;
|
||||
positionManager_->EnablePositionUpdates(uuid_, locationEnabled);
|
||||
}
|
||||
|
||||
std::shared_ptr<AlertManager> AlertManager::Instance()
|
||||
{
|
||||
static std::weak_ptr<AlertManager> alertManagerReference_ {};
|
||||
static std::mutex instanceMutex_ {};
|
||||
|
||||
std::unique_lock lock(instanceMutex_);
|
||||
|
||||
std::shared_ptr<AlertManager> alertManager = alertManagerReference_.lock();
|
||||
|
||||
if (alertManager == nullptr)
|
||||
{
|
||||
alertManager = std::make_shared<AlertManager>();
|
||||
alertManagerReference_ = alertManager;
|
||||
}
|
||||
|
||||
return alertManager;
|
||||
}
|
||||
|
||||
} // namespace manager
|
||||
} // namespace qt
|
||||
} // namespace scwx
|
||||
32
scwx-qt/source/scwx/qt/manager/alert_manager.hpp
Normal file
32
scwx-qt/source/scwx/qt/manager/alert_manager.hpp
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <QObject>
|
||||
|
||||
namespace scwx
|
||||
{
|
||||
namespace qt
|
||||
{
|
||||
namespace manager
|
||||
{
|
||||
|
||||
class AlertManager : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY_MOVE(AlertManager)
|
||||
|
||||
public:
|
||||
explicit AlertManager();
|
||||
~AlertManager();
|
||||
|
||||
static std::shared_ptr<AlertManager> Instance();
|
||||
|
||||
private:
|
||||
class Impl;
|
||||
std::unique_ptr<Impl> p;
|
||||
};
|
||||
|
||||
} // namespace manager
|
||||
} // namespace qt
|
||||
} // namespace scwx
|
||||
Loading…
Add table
Add a link
Reference in a new issue