summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gui/kernel/qpalette.cpp10
-rw-r--r--src/gui/widgets/qlineedit.cpp3
-rw-r--r--tests/auto/qlineedit/tst_qlineedit.cpp18
3 files changed, 29 insertions, 2 deletions
diff --git a/src/gui/kernel/qpalette.cpp b/src/gui/kernel/qpalette.cpp
index 98e8f66..38ec806 100644
--- a/src/gui/kernel/qpalette.cpp
+++ b/src/gui/kernel/qpalette.cpp
@@ -868,11 +868,21 @@ void QPalette::detach()
Returns true (slowly) if this palette is different from \a p;
otherwise returns false (usually quickly).
+
+ \note The current ColorGroup is not taken into account when
+ comparing palettes
+
+ \sa operator==
*/
/*!
Returns true (usually quickly) if this palette is equal to \a p;
otherwise returns false (slowly).
+
+ \note The current ColorGroup is not taken into account when
+ comparing palettes
+
+ \sa operator!=
*/
bool QPalette::operator==(const QPalette &p) const
{
diff --git a/src/gui/widgets/qlineedit.cpp b/src/gui/widgets/qlineedit.cpp
index d7311ef..981e934 100644
--- a/src/gui/widgets/qlineedit.cpp
+++ b/src/gui/widgets/qlineedit.cpp
@@ -1949,7 +1949,8 @@ void QLineEdit::paintEvent(QPaintEvent *)
if (d->control->hasSelectedText() || (d->cursorVisible && !d->control->inputMask().isEmpty() && !d->control->isReadOnly())){
flags |= QLineControl::DrawSelections;
// Palette only used for selections/mask and may not be in sync
- if(d->control->palette() != pal)
+ if (d->control->palette() != pal
+ || d->control->palette().currentColorGroup() != pal.currentColorGroup())
d->control->setPalette(pal);
}
diff --git a/tests/auto/qlineedit/tst_qlineedit.cpp b/tests/auto/qlineedit/tst_qlineedit.cpp
index b34e559..e0747f8 100644
--- a/tests/auto/qlineedit/tst_qlineedit.cpp
+++ b/tests/auto/qlineedit/tst_qlineedit.cpp
@@ -66,7 +66,6 @@
#include <qspinbox.h>
#include <qdebug.h>
-
//TESTED_CLASS=
//TESTED_FILES=
@@ -275,6 +274,7 @@ private slots:
void taskQTBUG_7902_contextMenuCrash();
#endif
void taskQTBUG_7395_readOnlyShortcut();
+ void QTBUG697_paletteCurrentColorGroup();
#ifdef QT3_SUPPORT
void validateAndSet_data();
@@ -3714,5 +3714,21 @@ void tst_QLineEdit::taskQTBUG_7395_readOnlyShortcut()
QCOMPARE(spy.count(), 1);
}
+void tst_QLineEdit::QTBUG697_paletteCurrentColorGroup()
+{
+ testWidget->setText(" ");
+ QPalette p = testWidget->palette();
+ p.setBrush(QPalette::Active, QPalette::Highlight, Qt::green);
+ p.setBrush(QPalette::Inactive, QPalette::Highlight, Qt::red);
+ testWidget->setPalette(p);
+ testWidget->selectAll();
+ QImage img(testWidget->rect().size(),QImage::Format_ARGB32 );
+ testWidget->render(&img);
+ QCOMPARE(img.pixel(10, testWidget->height()/2), QColor(Qt::green).rgb());
+ QApplication::setActiveWindow(0);
+ testWidget->render(&img);
+ QCOMPARE(img.pixel(10, testWidget->height()/2), QColor(Qt::red).rgb());
+}
+
QTEST_MAIN(tst_QLineEdit)
#include "tst_qlineedit.moc"