mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 05:10:04 +00:00 
			
		
		
		
	Adding update notifications setting option
This commit is contained in:
		
							parent
							
								
									19f0ab9898
								
							
						
					
					
						commit
						a609f14f1f
					
				
					 6 changed files with 38 additions and 8 deletions
				
			
		|  | @ -506,9 +506,14 @@ void MainWindow::on_resourceTreeView_doubleClicked(const QModelIndex& index) | |||
| 
 | ||||
| void MainWindowImpl::AsyncSetup() | ||||
| { | ||||
|    auto& generalSettings = manager::SettingsManager::general_settings(); | ||||
| 
 | ||||
|    // Check for updates
 | ||||
|    scwx::util::async( | ||||
|       [this]() { updateManager_->CheckForUpdates(main::kVersionString_); }); | ||||
|    if (generalSettings.update_notifications_enabled().GetValue()) | ||||
|    { | ||||
|       scwx::util::async( | ||||
|          [this]() { updateManager_->CheckForUpdates(main::kVersionString_); }); | ||||
|    } | ||||
| } | ||||
| 
 | ||||
| void MainWindowImpl::ConfigureMapLayout() | ||||
|  |  | |||
|  | @ -21,6 +21,7 @@ public: | |||
|       gridWidth_.SetDefault(1); | ||||
|       gridHeight_.SetDefault(1); | ||||
|       mapboxApiKey_.SetDefault("?"); | ||||
|       updateNotificationsEnabled_.SetDefault(true); | ||||
| 
 | ||||
|       fontSizes_.SetElementMinimum(1); | ||||
|       fontSizes_.SetElementMaximum(72); | ||||
|  | @ -42,6 +43,7 @@ public: | |||
|    SettingsVariable<std::int64_t>               gridWidth_ {"grid_width"}; | ||||
|    SettingsVariable<std::int64_t>               gridHeight_ {"grid_height"}; | ||||
|    SettingsVariable<std::string> mapboxApiKey_ {"mapbox_api_key"}; | ||||
|    SettingsVariable<bool> updateNotificationsEnabled_ {"update_notifications"}; | ||||
| }; | ||||
| 
 | ||||
| GeneralSettings::GeneralSettings() : | ||||
|  | @ -52,7 +54,8 @@ GeneralSettings::GeneralSettings() : | |||
|                       &p->fontSizes_, | ||||
|                       &p->gridWidth_, | ||||
|                       &p->gridHeight_, | ||||
|                       &p->mapboxApiKey_}); | ||||
|                       &p->mapboxApiKey_, | ||||
|                       &p->updateNotificationsEnabled_}); | ||||
|    SetDefaults(); | ||||
| } | ||||
| GeneralSettings::~GeneralSettings() = default; | ||||
|  | @ -92,6 +95,11 @@ SettingsVariable<std::string>& GeneralSettings::mapbox_api_key() const | |||
|    return p->mapboxApiKey_; | ||||
| } | ||||
| 
 | ||||
| SettingsVariable<bool>& GeneralSettings::update_notifications_enabled() const | ||||
| { | ||||
|    return p->updateNotificationsEnabled_; | ||||
| } | ||||
| 
 | ||||
| bool operator==(const GeneralSettings& lhs, const GeneralSettings& rhs) | ||||
| { | ||||
|    return (lhs.p->debugEnabled_ == rhs.p->debugEnabled_ && | ||||
|  | @ -99,7 +107,9 @@ bool operator==(const GeneralSettings& lhs, const GeneralSettings& rhs) | |||
|            lhs.p->fontSizes_ == rhs.p->fontSizes_ && | ||||
|            lhs.p->gridWidth_ == rhs.p->gridWidth_ && | ||||
|            lhs.p->gridHeight_ == rhs.p->gridHeight_ && | ||||
|            lhs.p->mapboxApiKey_ == rhs.p->mapboxApiKey_); | ||||
|            lhs.p->mapboxApiKey_ == rhs.p->mapboxApiKey_ && | ||||
|            lhs.p->updateNotificationsEnabled_ == | ||||
|               rhs.p->updateNotificationsEnabled_); | ||||
| } | ||||
| 
 | ||||
