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

Merge pull request #4124

Yuri (1):
      fix(font): Fixed the editbox font reset problem
This commit is contained in:
sudden6 2017-02-04 22:51:07 +01:00
commit 5a04359901
No known key found for this signature in database
GPG Key ID: 279509B499E032B9
2 changed files with 15 additions and 3 deletions

View File

@ -95,8 +95,6 @@ GenericChatForm::GenericChatForm(QWidget *parent)
chatWidget, &ChatLog::forceRelayout); chatWidget, &ChatLog::forceRelayout);
msgEdit = new ChatTextEdit(); msgEdit = new ChatTextEdit();
// TODO: make it work without restart
msgEdit->setCurrentFont(s.getChatMessageFont());
sendButton = new QPushButton(); sendButton = new QPushButton();
emoteButton = new QPushButton(); emoteButton = new QPushButton();
@ -127,7 +125,8 @@ GenericChatForm::GenericChatForm(QWidget *parent)
fileLayout->setSpacing(0); fileLayout->setSpacing(0);
fileLayout->setMargin(0); fileLayout->setMargin(0);
msgEdit->setStyleSheet(Style::getStylesheet(":/ui/msgEdit/msgEdit.css")); msgEdit->setStyleSheet(Style::getStylesheet(":/ui/msgEdit/msgEdit.css")
+ fontToCss(s.getChatMessageFont(), "QTextEdit"));
msgEdit->setFixedHeight(50); msgEdit->setFixedHeight(50);
msgEdit->setFrameStyle(QFrame::NoFrame); msgEdit->setFrameStyle(QFrame::NoFrame);
@ -671,6 +670,18 @@ void GenericChatForm::retranslateUi()
copyLinkAction->setText(tr("Copy link address")); copyLinkAction->setText(tr("Copy link address"));
} }
QString GenericChatForm::fontToCss(const QFont& font, const char* name)
{
return QString("%1{font-family: \"%2\"; font-size: %3px; font-style: \"%4\"; font-weight: %5;}")
.arg(name)
.arg(font.family())
.arg(font.pixelSize())
.arg(font.style() == QFont::StyleNormal ? "normal"
: font.style() == QFont::StyleItalic ? "italic"
: "bold")
.arg(font.weight()*10); // QFont weight is 0..100, but CSS font-weight is 0..1000
}
void GenericChatForm::showNetcam() void GenericChatForm::showNetcam()
{ {
if (!netcam) if (!netcam)

View File

@ -102,6 +102,7 @@ protected slots:
private: private:
void retranslateUi(); void retranslateUi();
static QString fontToCss(const QFont& font, const char* name);
protected: protected:
void showNetcam(); void showNetcam();