Changeset 13883 for trunk/qt/mainwin.cc


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

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

File:
1 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{
Note: See TracChangeset for help on using the changeset viewer.