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

refactor(chat-settings): use safe methods to get the font's pixel size

Further rename the pixel size vars to improve readability.
This commit is contained in:
Nils Fenner 2016-07-04 12:15:53 +02:00
parent 9ec5c11caa
commit 1dd730841a
No known key found for this signature in database
GPG Key ID: 9591A163FF9BE04C
2 changed files with 8 additions and 7 deletions

View File

@ -581,22 +581,23 @@ void GeneralForm::retranslateUi()
void GeneralForm::on_txtChatFont_currentFontChanged(const QFont& f) void GeneralForm::on_txtChatFont_currentFontChanged(const QFont& f)
{ {
QFont tmpFont = f; QFont tmpFont = f;
const int fontSize = bodyUI->txtChatFontSize->value(); const int px = bodyUI->txtChatFontSize->value();
if (tmpFont.pixelSize() != fontSize) if (QFontInfo(tmpFont).pixelSize() != px)
tmpFont.setPixelSize(fontSize); tmpFont.setPixelSize(px);
Settings::getInstance().setChatMessageFont(tmpFont); Settings::getInstance().setChatMessageFont(tmpFont);
} }
void GeneralForm::on_txtChatFontSize_valueChanged(int arg1) void GeneralForm::on_txtChatFontSize_valueChanged(int px)
{ {
Settings& s = Settings::getInstance(); Settings& s = Settings::getInstance();
QFont tmpFont = s.getChatMessageFont(); QFont tmpFont = s.getChatMessageFont();
const int fontSize = QFontInfo(tmpFont).pixelSize();
if (tmpFont.pixelSize() != arg1) if (px != fontSize)
{ {
tmpFont.setPixelSize(arg1); tmpFont.setPixelSize(px);
s.setChatMessageFont(tmpFont); s.setChatMessageFont(tmpFont);
} }
} }

View File

@ -75,7 +75,7 @@ private slots:
void onThemeColorChanged(int); void onThemeColorChanged(int);
void on_txtChatFont_currentFontChanged(const QFont& f); void on_txtChatFont_currentFontChanged(const QFont& f);
void on_txtChatFontSize_valueChanged(int arg1); void on_txtChatFontSize_valueChanged(int px);
private: private:
void retranslateUi(); void retranslateUi();