mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 00:00:04 +00:00 
			
		
		
		
	Add audio page to settings dialog
This commit is contained in:
		
							parent
							
								
									ec97231bca
								
							
						
					
					
						commit
						c03884c2c0
					
				
					 5 changed files with 317 additions and 2 deletions
				
			
		|  | @ -6,12 +6,14 @@ | |||
| #include <scwx/qt/config/radar_site.hpp> | ||||
| #include <scwx/qt/manager/settings_manager.hpp> | ||||
| #include <scwx/qt/map/map_provider.hpp> | ||||
| #include <scwx/qt/settings/audio_settings.hpp> | ||||
| #include <scwx/qt/settings/general_settings.hpp> | ||||
| #include <scwx/qt/settings/palette_settings.hpp> | ||||
| #include <scwx/qt/settings/settings_interface.hpp> | ||||
| #include <scwx/qt/settings/text_settings.hpp> | ||||
| #include <scwx/qt/types/alert_types.hpp> | ||||
| #include <scwx/qt/types/font_types.hpp> | ||||
| #include <scwx/qt/types/location_types.hpp> | ||||
| #include <scwx/qt/types/qt_types.hpp> | ||||
| #include <scwx/qt/types/text_types.hpp> | ||||
| #include <scwx/qt/ui/radar_site_dialog.hpp> | ||||
|  | @ -84,6 +86,24 @@ static const std::unordered_map<std::string, ColorTableConversions> | |||
|                             {"VIL", {0u, 255u, 1.0f, 2.5f}}, | ||||
|                             {"???", {0u, 15u, 0.0f, 1.0f}}}; | ||||
| 
 | ||||
| #define SCWX_ENUM_MAP_FROM_VALUE(Type, Iterator, ToName)                       \ | ||||
|    [](const std::string& text) -> std::string                                  \ | ||||
|    {                                                                           \ | ||||
|       for (Type enumValue : Iterator)                                          \ | ||||
|       {                                                                        \ | ||||
|          const std::string enumName = ToName(enumValue);                       \ | ||||
|                                                                                \ | ||||
|          if (boost::iequals(text, enumName))                                   \ | ||||
|          {                                                                     \ | ||||
|             /* Return label */                                                 \ | ||||
|             return enumName;                                                   \ | ||||
|          }                                                                     \ | ||||
|       }                                                                        \ | ||||
|                                                                                \ | ||||
|       /* Label not found, return unknown */                                    \ | ||||
|       return "?";                                                              \ | ||||
|    } | ||||
| 
 | ||||
| class SettingsDialogImpl | ||||
| { | ||||
| public: | ||||
|  | @ -104,6 +124,9 @@ public: | |||
|           &antiAliasingEnabled_, | ||||
|           &updateNotificationsEnabled_, | ||||
|           &debugEnabled_, | ||||
|           &alertAudioLocationMethod_, | ||||
|           &alertAudioLatitude_, | ||||
|           &alertAudioLongitude_, | ||||
|           &hoverTextWrap_, | ||||
|           &tooltipMethod_, | ||||
|           &placefileTextDropShadowEnabled_}} | ||||
|  | @ -136,6 +159,7 @@ public: | |||
|    void SetupGeneralTab(); | ||||
|    void SetupPalettesColorTablesTab(); | ||||
|    void SetupPalettesAlertsTab(); | ||||
|    void SetupAudioTab(); | ||||
|    void SetupTextTab(); | ||||
| 
 | ||||
|    void ShowColorDialog(QLineEdit* lineEdit, QFrame* frame = nullptr); | ||||
|  | @ -191,6 +215,13 @@ public: | |||
|                       settings::SettingsInterface<std::string>> | ||||
|       inactiveAlertColors_ {}; | ||||
| 
 | ||||
|    settings::SettingsInterface<std::string> alertAudioLocationMethod_ {}; | ||||
|    settings::SettingsInterface<double>      alertAudioLatitude_ {}; | ||||
|    settings::SettingsInterface<double>      alertAudioLongitude_ {}; | ||||
| 
 | ||||
|    std::unordered_map<awips::Phenomenon, settings::SettingsInterface<bool>> | ||||
|       alertAudioEnabled_ {}; | ||||
| 
 | ||||
|    std::unordered_map<types::FontCategory, | ||||
|                       settings::SettingsInterface<std::string>> | ||||
|       fontFamilies_ {}; | ||||
|  | @ -223,6 +254,9 @@ SettingsDialog::SettingsDialog(QWidget* parent) : | |||
|    // Palettes > Alerts
 | ||||
|    p->SetupPalettesAlertsTab(); | ||||
| 
 | ||||
|    // Audio
 | ||||
