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