Changeset View
Changeset View
Standalone View
Standalone View
src/agenda/agendaitem.cpp
Show First 20 Lines • Show All 1136 Lines • ▼ Show 20 Line(s) | 1136 | if (!mValid) { | |||
---|---|---|---|---|---|
1137 | return; | 1137 | return; | ||
1138 | } | 1138 | } | ||
1139 | 1139 | | |||
1140 | QPainterPath path; | 1140 | QPainterPath path; | ||
1141 | 1141 | | |||
1142 | const int RECT_MARGIN = 2; // the distance between two item is then RECT_MARGIN * 2 | 1142 | const int RECT_MARGIN = 2; // the distance between two item is then RECT_MARGIN * 2 | ||
1143 | const int RADIUS = 4; // absolute radius | 1143 | const int RADIUS = 4; // absolute radius | ||
1144 | 1144 | | |||
1145 | QRect rectWithMargin(rect.x() + RECT_MARGIN, rect.y() + RECT_MARGIN, rect.width() - 2 * RECT_MARGIN, rect.height() - 2 * RECT_MARGIN); | 1145 | const QRect rectWithMargin(rect.x() + RECT_MARGIN, rect.y() + RECT_MARGIN, rect.width() - 2 * RECT_MARGIN, rect.height() - 2 * RECT_MARGIN); | ||
1146 | 1146 | | |||
1147 | QPoint pointLeftTop(rectWithMargin.x(), rectWithMargin.y()); | 1147 | const QPoint pointLeftTop(rectWithMargin.x(), rectWithMargin.y()); | ||
1148 | QPoint pointRightTop(rectWithMargin.x() + rectWithMargin.width(), rectWithMargin.y()); | 1148 | const QPoint pointRightTop(rectWithMargin.x() + rectWithMargin.width(), rectWithMargin.y()); | ||
1149 | QPoint pointLeftBottom(rectWithMargin.x(), rectWithMargin.y() + rectWithMargin.height()); | 1149 | const QPoint pointLeftBottom(rectWithMargin.x(), rectWithMargin.y() + rectWithMargin.height()); | ||
1150 | QPoint pointRightBottom(rectWithMargin.x() + rectWithMargin.width(), rectWithMargin.y() + rectWithMargin.height()); | 1150 | const QPoint pointRightBottom(rectWithMargin.x() + rectWithMargin.width(), rectWithMargin.y() + rectWithMargin.height()); | ||
1151 | 1151 | | |||
1152 | if (!roundTop && !roundBottom) { | 1152 | if (!roundTop && !roundBottom) { | ||
1153 | path.addRect(rectWithMargin); | 1153 | path.addRect(rectWithMargin); | ||
1154 | } else if (roundTop && roundBottom) { | 1154 | } else if (roundTop && roundBottom) { | ||
1155 | path.addRoundedRect(rectWithMargin, RADIUS, RADIUS, Qt::AbsoluteSize); | 1155 | path.addRoundedRect(rectWithMargin, RADIUS, RADIUS, Qt::AbsoluteSize); | ||
1156 | } else if (roundTop) { | 1156 | } else if (roundTop) { | ||
1157 | path.moveTo(pointRightBottom); | 1157 | path.moveTo(pointRightBottom); | ||
1158 | path.lineTo(pointLeftBottom); | 1158 | path.lineTo(pointLeftBottom); | ||
1159 | path.lineTo(QPoint(pointLeftTop.x(), pointLeftTop.y() + RADIUS)); | 1159 | path.lineTo(QPoint(pointLeftTop.x(), pointLeftTop.y() + RADIUS)); | ||
1160 | path.quadTo(pointLeftTop, QPoint(pointLeftTop.x() + RADIUS, pointLeftTop.y())); | 1160 | path.quadTo(pointLeftTop, QPoint(pointLeftTop.x() + RADIUS, pointLeftTop.y())); | ||
1161 | path.lineTo(QPoint(pointRightTop.x() - RADIUS, pointRightTop.y())); | 1161 | path.lineTo(QPoint(pointRightTop.x() - RADIUS, pointRightTop.y())); | ||
1162 | path.quadTo(pointRightTop, QPoint(pointRightTop.x(), pointRightTop.y() + RADIUS)); | 1162 | path.quadTo(pointRightTop, QPoint(pointRightTop.x(), pointRightTop.y() + RADIUS)); | ||
1163 | path.lineTo(pointRightBottom); | 1163 | path.lineTo(pointRightBottom); | ||
1164 | } else if (roundBottom) { | 1164 | } else if (roundBottom) { | ||
1165 | // not used and tested | 1165 | // not used and tested | ||
1166 | path.moveTo(pointRightTop); | 1166 | path.moveTo(pointRightTop); | ||
1167 | path.moveTo(QPoint(pointRightBottom.x(), pointRightBottom.y() - RADIUS)); | 1167 | path.moveTo(QPoint(pointRightBottom.x(), pointRightBottom.y() - RADIUS)); | ||
1168 | path.quadTo(pointRightBottom, QPoint(pointRightBottom.x() - RADIUS, pointRightBottom.y())); | 1168 | path.quadTo(pointRightBottom, QPoint(pointRightBottom.x() - RADIUS, pointRightBottom.y())); | ||
1169 | path.moveTo(QPoint(pointLeftBottom.x() - RADIUS, pointLeftBottom.y())); | 1169 | path.moveTo(QPoint(pointLeftBottom.x() - RADIUS, pointLeftBottom.y())); | ||
1170 | path.quadTo(pointLeftBottom, QPoint(pointLeftBottom.x() + RADIUS, pointRightBottom.y())); | 1170 | path.quadTo(pointLeftBottom, QPoint(pointLeftBottom.x() + RADIUS, pointRightBottom.y())); | ||
1171 | path.lineTo(pointLeftTop); | 1171 | path.lineTo(pointLeftTop); | ||
1172 | path.lineTo(pointRightTop); | 1172 | path.lineTo(pointRightTop); | ||
1173 | } | 1173 | } | ||
1174 | 1174 | | |||
1175 | path.closeSubpath(); | 1175 | path.closeSubpath(); | ||
dvratil: Could you try how it looks with `RADIUS = 2`? That might make it look close to what Breeze… | |||||
1176 | p->save(); | 1176 | p->save(); | ||
1177 | p->setRenderHint(QPainter::Antialiasing, false); | 1177 | p->setRenderHint(QPainter::Antialiasing, false); | ||
1178 | QPen border = QPen(QBrush(QColor(200, 200, 200, 255)),1.0, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); | 1178 | const QPen border(QBrush(QColor(200, 200, 200, 255)),1.0, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); | ||
1179 | p->setPen(border); | 1179 | p->setPen(border); | ||
mlaurent: const each time that it's a constant variable please | |||||
1180 | 1180 | | |||
1181 | // header | 1181 | // header | ||
1182 | if (!frame) { | 1182 | if (!frame) { | ||
1183 | QBrush brushSolid = QBrush(Qt::SolidPattern); | 1183 | QBrush brushSolid(Qt::SolidPattern); | ||
mlaurent: QBrush brushSolid(Qt::SolidPattern); | |||||
1184 | 1184 | | |||
1185 | if (selected) { | 1185 | if (selected) { | ||
1186 | QColor top = bgColor.darker(250); | 1186 | QColor top = bgColor.darker(250); | ||
1187 | top.setAlpha(20); | 1187 | top.setAlpha(20); | ||
1188 | brushSolid.setColor(top); | 1188 | brushSolid.setColor(top); | ||
1189 | } else { | 1189 | } else { | ||
1190 | brushSolid.setColor(QColor(255, 255, 255, 10)); | 1190 | brushSolid.setColor(QColor(255, 255, 255, 10)); | ||
1191 | } | 1191 | } | ||
1192 | 1192 | | |||
1193 | p->setBrush(bgColor); | 1193 | p->setBrush(bgColor); | ||
1194 | p->drawPath(path); | 1194 | p->drawPath(path); | ||
1195 | 1195 | | |||
1196 | p->setBrush(brushSolid); | 1196 | p->setBrush(brushSolid); | ||
1197 | p->drawPath(path); | 1197 | p->drawPath(path); | ||
I believe you should get here if an event in agenda spans multiple days: then the top is rounded only on the first day and the bottom is rounded only on the end day. dvratil: I believe you should get here if an event in agenda spans multiple days: then the top is… | |||||
ognarb: Thanks I, found a bug | |||||
1198 | p->restore(); | 1198 | p->restore(); | ||
1199 | 1199 | | |||
1200 | return; | 1200 | return; | ||
1201 | } | 1201 | } | ||
1202 | 1202 | | |||
1203 | p->setBrush(bgColor); | 1203 | p->setBrush(bgColor); | ||
1204 | p->drawPath(path); | 1204 | p->drawPath(path); | ||
1205 | p->restore(); | 1205 | p->restore(); | ||
Show All 29 Lines |
Could you try how it looks with RADIUS = 2? That might make it look close to what Breeze widgets look like (the rounderd corners are barely visible there).