Changeset 13992


Ignore:
Timestamp:
Feb 9, 2013, 4:42:07 AM (8 years ago)
Author:
jordan
Message:

(qt) #4076 'free space indicator': better user feedback when updating the freespace indicator in remote mode

Location:
trunk/qt
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/qt/freespace-label.cc

    r13991 r13992  
    2929  mySession (session),
    3030  myTag (-1),
    31   myPath (path),
    3231  myTimer (this)
    3332{
     
    4140           this,       SLOT(onSessionExecuted(int64_t, const QString&, struct tr_variant*)));
    4241
    43   onTimer ();
     42  setPath (path);
     43}
     44
     45void
     46FreespaceLabel :: setPath (const QString& path)
     47{
     48  if (myPath != path)
     49    {
     50      setText (tr("<i>Counting Free Space...</i>"));
     51      myPath = path;
     52      onTimer ();
     53    }
    4454}
    4555
  • trunk/qt/freespace-label.h

    r13991 r13992  
    2828    FreespaceLabel (Session&, const QString& path, QWidget *parent=0);
    2929    virtual ~FreespaceLabel () {}
    30     void setPath (const QString& folder) { myPath=folder; onTimer(); }
     30    void setPath (const QString& folder);
    3131
    3232  private:
  • trunk/qt/options.cc

    r13991 r13992  
    1010 * $Id$
    1111 */
    12 
    13 #include <cstdio>
    1412
    1513#include <QApplication>
     
    8886    myVerifyButton( 0 ),
    8987    myVerifyFile( 0 ),
    90     myVerifyHash( QCryptographicHash::Sha1 )
    91 
     88    myVerifyHash( QCryptographicHash::Sha1 ),
     89    myEditTimer (this)
    9290{
    9391    setWindowTitle( tr( "Open Torrent" ) );
     
    9593    QGridLayout * layout = new QGridLayout( this );
    9694    int row = 0;
     95
     96    myEditTimer.setInterval (2000);
     97    myEditTimer.setSingleShot (true);
     98    connect (&myEditTimer, SIGNAL(timeout()), this, SLOT(onDestinationEditedIdle()));
    9799
    98100    const int iconSize( style( )->pixelMetric( QStyle :: PM_SmallIconSize ) );
     
    121123    layout->addWidget( l, ++row, 0, Qt::AlignLeft );
    122124    const QString downloadDir (prefs.getString (Prefs::DOWNLOAD_DIR));
     125    myFreespaceLabel = new FreespaceLabel (mySession, downloadDir, this);
    123126
    124127    if( session.isLocal( ) )
     
    139142        layout->addWidget( e, row, 1 );
    140143        l->setBuddy( e );
    141     }
    142 
    143     l = myFreespaceLabel = new FreespaceLabel (mySession, downloadDir, this);
     144        connect (e, SIGNAL(textEdited(const QString&)), this, SLOT(onDestinationEdited(const QString&)));
     145    }
     146
     147    l = myFreespaceLabel;
    144148    layout->addWidget (l, ++row, 0, 1, 2, Qt::Alignment (Qt::AlignRight | Qt::AlignTop));
    145149    layout->setRowMinimumHeight (row, l->height() + HIG::PAD);
     
    464468      refreshDestinationButton ();
    465469    }
     470}
     471
     472void
     473Options :: onDestinationEdited (const QString& text)
     474{
     475  Q_UNUSED (text);
     476
     477  myEditTimer.start ();
     478}
     479
     480void
     481Options :: onDestinationEditedIdle ()
     482{
     483  myFreespaceLabel->setPath (myDestinationEdit->text());
    466484}
    467485
  • trunk/qt/options.h

    r13991 r13992  
    103103        void onFilesSelected( const QStringList& );
    104104        void onDestinationsSelected( const QStringList& );
     105        void onDestinationEdited (const QString&);
     106        void onDestinationEditedIdle ();
    105107
    106108    private:
     
    120122        typedef QMap<uint32_t,int32_t> mybins_t;
    121123        mybins_t myVerifyBins;
     124        QTimer myEditTimer;
    122125
    123126};
Note: See TracChangeset for help on using the changeset viewer.