| } // namespace settings
 | ||||
|  |  | |||
|  | @ -33,6 +33,7 @@ public: | |||
|    SettingsVariable<std::int64_t>&               grid_height() const; | ||||
|    SettingsVariable<std::int64_t>&               grid_width() const; | ||||
|    SettingsVariable<std::string>&                mapbox_api_key() const; | ||||
|    SettingsVariable<bool>& update_notifications_enabled() const; | ||||
| 
 | ||||
|    friend bool operator==(const GeneralSettings& lhs, | ||||
|                           const GeneralSettings& rhs); | ||||
|  |  | |||
|  | @ -84,6 +84,7 @@ public: | |||
|           &gridWidth_, | ||||
|           &gridHeight_, | ||||
|           &mapboxApiKey_, | ||||
|           &updateNotificationsEnabled_, | ||||
|           &debugEnabled_}} | ||||
|    { | ||||
|       // Configure default alert phenomena colors
 | ||||
|  | @ -137,7 +138,8 @@ public: | |||
|    settings::SettingsInterface<std::int64_t>              gridWidth_ {}; | ||||
|    settings::SettingsInterface<std::int64_t>              gridHeight_ {}; | ||||
|    settings::SettingsInterface<std::string>               mapboxApiKey_ {}; | ||||
|    settings::SettingsInterface<bool>                      debugEnabled_ {}; | ||||
|    settings::SettingsInterface<bool> updateNotificationsEnabled_ {}; | ||||
|    settings::SettingsInterface<bool> debugEnabled_ {}; | ||||
| 
 | ||||
|    std::unordered_map<std::string, settings::SettingsInterface<std::string>> | ||||
|       colorTables_ {}; | ||||
|  | @ -315,6 +317,11 @@ void SettingsDialogImpl::SetupGeneralTab() | |||
|    mapboxApiKey_.SetEditWidget(self_->ui->mapboxApiKeyLineEdit); | ||||
|    mapboxApiKey_.SetResetButton(self_->ui->resetMapboxApiKeyButton); | ||||
| 
 | ||||
|    updateNotificationsEnabled_.SetSettingsVariable( | ||||
|       generalSettings.update_notifications_enabled()); | ||||
|    updateNotificationsEnabled_.SetEditWidget( | ||||
|       self_->ui->enableUpdateNotificationsCheckBox); | ||||
| 
 | ||||
|    debugEnabled_.SetSettingsVariable(generalSettings.debug_enabled()); | ||||
|    debugEnabled_.SetEditWidget(self_->ui->debugEnabledCheckBox); | ||||
| } | ||||
|  |  | |||
|  | @ -224,6 +224,13 @@ | |||
|             </layout> | ||||
|            </widget> | ||||
|           </item> | ||||
|           <item> | ||||
|            <widget class="QCheckBox" name="enableUpdateNotificationsCheckBox"> | ||||
|             <property name="text"> | ||||
|              <string>Update Notifications Enabled</string> | ||||
|             </property> | ||||
|            </widget> | ||||
|           </item> | ||||
|           <item> | ||||
|            <widget class="QCheckBox" name="debugEnabledCheckBox"> | ||||
|             <property name="text"> | ||||
|  | @ -268,8 +275,8 @@ | |||
|                   <rect> | ||||
|                    <x>0</x> | ||||
|                    <y>0</y> | ||||
|                    <width>489</width> | ||||
|                    <height>382</height> | ||||
|                    <width>66</width> | ||||
|                    <height>18</height> | ||||
|                   </rect> | ||||
|                  </property> | ||||
|                  <layout class="QGridLayout" name="gridLayout_3"> | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat