mirror of
https://github.com/dashpay/dash.git
synced 2024-12-27 21:12:48 +01:00
qt: Fix default font weight values if selected values aren't supported by the font (#3849)
* qt: Fix default value if not supported values are selected * qt: Fix comment * qt: Fix logic of supported weight check * qt: Inline std::find check * qt: Rename vecSupportedWeights -> vecWeights
This commit is contained in:
parent
eebd50332d
commit
b80ef47ead
@ -302,13 +302,23 @@ void setupAmountWidget(QLineEdit *widget, QWidget *parent)
|
|||||||
void setupAppearance(QWidget* parent, OptionsModel* model)
|
void setupAppearance(QWidget* parent, OptionsModel* model)
|
||||||
{
|
{
|
||||||
if (!QSettings().value("fAppearanceSetupDone", false).toBool()) {
|
if (!QSettings().value("fAppearanceSetupDone", false).toBool()) {
|
||||||
// First make sure SystemDefault has reasonable default values if it does not support the full range of weights.
|
std::vector<QFont::Weight> vecWeights = getSupportedWeights();
|
||||||
if (fontFamily == FontFamily::SystemDefault && getSupportedWeights().size() < 4) {
|
// See if the default value for normal weight is available
|
||||||
fontWeightNormal = mapSupportedWeights[FontFamily::SystemDefault].front();
|
if (std::find(vecWeights.begin(), vecWeights.end(), defaultFontWeightNormal) == vecWeights.end()) {
|
||||||
fontWeightBold = mapSupportedWeights[FontFamily::SystemDefault].back();
|
// If not, use the lightest available weight as normal weight
|
||||||
|
fontWeightNormal = vecWeights.front();
|
||||||
|
}
|
||||||
|
|
||||||
|
// See if the default value for bold weight is available
|
||||||
|
if (std::find(vecWeights.begin(), vecWeights.end(), defaultFontWeightBold) == vecWeights.end()) {
|
||||||
|
// If not, use the second lightest available weight as bold weight default or also the lightest if there is only one
|
||||||
|
int nBoldOffset = vecWeights.size() > 1 ? 1 : 0;
|
||||||
|
fontWeightBold = vecWeights[nBoldOffset];
|
||||||
|
}
|
||||||
|
|
||||||
QSettings().setValue("fontWeightNormal", weightToArg(fontWeightNormal));
|
QSettings().setValue("fontWeightNormal", weightToArg(fontWeightNormal));
|
||||||
QSettings().setValue("fontWeightBold", weightToArg(fontWeightBold));
|
QSettings().setValue("fontWeightBold", weightToArg(fontWeightBold));
|
||||||
}
|
|
||||||
// Create the dialog
|
// Create the dialog
|
||||||
QDialog dlg(parent);
|
QDialog dlg(parent);
|
||||||
dlg.setObjectName("AppearanceSetup");
|
dlg.setObjectName("AppearanceSetup");
|
||||||
|
Loading…
Reference in New Issue
Block a user