mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
7df7da70cb
Remove unused constructor of messages::Message Fixed LimitedQueueSnapshot _-prefixes Changed LimitedQueueSnapshot's usage of int to std::size_t ColorScheme is no longer a singleton Created a "BaseWidget" class which is pretty much a QWidget except it has a reference of ColorScheme since most widgets will need a reference to the style they should use. BaseWidget can be implemented either with a BaseWidget parent (which will copy the ColorScheme reference from the parent) or with a normal QWidget parent and an explicit ColorScheme reference. Save main window geometry on close Fix font changing in the Settings Dialog Update settings library version
61 lines
1.6 KiB
C++
61 lines
1.6 KiB
C++
#include "fontmanager.hpp"
|
|
|
|
#include <QDebug>
|
|
|
|
namespace chatterino {
|
|
|
|
FontManager::FontManager()
|
|
: currentFontFamily("/appearance/currentFontFamily", "Arial")
|
|
, currentFontSize("/appearance/currentFontSize", 14)
|
|
, currentFont(this->currentFontFamily.getValue().c_str(), currentFontSize.getValue())
|
|
{
|
|
this->currentFontFamily.getValueChangedSignal().connect([this](const std::string &newValue) {
|
|
this->currentFont.setFamily(newValue.c_str()); //
|
|
});
|
|
this->currentFontSize.getValueChangedSignal().connect([this](const int &newValue) {
|
|
this->currentFont.setSize(newValue); //
|
|
});
|
|
}
|
|
|
|
QFont &FontManager::getFont(Type type)
|
|
{
|
|
return this->currentFont.getFont(type);
|
|
}
|
|
|
|
QFontMetrics &FontManager::getFontMetrics(Type type)
|
|
{
|
|
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;
|
|
}
|
|
|
|
} // namespace chatterino
|