Changeset 13244


Ignore:
Timestamp:
Mar 4, 2012, 1:15:43 PM (10 years ago)
Author:
jordan
Message:

(trunk qt) #4389 "share ratio progressbar indication counter-intuitive" -- apply rb07's 'color-progress-bar.patch' to to add color to the progress bar, similar to the Mac and Web client. It also restores seed bar to normal filling, not reverse or emptying.

Location:
trunk/qt
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/qt/torrent-delegate-min.cc

    r12470 r13244  
    155155    painter->drawText( statusArea, 0, statusStr );
    156156    myProgressBarStyle->rect = barArea;
    157     myProgressBarStyle->direction = option.direction;
    158     myProgressBarStyle->palette = option.palette;
    159     myProgressBarStyle->palette.setCurrentColorGroup( cg );
     157    if ( tor.isDownloading() ) {
     158        myProgressBarStyle->palette.setBrush( QPalette::Highlight, blueBrush );
     159        myProgressBarStyle->palette.setColor( QPalette::Base, blueBack );
     160        myProgressBarStyle->palette.setColor( QPalette::Background, blueBack );
     161    }
     162    else if ( tor.isSeeding() ) {
     163        myProgressBarStyle->palette.setBrush( QPalette::Highlight, greenBrush );
     164        myProgressBarStyle->palette.setColor( QPalette::Base, greenBack );
     165        myProgressBarStyle->palette.setColor( QPalette::Background, greenBack );
     166    }
    160167    myProgressBarStyle->state = progressBarState;
    161168    char buf[32];
  • trunk/qt/torrent-delegate.cc

    r12827 r13244  
    1414
    1515#include <QApplication>
    16 #include <QBrush>
    1716#include <QFont>
    1817#include <QFontMetrics>
     
    3534};
    3635
     36QColor TorrentDelegate :: greenBrush;
     37QColor TorrentDelegate :: blueBrush;
     38QColor TorrentDelegate :: greenBack;
     39QColor TorrentDelegate :: blueBack;
     40
    3741TorrentDelegate :: TorrentDelegate( QObject * parent ):
    38     QItemDelegate( parent ),
     42    QStyledItemDelegate( parent ),
    3943    myProgressBarStyle( new QStyleOptionProgressBarV2 )
    4044{
    4145    myProgressBarStyle->minimum = 0;
    4246    myProgressBarStyle->maximum = 1000;
     47
     48    greenBrush = QColor("forestgreen");
     49    greenBack = QColor("darkseagreen");
     50
     51    blueBrush = QColor("steelblue");
     52    blueBack = QColor("lightgrey");
    4353}
    4454
     
    315325    painter->save( );
    316326    painter->setClipRect( option.rect );
    317     drawBackground( painter, option, index );
    318327    drawTorrent( painter, option, *tor );
    319     drawFocus(painter, option, option.rect );
    320328    painter->restore( );
    321329}
     
    328336    {
    329337        const double seedRateRatio = tor.ratio() / seedRatioLimit;
    330         const double invertedRatio = 1. - seedRateRatio;
    331         const int scaledProgress = invertedRatio * (myProgressBarStyle->maximum - myProgressBarStyle->minimum);
     338        const int scaledProgress = seedRateRatio * (myProgressBarStyle->maximum - myProgressBarStyle->minimum);
    332339        myProgressBarStyle->progress = myProgressBarStyle->minimum + scaledProgress;
    333340    }
     
    420427    painter->drawText( progArea, 0, progressFM.elidedText( progressStr, Qt::ElideRight, progArea.width( ) ) );
    421428    myProgressBarStyle->rect = barArea;
    422     myProgressBarStyle->palette = option.palette;
    423     myProgressBarStyle->palette.setCurrentColorGroup( cg );
     429    if ( tor.isDownloading() ) {
     430        myProgressBarStyle->palette.setBrush( QPalette::Highlight, blueBrush );
     431        myProgressBarStyle->palette.setColor( QPalette::Base, blueBack );
     432        myProgressBarStyle->palette.setColor( QPalette::Background, blueBack );
     433    }
     434    else if ( tor.isSeeding() ) {
     435        myProgressBarStyle->palette.setBrush( QPalette::Highlight, greenBrush );
     436        myProgressBarStyle->palette.setColor( QPalette::Base, greenBack );
     437        myProgressBarStyle->palette.setColor( QPalette::Background, greenBack );
     438    }
    424439    myProgressBarStyle->state = progressBarState;
    425440    setProgressBarPercentDone( option, tor );
  • trunk/qt/torrent-delegate.h

    r12464 r13244  
    1414#define QTR_TORRENT_DELEGATE_H
    1515
    16 #include <QItemDelegate>
     16#include <QStyledItemDelegate>
    1717#include <QSize>
    1818
     
    2323class Torrent;
    2424
    25 class TorrentDelegate: public QItemDelegate
     25class TorrentDelegate: public QStyledItemDelegate
    2626{
    2727        Q_OBJECT
     28
     29    public:
     30      static QColor blueBrush, greenBrush;
     31      static QColor blueBack,  greenBack;
    2832
    2933    protected:
     
    4852        QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const;
    4953        void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const;
     54
    5055};
    5156
Note: See TracChangeset for help on using the changeset viewer.