fix: the font switcher now remembers your previous font (#5224)

Fixes #2112
This commit is contained in:
pajlada
2024-03-03 13:41:32 +01:00
committed by GitHub
parent 449c5397b7
commit 77cfd1393c
3 changed files with 29 additions and 17 deletions
+7 -9
View File
@@ -173,7 +173,8 @@ void GeneralPage::initLayout(GeneralPageView &layout)
},
[this](auto args) {
return this->getFont(args);
});
},
true, "", true);
layout.addDropdown<int>(
"Font size", {"9pt", "10pt", "12pt", "14pt", "16pt", "20pt"},
getIApp()->getFonts()->chatFontSize,
@@ -1293,22 +1294,19 @@ QString GeneralPage::getFont(const DropdownArgs &args) const
{
if (args.combobox->currentIndex() == args.combobox->count() - 1)
{
args.combobox->setCurrentIndex(0);
args.combobox->setEditText("Choosing...");
QFontDialog dialog(
getIApp()->getFonts()->getFont(FontStyle::ChatMedium, 1.));
auto ok = bool();
auto font = dialog.getFont(&ok, this->window());
auto previousFont =
getIApp()->getFonts()->getFont(FontStyle::ChatMedium, 1.);
auto font = QFontDialog::getFont(&ok, previousFont, this->window());
if (ok)
{
return font.family();
}
else
{
return args.combobox->itemText(0);
}
return previousFont.family();
}
return args.value;
}