|    p->SetupAudioTab(); | ||||
| 
 | ||||
|    // Text
 | ||||
|    p->SetupTextTab(); | ||||
| 
 | ||||
|  | @ -766,6 +800,70 @@ void SettingsDialogImpl::SetupPalettesAlertsTab() | |||
|    } | ||||
| } | ||||
| 
 | ||||
| void SettingsDialogImpl::SetupAudioTab() | ||||
| { | ||||
|    settings::AudioSettings& audioSettings = settings::AudioSettings::Instance(); | ||||
| 
 | ||||
|    for (const auto& locationMethod : types::LocationMethodIterator()) | ||||
|    { | ||||
|       self_->ui->alertAudioLocationMethodComboBox->addItem( | ||||
|          QString::fromStdString(types::GetLocationMethodName(locationMethod))); | ||||
|    } | ||||
| 
 | ||||
|    alertAudioLocationMethod_.SetSettingsVariable( | ||||
|       audioSettings.alert_location_method()); | ||||
|    alertAudioLocationMethod_.SetMapFromValueFunction( | ||||
|       SCWX_ENUM_MAP_FROM_VALUE(types::LocationMethod, | ||||
|                                types::LocationMethodIterator(), | ||||
|                                types::GetLocationMethodName)); | ||||
|    alertAudioLocationMethod_.SetMapToValueFunction( | ||||
|       [](std::string text) -> std::string | ||||
|       { | ||||
|          // Convert label to lower case and return
 | ||||
|          boost::to_lower(text); | ||||
|          return text; | ||||
|       }); | ||||
|    alertAudioLocationMethod_.SetEditWidget( | ||||
|       self_->ui->alertAudioLocationMethodComboBox); | ||||
|    alertAudioLocationMethod_.SetResetButton( | ||||
|       self_->ui->resetAlertAudioLocationMethodButton); | ||||
| 
 | ||||
|    alertAudioLatitude_.SetSettingsVariable(audioSettings.alert_latitude()); | ||||
|    alertAudioLatitude_.SetEditWidget(self_->ui->alertAudioLatitudeSpinBox); | ||||
|    alertAudioLatitude_.SetResetButton(self_->ui->resetAlertAudioLatitudeButton); | ||||
| 
 | ||||
|    alertAudioLongitude_.SetSettingsVariable(audioSettings.alert_longitude()); | ||||
|    alertAudioLongitude_.SetEditWidget(self_->ui->alertAudioLongitudeSpinBox); | ||||
|    alertAudioLongitude_.SetResetButton( | ||||
|       self_->ui->resetAlertAudioLongitudeButton); | ||||
| 
 | ||||
|    auto alertAudioLayout = | ||||
|       static_cast<QGridLayout*>(self_->ui->alertAudioGroupBox->layout()); | ||||
| 
 | ||||
|    for (const auto& phenomenon : types::GetAlertAudioPhenomena()) | ||||
|    { | ||||
|       QCheckBox* alertAudioCheckbox = new QCheckBox(self_); | ||||
|       alertAudioCheckbox->setText( | ||||
|          QString::fromStdString(awips::GetPhenomenonText(phenomenon))); | ||||
| 
 | ||||
|       static_cast<QGridLayout*>(self_->ui->alertAudioGroupBox->layout()) | ||||
|          ->addWidget( | ||||
|             alertAudioCheckbox, alertAudioLayout->rowCount(), 0, 1, -1); | ||||
| 
 | ||||
|       // Create settings interface
 | ||||
|       auto result = alertAudioEnabled_.emplace( | ||||
|          phenomenon, settings::SettingsInterface<bool> {}); | ||||
|       auto& alertAudioEnabled = result.first->second; | ||||
| 
 | ||||
|       // Add to settings list
 | ||||
|       settings_.push_back(&alertAudioEnabled); | ||||
| 
 | ||||
|       alertAudioEnabled.SetSettingsVariable( | ||||
|          audioSettings.alert_enabled(phenomenon)); | ||||
|       alertAudioEnabled.SetEditWidget(alertAudioCheckbox); | ||||
|    } | ||||
| } | ||||
| 
 | ||||
