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

This commit is contained in:
Jordan Lee 2013-02-09 04:42:07 +00:00
parent cd09204a6e
commit d1da0204c7
4 changed files with 39 additions and 8 deletions

View File

@ -28,7 +28,6 @@ FreespaceLabel :: FreespaceLabel (Session & session,
QLabel (parent),
mySession (session),
myTag (-1),
myPath (path),
myTimer (this)
{
myTimer.setSingleShot (false);
@ -40,7 +39,18 @@ FreespaceLabel :: FreespaceLabel (Session & session,
connect (&mySession, SIGNAL(executed(int64_t, const QString&, struct tr_variant*)),
this, SLOT(onSessionExecuted(int64_t, const QString&, struct tr_variant*)));
onTimer ();
setPath (path);
}
void
FreespaceLabel :: setPath (const QString& path)
{
if (myPath != path)
{
setText (tr("<i>Counting Free Space...</i>"));
myPath = path;
onTimer ();
}
}
void

View File

@ -27,7 +27,7 @@ class FreespaceLabel: public QLabel
public:
FreespaceLabel (Session&, const QString& path, QWidget *parent=0);
virtual ~FreespaceLabel () {}
void setPath (const QString& folder) { myPath=folder; onTimer(); }
void setPath (const QString& folder);
private:
Session& mySession;

View File

@ -10,8 +10,6 @@
* $Id$
*/
#include <cstdio>
#include <QApplication>
#include <QCheckBox>
#include <QComboBox>
@ -87,14 +85,18 @@ Options :: Options( Session& session, const Prefs& prefs, const AddData& addme,
myDestinationButton( 0 ),
myVerifyButton( 0 ),
myVerifyFile( 0 ),
myVerifyHash( QCryptographicHash::Sha1 )
myVerifyHash( QCryptographicHash::Sha1 ),
myEditTimer (this)
{
setWindowTitle( tr( "Open Torrent" ) );
QFontMetrics fontMetrics( font( ) );
QGridLayout * layout = new QGridLayout( this );
int row = 0;
myEditTimer.setInterval (2000);
myEditTimer.setSingleShot (true);
connect (&myEditTimer, SIGNAL(timeout()), this, SLOT(onDestinationEditedIdle()));
const int iconSize( style( )->pixelMetric( QStyle :: PM_SmallIconSize ) );
QIcon fileIcon = style( )->standardIcon( QStyle::SP_FileIcon );
const QPixmap filePixmap = fileIcon.pixmap( iconSize );
@ -120,6 +122,7 @@ Options :: Options( Session& session, const Prefs& prefs, const AddData& addme,
l = new QLabel( tr( "&Destination folder:" ) );
layout->addWidget( l, ++row, 0, Qt::AlignLeft );
const QString downloadDir (prefs.getString (Prefs::DOWNLOAD_DIR));
myFreespaceLabel = new FreespaceLabel (mySession, downloadDir, this);
if( session.isLocal( ) )
{
@ -138,9 +141,10 @@ Options :: Options( Session& session, const Prefs& prefs, const AddData& addme,
e->setText (downloadDir);
layout->addWidget( e, row, 1 );
l->setBuddy( e );
connect (e, SIGNAL(textEdited(const QString&)), this, SLOT(onDestinationEdited(const QString&)));
}
l = myFreespaceLabel = new FreespaceLabel (mySession, downloadDir, this);
l = myFreespaceLabel;
layout->addWidget (l, ++row, 0, 1, 2, Qt::Alignment (Qt::AlignRight | Qt::AlignTop));
layout->setRowMinimumHeight (row, l->height() + HIG::PAD);
@ -465,6 +469,20 @@ Options :: onDestinationsSelected (const QStringList& destinations)
}
}
void
Options :: onDestinationEdited (const QString& text)
{
Q_UNUSED (text);
myEditTimer.start ();
}
void
Options :: onDestinationEditedIdle ()
{
myFreespaceLabel->setPath (myDestinationEdit->text());
}
/***
****
**** VERIFY

View File

@ -102,6 +102,8 @@ class Options: public QDialog
void onDestinationClicked( );
void onFilesSelected( const QStringList& );
void onDestinationsSelected( const QStringList& );
void onDestinationEdited (const QString&);
void onDestinationEditedIdle ();
private:
bool eventFilter( QObject *, QEvent * );
@ -119,6 +121,7 @@ class Options: public QDialog
QCryptographicHash myVerifyHash;
typedef QMap<uint32_t,int32_t> mybins_t;
mybins_t myVerifyBins;
QTimer myEditTimer;
};