Merge pull request #1208 from PhenomRetroShare/Fix_ChangeChatTextColorWhenChangeStyle

Fix ChatWidget current text edit color when changing appearance style.
This commit is contained in:
csoler 2018-03-14 20:49:42 +01:00 committed by GitHub
commit c7549a260a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -474,6 +474,7 @@ uint32_t ChatWidget::maxMessageSize()
bool ChatWidget::eventFilter(QObject *obj, QEvent *event)
{
//QEvent::Type type = event->type();
if (obj == ui->textBrowser || obj == ui->textBrowser->viewport()
|| obj == ui->leSearch || obj == ui->chatTextEdit) {
if (event->type() == QEvent::KeyPress) {
@ -673,6 +674,17 @@ bool ChatWidget::eventFilter(QObject *obj, QEvent *event)
}
}
}
if (event->type() == QEvent::StyleChange)
{
QString colorName = currentColor.name();
qreal desiredContrast = Settings->valueFromGroup("Chat", "MinimumContrast", 4.5).toDouble();
QColor backgroundColor = ui->chatTextEdit->palette().base().color();
RsHtml::findBestColor(colorName, backgroundColor, desiredContrast);
currentColor = QColor(colorName);
ui->chatTextEdit->setTextColor(currentColor);
colorChanged();
}
} else if (obj == ui->leSearch) {
if (event->type() == QEvent::KeyPress) {