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
+1
View File
@@ -53,6 +53,7 @@
- Bugfix: Fixed selection of tabs after closing a tab when using "Live Tabs Only". (#4770) - Bugfix: Fixed selection of tabs after closing a tab when using "Live Tabs Only". (#4770)
- Bugfix: Fixed input in reply thread popup losing focus when dragging. (#4815) - Bugfix: Fixed input in reply thread popup losing focus when dragging. (#4815)
- Bugfix: Fixed the Quick Switcher (CTRL+K) from sometimes showing up on the wrong window. (#4819) - Bugfix: Fixed the Quick Switcher (CTRL+K) from sometimes showing up on the wrong window. (#4819)
- Bugfix: Fixed the font switcher not remembering what font you had previously selected. (#5224)
- Bugfix: Fixed too much text being copied when copying chat messages. (#4812, #4830, #4839) - Bugfix: Fixed too much text being copied when copying chat messages. (#4812, #4830, #4839)
- Bugfix: Fixed an issue where the setting `Only search for emote autocompletion at the start of emote names` wouldn't disable if it was enabled when the client started. (#4855) - Bugfix: Fixed an issue where the setting `Only search for emote autocompletion at the start of emote names` wouldn't disable if it was enabled when the client started. (#4855)
- Bugfix: Fixed empty page being added when showing out of bounds dialog. (#4849) - Bugfix: Fixed empty page being added when showing out of bounds dialog. (#4849)
+7 -9
View File
@@ -173,7 +173,8 @@ void GeneralPage::initLayout(GeneralPageView &layout)
}, },
[this](auto args) { [this](auto args) {
return this->getFont(args); return this->getFont(args);
}); },
true, "", true);
layout.addDropdown<int>( layout.addDropdown<int>(
"Font size", {"9pt", "10pt", "12pt", "14pt", "16pt", "20pt"}, "Font size", {"9pt", "10pt", "12pt", "14pt", "16pt", "20pt"},
getIApp()->getFonts()->chatFontSize, getIApp()->getFonts()->chatFontSize,
@@ -1293,22 +1294,19 @@ QString GeneralPage::getFont(const DropdownArgs &args) const
{ {
if (args.combobox->currentIndex() == args.combobox->count() - 1) if (args.combobox->currentIndex() == args.combobox->count() - 1)
{ {
args.combobox->setCurrentIndex(0);
args.combobox->setEditText("Choosing..."); args.combobox->setEditText("Choosing...");
QFontDialog dialog(
getIApp()->getFonts()->getFont(FontStyle::ChatMedium, 1.));
auto ok = bool(); 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) if (ok)
{ {
return font.family(); return font.family();
} }
else
{ return previousFont.family();
return args.combobox->itemText(0);
}
} }
return args.value; return args.value;
} }
+21 -8
View File
@@ -147,7 +147,7 @@ public:
pajlada::Settings::Setting<T> &setting, pajlada::Settings::Setting<T> &setting,
std::function<boost::variant<int, QString>(T)> getValue, std::function<boost::variant<int, QString>(T)> getValue,
std::function<T(DropdownArgs)> setValue, bool editable = true, std::function<T(DropdownArgs)> setValue, bool editable = true,
QString toolTipText = {}) QString toolTipText = {}, bool listenToActivated = false)
{ {
auto items2 = items; auto items2 = items;
auto selected = getValue(setting.getValue()); auto selected = getValue(setting.getValue());
@@ -197,14 +197,27 @@ public:
}, },
this->managedConnections_); this->managedConnections_);
QObject::connect( auto updateSetting = [combo, &setting, setValue = std::move(setValue)](
combo, QOverload<const int>::of(&QComboBox::currentIndexChanged), const int newIndex) {
[combo, &setting, setting = setValue(DropdownArgs{
setValue = std::move(setValue)](const int newIndex) { .value = combo->itemText(newIndex),
setting = setValue(DropdownArgs{combo->itemText(newIndex), .index = combo->currentIndex(),
combo->currentIndex(), combo}); .combobox = combo,
getIApp()->getWindows()->forceLayoutChannelViews();
}); });
getIApp()->getWindows()->forceLayoutChannelViews();
};
if (listenToActivated)
{
QObject::connect(combo, &QComboBox::activated, updateSetting);
}
else
{
QObject::connect(
combo,
QOverload<const int>::of(&QComboBox::currentIndexChanged),
updateSetting);
}
return combo; return combo;
} }