mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-19 06:15:26 +00:00
modeldelegates.cpp: add custom highlight drawing in location items
There is a problem in LocationFilterDelegate::paint(), which can manifest as very light background with white text in the combo box from which the user selects a location - a Windows 7 test case. The main offenders are the drawControl() call which draws the selected item background very bright and the fact that the highlightText() is returning white. It seems as if the combination of these is just wrong, theme wise.e5fa424a
and44762c42
fix that by branching Windows by version, but do not cover the case where the user can use a custom theme - e.g. dark selection highlight on Windows 7. This patch skips drawControl() and draws the highlighted item background manually. It makes it look similar to the small tag highlights in TagWidget. The patch adjust slightly the X offset of the drawn text. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
2f89a2e6e2
commit
afed054d82
1 changed files with 16 additions and 10 deletions
|
@ -558,28 +558,34 @@ print_part:
|
|||
|
||||
fontBigger.setPointSize(fontBigger.pointSize() + 1);
|
||||
fontBigger.setBold(true);
|
||||
QPen textPen;
|
||||
#ifdef WIN32
|
||||
if(QSysInfo::windowsVersion() > QSysInfo::WV_VISTA)
|
||||
textPen = QPen(option.palette.text(), 1);
|
||||
else
|
||||
#endif
|
||||
textPen = QPen(option.state & QStyle::State_Selected ? option.palette.brightText() : option.palette.text(), 1);
|
||||
QPen textPen = QPen(option.state & QStyle::State_Selected ? option.palette.highlightedText().color() : option.palette.text().color(), 1);
|
||||
|
||||
initStyleOption(&opt, index);
|
||||
opt.text = QString();
|
||||
opt.icon = QIcon();
|
||||
painter->setClipRect(option.rect);
|
||||
qApp->style()->drawControl(QStyle::CE_ItemViewItem, &opt, painter, NULL);
|
||||
|
||||
painter->save();
|
||||
if (option.state & QStyle::State_Selected) {
|
||||
painter->setPen(QPen(opt.palette.highlight().color().darker()));
|
||||
painter->setBrush(opt.palette.highlight());
|
||||
const qreal pad = 1.0;
|
||||
const qreal pad2 = pad * 2.0;
|
||||
const qreal rounding = 5.0;
|
||||
painter->drawRoundedRect(option.rect.x() + pad,
|
||||
option.rect.y() + pad,
|
||||
option.rect.width() - pad2,
|
||||
option.rect.height() - pad2,
|
||||
rounding, rounding);
|
||||
}
|
||||
painter->setPen(textPen);
|
||||
painter->setFont(fontBigger);
|
||||
painter->drawText(option.rect.x(),option.rect.y() + fmBigger.boundingRect("YH").height(), diveSiteName);
|
||||
const qreal textPad = 5.0;
|
||||
painter->drawText(option.rect.x() + textPad, option.rect.y() + fmBigger.boundingRect("YH").height(), diveSiteName);
|
||||
double pointSize = fontSmaller.pointSizeF();
|
||||
fontSmaller.setPointSizeF(0.9 * pointSize);
|
||||
painter->setFont(fontSmaller);
|
||||
painter->drawText(option.rect.x(),option.rect.y() + fmBigger.boundingRect("YH").height() * 2, bottomText);
|
||||
painter->drawText(option.rect.x() + textPad, option.rect.y() + fmBigger.boundingRect("YH").height() * 2, bottomText);
|
||||
painter->restore();
|
||||
|
||||
if (!icon.isNull()) {
|
||||
|
|
Loading…
Add table
Reference in a new issue