diff options
author | Tobias Markmann <tm@ayena.de> | 2016-09-13 10:43:50 (GMT) |
---|---|---|
committer | Edwin Mons <edwin.mons@isode.com> | 2016-11-07 08:20:00 (GMT) |
commit | b55dcace49c6dc8c18c854f27fbb75f96e846f24 (patch) | |
tree | 959ed3c5f5b418271c305853fe507d613501ab26 | |
parent | fca0cd94aa9136a58f9a76937e146048bf94811a (diff) | |
download | swift-b55dcace49c6dc8c18c854f27fbb75f96e846f24.zip swift-b55dcace49c6dc8c18c854f27fbb75f96e846f24.tar.bz2 |
Improve roster item readability for selected items
Due to the style independent fixed text color for the status
message of non-compact roster item, it was barely readable on
Windows 7. This commit has the color for the status message
in non-compact roster items depend on the used text color
for the name. It uses a brightness adjusted highlight text
color for the second line.
Test-Information:
Tested on OS X 10.11.6 with Qt 5.5.1 and Windows 8 with Qt
5.5.1.
Change-Id: I41beb0f3eaede3f9413a39662c213a4e904bdd69
-rw-r--r-- | Swift/QtUI/Roster/DelegateCommons.cpp | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/Swift/QtUI/Roster/DelegateCommons.cpp b/Swift/QtUI/Roster/DelegateCommons.cpp index 21d42ef..a8dd8a7 100644 --- a/Swift/QtUI/Roster/DelegateCommons.cpp +++ b/Swift/QtUI/Roster/DelegateCommons.cpp @@ -1,64 +1,63 @@ /* * Copyright (c) 2010-2016 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swift/QtUI/Roster/DelegateCommons.h> #include <QColor> #include <QFileInfo> #include <Swift/QtUI/QtScaledAvatarCache.h> namespace Swift { -namespace { - const QColor secondLineColor = QColor(160,160,160); -} - void DelegateCommons::drawElidedText(QPainter* painter, const QRect& region, const QString& text, int flags) { QString adjustedText(painter->fontMetrics().elidedText(text, Qt::ElideRight, region.width(), Qt::TextShowMnemonic)); painter->setClipRect(region); painter->drawText(region, flags, adjustedText.simplified()); painter->setClipping(false); } void DelegateCommons::paintContact(QPainter* painter, const QStyleOptionViewItem& option, const QColor& nameColor, const QString& avatarPath, const QIcon& presenceIcon, const QString& name, const QString& statusText, bool isIdle, int unreadCount, bool compact) const { painter->save(); QRect fullRegion(option.rect); + QPen secondLineColor; if ( option.state & QStyle::State_Selected ) { painter->fillRect(fullRegion, option.palette.highlight()); painter->setPen(option.palette.highlightedText().color()); + secondLineColor = painter->pen().color().darker(125); } else { painter->setPen(QPen(nameColor)); + secondLineColor = painter->pen().color().lighter(); } QRect presenceIconRegion(QPoint(farLeftMargin, fullRegion.top()), QSize(presenceIconWidth, fullRegion.height() - verticalMargin)); QRect idleIconRegion(QPoint(farLeftMargin, fullRegion.top()), QSize(presenceIconWidth*2, fullRegion.height() - verticalMargin)); int calculatedAvatarSize = presenceIconRegion.height(); //This overlaps the presenceIcon, so must be painted first QRect avatarRegion(QPoint(presenceIconRegion.right() - presenceIconWidth / 2, presenceIconRegion.top()), QSize(calculatedAvatarSize, calculatedAvatarSize)); QPixmap avatarPixmap; if (!compact && !avatarPath.isEmpty()) { QString scaledAvatarPath = QtScaledAvatarCache(avatarRegion.height()).getScaledAvatarPath(avatarPath); if (QFileInfo(scaledAvatarPath).exists()) { avatarPixmap.load(scaledAvatarPath); } } if (!compact && avatarPixmap.isNull()) { avatarPixmap = QPixmap(":/icons/avatar.svg").scaled(avatarRegion.height(), avatarRegion.width(), Qt::KeepAspectRatio, Qt::SmoothTransformation); } if (!compact) { painter->drawPixmap(avatarRegion.topLeft() + QPoint(((avatarRegion.width() - avatarPixmap.width()) / 2), (avatarRegion.height() - avatarPixmap.height()) / 2), avatarPixmap); } //Paint the presence icon over the top of the avatar presenceIcon.paint(painter, presenceIconRegion, Qt::AlignBottom | Qt::AlignHCenter); if (isIdle) { idleIcon.paint(painter, idleIconRegion, Qt::AlignBottom | Qt::AlignHCenter); } |