Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 3 commits into from
Mar 3, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
- 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 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 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)
Expand Down
16 changes: 7 additions & 9 deletions src/widgets/settingspages/GeneralPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
}
Expand Down
34 changes: 25 additions & 9 deletions src/widgets/settingspages/GeneralPageView.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ class GeneralPageView : public QWidget
pajlada::Settings::Setting<T> &setting,
std::function<boost::variant<int, QString>(T)> getValue,
std::function<T(DropdownArgs)> setValue, bool editable = true,
QString toolTipText = {})
QString toolTipText = {}, bool listenToActivated = false)
{
auto items2 = items;
auto selected = getValue(setting.getValue());
Expand Down Expand Up @@ -197,14 +197,30 @@ class GeneralPageView : public QWidget
},
this->managedConnections_);

QObject::connect(
combo, QOverload<const int>::of(&QComboBox::currentIndexChanged),
[combo, &setting,
setValue = std::move(setValue)](const int newIndex) {
setting = setValue(DropdownArgs{combo->itemText(newIndex),
combo->currentIndex(), combo});
getIApp()->getWindows()->forceLayoutChannelViews();
});
if (listenToActivated)
{
QObject::connect(
combo, &QComboBox::activated,
[combo, &setting,
setValue = std::move(setValue)](const int index) {
setting = setValue(DropdownArgs{
combo->itemText(index), combo->currentIndex(), combo});
getIApp()->getWindows()->forceLayoutChannelViews();
});
}
else
{
QObject::connect(
combo,
QOverload<const int>::of(&QComboBox::currentIndexChanged),
[combo, &setting,
setValue = std::move(setValue)](const int newIndex) {
setting =
setValue(DropdownArgs{combo->itemText(newIndex),
combo->currentIndex(), combo});
getIApp()->getWindows()->forceLayoutChannelViews();
});
pajlada marked this conversation as resolved.
Show resolved Hide resolved
}

return combo;
}
Expand Down
Loading