mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 01:50:06 +00:00 
			
		
		
		
	Initial setup for font settings
This commit is contained in:
		
							parent
							
								
									e0aa327bb7
								
							
						
					
					
						commit
						ad1646d725
					
				
					 7 changed files with 192 additions and 23 deletions
				
			
		|  | @ -22,6 +22,7 @@ | |||
| #include <QColorDialog> | ||||
| #include <QFileDialog> | ||||
| #include <QFontDialog> | ||||
| #include <QStandardItemModel> | ||||
| #include <QToolButton> | ||||
| 
 | ||||
| namespace scwx | ||||
|  | @ -86,6 +87,7 @@ public: | |||
|        self_ {self}, | ||||
|        radarSiteDialog_ {new RadarSiteDialog(self)}, | ||||
|        fontDialog_ {new QFontDialog(self)}, | ||||
|        fontCategoryModel_ {new QStandardItemModel(self)}, | ||||
|        settings_ {std::initializer_list<settings::SettingsInterfaceBase*> { | ||||
|           &defaultRadarSite_, | ||||
|           &fontSizes_, | ||||
|  | @ -153,6 +155,8 @@ public: | |||
|    RadarSiteDialog*         radarSiteDialog_; | ||||
|    QFontDialog*             fontDialog_; | ||||
| 
 | ||||
|    QStandardItemModel* fontCategoryModel_; | ||||
| 
 | ||||
|    settings::SettingsInterface<std::string>               defaultRadarSite_ {}; | ||||
|    settings::SettingsInterface<std::vector<std::int64_t>> fontSizes_ {}; | ||||
|    settings::SettingsInterface<std::int64_t>              gridWidth_ {}; | ||||
|  | @ -173,6 +177,15 @@ public: | |||
|                       settings::SettingsInterface<std::string>> | ||||
|       inactiveAlertColors_ {}; | ||||
| 
 | ||||
|    std::unordered_map<types::FontCategory, | ||||
|                       settings::SettingsInterface<std::string>> | ||||
|       fontFamilies_ {}; | ||||
|    std::unordered_map<types::FontCategory, | ||||
|                       settings::SettingsInterface<std::string>> | ||||
|       fontStyles_ {}; | ||||
|    std::unordered_map<types::FontCategory, settings::SettingsInterface<double>> | ||||
|       fontPointSizes_ {}; | ||||
| 
 | ||||
|    settings::SettingsInterface<std::int64_t> hoverTextWrap_ {}; | ||||
|    settings::SettingsInterface<std::string>  tooltipMethod_ {}; | ||||
| 
 | ||||
|  | @ -663,6 +676,37 @@ void SettingsDialogImpl::SetupTextTab() | |||
| { | ||||
|    settings::TextSettings& textSettings = settings::TextSettings::Instance(); | ||||
| 
 | ||||
|    self_->ui->fontListView->setModel(fontCategoryModel_); | ||||
|    for (const auto& fontCategory : types::FontCategoryIterator()) | ||||
|    { | ||||
|       // Add font category to list view
 | ||||
|       fontCategoryModel_->appendRow(new QStandardItem( | ||||
|          QString::fromStdString(types::GetFontCategoryName(fontCategory)))); | ||||
| 
 | ||||
|       // Create settings interface
 | ||||
|       auto fontFamilyResult = fontFamilies_.emplace( | ||||
|          fontCategory, settings::SettingsInterface<std::string> {}); | ||||
|       auto fontStyleResult = fontStyles_.emplace( | ||||
|          fontCategory, settings::SettingsInterface<std::string> {}); | ||||
|       auto fontSizeResult = fontPointSizes_.emplace( | ||||
|          fontCategory, settings::SettingsInterface<double> {}); | ||||
| 
 | ||||
|       auto& fontFamily = (*fontFamilyResult.first).second; | ||||
|       auto& fontStyle  = (*fontStyleResult.first).second; | ||||
|       auto& fontSize   = (*fontSizeResult.first).second; | ||||
| 
 | ||||
|       // Add to settings list
 | ||||
|       settings_.push_back(&fontFamily); | ||||
|       settings_.push_back(&fontStyle); | ||||
|       settings_.push_back(&fontSize); | ||||
| 
 | ||||
|       // Set settings variables
 | ||||
|       fontFamily.SetSettingsVariable(textSettings.font_family(fontCategory)); | ||||
|       fontStyle.SetSettingsVariable(textSettings.font_style(fontCategory)); | ||||
|       fontSize.SetSettingsVariable(textSettings.font_point_size(fontCategory)); | ||||
|    } | ||||
|    self_->ui->fontListView->setCurrentIndex(fontCategoryModel_->index(0, 0)); | ||||
| 
 | ||||
|    hoverTextWrap_.SetSettingsVariable(textSettings.hover_text_wrap()); | ||||
|    hoverTextWrap_.SetEditWidget(self_->ui->hoverTextWrapSpinBox); | ||||
|    hoverTextWrap_.SetResetButton(self_->ui->resetHoverTextWrapButton); | ||||
|  |  | |||
|  | @ -469,13 +469,6 @@ | |||
|                  <number>0</number> | ||||
|                 </property> | ||||
|                 <item row="2" column="1"> | ||||
|                  <widget class="QPushButton" name="resetAllFontsButton"> | ||||
|                   <property name="text"> | ||||
|                    <string>Reset All Fonts</string> | ||||
|                   </property> | ||||
|                  </widget> | ||||
|                 </item> | ||||
|                 <item row="2" column="0"> | ||||
|                  <spacer name="horizontalSpacer_2"> | ||||
|                   <property name="orientation"> | ||||
|                    <enum>Qt::Horizontal</enum> | ||||
|  | @ -488,10 +481,17 @@ | |||
|                   </property> | ||||
|                  </spacer> | ||||
|                 </item> | ||||
|                 <item row="1" column="0" colspan="2"> | ||||
|                 <item row="2" column="0"> | ||||
|                  <widget class="QPushButton" name="resetAllFontsButton"> | ||||
|                   <property name="text"> | ||||
|                    <string>Reset All Fonts</string> | ||||
|                   </property> | ||||
|                  </widget> | ||||
|                 </item> | ||||
|                 <item row="1" column="0" colspan="3"> | ||||
|                  <widget class="QListView" name="fontListView"/> | ||||
|                 </item> | ||||
|                 <item row="0" column="0" colspan="2"> | ||||
|                 <item row="0" column="0" colspan="3"> | ||||
|                  <widget class="QLabel" name="label_10"> | ||||
|                   <property name="text"> | ||||
|                    <string>Display Item:</string> | ||||
|  | @ -581,17 +581,6 @@ | |||
|                   </property> | ||||
|                  </widget> | ||||
|                 </item> | ||||
|                 <item row="0" column="4"> | ||||
|                  <widget class="QToolButton" name="resetFontButton"> | ||||
|                   <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="5" column="2"> | ||||
|                  <widget class="QLabel" name="fontSizeLabel"> | ||||
|                   <property name="text"> | ||||
|  | @ -640,6 +629,17 @@ | |||
|                   </property> | ||||
|                  </spacer> | ||||
|                 </item> | ||||
|                 <item row="0" column="4"> | ||||
|                  <widget class="QToolButton" name="resetFontButton"> | ||||
|                   <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> | ||||
|                </layout> | ||||
|               </widget> | ||||
|              </item> | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat