1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

refactor(Style): Move fonts storage from array to std::map

Strongly enforces ordering instead of being based off comments, and logically
represents the relation better.
This commit is contained in:
Anthony Bilinski 2022-03-13 21:34:45 -07:00
parent b9c4b0075c
commit cf5be40511
No known key found for this signature in database
GPG Key ID: 2AA8E0DA1B31FB3C

View File

@ -219,17 +219,17 @@ QFont Style::getFont(Font font)
static int defSize = QFontInfo(QFont()).pixelSize(); static int defSize = QFontInfo(QFont()).pixelSize();
static QFont fonts[] = { static const std::map<Font, QFont> fonts = {
appFont(defSize + 3, QFont::Bold), // extra big {Font::ExtraBig, appFont(defSize + 3, QFont::Bold)},
appFont(defSize + 1, QFont::Normal), // big {Font::Big, appFont(defSize + 1, QFont::Normal)},
appFont(defSize + 1, QFont::Bold), // big bold {Font::BigBold, appFont(defSize + 1, QFont::Bold)},
appFont(defSize, QFont::Normal), // medium {Font::Medium, appFont(defSize, QFont::Normal)},
appFont(defSize, QFont::Bold), // medium bold {Font::MediumBold, appFont(defSize, QFont::Bold)},
appFont(defSize - 1, QFont::Normal), // small {Font::Small, appFont(defSize - 1, QFont::Normal)},
appFont(defSize - 1, QFont::Light), // small light {Font::SmallLight, appFont(defSize - 1, QFont::Light)},
}; };
return fonts[static_cast<int>(font)]; return fonts.at(font);
} }
const QString Style::resolve(const QString& filename, Settings& settings, const QFont& baseFont) const QString Style::resolve(const QString& filename, Settings& settings, const QFont& baseFont)