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 (false) { | |||
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 | |||||
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 | } | ||||
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 (false) { | ||||
mlaurent: same | |||||
1552 | workColor = d->preferences()->workingHoursColor(); | ||||
1553 | } else { | ||||
1554 | workColor = palette().color(QPalette::Base); | ||||
1555 | /*if (workColor.blue() + workColor.red() + workColor.green() < 256 / 2 * 3 ) { | ||||
1556 | // dark | ||||
1557 | workColor.lighter(130); | ||||
1558 | } else { | ||||
1559 | // light | ||||
1560 | workColor.darker(130); | ||||
1561 | }*/ | ||||
1562 | } | ||||
1548 | 1563 | | |||
1549 | QPoint pt1(cx, d->mWorkingHoursYTop); | 1564 | QPoint pt1(cx, d->mWorkingHoursYTop); | ||
1550 | QPoint pt2(cx + cw, d->mWorkingHoursYBottom); | 1565 | QPoint pt2(cx + cw, d->mWorkingHoursYBottom); | ||
1551 | if (pt2.x() >= pt1.x() /*&& pt2.y() >= pt1.y()*/) { | 1566 | if (pt2.x() >= pt1.x() /*&& pt2.y() >= pt1.y()*/) { | ||
1552 | int gxStart = contentsToGrid(pt1).x(); | 1567 | int gxStart = contentsToGrid(pt1).x(); | ||
1553 | int gxEnd = contentsToGrid(pt2).x(); | 1568 | int gxEnd = contentsToGrid(pt2).x(); | ||
1554 | // correct start/end for rtl layouts | 1569 | // correct start/end for rtl layouts | ||
1555 | if (gxStart > gxEnd) { | 1570 | if (gxStart > gxEnd) { | ||
Show All 35 Lines | |||||
1591 | } | 1606 | } | ||
1592 | 1607 | | |||
1593 | // busy days | 1608 | // busy days | ||
1594 | if (d->preferences()->colorAgendaBusyDays() && !d->mAllDayMode) { | 1609 | if (d->preferences()->colorAgendaBusyDays() && !d->mAllDayMode) { | ||
1595 | for (int i = 0; i < busyDayMask.count(); ++i) { | 1610 | for (int i = 0; i < busyDayMask.count(); ++i) { | ||
1596 | if (busyDayMask[i]) { | 1611 | if (busyDayMask[i]) { | ||
1597 | const QPoint pt1(cx + d->mGridSpacingX *i, 0); | 1612 | const QPoint pt1(cx + d->mGridSpacingX *i, 0); | ||
1598 | // const QPoint pt2(cx + mGridSpacingX * (i+1), ch); | 1613 | // const QPoint pt2(cx + mGridSpacingX * (i+1), ch); | ||
1599 | QColor busyColor = d->preferences()->viewBgBusyColor(); | 1614 | QColor busyColor; | ||
1615 | if (false) { | ||||
mlaurent: same | |||||
1616 | busyColor = d->preferences()->viewBgBusyColor(); | ||||
1617 | } else { | ||||
1618 | busyColor = palette().color(QPalette::Window); | ||||
1619 | if ((busyColor.blue() + busyColor.red() + busyColor.green()) > (256 / 2 * 3)) { | ||||
1620 | // dark | ||||
1621 | busyColor.lighter(140); | ||||
1622 | } else { | ||||
1623 | // light | ||||
1624 | busyColor.darker(140); | ||||
1625 | } | ||||
1626 | } | ||||
1600 | busyColor.setAlpha(EventViews::BUSY_BACKGROUND_ALPHA); | 1627 | busyColor.setAlpha(EventViews::BUSY_BACKGROUND_ALPHA); | ||
1601 | dbp.fillRect(pt1.x(), pt1.y(), d->mGridSpacingX, cy + ch, busyColor); | 1628 | dbp.fillRect(pt1.x(), pt1.y(), d->mGridSpacingX, cy + ch, busyColor); | ||
1602 | } | 1629 | } | ||
1603 | } | 1630 | } | ||
1604 | } | 1631 | } | ||
1605 | 1632 | | |||
1606 | // draw selection | 1633 | // draw selection | ||
1607 | if (d->mHasSelection && d->mAgendaView->dateRangeSelectionEnabled()) { | 1634 | if (d->mHasSelection && d->mAgendaView->dateRangeSelectionEnabled()) { | ||
1608 | QPoint pt, pt1; | 1635 | QPoint pt, pt1; | ||
1636 | QColor highlightColor; | ||||
1637 | if (false) { | ||||
1638 | highlightColor = d->preferences()->agendaGridHighlightColor(); | ||||
1639 | } else { | ||||
1640 | highlightColor = palette().color(QPalette::Highlight); | ||||
1641 | } | ||||
1609 | 1642 | | |||
1610 | if (d->mSelectionEndCell.x() > d->mSelectionStartCell.x()) { // multi day selection | 1643 | if (d->mSelectionEndCell.x() > d->mSelectionStartCell.x()) { // multi day selection | ||
1611 | // draw start day | 1644 | // draw start day | ||
1612 | pt = gridToContents(d->mSelectionStartCell); | 1645 | pt = gridToContents(d->mSelectionStartCell); | ||
1613 | pt1 = gridToContents(QPoint(d->mSelectionStartCell.x() + 1, d->mRows + 1)); | 1646 | pt1 = gridToContents(QPoint(d->mSelectionStartCell.x() + 1, d->mRows + 1)); | ||
1614 | dbp.fillRect(QRect(pt, pt1), d->preferences()->agendaGridHighlightColor()); | 1647 | dbp.fillRect(QRect(pt, pt1), highlightColor); | ||
1615 | // draw all other days between the start day and the day of the selection end | 1648 | // 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) { | 1649 | for (int c = d->mSelectionStartCell.x() + 1; c < d->mSelectionEndCell.x(); ++c) { | ||
1617 | pt = gridToContents(QPoint(c, 0)); | 1650 | pt = gridToContents(QPoint(c, 0)); | ||
1618 | pt1 = gridToContents(QPoint(c + 1, d->mRows + 1)); | 1651 | pt1 = gridToContents(QPoint(c + 1, d->mRows + 1)); | ||
1619 | dbp.fillRect(QRect(pt, pt1), d->preferences()->agendaGridHighlightColor()); | 1652 | dbp.fillRect(QRect(pt, pt1), highlightColor); | ||
1620 | } | 1653 | } | ||
1621 | // draw end day | 1654 | // draw end day | ||
1622 | pt = gridToContents(QPoint(d->mSelectionEndCell.x(), 0)); | 1655 | pt = gridToContents(QPoint(d->mSelectionEndCell.x(), 0)); | ||
1623 | pt1 = gridToContents(d->mSelectionEndCell + QPoint(1, 1)); | 1656 | pt1 = gridToContents(d->mSelectionEndCell + QPoint(1, 1)); | ||
1624 | dbp.fillRect(QRect(pt, pt1), d->preferences()->agendaGridHighlightColor()); | 1657 | dbp.fillRect(QRect(pt, pt1), highlightColor); | ||
1625 | } else { // single day selection | 1658 | } else { // single day selection | ||
1626 | pt = gridToContents(d->mSelectionStartCell); | 1659 | pt = gridToContents(d->mSelectionStartCell); | ||
1627 | pt1 = gridToContents(d->mSelectionEndCell + QPoint(1, 1)); | 1660 | pt1 = gridToContents(d->mSelectionEndCell + QPoint(1, 1)); | ||
1628 | dbp.fillRect(QRect(pt, pt1), d->preferences()->agendaGridHighlightColor()); | 1661 | dbp.fillRect(QRect(pt, pt1), highlightColor); | ||
1629 | } | 1662 | } | ||
1630 | } | 1663 | } | ||
1631 | 1664 | | |||
1632 | QPen hourPen(d->preferences()->agendaGridBackgroundColor().darker(150)); | 1665 | QPen hourPen; | ||
1633 | QPen halfHourPen(d->preferences()->agendaGridBackgroundColor().darker(125)); | 1666 | QPen halfHourPen; | ||
1667 | | ||||
1668 | if (!false) { | ||||
1669 | hourPen = d->preferences()->agendaGridBackgroundColor().darker(150); | ||||
1670 | halfHourPen = d->preferences()->agendaGridBackgroundColor().darker(125); | ||||
1671 | } else { | ||||
mlaurent: same | |||||
1672 | hourPen = palette().color(QPalette::WindowText).darker(150); | ||||
1673 | halfHourPen = palette().color(QPalette::WindowText).darker(125); | ||||
1674 | } | ||||
1634 | dbp.setPen(hourPen); | 1675 | dbp.setPen(hourPen); | ||
1635 | 1676 | | |||
1636 | // Draw vertical lines of grid, start with the last line not yet visible | 1677 | // Draw vertical lines of grid, start with the last line not yet visible | ||
1637 | double x = (int(cx / d->mGridSpacingX)) * d->mGridSpacingX; | 1678 | double x = (int(cx / d->mGridSpacingX)) * d->mGridSpacingX; | ||
1638 | while (x < cx + cw) { | 1679 | while (x < cx + cw) { | ||
1639 | dbp.drawLine(int(x), cy, int(x), cy + ch); | 1680 | dbp.drawLine(int(x), cy, int(x), cy + ch); | ||
1640 | x += d->mGridSpacingX; | 1681 | x += d->mGridSpacingX; | ||
1641 | } | 1682 | } | ||
▲ Show 20 Lines • Show All 715 Lines • Show Last 20 Lines |
REmove code if it's always false please