diff --git a/src/agenda/agenda.cpp b/src/agenda/agenda.cpp --- a/src/agenda/agenda.cpp +++ b/src/agenda/agenda.cpp @@ -1528,9 +1528,12 @@ // QPixmap bgImage(d->preferences()->agendaGridBackgroundImage()); // dbp.drawPixmap(0, 0, cw, ch, bgImage); FIXME // } - - dbp.fillRect(0, 0, cw, ch, - d->preferences()->agendaGridBackgroundColor()); + if (!d->preferences()->useSystemColor()) { + dbp.fillRect(0, 0, cw, ch, + d->preferences()->agendaGridBackgroundColor()); + } else { + dbp.fillRect(0, 0, cw, ch, palette().color(QPalette::Window)); + } dbp.translate(-cx, -cy); @@ -1544,7 +1547,12 @@ // Highlight working hours if (d->mWorkingHoursEnable && d->mHolidayMask) { - const QColor workColor = d->preferences()->workingHoursColor(); + QColor workColor; + if (!d->preferences()->useSystemColor()) { + workColor = d->preferences()->workingHoursColor(); + } else { + workColor = palette().color(QPalette::Base); + } QPoint pt1(cx, d->mWorkingHoursYTop); QPoint pt2(cx + cw, d->mWorkingHoursYBottom); @@ -1596,7 +1604,19 @@ if (busyDayMask[i]) { const QPoint pt1(cx + d->mGridSpacingX *i, 0); // const QPoint pt2(cx + mGridSpacingX * (i+1), ch); - QColor busyColor = d->preferences()->viewBgBusyColor(); + QColor busyColor; + if (!d->preferences()->useSystemColor()) { + busyColor = d->preferences()->viewBgBusyColor(); + } else { + busyColor = palette().color(QPalette::Window); + if ((busyColor.blue() + busyColor.red() + busyColor.green()) > (256 / 2 * 3)) { + // dark + busyColor.lighter(140); + } else { + // light + busyColor.darker(140); + } + } busyColor.setAlpha(EventViews::BUSY_BACKGROUND_ALPHA); dbp.fillRect(pt1.x(), pt1.y(), d->mGridSpacingX, cy + ch, busyColor); } @@ -1606,31 +1626,45 @@ // draw selection if (d->mHasSelection && d->mAgendaView->dateRangeSelectionEnabled()) { QPoint pt, pt1; + QColor highlightColor; + if (!d->preferences()->useSystemColor()) { + highlightColor = d->preferences()->agendaGridHighlightColor(); + } else { + highlightColor = palette().color(QPalette::Highlight); + } if (d->mSelectionEndCell.x() > d->mSelectionStartCell.x()) { // multi day selection // draw start day pt = gridToContents(d->mSelectionStartCell); pt1 = gridToContents(QPoint(d->mSelectionStartCell.x() + 1, d->mRows + 1)); - dbp.fillRect(QRect(pt, pt1), d->preferences()->agendaGridHighlightColor()); + dbp.fillRect(QRect(pt, pt1), highlightColor); // draw all other days between the start day and the day of the selection end for (int c = d->mSelectionStartCell.x() + 1; c < d->mSelectionEndCell.x(); ++c) { pt = gridToContents(QPoint(c, 0)); pt1 = gridToContents(QPoint(c + 1, d->mRows + 1)); - dbp.fillRect(QRect(pt, pt1), d->preferences()->agendaGridHighlightColor()); + dbp.fillRect(QRect(pt, pt1), highlightColor); } // draw end day pt = gridToContents(QPoint(d->mSelectionEndCell.x(), 0)); pt1 = gridToContents(d->mSelectionEndCell + QPoint(1, 1)); - dbp.fillRect(QRect(pt, pt1), d->preferences()->agendaGridHighlightColor()); + dbp.fillRect(QRect(pt, pt1), highlightColor); } else { // single day selection pt = gridToContents(d->mSelectionStartCell); pt1 = gridToContents(d->mSelectionEndCell + QPoint(1, 1)); - dbp.fillRect(QRect(pt, pt1), d->preferences()->agendaGridHighlightColor()); + dbp.fillRect(QRect(pt, pt1), highlightColor); } } - QPen hourPen(d->preferences()->agendaGridBackgroundColor().darker(150)); - QPen halfHourPen(d->preferences()->agendaGridBackgroundColor().darker(125)); + QPen hourPen; + QPen halfHourPen; + + if (d->preferences()->useSystemColor()) { + hourPen = d->preferences()->agendaGridBackgroundColor().darker(150); + halfHourPen = d->preferences()->agendaGridBackgroundColor().darker(125); + } else { + hourPen = palette().color(QPalette::WindowText).darker(150); + halfHourPen = palette().color(QPalette::WindowText).darker(125); + } dbp.setPen(hourPen); // Draw vertical lines of grid, start with the last line not yet visible diff --git a/src/eventviews.kcfg b/src/eventviews.kcfg --- a/src/eventviews.kcfg +++ b/src/eventviews.kcfg @@ -374,6 +374,7 @@ + Select the holiday color here. The holiday color will be used for the holiday name in the month view and the holiday number in the date navigator. @@ -711,5 +712,11 @@ + + + + Use system color. If enabled will ignore all other color settings + true + diff --git a/src/month/monthgraphicsitems.cpp b/src/month/monthgraphicsitems.cpp --- a/src/month/monthgraphicsitems.cpp +++ b/src/month/monthgraphicsitems.cpp @@ -63,7 +63,7 @@ arrow.setPoint(2, -mWidth / 2, -mHeight / 2); arrow.setPoint(0, 0, mHeight / 2); } - QColor color(Qt::black); + QColor color(QPalette().color(QPalette::WindowText)); color.setAlpha(155); painter->setBrush(color); painter->setPen(color); diff --git a/src/month/monthscene.cpp b/src/month/monthscene.cpp --- a/src/month/monthscene.cpp +++ b/src/month/monthscene.cpp @@ -184,7 +184,7 @@ Q_ASSERT(mScene); PrefsPtr prefs = mScene->monthView()->preferences(); p->setFont(prefs->monthViewFont()); - p->fillRect(rect, palette().color(QPalette::Base)); + p->fillRect(rect, palette().color(QPalette::Window)); /* Headers @@ -246,10 +246,18 @@ MonthCell *cell = mScene->mMonthCellMap[ d ]; QColor color; - if (workDays.contains(d)) { - color = mMonthView->preferences()->monthGridWorkHoursBackgroundColor(); + if (!mMonthView->preferences()->useSystemColor()) { + if (workDays.contains(d)) { + color = mMonthView->preferences()->monthGridWorkHoursBackgroundColor(); + } else { + color = mMonthView->preferences()->monthGridBackgroundColor(); + } } else { - color = mMonthView->preferences()->monthGridBackgroundColor(); + if (workDays.contains(d)) { + color = palette().color(QPalette::Base); + } else { + color = palette().color(QPalette::AlternateBase); + } } if (cell == mScene->selectedCell()) { color = color.darker(115); @@ -280,10 +288,13 @@ QLinearGradient bgGradient(QPointF(cellHeaderX, cellHeaderY), QPointF(cellHeaderX + cellHeaderWidth, cellHeaderY + cellHeaderHeight)); - bgGradient.setColorAt(0, color.darker(105)); - bgGradient.setColorAt(0.7, color.darker(105)); + if ((color.blue() + color.red() + color.green()) > (256 / 2 * 3)) { + p->setBrush(color.darker(110)); + } else { + p->setBrush(color.lighter(140)); + } + bgGradient.setColorAt(1, color); - p->setBrush(bgGradient); p->setPen(Qt::NoPen); p->drawRect(QRect(cellHeaderX, cellHeaderY, @@ -295,7 +306,13 @@ p->setFont(font); - QPen oldPen = mMonthView->preferences()->monthGridBackgroundColor().darker(150); + QPen oldPen; + if (!mMonthView->preferences()->useSystemColor()) { + oldPen = mMonthView->preferences()->monthGridBackgroundColor().darker(150); + } else { + oldPen = palette().color(QPalette::WindowText).darker(150); + } + // Draw dates for (QDate d = mMonthView->actualStartDateTime().date(); @@ -311,7 +328,7 @@ p->setFont(font); if (d.month() == mMonthView->currentMonth()) { - p->setPen(QPalette::Text); + p->setPen(palette().color(QPalette::WindowText)); } else { p->setPen(oldPen); } diff --git a/src/prefs.h b/src/prefs.h --- a/src/prefs.h +++ b/src/prefs.h @@ -82,6 +82,9 @@ void setSelectionStartsEditor(bool startEditor); Q_REQUIRED_RESULT bool selectionStartsEditor() const; + + void setUseSystemColor(bool useSystemColor); + Q_REQUIRED_RESULT bool useSystemColor() const; void setAgendaGridWorkHoursBackgroundColor(const QColor &color); Q_REQUIRED_RESULT QColor agendaGridWorkHoursBackgroundColor() const; diff --git a/src/prefs.cpp b/src/prefs.cpp --- a/src/prefs.cpp +++ b/src/prefs.cpp @@ -556,6 +556,16 @@ } } +void Prefs::setUseSystemColor(bool useSystemColor) +{ + d->setBool(d->mBaseConfig.useSystemColorItem(), useSystemColor); +} + +bool Prefs::useSystemColor() const +{ + return d->getBool(d->mBaseConfig.useSystemColorItem()); +} + void Prefs::setMarcusBainsShowSeconds(bool showSeconds) { d->setBool(d->mBaseConfig.marcusBainsShowSecondsItem(), showSeconds);