2017-06-11 09:31:45 +02:00
|
|
|
#include "fontmanager.hpp"
|
2017-04-12 17:46:44 +02:00
|
|
|
|
2017-06-17 11:37:13 +02:00
|
|
|
#include <QDebug>
|
2017-04-12 17:46:44 +02:00
|
|
|
|
2017-04-14 17:52:22 +02:00
|
|
|
namespace chatterino {
|
2017-04-12 17:46:44 +02:00
|
|
|
|
|
|
|
FontManager::FontManager()
|
2017-06-17 11:37:13 +02:00
|
|
|
: currentFontFamily("/appearance/currentFontFamily", "Arial")
|
|
|
|
, currentFontSize("/appearance/currentFontSize", 14)
|
|
|
|
, currentFont(this->currentFontFamily.getValue().c_str(), currentFontSize.getValue())
|
2017-04-12 17:46:44 +02:00
|
|
|
{
|
2017-06-26 16:41:20 +02:00
|
|
|
this->currentFontFamily.getValueChangedSignal().connect([this](const std::string &newValue) {
|
2017-06-17 11:37:13 +02:00
|
|
|
this->currentFont.setFamily(newValue.c_str()); //
|
|
|
|
});
|
2017-06-26 16:41:20 +02:00
|
|
|
this->currentFontSize.getValueChangedSignal().connect([this](const int &newValue) {
|
2017-06-17 11:37:13 +02:00
|
|
|
this->currentFont.setSize(newValue); //
|
|
|
|
});
|
2017-04-12 17:46:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
QFont &FontManager::getFont(Type type)
|
|
|
|
{
|
2017-06-17 11:37:13 +02:00
|
|
|
return this->currentFont.getFont(type);
|
2017-04-12 17:46:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
QFontMetrics &FontManager::getFontMetrics(Type type)
|
|
|
|
{
|
2017-06-17 11:37:13 +02:00
|
|
|
return this->currentFont.getFontMetrics(type);
|
|
|
|
}
|
|
|
|
|
|
|
|
FontManager::FontData &FontManager::Font::getFontData(Type type)
|
|
|
|
{
|
|
|
|
switch (type) {
|
|
|
|
case Small:
|
|
|
|
return this->small;
|
|
|
|
case Medium:
|
|
|
|
return this->medium;
|
|
|
|
case MediumBold:
|
|
|
|
return this->mediumBold;
|
|
|
|
case MediumItalic:
|
|
|
|
return this->mediumItalic;
|
|
|
|
case Large:
|
|
|
|
return this->large;
|
|
|
|
case VeryLarge:
|
|
|
|
return this->veryLarge;
|
|
|
|
default:
|
|
|
|
qDebug() << "Unknown font type:" << type << ", defaulting to medium";
|
|
|
|
return this->medium;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
QFont &FontManager::Font::getFont(Type type)
|
|
|
|
{
|
|
|
|
return this->getFontData(type).font;
|
|
|
|
}
|
|
|
|
|
|
|
|
QFontMetrics &FontManager::Font::getFontMetrics(Type type)
|
|
|
|
{
|
|
|
|
return this->getFontData(type).metrics;
|
2017-04-12 17:46:44 +02:00
|
|
|
}
|
2017-06-07 10:09:24 +02:00
|
|
|
|
|
|
|
} // namespace chatterino
|