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 QFont fonts[] = {
appFont(defSize + 3, QFont::Bold), // extra big
appFont(defSize + 1, QFont::Normal), // big
appFont(defSize + 1, QFont::Bold), // big bold
appFont(defSize, QFont::Normal), // medium
appFont(defSize, QFont::Bold), // medium bold
appFont(defSize - 1, QFont::Normal), // small
appFont(defSize - 1, QFont::Light), // small light
static const std::map<Font, QFont> fonts = {
{Font::ExtraBig, appFont(defSize + 3, QFont::Bold)},
{Font::Big, appFont(defSize + 1, QFont::Normal)},
{Font::BigBold, appFont(defSize + 1, QFont::Bold)},
{Font::Medium, appFont(defSize, QFont::Normal)},
{Font::MediumBold, appFont(defSize, QFont::Bold)},
{Font::Small, appFont(defSize - 1, QFont::Normal)},
{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)