summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierre Rossi <pierre.rossi@nokia.com>2010-07-22 15:53:59 (GMT)
committerPierre Rossi <pierre.rossi@nokia.com>2010-07-22 16:52:39 (GMT)
commitd9d877326b13c55dc33b1cac13f3ee70e8de62bf (patch)
tree64c798037a1d343280068619a1c9009f0f745594
parentc8bb76ec0b19da9e24512852dc8b00461e1a1b7b (diff)
downloadQt-d9d877326b13c55dc33b1cac13f3ee70e8de62bf.zip
Qt-d9d877326b13c55dc33b1cac13f3ee70e8de62bf.tar.gz
Qt-d9d877326b13c55dc33b1cac13f3ee70e8de62bf.tar.bz2
Make QPalette::operator== return false if the currentColorGroup differs
This was affecting QLineEdit's selected text color when the window is inactive. Task-number: QTBUG-697 Reviewed-by: ogoffart
-rw-r--r--src/gui/kernel/qpalette.cpp2
-rw-r--r--src/gui/widgets/qlineedit.cpp2
-rw-r--r--tests/auto/qpalette/tst_qpalette.cpp30
-rw-r--r--tests/auto/qwidget/tst_qwidget.cpp6
4 files changed, 36 insertions, 4 deletions
diff --git a/src/gui/kernel/qpalette.cpp b/src/gui/kernel/qpalette.cpp
index 98e8f66..910dfa9 100644
--- a/src/gui/kernel/qpalette.cpp
+++ b/src/gui/kernel/qpalette.cpp
@@ -876,6 +876,8 @@ void QPalette::detach()
*/
bool QPalette::operator==(const QPalette &p) const
{
+ if (p.currentColorGroup() != current_group)
+ return false;
if (isCopyOf(p))
return true;
for(int grp = 0; grp < (int)NColorGroups; grp++) {
diff --git a/src/gui/widgets/qlineedit.cpp b/src/gui/widgets/qlineedit.cpp
index 1bffde1..98f0f44 100644
--- a/src/gui/widgets/qlineedit.cpp
+++ b/src/gui/widgets/qlineedit.cpp
@@ -1946,7 +1946,7 @@ 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->setPalette(pal);
}
diff --git a/tests/auto/qpalette/tst_qpalette.cpp b/tests/auto/qpalette/tst_qpalette.cpp
index 2501f8d..65eabbd 100644
--- a/tests/auto/qpalette/tst_qpalette.cpp
+++ b/tests/auto/qpalette/tst_qpalette.cpp
@@ -65,6 +65,7 @@ public slots:
private slots:
void roleValues_data();
void roleValues();
+ void operators();
};
tst_QPalette::tst_QPalette()
@@ -128,5 +129,34 @@ void tst_QPalette::roleValues()
QCOMPARE(role, value);
}
+void tst_QPalette::operators()
+{
+ {
+ QPalette palette = qApp->palette();
+ QPalette copy = palette;
+ QCOMPARE(palette.currentColorGroup(), copy.currentColorGroup());
+ QCOMPARE(palette.resolve(), copy.resolve());
+ QVERIFY(copy.isCopyOf(palette));
+
+ }
+
+ {
+ QPalette palette = qApp->palette();
+ QPalette copy = palette;
+ copy.setColor(QPalette::Base, palette.color(QPalette::Base).lighter());
+ QVERIFY(palette != copy);
+ QVERIFY(!copy.isCopyOf(palette));
+ }
+
+ {
+ QPalette palette = qApp->palette();
+ QPalette copy = palette;
+ copy.setCurrentColorGroup(QPalette::Inactive);
+ palette.setCurrentColorGroup(QPalette::Active);
+ QVERIFY(palette != copy);
+ }
+
+}
+
QTEST_MAIN(tst_QPalette)
#include "tst_qpalette.moc"
diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp
index 2d559c8..f0c40e8 100644
--- a/tests/auto/qwidget/tst_qwidget.cpp
+++ b/tests/auto/qwidget/tst_qwidget.cpp
@@ -988,8 +988,8 @@ void tst_QWidget::palettePropagation2()
{
// ! Note, the code below is executed in tst_QWidget's constructor.
// QPalette palette;
- // font.setColor(QPalette::ToolTipBase, QColor(12, 13, 14));
- // font.setColor(QPalette::Text, QColor(21, 22, 23));
+ // palette.setColor(QPalette::ToolTipBase, QColor(12, 13, 14));
+ // palette.setColor(QPalette::Text, QColor(21, 22, 23));
// qApp->setPalette(palette, "QPropagationTestWidget");
QWidget *root = new QWidget;
@@ -1000,7 +1000,7 @@ void tst_QWidget::palettePropagation2()
QWidget *child4 = new QWidget(child3);
QWidget *child5 = new QWidget(child4);
root->show();
- QTest::qWait(100);
+ QTest::qWaitForWindowShown(root);
// These colors are unlikely to be imposed on the default palette of
// QWidget ;-).