| void SettingsDialogImpl::SetupTextTab() | ||||
| { | ||||
|    settings::TextSettings& textSettings = settings::TextSettings::Instance(); | ||||
|  |  | |||
|  | @ -77,6 +77,15 @@ | |||
|             <normaloff>:/res/icons/font-awesome-6/palette-solid.svg</normaloff>:/res/icons/font-awesome-6/palette-solid.svg</iconset> | ||||
|           </property> | ||||
|          </item> | ||||
|          <item> | ||||
|           <property name="text"> | ||||
|            <string>Audio</string> | ||||
|           </property> | ||||
|           <property name="icon"> | ||||
|            <iconset resource="../../../../scwx-qt.qrc"> | ||||
|             <normaloff>:/res/icons/font-awesome-6/volume-high-solid.svg</normaloff>:/res/icons/font-awesome-6/volume-high-solid.svg</iconset> | ||||
|           </property> | ||||
|          </item> | ||||
|          <item> | ||||
|           <property name="text"> | ||||
|            <string>Text</string> | ||||
|  | @ -364,8 +373,8 @@ | |||
|                    <rect> | ||||
|                     <x>0</x> | ||||
|                     <y>0</y> | ||||
|                     <width>63</width> | ||||
|                     <height>18</height> | ||||
|                     <width>508</width> | ||||
|                     <height>383</height> | ||||
|                    </rect> | ||||
|                   </property> | ||||
|                   <layout class="QGridLayout" name="gridLayout_3"> | ||||
|  | @ -436,6 +445,128 @@ | |||
|            </item> | ||||
|           </layout> | ||||
|          </widget> | ||||
|          <widget class="QWidget" name="page"> | ||||
|           <layout class="QVBoxLayout" name="verticalLayout_4"> | ||||
|            <item> | ||||
|             <widget class="QGroupBox" name="alertAudioGroupBox"> | ||||
|              <property name="title"> | ||||
|               <string>Alerts</string> | ||||
|              </property> | ||||
|              <layout class="QGridLayout" name="gridLayout_10"> | ||||
|               <item row="1" column="0"> | ||||
|                <widget class="QLabel" name="label_14"> | ||||
|                 <property name="text"> | ||||
|                  <string>Latitude</string> | ||||
|                 </property> | ||||
|                </widget> | ||||
|               </item> | ||||
|               <item row="1" column="1"> | ||||
|                <widget class="QDoubleSpinBox" name="alertAudioLatitudeSpinBox"> | ||||
|                 <property name="decimals"> | ||||
|                  <number>6</number> | ||||
|                 </property> | ||||
|                 <property name="minimum"> | ||||
|                  <double>-90.000000000000000</double> | ||||
|                 </property> | ||||
|                 <property name="maximum"> | ||||
|                  <double>90.000000000000000</double> | ||||
|                 </property> | ||||
|                 <property name="singleStep"> | ||||
|                  <double>0.010000000000000</double> | ||||
|                 </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"> | ||||
|                <widget class="QToolButton" name="resetAlertAudioLocationMethodButton"> | ||||
|                 <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="0"> | ||||
|                <widget class="QLabel" name="label_12"> | ||||
|                 <property name="text"> | ||||
|                  <string>Location Method</string> | ||||
|                 </property> | ||||
|                </widget> | ||||
|               </item> | ||||
|               <item row="2" column="1"> | ||||
|                <widget class="QDoubleSpinBox" name="alertAudioLongitudeSpinBox"> | ||||
|                 <property name="decimals"> | ||||
|                  <number>6</number> | ||||
|                 </property> | ||||
|                 <property name="minimum"> | ||||
|                  <double>-180.000000000000000</double> | ||||
|                 </property> | ||||
|                 <property name="maximum"> | ||||
|                  <double>180.000000000000000</double> | ||||
|                 </property> | ||||
|                 <property name="singleStep"> | ||||
|                  <double>0.010000000000000</double> | ||||
|                 </property> | ||||
|                </widget> | ||||
|               </item> | ||||
|               <item row="0" column="1"> | ||||
|                <widget class="QComboBox" name="alertAudioLocationMethodComboBox"> | ||||
|                 <property name="sizePolicy"> | ||||
|                  <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> | ||||
|                   <horstretch>0</horstretch> | ||||
|                   <verstretch>0</verstretch> | ||||
|                  </sizepolicy> | ||||
|                 </property> | ||||
|                </widget> | ||||
|               </item> | ||||
|              </layout> | ||||
|             </widget> | ||||
|            </item> | ||||
|            <item> | ||||
|             <spacer name="verticalSpacer_6"> | ||||
|              <property name="orientation"> | ||||
|               <enum>Qt::Vertical</enum> | ||||
|              </property> | ||||
|              <property name="sizeHint" stdset="0"> | ||||
|               <size> | ||||
|                <width>20</width> | ||||
|                <height>309</height> | ||||
|               </size> | ||||
|              </property> | ||||
|             </spacer> | ||||
|            </item> | ||||
|           </layout> | ||||
|          </widget> | ||||
|          <widget class="QWidget" name="text"> | ||||
|           <layout class="QVBoxLayout" name="verticalLayout_5"> | ||||
|            <item> | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat