Changeset 13883


Ignore:
Timestamp:
Jan 27, 2013, 5:19:51 PM (8 years ago)
Author:
jordan
Message:

(qt) #4076 'free space indicator' -- added.

Location:
trunk/qt
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/qt/mainwin.cc

    r13735 r13883  
    283283    connect( &mySession, SIGNAL(sourceChanged()), this, SLOT(onSessionSourceChanged()) );
    284284    connect( &mySession, SIGNAL(statsUpdated()), this, SLOT(refreshStatusBar()) );
     285    connect( &mySession, SIGNAL(sessionUpdated()), this, SLOT(refreshFreeSpace()) );
    285286    connect( &mySession, SIGNAL(dataReadProgress()), this, SLOT(dataReadProgress()) );
    286287    connect( &mySession, SIGNAL(dataSendProgress()), this, SLOT(dataSendProgress()) );
     
    301302    refreshTrayIconSoon( );
    302303    refreshStatusBar( );
     304    refreshFreeSpace( );
    303305    refreshTitle( );
    304306    refreshVisibleCount( );
     
    393395        h->addWidget( l );
    394396
     397    //h->addStretch( 1 );
     398    h->addSpacing ( HIG::PAD_BIG );
     399
     400        l = myFreeSpaceTextLabel = new QLabel (this);
     401        const int minimumFreeSpaceWidth = l->fontMetrics().width( Formatter::sizeToString(1024 * 1024));
     402        l->setMinimumWidth( minimumFreeSpaceWidth );
     403        h->addWidget( l );
     404        l = myFreeSpaceIconLabel = new QLabel (this);
     405        l->setPixmap( getStockIcon( "drive-harddisk", QStyle::SP_DriveHDIcon ).pixmap( smallIconSize ) );
     406        h->addWidget( l );
     407
    395408    h->addStretch( 1 );
    396409
     410        l = myStatsLabel = new QLabel( this );
     411        h->addWidget( l );
    397412        a = new QActionGroup( this );
    398413        a->addAction( ui.action_TotalRatio );
     
    415430        p->setMenu( m );
    416431        h->addWidget( p );
    417         l = myStatsLabel = new QLabel( this );
    418         h->addWidget( l );
    419 
    420     h->addStretch( 1 );
     432
     433    //h->addStretch( 1 );
     434    h->addSpacing ( HIG::PAD );
    421435
    422436        l = myDownloadSpeedLabel = new QLabel( this );
     
    429443        h->addWidget( l );
    430444
    431     h->addStretch( 1 );
     445    h->addSpacing ( HIG::PAD );
    432446
    433447        l = myUploadSpeedLabel = new QLabel;
     
    718732
    719733void
     734TrMainWindow :: refreshFreeSpace( )
     735{
     736  const int64_t bytes (mySession.downloadDirFreeSpace());
     737
     738  if (bytes >= 0)
     739    {
     740      const QString text = Formatter::sizeToString (bytes);
     741
     742      const QString tip = tr("Download directory \"%1\" has %2 space free")
     743        .arg(myPrefs.getString(Prefs::DOWNLOAD_DIR))
     744        .arg(text);
     745
     746      myFreeSpaceTextLabel->setText (text);
     747      myFreeSpaceTextLabel->setToolTip (tip);
     748      myFreeSpaceIconLabel->setToolTip (tip);
     749    }
     750
     751  myFreeSpaceTextLabel->setVisible (bytes >= 0);
     752  myFreeSpaceIconLabel->setVisible (bytes >= 0);
     753}
     754
     755void
    720756TrMainWindow :: refreshTrayIconSoon( )
    721757{
  • trunk/qt/mainwin.h

    r13733 r13883  
    106106        void showSessionTransfer( );
    107107        void refreshVisibleCount( );
     108        void refreshFreeSpace( );
    108109        void refreshTitle( );
    109110        void refreshStatusBar( );
     
    160161        QLabel * myDownloadSpeedLabel;
    161162        QLabel * myUploadSpeedLabel;
     163        QLabel * myFreeSpaceTextLabel;
     164        QLabel * myFreeSpaceIconLabel;
    162165        QLabel * myNetworkLabel;
    163166
  • trunk/qt/session.cc

    r13864 r13883  
    248248    mySession( 0 ),
    249249    myConfigDir( QString::fromUtf8( configDir ) ),
    250     myNAM( 0 )
     250    myNAM( 0 ),
     251    myDownloadDirFreeSpace( -1 )
    251252{
    252253    myStats.ratio = TR_RATIO_NA;
     
    993994        mySessionVersion = str;
    994995
     996    if( tr_variantDictFindInt( d, TR_KEY_download_dir_free_space, &i ) && ( myDownloadDirFreeSpace != i ) )
     997        myDownloadDirFreeSpace = i;
     998
    995999    //std::cerr << "Session :: updateInfo end" << std::endl;
    9961000    connect( &myPrefs, SIGNAL(changed(int)), this, SLOT(updatePref(int)) );
  • trunk/qt/session.h

    r13864 r13883  
    5858        const struct tr_session_stats& getCumulativeStats( ) const { return myCumulativeStats; }
    5959        const QString& sessionVersion( ) const { return mySessionVersion; }
     60        int64_t downloadDirFreeSpace( ) const { return myDownloadDirFreeSpace; }
    6061
    6162    public:
     
    160161        struct tr_session_stats myCumulativeStats;
    161162        QString mySessionVersion;
     163        int64_t myDownloadDirFreeSpace;
    162164};
    163165
Note: See TracChangeset for help on using the changeset viewer.