Changeset View
Changeset View
Standalone View
Standalone View
src/agenda/agenda.cpp
Show First 20 Lines • Show All 1522 Lines • ▼ Show 20 Line(s) | 1522 | { | |||
---|---|---|---|---|---|
1523 | QPixmap db(cw, ch); | 1523 | QPixmap db(cw, ch); | ||
1524 | db.fill(); // We don't want to see leftovers from previous paints | 1524 | db.fill(); // We don't want to see leftovers from previous paints | ||
1525 | QPainter dbp(&db); | 1525 | QPainter dbp(&db); | ||
1526 | // TODO: CHECK THIS | 1526 | // TODO: CHECK THIS | ||
1527 | // if (! d->preferences()->agendaGridBackgroundImage().isEmpty()) { | 1527 | // if (! d->preferences()->agendaGridBackgroundImage().isEmpty()) { | ||
1528 | // QPixmap bgImage(d->preferences()->agendaGridBackgroundImage()); | 1528 | // QPixmap bgImage(d->preferences()->agendaGridBackgroundImage()); | ||
1529 | // dbp.drawPixmap(0, 0, cw, ch, bgImage); FIXME | 1529 | // dbp.drawPixmap(0, 0, cw, ch, bgImage); FIXME | ||
1530 | // } | 1530 | // } | ||
1531 | 1531 | if (!d->preferences()->useSystemColor()) { | |||
1532 | dbp.fillRect(0, 0, cw, ch, | 1532 | dbp.fillRect(0, 0, cw, ch, | ||
1533 | d->preferences()->agendaGridBackgroundColor()); | 1533 | d->preferences()->agendaGridBackgroundColor()); | ||
1534 | } else { | ||||
1535 | dbp.fillRect(0, 0, cw, ch, palette().color(QPalette::Window)); | ||||
1536 | } | ||||
mlaurent: REmove code if it's always false please | |||||
Like I said it's WIP. I want to add a button in the config, so that the user can choose between using the system color scheme or manually set the color using the old system. ognarb: Like I said it's WIP. I want to add a button in the config, so that the user can choose between… | |||||
ognarb: I changed the condition | |||||
1534 | 1537 | | |||
1535 | dbp.translate(-cx, -cy); | 1538 | dbp.translate(-cx, -cy); | ||
1536 | 1539 | | |||
1537 | double lGridSpacingY = d->mGridSpacingY * 2; | 1540 | double lGridSpacingY = d->mGridSpacingY * 2; | ||
1538 | 1541 | | |||
1539 | // If work day, use work color | 1542 | // If work day, use work color | ||
1540 | // If busy day, use busy color | 1543 | // If busy day, use busy color | ||
1541 | // if work and busy day, mix both, and busy color has alpha | 1544 | // if work and busy day, mix both, and busy color has alpha | ||
1542 | 1545 | | |||
1543 | const QVector<bool> busyDayMask = d->mAgendaView->busyDayMask(); | 1546 | const QVector<bool> busyDayMask = d->mAgendaView->busyDayMask(); | ||
1544 | 1547 | | |||
1545 | // Highlight working hours | 1548 | // Highlight working hours | ||
1546 | if (d->mWorkingHoursEnable && d->mHolidayMask) { | 1549 | if (d->mWorkingHoursEnable && d->mHolidayMask) { | ||
1547 | const QColor workColor = d->preferences()->workingHoursColor(); | 1550 | QColor workColor; | ||
1551 | if (!d->preferences()->useSystemColor()) { | ||||
mlaurent: same | |||||
1552 | workColor = d->preferences()->workingHoursColor(); | ||||
1553 | } else { | ||||
1554 | workColor = palette().color(QPalette::Base); | ||||
1555 | } | ||||
1548 | 1556 | | |||
1549 | QPoint pt1(cx, d->mWorkingHoursYTop); | 1557 | QPoint pt1(cx, d->mWorkingHoursYTop); | ||
1550 | QPoint pt2(cx + cw, d->mWorkingHoursYBottom); | 1558 | QPoint pt2(cx + cw, d->mWorkingHoursYBottom); | ||
1551 | if (pt2.x() >= pt1.x() /*&& pt2.y() >= pt1.y()*/) { | 1559 | if (pt2.x() >= pt1.x() /*&& pt2.y() >= pt1.y()*/) { | ||
1552 | int gxStart = contentsToGrid(pt1).x(); | 1560 | int gxStart = contentsToGrid(pt1).x(); | ||
1553 | int gxEnd = contentsToGrid(pt2).x(); | 1561 | int gxEnd = contentsToGrid(pt2).x(); | ||
1554 | // correct start/end for rtl layouts | 1562 | // correct start/end for rtl layouts | ||
1555 | if (gxStart > gxEnd) { | 1563 | if (gxStart > gxEnd) { | ||
Show All 35 Lines | |||||
1591 | } | 1599 | } | ||
1592 | 1600 | | |||
1593 | // busy days | 1601 | // busy days | ||
1594 | if (d->preferences()->colorAgendaBusyDays() && !d->mAllDayMode) { | 1602 | if (d->preferences()->colorAgendaBusyDays() && !d->mAllDayMode) { | ||
1595 | for (int i = 0; i < busyDayMask.count(); ++i) { | 1603 | for (int i = 0; i < busyDayMask.count(); ++i) { | ||
1596 | if (busyDayMask[i]) { | 1604 | if (busyDayMask[i]) { | ||
1597 | const QPoint pt1(cx + d->mGridSpacingX *i, 0); | 1605 | const QPoint pt1(cx + d->mGridSpacingX *i, 0); | ||
1598 | // const QPoint pt2(cx + mGridSpacingX * (i+1), ch); | 1606 | // const QPoint pt2(cx + mGridSpacingX * (i+1), ch); | ||
1599 | QColor busyColor = d->preferences()->viewBgBusyColor(); | 1607 | QColor busyColor; | ||
1608 | if (!d->preferences()->useSystemColor()) { | ||||
mlaurent: same | |||||
1609 | busyColor = d->preferences()->viewBgBusyColor(); | ||||
1610 | } else { | ||||
1611 | busyColor = palette().color(QPalette::Window); | ||||
1612 | if ((busyColor.blue() + busyColor.red() + busyColor.green()) > (256 / 2 * 3)) { | ||||
1613 | // dark | ||||
1614 | busyColor.lighter(140); | ||||
1615 | } else { | ||||
1616 | // light | ||||
1617 | busyColor.darker(140); | ||||
1618 | } | ||||
1619 | } | ||||
1600 | busyColor.setAlpha(EventViews::BUSY_BACKGROUND_ALPHA); | 1620 | busyColor.setAlpha(EventViews::BUSY_BACKGROUND_ALPHA); | ||
1601 | dbp.fillRect(pt1.x(), pt1.y(), d->mGridSpacingX, cy + ch, busyColor); | 1621 | dbp.fillRect(pt1.x(), pt1.y(), d->mGridSpacingX, cy + ch, busyColor); | ||
1602 | } | 1622 | } | ||
1603 | } | 1623 | } | ||
1604 | } | 1624 | } | ||
1605 | 1625 | | |||
1606 | // draw selection | 1626 | // draw selection | ||
1607 | if (d->mHasSelection && d->mAgendaView->dateRangeSelectionEnabled()) { | 1627 | if (d->mHasSelection && d->mAgendaView->dateRangeSelectionEnabled()) { | ||
1608 | QPoint pt, pt1; | 1628 | QPoint pt, pt1; | ||
1629 | QColor highlightColor; | ||||
1630 | if (!d->preferences()->useSystemColor()) { | ||||
1631 | highlightColor = d->preferences()->agendaGridHighlightColor(); | ||||
1632 | } else { | ||||
1633 | highlightColor = palette().color(QPalette::Highlight); | ||||
1634 | } | ||||
1609 | 1635 | | |||
1610 | if (d->mSelectionEndCell.x() > d->mSelectionStartCell.x()) { // multi day selection | 1636 | if (d->mSelectionEndCell.x() > d->mSelectionStartCell.x()) { // multi day selection | ||
1611 | // draw start day | 1637 | // draw start day | ||
1612 | pt = gridToContents(d->mSelectionStartCell); | 1638 | pt = gridToContents(d->mSelectionStartCell); | ||
1613 | pt1 = gridToContents(QPoint(d->mSelectionStartCell.x() + 1, d->mRows + 1)); | 1639 | pt1 = gridToContents(QPoint(d->mSelectionStartCell.x() + 1, d->mRows + 1)); | ||
1614 | dbp.fillRect(QRect(pt, pt1), d->preferences()->agendaGridHighlightColor()); | 1640 | dbp.fillRect(QRect(pt, pt1), highlightColor); | ||
1615 | // draw all other days between the start day and the day of the selection end | 1641 | // draw all other days between the start day and the day of the selection end | ||
1616 | for (int c = d->mSelectionStartCell.x() + 1; c < d->mSelectionEndCell.x(); ++c) { | 1642 | for (int c = d->mSelectionStartCell.x() + 1; c < d->mSelectionEndCell.x(); ++c) { | ||
1617 | pt = gridToContents(QPoint(c, 0)); | 1643 | pt = gridToContents(QPoint(c, 0)); | ||
1618 | pt1 = gridToContents(QPoint(c + 1, d->mRows + 1)); | 1644 | pt1 = gridToContents(QPoint(c + 1, d->mRows + 1)); | ||
1619 | dbp.fillRect(QRect(pt, pt1), d->preferences()->agendaGridHighlightColor()); | 1645 | dbp.fillRect(QRect(pt, pt1), highlightColor); | ||
1620 | } | 1646 | } | ||
1621 | // draw end day | 1647 | // draw end day | ||
1622 | pt = gridToContents(QPoint(d->mSelectionEndCell.x(), 0)); | 1648 | pt = gridToContents(QPoint(d->mSelectionEndCell.x(), 0)); | ||
1623 | pt1 = gridToContents(d->mSelectionEndCell + QPoint(1, 1)); | 1649 | pt1 = gridToContents(d->mSelectionEndCell + QPoint(1, 1)); | ||
1624 | dbp.fillRect(QRect(pt, pt1), d->preferences()->agendaGridHighlightColor()); | 1650 | dbp.fillRect(QRect(pt, pt1), highlightColor); | ||
1625 | } else { // single day selection | 1651 | } else { // single day selection | ||
1626 | pt = gridToContents(d->mSelectionStartCell); | 1652 | pt = gridToContents(d->mSelectionStartCell); | ||
1627 | pt1 = gridToContents(d->mSelectionEndCell + QPoint(1, 1)); | 1653 | pt1 = gridToContents(d->mSelectionEndCell + QPoint(1, 1)); | ||
1628 | dbp.fillRect(QRect(pt, pt1), d->preferences()->agendaGridHighlightColor()); | 1654 | dbp.fillRect(QRect(pt, pt1), highlightColor); | ||
1629 | } | 1655 | } | ||
1630 | } | 1656 | } | ||
1631 | 1657 | | |||
1632 | QPen hourPen(d->preferences()->agendaGridBackgroundColor().darker(150)); | 1658 | QPen hourPen; | ||
1633 | QPen halfHourPen(d->preferences()->agendaGridBackgroundColor().darker(125)); | 1659 | QPen halfHourPen; | ||
1660 | | ||||
1661 | if (d->preferences()->useSystemColor()) { | ||||
1662 | hourPen = d->preferences()->agendaGridBackgroundColor().darker(150); | ||||
1663 | halfHourPen = d->preferences()->agendaGridBackgroundColor().darker(125); | ||||
1664 | } else { | ||||
mlaurent: same | |||||
1665 | hourPen = palette().color(QPalette::WindowText).darker(150); | ||||
1666 | halfHourPen = palette().color(QPalette::WindowText).darker(125); | ||||
1667 | } | ||||
1634 | dbp.setPen(hourPen); | 1668 | dbp.setPen(hourPen); | ||
1635 | 1669 | | |||
1636 | // Draw vertical lines of grid, start with the last line not yet visible | 1670 | // Draw vertical lines of grid, start with the last line not yet visible | ||
1637 | double x = (int(cx / d->mGridSpacingX)) * d->mGridSpacingX; | 1671 | double x = (int(cx / d->mGridSpacingX)) * d->mGridSpacingX; | ||
1638 | while (x < cx + cw) { | 1672 | while (x < cx + cw) { | ||
1639 | dbp.drawLine(int(x), cy, int(x), cy + ch); | 1673 | dbp.drawLine(int(x), cy, int(x), cy + ch); | ||
1640 | x += d->mGridSpacingX; | 1674 | x += d->mGridSpacingX; | ||
1641 | } | 1675 | } | ||
▲ Show 20 Lines • Show All 715 Lines • Show Last 20 Lines |
REmove code if it's always false please