mirror of
https://gitlab.com/pholy/OSCAR-code.git
synced 2025-04-06 11:10:44 +00:00
Add font validation and setting methods. Call at startup or after preference changes to force fonts to be acceptable to operating system and to set application font.
This commit is contained in:
parent
86d5c074a4
commit
a424a1903e
@ -180,24 +180,28 @@ PreferencesDialog::PreferencesDialog(QWidget *parent, Profile *_profile) :
|
|||||||
ui->applicationFontSize->setValue(QApplication::font().pointSize());
|
ui->applicationFontSize->setValue(QApplication::font().pointSize());
|
||||||
ui->applicationFontBold->setChecked(QApplication::font().weight() == QFont::Bold);
|
ui->applicationFontBold->setChecked(QApplication::font().weight() == QFont::Bold);
|
||||||
ui->applicationFontItalic->setChecked(QApplication::font().italic());
|
ui->applicationFontItalic->setChecked(QApplication::font().italic());
|
||||||
|
// ui->applicationFont->setEditable(false);
|
||||||
|
|
||||||
ui->graphFont->setCurrentFont(*defaultfont);
|
ui->graphFont->setCurrentFont(*defaultfont);
|
||||||
//ui->graphFont->setFont(*defaultfont);
|
//ui->graphFont->setFont(*defaultfont);
|
||||||
ui->graphFontSize->setValue(defaultfont->pointSize());
|
ui->graphFontSize->setValue(defaultfont->pointSize());
|
||||||
ui->graphFontBold->setChecked(defaultfont->weight() == QFont::Bold);
|
ui->graphFontBold->setChecked(defaultfont->weight() == QFont::Bold);
|
||||||
ui->graphFontItalic->setChecked(defaultfont->italic());
|
ui->graphFontItalic->setChecked(defaultfont->italic());
|
||||||
|
// ui->graphFont->setEditable(false);
|
||||||
|
|
||||||
ui->titleFont->setCurrentFont(*mediumfont);
|
ui->titleFont->setCurrentFont(*mediumfont);
|
||||||
//ui->titleFont->setFont(*mediumfont);
|
//ui->titleFont->setFont(*mediumfont);
|
||||||
ui->titleFontSize->setValue(mediumfont->pointSize());
|
ui->titleFontSize->setValue(mediumfont->pointSize());
|
||||||
ui->titleFontBold->setChecked(mediumfont->weight() == QFont::Bold);
|
ui->titleFontBold->setChecked(mediumfont->weight() == QFont::Bold);
|
||||||
ui->titleFontItalic->setChecked(mediumfont->italic());
|
ui->titleFontItalic->setChecked(mediumfont->italic());
|
||||||
|
// ui->titleFont->setEditable(false);
|
||||||
|
|
||||||
ui->bigFont->setCurrentFont(*bigfont);
|
ui->bigFont->setCurrentFont(*bigfont);
|
||||||
//ui->bigFont->setFont(*bigfont);
|
//ui->bigFont->setFont(*bigfont);
|
||||||
ui->bigFontSize->setValue(bigfont->pointSize());
|
ui->bigFontSize->setValue(bigfont->pointSize());
|
||||||
ui->bigFontBold->setChecked(bigfont->weight() == QFont::Bold);
|
ui->bigFontBold->setChecked(bigfont->weight() == QFont::Bold);
|
||||||
ui->bigFontItalic->setChecked(bigfont->italic());
|
ui->bigFontItalic->setChecked(bigfont->italic());
|
||||||
|
// ui->bigFont->setEditable(false);
|
||||||
|
|
||||||
ui->lineThicknessSlider->setValue(AppSetting->lineThickness()*2.0);
|
ui->lineThicknessSlider->setValue(AppSetting->lineThickness()*2.0);
|
||||||
|
|
||||||
@ -901,7 +905,6 @@ bool PreferencesDialog::Save()
|
|||||||
(*p_pref)["Fonts_Application_Bold"] = ui->applicationFontBold->isChecked();
|
(*p_pref)["Fonts_Application_Bold"] = ui->applicationFontBold->isChecked();
|
||||||
(*p_pref)["Fonts_Application_Italic"] = ui->applicationFontItalic->isChecked();
|
(*p_pref)["Fonts_Application_Italic"] = ui->applicationFontItalic->isChecked();
|
||||||
|
|
||||||
|
|
||||||
(*p_pref)["Fonts_Graph_Name"] = ui->graphFont->currentText();
|
(*p_pref)["Fonts_Graph_Name"] = ui->graphFont->currentText();
|
||||||
(*p_pref)["Fonts_Graph_Size"] = ui->graphFontSize->value();
|
(*p_pref)["Fonts_Graph_Size"] = ui->graphFontSize->value();
|
||||||
(*p_pref)["Fonts_Graph_Bold"] = ui->graphFontBold->isChecked();
|
(*p_pref)["Fonts_Graph_Bold"] = ui->graphFontBold->isChecked();
|
||||||
@ -917,28 +920,25 @@ bool PreferencesDialog::Save()
|
|||||||
(*p_pref)["Fonts_Big_Bold"] = ui->bigFontBold->isChecked();
|
(*p_pref)["Fonts_Big_Bold"] = ui->bigFontBold->isChecked();
|
||||||
(*p_pref)["Fonts_Big_Italic"] = ui->bigFontItalic->isChecked();
|
(*p_pref)["Fonts_Big_Italic"] = ui->bigFontItalic->isChecked();
|
||||||
|
|
||||||
QFont font = ui->applicationFont->currentFont();
|
validateAllFonts(); // Make sure fonts are valid and reset to default values if not
|
||||||
font.setPointSize(ui->applicationFontSize->value());
|
|
||||||
font.setWeight(ui->applicationFontBold->isChecked() ? QFont::Bold : QFont::Normal);
|
|
||||||
font.setItalic(ui->applicationFontItalic->isChecked());
|
|
||||||
QApplication::setFont(font);
|
|
||||||
mainwin->menuBar()->setFont(font);
|
|
||||||
|
|
||||||
*defaultfont = ui->graphFont->currentFont();
|
// Changes to the application font will be set by the caller (mainwindow.cpp)
|
||||||
defaultfont->setPointSize(ui->graphFontSize->value());
|
|
||||||
defaultfont->setWeight(ui->graphFontBold->isChecked() ? QFont::Bold : QFont::Normal);
|
|
||||||
defaultfont->setItalic(ui->graphFontItalic->isChecked());
|
|
||||||
|
|
||||||
*mediumfont = ui->titleFont->currentFont();
|
// Set other fonts for use by graph etc. pages
|
||||||
mediumfont->setPointSize(ui->titleFontSize->value());
|
defaultfont = new QFont(((*p_pref)["Fonts_Graph_Name"]).toString());
|
||||||
mediumfont->setWeight(ui->titleFontBold->isChecked() ? QFont::Bold : QFont::Normal);
|
defaultfont->setPointSize(((*p_pref)["Fonts_Graph_Size"]).toInt());
|
||||||
mediumfont->setItalic(ui->titleFontItalic->isChecked());
|
defaultfont->setWeight(((*p_pref)["Fonts_Graph_Bold"]).toBool() ? QFont::Bold : QFont::Normal);
|
||||||
|
defaultfont->setItalic(((*p_pref)["Fonts_Graph_Italic"]).toBool());
|
||||||
|
|
||||||
*bigfont = ui->bigFont->currentFont();
|
mediumfont = new QFont(((*p_pref)["Fonts_Title_Name"]).toString());
|
||||||
bigfont->setPointSize(ui->bigFontSize->value());
|
mediumfont->setPointSize(((*p_pref)["Fonts_Title_Size"]).toInt());
|
||||||
bigfont->setWeight(ui->bigFontBold->isChecked() ? QFont::Bold : QFont::Normal);
|
mediumfont->setWeight(((*p_pref)["Fonts_Title_Bold"]).toBool() ? QFont::Bold : QFont::Normal);
|
||||||
bigfont->setItalic(ui->bigFontItalic->isChecked());
|
mediumfont->setItalic(((*p_pref)["Fonts_Title_Italic"]).toBool());
|
||||||
|
|
||||||
|
bigfont = new QFont(((*p_pref)["Fonts_Big_Name"]).toString());
|
||||||
|
bigfont->setPointSize(((*p_pref)["Fonts_Big_Size"]).toInt());
|
||||||
|
bigfont->setWeight(((*p_pref)["Fonts_Big_Bold"]).toBool() ? QFont::Bold : QFont::Normal);
|
||||||
|
bigfont->setItalic(((*p_pref)["Fonts_Big_Italic"]).toBool());
|
||||||
|
|
||||||
saveChanInfo();
|
saveChanInfo();
|
||||||
saveWaveInfo();
|
saveWaveInfo();
|
||||||
|
Loading…
Reference in New Issue
Block a user