refactor: consolidate font picking into one dialog (#6531)
Instead of three separate dropdowns in the setting dialog, we now expose a single label + button combo for modifying the font. When the button is pressed, we open a custom font dialog allowing the user to customize the font family, font size, and font weight. Reviewed-by: nerix <nerixdev@outlook.de> Reviewed-by: pajlada <rasmus.karlsson@pajlada.com>
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
#include "util/Helpers.hpp"
|
||||
#include "util/IncognitoBrowser.hpp"
|
||||
#include "widgets/BaseWindow.hpp"
|
||||
#include "widgets/helper/FontSettingWidget.hpp"
|
||||
#include "widgets/settingspages/GeneralPageView.hpp"
|
||||
#include "widgets/settingspages/SettingWidget.hpp"
|
||||
|
||||
@@ -153,34 +154,6 @@ void GeneralPage::initLayout(GeneralPageView &layout)
|
||||
#endif
|
||||
}
|
||||
|
||||
layout.addDropdown<QString>(
|
||||
"Font", {"Segoe UI", "Arial", "Choose..."}, s.chatFontFamily,
|
||||
[](auto val) {
|
||||
return val;
|
||||
},
|
||||
[this](auto args) {
|
||||
return this->getFont(args);
|
||||
},
|
||||
true, "", true);
|
||||
layout.addDropdown<int>(
|
||||
"Font size", {"9pt", "10pt", "12pt", "14pt", "16pt", "20pt"},
|
||||
s.chatFontSize,
|
||||
[](auto val) {
|
||||
return QString::number(val) + "pt";
|
||||
},
|
||||
[](auto args) {
|
||||
return fuzzyToInt(args.value, 10);
|
||||
});
|
||||
layout.addDropdown<int>(
|
||||
"Font weight",
|
||||
{"100", "200", "300", "400", "500", "600", "700", "800", "900"},
|
||||
s.chatFontWeight,
|
||||
[](auto val) {
|
||||
return QString::number(val);
|
||||
},
|
||||
[](auto args) {
|
||||
return fuzzyToInt(args.value, 400);
|
||||
});
|
||||
layout.addDropdown<float>(
|
||||
"Zoom", ZOOM_LEVELS, s.uiScale,
|
||||
[](auto val) {
|
||||
@@ -263,6 +236,10 @@ void GeneralPage::initLayout(GeneralPageView &layout)
|
||||
|
||||
SettingWidget::dropdown("Tab style", s.tabStyle)->addTo(layout);
|
||||
|
||||
layout.addWidget(new FontSettingWidget(s.chatFontFamily, s.chatFontSize,
|
||||
s.chatFontWeight),
|
||||
{"font", "weight", "size"});
|
||||
|
||||
SettingWidget::inverseCheckbox("Show message reply context",
|
||||
s.hideReplyContext)
|
||||
->setTooltip(
|
||||
@@ -1541,25 +1518,4 @@ void GeneralPage::initExtra()
|
||||
}
|
||||
}
|
||||
|
||||
QString GeneralPage::getFont(const DropdownArgs &args) const
|
||||
{
|
||||
if (args.combobox->currentIndex() == args.combobox->count() - 1)
|
||||
{
|
||||
args.combobox->setEditText("Choosing...");
|
||||
|
||||
auto ok = bool();
|
||||
auto previousFont =
|
||||
getApp()->getFonts()->getFont(FontStyle::ChatMedium, 1.);
|
||||
auto font = QFontDialog::getFont(&ok, previousFont, this->window());
|
||||
|
||||
if (ok)
|
||||
{
|
||||
return font.family();
|
||||
}
|
||||
|
||||
return previousFont.family();
|
||||
}
|
||||
return args.value;
|
||||
}
|
||||
|
||||
} // namespace chatterino
|
||||
|
||||
Reference in New Issue
Block a user