From 9eea4ada83ccb0134703345f86f78b4f2d2e2cf4 Mon Sep 17 00:00:00 2001 From: Mike Gelfand Date: Sat, 17 Jan 2015 01:23:51 +0000 Subject: [PATCH] Improve the look of torrents with errors a bit (Qt client) Display emblem over mime icon if torrent has error(s) to indicate the issue. Use normal text color instead of red when drawing selected item: there is no easy way to be sure that red color looks nice on selection background, and most of the time it doesn't. Using red color for non- selected items is questionable too, but let's leave it at that for now. --- qt/icons/Faenza/Faenza.qrc | 2 + .../Faenza/emblems/16/emblem-important.icon | 84 +++++ .../Faenza/emblems/16/emblem-important.png | Bin 0 -> 539 bytes .../emblems/scalable/emblem-important.icon | 84 +++++ .../emblems/scalable/emblem-important.svg | 290 ++++++++++++++++++ qt/torrent-delegate-min.cc | 31 +- qt/torrent-delegate.cc | 30 +- 7 files changed, 501 insertions(+), 20 deletions(-) create mode 100644 qt/icons/Faenza/emblems/16/emblem-important.icon create mode 100644 qt/icons/Faenza/emblems/16/emblem-important.png create mode 100644 qt/icons/Faenza/emblems/scalable/emblem-important.icon create mode 100644 qt/icons/Faenza/emblems/scalable/emblem-important.svg diff --git a/qt/icons/Faenza/Faenza.qrc b/qt/icons/Faenza/Faenza.qrc index 6df01f40e..84834b5a0 100644 --- a/qt/icons/Faenza/Faenza.qrc +++ b/qt/icons/Faenza/Faenza.qrc @@ -71,6 +71,8 @@ categories/16/preferences-system.png categories/22/preferences-system.png categories/24/preferences-system.png + emblems/16/emblem-important.icon + emblems/16/emblem-important.png status/16/network-error.png status/16/network-idle.png status/16/network-receive.png diff --git a/qt/icons/Faenza/emblems/16/emblem-important.icon b/qt/icons/Faenza/emblems/16/emblem-important.icon new file mode 100644 index 000000000..2f8a70baf --- /dev/null +++ b/qt/icons/Faenza/emblems/16/emblem-important.icon @@ -0,0 +1,84 @@ + +[Icon Data] + +DisplayName=Important +DisplayName[af]=Belangrik +DisplayName[am]=አስፈላጊ +DisplayName[ar]=مهمّ +DisplayName[az]=Vacib +DisplayName[be]=Важны +DisplayName[be@latin]=Važny +DisplayName[bg]=Важно +DisplayName[bn]=গুরুত্বপূর্ণ +DisplayName[bn_IN]=গুরুত্বপূর্ণ +DisplayName[bs]=Važno +DisplayName[ca]=Important +DisplayName[cs]=Důležité +DisplayName[cy]=Pwysig +DisplayName[da]=Vigtig +DisplayName[de]=Wichtig +DisplayName[dz]=གལ་ཅན། +DisplayName[el]=Σημαντικό +DisplayName[en_CA]=Important +DisplayName[en_GB]=Important +DisplayName[es]=Importante +DisplayName[et]=Tähtis +DisplayName[eu]=Garrantzitsua +DisplayName[fa]=مهم +DisplayName[fi]=Tärkeä +DisplayName[fr]=Important +DisplayName[fur]=Impuartant +DisplayName[ga]=Tábhachtach +DisplayName[gl]=Importante +DisplayName[gu]=મહત્વનુ +DisplayName[he]=חשוב +DisplayName[hi]=महत्वपूर्ण +DisplayName[hr]=Važno +DisplayName[hu]=Fontos +DisplayName[id]=Penting +DisplayName[is]=Mikilvægt +DisplayName[it]=Importante +DisplayName[ja]=重要 +DisplayName[ka]=მნიშვნელოვანი +DisplayName[ko]=중요 +DisplayName[li]=Wichtig +DisplayName[lt]=Svarbu +DisplayName[lv]=Svarīgs +DisplayName[mg]=Manan-danja +DisplayName[mk]=Важно +DisplayName[ml]=സുപ്രധാനമായ +DisplayName[mn]=Чухал +DisplayName[mr]=महत्वाचे +DisplayName[ms]=Penting +DisplayName[nb]=Viktig +DisplayName[ne]=महत्वपूर्ण +DisplayName[nl]=Belangrijk +DisplayName[nn]=Viktig +DisplayName[oc]=Important +DisplayName[or]=ଗୁରୁତ୍ବପୂର୍ଣ୍ଣ +DisplayName[pa]=ਖਾਸ +DisplayName[pl]=Ważny +DisplayName[pt]=Importante +DisplayName[pt_BR]=Importante +DisplayName[ro]=Important +DisplayName[ru]=Важно +DisplayName[rw]=By'ingirakamaro +DisplayName[si]=වැදගත් +DisplayName[sk]=Dôležitý +DisplayName[sl]=Pomembno +DisplayName[sq]=I rëndësishëm +DisplayName[sr]=Важно +DisplayName[sr@Latn]=Važno +DisplayName[sv]=Viktig +DisplayName[ta]=முக்கியம் +DisplayName[te]=ముఖ్యమైన +DisplayName[th]=สำคัญ +DisplayName[tk]=Möhüm +DisplayName[tr]=Önemli +DisplayName[uk]=Важливе +DisplayName[vi]=Quan trọng +DisplayName[wa]=Impôrtant +DisplayName[xh]=Ibalulekile +DisplayName[zh_CN]=重要 +DisplayName[zh_HK]=重要 +DisplayName[zh_TW]=重要 diff --git a/qt/icons/Faenza/emblems/16/emblem-important.png b/qt/icons/Faenza/emblems/16/emblem-important.png new file mode 100644 index 0000000000000000000000000000000000000000..d0d54f81afcc52ae629ce04ba11f10fed73809c1 GIT binary patch literal 539 zcmV+$0_6RPP)LM(xHT?8cx?Y6t_ zrLWLze1R_A6#4?bM7C`fSxO(ER1I8-MO<7Y37MR8Ca%OJ_iFXPfjRU2=Hr`V+U@qH zs(ww9q=83NjPXyJrr&8YnY5bC=4P!{bB{3?4u>zg-ENCiwE^HV&-2kN(Ej-0{lDX5 z4*;(=HU^)5{yLh~E0xNUsx~Nufbn=d_ZR?{&(Hj8{{#SVb$;embxv2+Q3&BFF|(OY zr-g_wtM>K`pp0Q=Lm>nsA_dX9bZ#zVLI{Rb)x;PJqO&wNmochph?z?btoy$KGv8zI zfCS8J5)na+vC!46o!mNtb%g5HPF}`{2uMUq6Quj!P8?AM07Qi2U{GL0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/qt/torrent-delegate-min.cc b/qt/torrent-delegate-min.cc index e3a182023..9ddee6e2f 100644 --- a/qt/torrent-delegate-min.cc +++ b/qt/torrent-delegate-min.cc @@ -90,22 +90,25 @@ TorrentDelegateMin::drawTorrent (QPainter * painter, const QString statusStr (shortStatusString (tor)); const QSize statusSize (statusFM.size (0, statusStr)); + const bool isItemSelected ((option.state & QStyle::State_Selected) != 0); + const bool isItemEnabled ((option.state & QStyle::State_Enabled) != 0); + const bool isItemActive ((option.state & QStyle::State_Active) != 0); + painter->save(); - if (option.state & QStyle::State_Selected) + if (isItemSelected) { - QPalette::ColorGroup cg = option.state & QStyle::State_Enabled - ? QPalette::Normal : QPalette::Disabled; - if (cg == QPalette::Normal && !(option.state & QStyle::State_Active)) + QPalette::ColorGroup cg = isItemEnabled ? QPalette::Normal : QPalette::Disabled; + if (cg == QPalette::Normal && !isItemActive) cg = QPalette::Inactive; painter->fillRect(option.rect, option.palette.brush(cg, QPalette::Highlight)); } QIcon::Mode im; - if (isPaused || !(option.state & QStyle::State_Enabled)) + if (isPaused || !isItemEnabled) im = QIcon::Disabled; - else if (option.state & QStyle::State_Selected) + else if (isItemSelected) im = QIcon::Selected; else im = QIcon::Normal; @@ -117,13 +120,13 @@ TorrentDelegateMin::drawTorrent (QPainter * painter, qs = QIcon::On; QPalette::ColorGroup cg = QPalette::Normal; - if (isPaused || !(option.state & QStyle::State_Enabled)) + if (isPaused || !isItemEnabled) cg = QPalette::Disabled; - if (cg == QPalette::Normal && !(option.state & QStyle::State_Active)) + if (cg == QPalette::Normal && !isItemActive) cg = QPalette::Inactive; QPalette::ColorRole cr; - if (option.state & QStyle::State_Selected) + if (isItemSelected) cr = QPalette::HighlightedText; else cr = QPalette::Text; @@ -133,6 +136,9 @@ TorrentDelegateMin::drawTorrent (QPainter * painter, progressBarState = QStyle::State_None; progressBarState |= QStyle::State_Small; + const QIcon::Mode emblemIm = isItemSelected ? QIcon::Selected : QIcon::Normal; + const QIcon emblemIcon = tor.hasError () ? QIcon::fromTheme ("emblem-important") : QIcon (); + // layout const QSize m (margin (*style)); QRect fillArea (option.rect); @@ -141,6 +147,9 @@ TorrentDelegateMin::drawTorrent (QPainter * painter, fillArea.y() + (fillArea.height() - iconSize) / 2, iconSize, iconSize); + const QRect emblemRect (style->alignedRect (option.direction, Qt::AlignRight | Qt::AlignBottom, + emblemIcon.actualSize (QSize (iconSize / 2, iconSize / 2), emblemIm, qs), + iconArea)); const QRect barArea (fillArea.x() + fillArea.width() - BAR_WIDTH, fillArea.y() + (fillArea.height() - BAR_HEIGHT) / 2, BAR_WIDTH, @@ -155,11 +164,13 @@ TorrentDelegateMin::drawTorrent (QPainter * painter, fillArea.height()); // render - if (tor.hasError()) + if (tor.hasError() && !isItemSelected) painter->setPen (QColor ("red")); else painter->setPen (option.palette.color (cg, cr)); tor.getMimeTypeIcon().paint (painter, iconArea, Qt::AlignCenter, im, qs); + if (!emblemIcon.isNull ()) + emblemIcon.paint (painter, emblemRect, Qt::AlignCenter, emblemIm, qs); painter->setFont (nameFont); painter->drawText (nameArea, 0, nameFM.elidedText (nameStr, Qt::ElideRight, nameArea.width())); painter->setFont (statusFont); diff --git a/qt/torrent-delegate.cc b/qt/torrent-delegate.cc index 3949c25f8..f63e2aa21 100644 --- a/qt/torrent-delegate.cc +++ b/qt/torrent-delegate.cc @@ -373,22 +373,25 @@ TorrentDelegate::drawTorrent (QPainter * painter, const QString progressStr (statusString (tor)); const bool isPaused (tor.isPaused ()); + const bool isItemSelected ((option.state & QStyle::State_Selected) != 0); + const bool isItemEnabled ((option.state & QStyle::State_Enabled) != 0); + const bool isItemActive ((option.state & QStyle::State_Active) != 0); + painter->save (); - if (option.state & QStyle::State_Selected) + if (isItemSelected) { - QPalette::ColorGroup cg = option.state & QStyle::State_Enabled - ? QPalette::Normal : QPalette::Disabled; - if (cg == QPalette::Normal && !(option.state & QStyle::State_Active)) + QPalette::ColorGroup cg = isItemEnabled ? QPalette::Normal : QPalette::Disabled; + if (cg == QPalette::Normal && !isItemActive) cg = QPalette::Inactive; painter->fillRect(option.rect, option.palette.brush(cg, QPalette::Highlight)); } QIcon::Mode im; - if (isPaused || !(option.state & QStyle::State_Enabled)) + if (isPaused || !isItemEnabled) im = QIcon::Disabled; - else if (option.state & QStyle::State_Selected) + else if (isItemSelected) im = QIcon::Selected; else im = QIcon::Normal; @@ -400,13 +403,13 @@ TorrentDelegate::drawTorrent (QPainter * painter, qs = QIcon::On; QPalette::ColorGroup cg = QPalette::Normal; - if (isPaused || !(option.state & QStyle::State_Enabled)) + if (isPaused || !isItemEnabled) cg = QPalette::Disabled; - if (cg == QPalette::Normal && !(option.state & QStyle::State_Active)) + if (cg == QPalette::Normal && !isItemActive) cg = QPalette::Inactive; QPalette::ColorRole cr; - if (option.state & QStyle::State_Selected) + if (isItemSelected) cr = QPalette::HighlightedText; else cr = QPalette::Text; @@ -416,11 +419,16 @@ TorrentDelegate::drawTorrent (QPainter * painter, progressBarState = QStyle::State_None; progressBarState |= QStyle::State_Small; + const QIcon::Mode emblemIm = isItemSelected ? QIcon::Selected : QIcon::Normal; + const QIcon emblemIcon = tor.hasError () ? QIcon::fromTheme ("emblem-important") : QIcon (); + // layout const QSize m (margin (*style)); QRect fillArea (option.rect); fillArea.adjust (m.width(), m.height(), -m.width(), -m.height()); QRect iconArea (fillArea.x (), fillArea.y () + (fillArea.height () - iconSize) / 2, iconSize, iconSize); + QRect emblemRect (style->alignedRect (option.direction, Qt::AlignRight | Qt::AlignBottom, + emblemIcon.actualSize (QSize (iconSize / 2, iconSize / 2), emblemIm, qs), iconArea)); QRect nameArea (iconArea.x () + iconArea.width () + GUI_PAD, fillArea.y (), fillArea.width () - GUI_PAD - iconArea.width (), nameSize.height ()); QRect statusArea (nameArea); @@ -433,11 +441,13 @@ TorrentDelegate::drawTorrent (QPainter * painter, progArea.moveTop (barArea.y () + barArea.height ()); // render - if (tor.hasError ()) + if (tor.hasError () && !isItemSelected) painter->setPen (QColor ("red")); else painter->setPen (option.palette.color (cg, cr)); tor.getMimeTypeIcon().paint (painter, iconArea, Qt::AlignCenter, im, qs); + if (!emblemIcon.isNull ()) + emblemIcon.paint (painter, emblemRect, Qt::AlignCenter, emblemIm, qs); painter->setFont (nameFont); painter->drawText (nameArea, 0, nameFM.elidedText (nameStr, Qt::ElideRight, nameArea.width ())); painter->setFont (statusFont); -- 2.40.0