Skip to content

Commit

Permalink
Check availability of font before setting up QFontComboBoxes
Browse files Browse the repository at this point in the history
  • Loading branch information
vtronko committed Aug 28, 2016
1 parent c7942da commit f64afff
Showing 1 changed file with 8 additions and 16 deletions.
24 changes: 8 additions & 16 deletions src/PreferencesDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,10 @@ void PreferencesDialog::loadSettings()
}

// Gracefully handle the preferred Data Browser font not being available
int matchingFont = ui->comboDataBrowserFont->findText(getSettingsValue("databrowser", "font").toString());
if (matchingFont != -1) {
// The requested font is available, so select it in the combo box
ui->comboDataBrowserFont->setCurrentIndex(matchingFont);
} else {
// The requested font isn't available, so fall back to the default one
ui->comboDataBrowserFont->setCurrentIndex(ui->comboDataBrowserFont->findText(QFont().defaultFamily()));
}
int matchingFont = ui->comboDataBrowserFont->findText(getSettingsValue("databrowser", "font").toString(), Qt::MatchExactly);
if (matchingFont == -1)
matchingFont = ui->comboDataBrowserFont->findText(getSettingsDefaultValue("databrowser", "font").toString());
ui->comboDataBrowserFont->setCurrentIndex(matchingFont);

ui->spinDataBrowserFontSize->setValue(getSettingsValue("databrowser", "fontsize").toInt());
loadColorSetting(ui->fr_null_fg, "null_fg");
Expand Down Expand Up @@ -112,14 +108,10 @@ void PreferencesDialog::loadSettings()
}

// Gracefully handle the preferred Editor font not being available
matchingFont = ui->comboEditorFont->findText(getSettingsValue("editor", "font").toString());
if (matchingFont != -1) {
// The requested font is available, so select it in the combo box
ui->comboEditorFont->setCurrentIndex(matchingFont);
} else {
// The requested font isn't available, so fall back to the default one
ui->comboEditorFont->setCurrentIndex(ui->comboEditorFont->findText(QFont().defaultFamily()));
}
matchingFont = ui->comboEditorFont->findText(getSettingsValue("editor", "font").toString(), Qt::MatchExactly);
if (matchingFont == -1)
matchingFont = ui->comboDataBrowserFont->findText(getSettingsDefaultValue("editor", "font").toString());
ui->comboEditorFont->setCurrentIndex(matchingFont);

ui->spinEditorFontSize->setValue(getSettingsValue("editor", "fontsize").toInt());
ui->spinTabSize->setValue(getSettingsValue("editor", "tabsize").toInt());
Expand Down

0 comments on commit f64afff

Please sign in to comment.