解决强调色修改后搜索框刷新不及时问题

This commit is contained in:
lixueman 2022-07-21 15:33:43 +08:00
parent 681e05b0ae
commit ec4329bd6f
4 changed files with 41 additions and 8 deletions

View File

@ -117,11 +117,16 @@ void FunctionClassifyButton::paintEvent(QPaintEvent *e)
painter.save();
QColor color;
if (m_fullscreen) {
color = Qt::white;
} else {
if ( g_curStyle == "ukui-light") {
color = Qt::black;
} else {
color = Qt::white;
}
}
color.setAlphaF(0.9);
painter.setPen(color);
painter.drawText(option.rect, Qt::AlignCenter, m_category);

View File

@ -102,11 +102,16 @@ void LetterClassifyButton::paintEvent(QPaintEvent *e)
painter.save();
QColor color;
if (m_fullscreen) {
color = Qt::white;
} else {
if ( g_curStyle == "ukui-light") {
color = Qt::black;
} else {
color = Qt::white;
}
}
color.setAlphaF(0.9);
painter.setPen(color);
painter.drawText(option.rect, Qt::AlignCenter, m_letter);

View File

@ -123,6 +123,13 @@ void FullMainWindow::initSearchUI()
if (key.contains(QString("styleName"))) {
changeStyle();
}
if (key.contains(QString("theme-color"))) {
QString highLightColor = QString::number(this->palette().color(QPalette::Highlight).rgba(), 16);
QString color = highLightColor.mid(2, 6);
QString searchStyle = QString("border-radius: 13px; border:1px solid #%1; background: transparent;").arg(color);
m_lineEdit->setStyleSheet(searchStyle);
}
});
}
@ -294,7 +301,7 @@ bool FullMainWindow::eventFilter(QObject *watched, QEvent *event)
QString style;
if (event->type() == QEvent::FocusIn) {
QString highLightColor = QString::number(m_lineEdit->palette().color(QPalette::Highlight).rgba(), 16);
QString highLightColor = QString::number(this->palette().color(QPalette::Highlight).rgba(), 16);
QString color = highLightColor.mid(2, 6);
style = QString("QLineEdit{border:2px solid #%1;background-color:%2;border-radius:17px;color:#ffffff;}")
.arg(color).arg(QueryLineEditClickedBackground);

View File

@ -275,6 +275,13 @@ void MainWindow::initGsettings()
if (key.contains(QString("styleName"))) {
changeStyle();
}
if (key.contains(QString("theme-color"))) {
QString highLightColor = QString::number(this->palette().color(QPalette::Highlight).rgba(), 16);
QString color = highLightColor.mid(2, 6);
QString searchStyle = QString("border-radius: 13px; border:1px solid #%1; background: transparent;").arg(color);
m_lineEdit->setStyleSheet(searchStyle);
}
});
}
}
@ -317,7 +324,7 @@ void MainWindow::initSearchUi()
m_leftTopSearchHorizontalLayout->setContentsMargins(8, 0, 8, 0);
m_lineEdit = new QLineEdit(m_minSearchPage);
m_lineEdit->setMinimumSize(QSize(30, 26));
QString highLightColor = QString::number(m_lineEdit->palette().color(QPalette::Highlight).rgba(), 16);
QString highLightColor = QString::number(this->palette().color(QPalette::Highlight).rgba(), 16);
QString color = highLightColor.mid(2, 6);
QString searchStyle = QString("border-radius: 13px; border:1px solid #%1; background: transparent;").arg(color);
m_lineEdit->setStyleSheet(searchStyle);
@ -942,6 +949,15 @@ bool MainWindow::eventFilter(QObject *target, QEvent *event)
}
}
if (target == m_lineEdit) {
if (event->type() == QEvent::FocusIn) {
QString highLightColor = QString::number(this->palette().color(QPalette::Highlight).rgba(), 16);
QString color = highLightColor.mid(2, 6);
QString searchStyle = QString("border-radius: 13px; border:1px solid #%1; background: transparent;").arg(color);
m_lineEdit->setStyleSheet(searchStyle);
}
}
if (event->type() == QEvent::KeyPress) {
QKeyEvent *ke = (QKeyEvent *)event;