diff --git a/src/kdatetable.cpp b/src/kdatetable.cpp --- a/src/kdatetable.cpp +++ b/src/kdatetable.cpp @@ -54,6 +54,7 @@ void endOfMonth(); void beginningOfWeek(); void endOfWeek(); + QColor appropriateDisabledTextColor(QColor backgroundColor); KDateTable *q; @@ -274,12 +275,13 @@ if (row == 0) { //We are drawing a header cell + cellBackgroundColor = palette().color(QPalette::Window); //If not a normal working day, then use "do not work today" color if (workingDay) { cellTextColor = palette().color(QPalette::WindowText); } else { - cellTextColor = Qt::darkRed; + cellTextColor = d->appropriateDisabledTextColor(cellBackgroundColor); } cellBackgroundColor = palette().color(QPalette::Window); @@ -366,7 +368,7 @@ //If the cell day is the day of religious observance, then always color text red unless Custom overrides if (! customDay && dayOfPray) { - cellTextColor = Qt::darkRed; + cellTextColor = d->appropriateDisabledTextColor(cellBackgroundColor); } } @@ -454,6 +456,18 @@ q->setDate(m_date.addDays(7 - m_date.dayOfWeek())); } +QColor KDateTable::KDateTablePrivate::appropriateDisabledTextColor(QColor backgroundColor) +{ + if (backgroundColor.lightnessF() < 0.3) { + // A "disabled" text color that looks good against a dark background + return Qt::gray; + } else { + // A "disabled" text color that looks good against a light background + return Qt::darkGray; + } +} + + void KDateTable::keyPressEvent(QKeyEvent *e) { switch (e->key()) {