mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 16:30:05 +00:00
Add alert audio sound to settings dialog
This commit is contained in:
parent
a495cf1b3b
commit
2345855a97
6 changed files with 128 additions and 39 deletions
1
scwx-qt/res/icons/font-awesome-6/stop-solid.svg
Normal file
1
scwx-qt/res/icons/font-awesome-6/stop-solid.svg
Normal file
|
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" height="16" width="12" viewBox="0 0 384 512"><!--!Font Awesome Free 6.5.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2023 Fonticons, Inc.--><path opacity="1" fill="#000000" d="M0 128C0 92.7 28.7 64 64 64H320c35.3 0 64 28.7 64 64V384c0 35.3-28.7 64-64 64H64c-35.3 0-64-28.7-64-64V128z"/></svg>
|
||||
|
After Width: | Height: | Size: 388 B |
|
|
@ -44,6 +44,7 @@
|
|||
<file>res/icons/font-awesome-6/square-caret-right-regular.svg</file>
|
||||
<file>res/icons/font-awesome-6/square-minus-regular.svg</file>
|
||||
<file>res/icons/font-awesome-6/square-plus-regular.svg</file>
|
||||
<file>res/icons/font-awesome-6/stop-solid.svg</file>
|
||||
<file>res/icons/font-awesome-6/volume-high-solid.svg</file>
|
||||
<file>res/palettes/wct/CC.pal</file>
|
||||
<file>res/palettes/wct/Default16.pal</file>
|
||||
|
|
|
|||
|
|
@ -81,15 +81,33 @@ void MediaManager::Impl::ConnectSignals()
|
|||
void MediaManager::Play(types::AudioFile media)
|
||||
{
|
||||
const std::string path = types::GetMediaPath(media);
|
||||
}
|
||||
|
||||
logger_->debug("Playing audio: {}", path);
|
||||
void MediaManager::Play(const std::string& mediaPath)
|
||||
{
|
||||
logger_->debug("Playing audio: {}", mediaPath);
|
||||
|
||||
p->mediaPlayer_->setSource(
|
||||
QUrl(QString("qrc:%1").arg(QString::fromStdString(path))));
|
||||
if (mediaPath.starts_with(':'))
|
||||
{
|
||||
p->mediaPlayer_->setSource(
|
||||
QUrl(QString("qrc%1").arg(QString::fromStdString(mediaPath))));
|
||||
}
|
||||
else
|
||||
{
|
||||
p->mediaPlayer_->setSource(
|
||||
QUrl::fromLocalFile(QString::fromStdString(mediaPath)));
|
||||
}
|
||||
|
||||
p->mediaPlayer_->setPosition(0);
|
||||
|
||||
QMetaObject::invokeMethod(p->mediaPlayer_, &QMediaPlayer::play);
|
||||
}
|
||||
|
||||
void MediaManager::Stop()
|
||||
{
|
||||
QMetaObject::invokeMethod(p->mediaPlayer_, &QMediaPlayer::stop);
|
||||
}
|
||||
|
||||
std::shared_ptr<MediaManager> MediaManager::Instance()
|
||||
{
|
||||
static std::weak_ptr<MediaManager> mediaManagerReference_ {};
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@ public:
|
|||
~MediaManager();
|
||||
|
||||
void Play(types::AudioFile media);
|
||||
void Play(const std::string& mediaPath);
|
||||
void Stop();
|
||||
|
||||
static std::shared_ptr<MediaManager> Instance();
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
#include <scwx/awips/phenomenon.hpp>
|
||||
#include <scwx/common/color_table.hpp>
|
||||
#include <scwx/qt/config/radar_site.hpp>
|
||||
#include <scwx/qt/manager/media_manager.hpp>
|
||||
#include <scwx/qt/manager/position_manager.hpp>
|
||||
#include <scwx/qt/manager/settings_manager.hpp>
|
||||
#include <scwx/qt/map/map_provider.hpp>
|
||||
|
|
@ -126,6 +127,7 @@ public:
|
|||
&antiAliasingEnabled_,
|
||||
&updateNotificationsEnabled_,
|
||||
&debugEnabled_,
|
||||
&alertAudioSoundFile_,
|
||||
&alertAudioLocationMethod_,
|
||||
&alertAudioLatitude_,
|
||||
&alertAudioLongitude_,
|
||||
|
|
@ -196,6 +198,8 @@ public:
|
|||
|
||||
types::FontCategory selectedFontCategory_ {types::FontCategory::Unknown};
|
||||
|
||||
std::shared_ptr<manager::MediaManager> mediaManager_ {
|
||||
manager::MediaManager::Instance()};
|
||||
std::shared_ptr<manager::PositionManager> positionManager_ {
|
||||
manager::PositionManager::Instance()};
|
||||
|
||||
|
|
@ -220,6 +224,7 @@ public:
|
|||
settings::SettingsInterface<std::string>>
|
||||
inactiveAlertColors_ {};
|
||||
|
||||
settings::SettingsInterface<std::string> alertAudioSoundFile_ {};
|
||||
settings::SettingsInterface<std::string> alertAudioLocationMethod_ {};
|
||||
settings::SettingsInterface<double> alertAudioLatitude_ {};
|
||||
settings::SettingsInterface<double> alertAudioLongitude_ {};
|
||||
|
|
@ -309,6 +314,20 @@ void SettingsDialogImpl::ConnectSignals()
|
|||
[this](const std::string& newValue)
|
||||
{ UpdateRadarDialogLocation(newValue); });
|
||||
|
||||
QObject::connect(
|
||||
self_->ui->alertAudioSoundTestButton,
|
||||
&QAbstractButton::clicked,
|
||||
self_,
|
||||
[this]()
|
||||
{
|
||||
mediaManager_->Play(
|
||||
self_->ui->alertAudioSoundLineEdit->text().toStdString());
|
||||
});
|
||||
QObject::connect(self_->ui->alertAudioSoundStopButton,
|
||||
&QAbstractButton::clicked,
|
||||
self_,
|
||||
[this]() { mediaManager_->Stop(); });
|
||||
|
||||
QObject::connect(
|
||||
self_->ui->fontListView->selectionModel(),
|
||||
&QItemSelectionModel::selectionChanged,
|
||||
|
|
@ -830,6 +849,10 @@ void SettingsDialogImpl::SetupAudioTab()
|
|||
|
||||
settings::AudioSettings& audioSettings = settings::AudioSettings::Instance();
|
||||
|
||||
alertAudioSoundFile_.SetSettingsVariable(audioSettings.alert_sound_file());
|
||||
alertAudioSoundFile_.SetEditWidget(self_->ui->alertAudioSoundLineEdit);
|
||||
alertAudioSoundFile_.SetResetButton(self_->ui->resetAlertAudioSoundButton);
|
||||
|
||||
for (const auto& locationMethod : types::LocationMethodIterator())
|
||||
{
|
||||
self_->ui->alertAudioLocationMethodComboBox->addItem(
|
||||
|
|
|
|||
|
|
@ -453,14 +453,14 @@
|
|||
<string>Alerts</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_10">
|
||||
<item row="1" column="0">
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_14">
|
||||
<property name="text">
|
||||
<string>Latitude</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<item row="2" column="2">
|
||||
<widget class="QDoubleSpinBox" name="alertAudioLatitudeSpinBox">
|
||||
<property name="decimals">
|
||||
<number>4</number>
|
||||
|
|
@ -476,36 +476,7 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QToolButton" name="resetAlertAudioLatitudeButton">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../../scwx-qt.qrc">
|
||||
<normaloff>:/res/icons/font-awesome-6/rotate-left-solid.svg</normaloff>:/res/icons/font-awesome-6/rotate-left-solid.svg</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_16">
|
||||
<property name="text">
|
||||
<string>Longitude</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QToolButton" name="resetAlertAudioLongitudeButton">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../../scwx-qt.qrc">
|
||||
<normaloff>:/res/icons/font-awesome-6/rotate-left-solid.svg</normaloff>:/res/icons/font-awesome-6/rotate-left-solid.svg</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<item row="1" column="6">
|
||||
<widget class="QToolButton" name="resetAlertAudioLocationMethodButton">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
|
|
@ -516,14 +487,28 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_16">
|
||||
<property name="text">
|
||||
<string>Longitude</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QToolButton" name="alertAudioSoundSelectButton">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_12">
|
||||
<property name="text">
|
||||
<string>Location Method</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<item row="3" column="2">
|
||||
<widget class="QDoubleSpinBox" name="alertAudioLongitudeSpinBox">
|
||||
<property name="decimals">
|
||||
<number>4</number>
|
||||
|
|
@ -539,7 +524,58 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<item row="3" column="6">
|
||||
<widget class="QToolButton" name="resetAlertAudioLongitudeButton">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../../scwx-qt.qrc">
|
||||
<normaloff>:/res/icons/font-awesome-6/rotate-left-solid.svg</normaloff>:/res/icons/font-awesome-6/rotate-left-solid.svg</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="6">
|
||||
<widget class="QToolButton" name="resetAlertAudioLatitudeButton">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../../scwx-qt.qrc">
|
||||
<normaloff>:/res/icons/font-awesome-6/rotate-left-solid.svg</normaloff>:/res/icons/font-awesome-6/rotate-left-solid.svg</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QLineEdit" name="alertAudioSoundLineEdit"/>
|
||||
</item>
|
||||
<item row="0" column="6">
|
||||
<widget class="QToolButton" name="resetAlertAudioSoundButton">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../../scwx-qt.qrc">
|
||||
<normaloff>:/res/icons/font-awesome-6/rotate-left-solid.svg</normaloff>:/res/icons/font-awesome-6/rotate-left-solid.svg</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="4">
|
||||
<widget class="QToolButton" name="alertAudioSoundTestButton">
|
||||
<property name="icon">
|
||||
<iconset resource="../../../../scwx-qt.qrc">
|
||||
<normaloff>:/res/icons/font-awesome-6/play-solid.svg</normaloff>:/res/icons/font-awesome-6/play-solid.svg</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_17">
|
||||
<property name="text">
|
||||
<string>Sound</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QComboBox" name="alertAudioLocationMethodComboBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
|
|
@ -549,6 +585,14 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="5">
|
||||
<widget class="QToolButton" name="alertAudioSoundStopButton">
|
||||
<property name="icon">
|
||||
<iconset resource="../../../../scwx-qt.qrc">
|
||||
<normaloff>:/res/icons/font-awesome-6/stop-solid.svg</normaloff>:/res/icons/font-awesome-6/stop-solid.svg</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
@ -560,7 +604,7 @@
|
|||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>309</height>
|
||||
<height>281</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue