Fix ChatWidget current text edit color when changing appearance style.

Don't change already typed text, who wants to change style while
typping?
This commit is contained in:
Phenom 2018-03-04 17:31:40 +01:00
parent 593e57b14c
commit 51cc94bfa7

View File

@ -474,6 +474,7 @@ uint32_t ChatWidget::maxMessageSize()
bool ChatWidget::eventFilter(QObject *obj, QEvent *event) bool ChatWidget::eventFilter(QObject *obj, QEvent *event)
{ {
//QEvent::Type type = event->type();
if (obj == ui->textBrowser || obj == ui->textBrowser->viewport() if (obj == ui->textBrowser || obj == ui->textBrowser->viewport()
|| obj == ui->leSearch || obj == ui->chatTextEdit) { || obj == ui->leSearch || obj == ui->chatTextEdit) {
if (event->type() == QEvent::KeyPress) { 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) { } else if (obj == ui->leSearch) {
if (event->type() == QEvent::KeyPress) { if (event->type() == QEvent::KeyPress) {