Changeset 14452


Ignore:
Timestamp:
Jan 17, 2015, 1:23:51 AM (6 years ago)
Author:
mikedld
Message:

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.

Location:
trunk/qt
Files:
7 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/qt/icons/Faenza/Faenza.qrc

    r14431 r14452  
    7272    <file>categories/22/preferences-system.png</file>
    7373    <file>categories/24/preferences-system.png</file>
     74    <file>emblems/16/emblem-important.icon</file>
     75    <file>emblems/16/emblem-important.png</file>
    7476    <file>status/16/network-error.png</file>
    7577    <file>status/16/network-idle.png</file>
  • trunk/qt/torrent-delegate-min.cc

    r14404 r14452  
    9191  const QSize statusSize (statusFM.size (0, statusStr));
    9292
     93  const bool isItemSelected ((option.state & QStyle::State_Selected) != 0);
     94  const bool isItemEnabled ((option.state & QStyle::State_Enabled) != 0);
     95  const bool isItemActive ((option.state & QStyle::State_Active) != 0);
     96
    9397  painter->save();
    9498
    95   if (option.state & QStyle::State_Selected)
    96     {
    97       QPalette::ColorGroup cg = option.state & QStyle::State_Enabled
    98                               ? QPalette::Normal : QPalette::Disabled;
    99       if (cg == QPalette::Normal && !(option.state & QStyle::State_Active))
     99  if (isItemSelected)
     100    {
     101      QPalette::ColorGroup cg = isItemEnabled ? QPalette::Normal : QPalette::Disabled;
     102      if (cg == QPalette::Normal && !isItemActive)
    100103        cg = QPalette::Inactive;
    101104
     
    104107
    105108  QIcon::Mode im;
    106   if (isPaused || !(option.state & QStyle::State_Enabled))
     109  if (isPaused || !isItemEnabled)
    107110    im = QIcon::Disabled;
    108   else if (option.state & QStyle::State_Selected)
     111  else if (isItemSelected)
    109112    im = QIcon::Selected;
    110113  else
     
    118121
    119122  QPalette::ColorGroup cg = QPalette::Normal;
    120   if (isPaused || !(option.state & QStyle::State_Enabled))
     123  if (isPaused || !isItemEnabled)
    121124    cg = QPalette::Disabled;
    122   if (cg == QPalette::Normal && !(option.state & QStyle::State_Active))
     125  if (cg == QPalette::Normal && !isItemActive)
    123126    cg = QPalette::Inactive;
    124127
    125128  QPalette::ColorRole cr;
    126   if (option.state & QStyle::State_Selected)
     129  if (isItemSelected)
    127130    cr = QPalette::HighlightedText;
    128131  else
     
    133136    progressBarState = QStyle::State_None;
    134137  progressBarState |= QStyle::State_Small;
     138
     139  const QIcon::Mode emblemIm = isItemSelected ? QIcon::Selected : QIcon::Normal;
     140  const QIcon emblemIcon = tor.hasError () ? QIcon::fromTheme ("emblem-important") : QIcon ();
    135141
    136142  // layout
     
    142148                        iconSize,
    143149                        iconSize);
     150  const QRect emblemRect (style->alignedRect (option.direction, Qt::AlignRight | Qt::AlignBottom,
     151                                              emblemIcon.actualSize (QSize (iconSize / 2, iconSize / 2), emblemIm, qs),
     152                                              iconArea));
    144153  const QRect barArea (fillArea.x() + fillArea.width() - BAR_WIDTH,
    145154                       fillArea.y() +  (fillArea.height() - BAR_HEIGHT) / 2,
     
    156165
    157166  // render
    158   if (tor.hasError())
     167  if (tor.hasError() && !isItemSelected)
    159168    painter->setPen (QColor ("red"));
    160169  else
    161170    painter->setPen (option.palette.color (cg, cr));
    162171  tor.getMimeTypeIcon().paint (painter, iconArea, Qt::AlignCenter, im, qs);
     172  if (!emblemIcon.isNull ())
     173    emblemIcon.paint (painter, emblemRect, Qt::AlignCenter, emblemIm, qs);
    163174  painter->setFont (nameFont);
    164175  painter->drawText (nameArea, 0, nameFM.elidedText (nameStr, Qt::ElideRight, nameArea.width()));
  • trunk/qt/torrent-delegate.cc

    r14404 r14452  
    374374  const bool isPaused (tor.isPaused ());
    375375
     376  const bool isItemSelected ((option.state & QStyle::State_Selected) != 0);
     377  const bool isItemEnabled ((option.state & QStyle::State_Enabled) != 0);
     378  const bool isItemActive ((option.state & QStyle::State_Active) != 0);
     379
    376380  painter->save ();
    377381
    378   if (option.state & QStyle::State_Selected)
    379     {
    380       QPalette::ColorGroup cg = option.state & QStyle::State_Enabled
    381                               ? QPalette::Normal : QPalette::Disabled;
    382       if (cg == QPalette::Normal && !(option.state & QStyle::State_Active))
     382  if (isItemSelected)
     383    {
     384      QPalette::ColorGroup cg = isItemEnabled ? QPalette::Normal : QPalette::Disabled;
     385      if (cg == QPalette::Normal && !isItemActive)
    383386        cg = QPalette::Inactive;
    384387
     
    387390
    388391  QIcon::Mode im;
    389   if (isPaused || !(option.state & QStyle::State_Enabled))
     392  if (isPaused || !isItemEnabled)
    390393    im = QIcon::Disabled;
    391   else if (option.state & QStyle::State_Selected)
     394  else if (isItemSelected)
    392395    im = QIcon::Selected;
    393396  else
     
    401404
    402405  QPalette::ColorGroup cg = QPalette::Normal;
    403   if (isPaused || !(option.state & QStyle::State_Enabled))
     406  if (isPaused || !isItemEnabled)
    404407    cg = QPalette::Disabled;
    405   if (cg == QPalette::Normal && !(option.state & QStyle::State_Active))
     408  if (cg == QPalette::Normal && !isItemActive)
    406409    cg = QPalette::Inactive;
    407410
    408411  QPalette::ColorRole cr;
    409   if (option.state & QStyle::State_Selected)
     412  if (isItemSelected)
    410413    cr = QPalette::HighlightedText;
    411414  else
     
    416419    progressBarState = QStyle::State_None;
    417420  progressBarState |= QStyle::State_Small;
     421
     422  const QIcon::Mode emblemIm = isItemSelected ? QIcon::Selected : QIcon::Normal;
     423  const QIcon emblemIcon = tor.hasError () ? QIcon::fromTheme ("emblem-important") : QIcon ();
    418424
    419425  // layout
     
    422428  fillArea.adjust (m.width(), m.height(), -m.width(), -m.height());
    423429  QRect iconArea (fillArea.x (), fillArea.y () +  (fillArea.height () - iconSize) / 2, iconSize, iconSize);
     430  QRect emblemRect (style->alignedRect (option.direction, Qt::AlignRight | Qt::AlignBottom,
     431                                        emblemIcon.actualSize (QSize (iconSize / 2, iconSize / 2), emblemIm, qs), iconArea));
    424432  QRect nameArea (iconArea.x () + iconArea.width () + GUI_PAD, fillArea.y (),
    425433                  fillArea.width () - GUI_PAD - iconArea.width (), nameSize.height ());
     
    434442
    435443  // render
    436   if (tor.hasError ())
     444  if (tor.hasError () && !isItemSelected)
    437445    painter->setPen (QColor ("red"));
    438446  else
    439447    painter->setPen (option.palette.color (cg, cr));
    440448  tor.getMimeTypeIcon().paint (painter, iconArea, Qt::AlignCenter, im, qs);
     449  if (!emblemIcon.isNull ())
     450    emblemIcon.paint (painter, emblemRect, Qt::AlignCenter, emblemIm, qs);
    441451  painter->setFont (nameFont);
    442452  painter->drawText (nameArea, 0, nameFM.elidedText (nameStr, Qt::ElideRight, nameArea.width ()));
Note: See TracChangeset for help on using the changeset viewer.