From db60d4e29df489f48c5f8c075da1128747e369e9 Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Mon, 15 Apr 2024 19:26:50 +0300 Subject: [PATCH] konsole: set the palette instead of the stylesheet of the search line editor this makes it adapt to palette changes (after match is found, not found or the search is cleared) Signed-off-by: Ivailo Monev --- konsole/src/IncrementalSearchBar.cpp | 25 +++++++++---------------- konsole/src/IncrementalSearchBar.h | 9 +++++---- 2 files changed, 14 insertions(+), 20 deletions(-) diff --git a/konsole/src/IncrementalSearchBar.cpp b/konsole/src/IncrementalSearchBar.cpp index aab98aa1..a097f8ad 100644 --- a/konsole/src/IncrementalSearchBar.cpp +++ b/konsole/src/IncrementalSearchBar.cpp @@ -20,13 +20,12 @@ // Own #include "IncrementalSearchBar.h" -// Qt +// Katie #include #include -#include -#include #include #include +#include // KDE #include @@ -242,27 +241,21 @@ void IncrementalSearchBar::setVisible(bool visible) void IncrementalSearchBar::setFoundMatch(bool match) { if (!match && !_searchEdit->text().isEmpty()) { - KStatefulBrush backgroundBrush(KColorScheme::View, KColorScheme::NegativeBackground); - - QString matchStyleSheet = QString("QLineEdit{ background-color:%1 }") - .arg(backgroundBrush.brush(_searchEdit).color().name()); - - _searchEdit->setStyleSheet(matchStyleSheet); + QPalette pal = palette(); + KColorScheme::adjustBackground(pal, KColorScheme::NegativeBackground); + _searchEdit->setPalette(pal); } else if (_searchEdit->text().isEmpty()) { clearLineEdit(); } else { - KStatefulBrush backgroundBrush(KColorScheme::View, KColorScheme::PositiveBackground); - - QString matchStyleSheet = QString("QLineEdit{ background-color:%1 }") - .arg(backgroundBrush.brush(_searchEdit).color().name()); - - _searchEdit->setStyleSheet(matchStyleSheet); + QPalette pal = palette(); + KColorScheme::adjustBackground(pal, KColorScheme::PositiveBackground); + _searchEdit->setPalette(pal); } } void IncrementalSearchBar::clearLineEdit() { - _searchEdit->setStyleSheet(QString()); + _searchEdit->setPalette(palette()); } void IncrementalSearchBar::focusLineEdit() diff --git a/konsole/src/IncrementalSearchBar.h b/konsole/src/IncrementalSearchBar.h index 86063394..8eb1ac59 100644 --- a/konsole/src/IncrementalSearchBar.h +++ b/konsole/src/IncrementalSearchBar.h @@ -20,15 +20,16 @@ #ifndef INCREMENTALSEARCHBAR_H #define INCREMENTALSEARCHBAR_H -// Qt +// Katie #include -#include - +#include #include #include #include -class KLineEdit; #include +#include + +class KLineEdit; namespace Konsole {