mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 12:32: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)
|
||||
{
|
||||
if (!QSettings().value("fAppearanceSetupDone", false).toBool()) {
|
||||
// First make sure SystemDefault has reasonable default values if it does not support the full range of weights.
|
||||
if (fontFamily == FontFamily::SystemDefault && getSupportedWeights().size() < 4) {
|
||||
fontWeightNormal = mapSupportedWeights[FontFamily::SystemDefault].front();
|
||||
fontWeightBold = mapSupportedWeights[FontFamily::SystemDefault].back();
|
||||
QSettings().setValue("fontWeightNormal", weightToArg(fontWeightNormal));
|
||||
QSettings().setValue("fontWeightBold", weightToArg(fontWeightBold));
|
||||
std::vector<QFont::Weight> vecWeights = getSupportedWeights();
|
||||
// See if the default value for normal weight is available
|
||||
if (std::find(vecWeights.begin(), vecWeights.end(), defaultFontWeightNormal) == vecWeights.end()) {
|
||||
// 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("fontWeightBold", weightToArg(fontWeightBold));
|
||||
|
||||
// Create the dialog
|
||||
QDialog dlg(parent);
|
||||
dlg.setObjectName("AppearanceSetup");
|
||||
|
Loading…
Reference in New Issue
Block a user