mirror of
https://github.com/transmission/transmission
synced 2025-03-10 06:02:57 +00:00
(trunk qt) first stab at getting the properties dialog's "options" controls operational.
This commit is contained in:
parent
cf552651f7
commit
c5aa896d83
5 changed files with 100 additions and 31 deletions
|
@ -56,7 +56,7 @@ class Session;
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
const int REFRESH_INTERVAL_MSEC = 3500;
|
const int REFRESH_INTERVAL_MSEC = 4000;
|
||||||
|
|
||||||
enum // peer columns
|
enum // peer columns
|
||||||
{
|
{
|
||||||
|
@ -243,25 +243,12 @@ Details :: onTorrentChanged( )
|
||||||
mySeedersLabel->setText( locale.toString( myTorrent.seeders( ) ) );
|
mySeedersLabel->setText( locale.toString( myTorrent.seeders( ) ) );
|
||||||
myLeechersLabel->setText( locale.toString( myTorrent.leechers( ) ) );
|
myLeechersLabel->setText( locale.toString( myTorrent.leechers( ) ) );
|
||||||
myTimesCompletedLabel->setText( locale.toString( myTorrent.timesCompleted( ) ) );
|
myTimesCompletedLabel->setText( locale.toString( myTorrent.timesCompleted( ) ) );
|
||||||
//const PeerList peers( myTorrent.peers( ) );
|
const PeerList peers( myTorrent.peers( ) );
|
||||||
PeerList peers( myTorrent.peers( ) );
|
|
||||||
#if 0
|
|
||||||
static double progress = 0.01;
|
|
||||||
{
|
|
||||||
Peer peer;
|
|
||||||
peer.address = "127.0.0.1";
|
|
||||||
peer.isEncrypted = true;
|
|
||||||
peer.progress = progress;
|
|
||||||
peer.rateToPeer = Speed::fromKbps(20);
|
|
||||||
peers << peer;
|
|
||||||
progress += 0.01;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
QMap<QString,QTreeWidgetItem*> peers2;
|
QMap<QString,QTreeWidgetItem*> peers2;
|
||||||
QList<QTreeWidgetItem*> newItems;
|
QList<QTreeWidgetItem*> newItems;
|
||||||
static const QIcon myEncryptionIcon( ":/icons/encrypted.png" );
|
static const QIcon myEncryptionIcon( ":/icons/encrypted.png" );
|
||||||
static const QIcon myEmptyIcon;
|
static const QIcon myEmptyIcon;
|
||||||
foreach( Peer peer, peers )
|
foreach( const Peer& peer, peers )
|
||||||
{
|
{
|
||||||
PeerItem * item = (PeerItem*) myPeers.value( peer.address, 0 );
|
PeerItem * item = (PeerItem*) myPeers.value( peer.address, 0 );
|
||||||
if( item == 0 ) { // new peer has connected
|
if( item == 0 ) { // new peer has connected
|
||||||
|
@ -372,9 +359,50 @@ Details :: createActivityTab( )
|
||||||
***/
|
***/
|
||||||
|
|
||||||
void
|
void
|
||||||
Details :: onSessionLimitsToggled( bool b )
|
Details :: onHonorsSessionLimitsToggled( bool val )
|
||||||
{
|
{
|
||||||
mySession.torrentSet( myTorrent.id(), "honorsSessionLimits", b );
|
mySession.torrentSet( myTorrent.id(), "honorsSessionLimits", val );
|
||||||
|
}
|
||||||
|
void
|
||||||
|
Details :: onDownloadLimitedToggled( bool val )
|
||||||
|
{
|
||||||
|
mySession.torrentSet( myTorrent.id(), "downloadLimited", val );
|
||||||
|
}
|
||||||
|
void
|
||||||
|
Details :: onDownloadLimitChanged( int val )
|
||||||
|
{
|
||||||
|
mySession.torrentSet( myTorrent.id(), "downloadLimit", val );
|
||||||
|
}
|
||||||
|
void
|
||||||
|
Details :: onUploadLimitedToggled( bool val )
|
||||||
|
{
|
||||||
|
mySession.torrentSet( myTorrent.id(), "uploadLimited", val );
|
||||||
|
}
|
||||||
|
void
|
||||||
|
Details :: onUploadLimitChanged( int val )
|
||||||
|
{
|
||||||
|
mySession.torrentSet( myTorrent.id(), "uploadLimit", val );
|
||||||
|
}
|
||||||
|
|
||||||
|
#define RATIO_KEY "seedRatioMode"
|
||||||
|
|
||||||
|
void
|
||||||
|
Details :: onSeedUntilChanged( bool b )
|
||||||
|
{
|
||||||
|
if( b )
|
||||||
|
mySession.torrentSet( myTorrent.id(), RATIO_KEY, sender()->property(RATIO_KEY).toInt() );
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Details :: onSeedRatioLimitChanged( double val )
|
||||||
|
{
|
||||||
|
mySession.torrentSet( myTorrent.id(), "seedRatioLimit", val );
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Details :: onMaxPeersChanged( int val )
|
||||||
|
{
|
||||||
|
mySession.torrentSet( myTorrent.id(), "peer-limit", val );
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget *
|
QWidget *
|
||||||
|
@ -393,7 +421,7 @@ Details :: createOptionsTab( )
|
||||||
c = new QCheckBox( tr( "Honor global &limits" ) );
|
c = new QCheckBox( tr( "Honor global &limits" ) );
|
||||||
mySessionLimitCheck = c;
|
mySessionLimitCheck = c;
|
||||||
hig->addWideControl( c );
|
hig->addWideControl( c );
|
||||||
connect( c, SIGNAL(toggled(bool)), this, SLOT(onSessionLimitsToggled(bool)) );
|
connect( c, SIGNAL(toggled(bool)), this, SLOT(onHonorsSessionLimitsToggled(bool)) );
|
||||||
|
|
||||||
c = new QCheckBox( tr( "Limit &download speed (KB/s)" ) );
|
c = new QCheckBox( tr( "Limit &download speed (KB/s)" ) );
|
||||||
mySingleDownCheck = c;
|
mySingleDownCheck = c;
|
||||||
|
@ -402,6 +430,8 @@ Details :: createOptionsTab( )
|
||||||
s->setRange( 0, INT_MAX );
|
s->setRange( 0, INT_MAX );
|
||||||
hig->addRow( c, s );
|
hig->addRow( c, s );
|
||||||
enableWhenChecked( c, s );
|
enableWhenChecked( c, s );
|
||||||
|
connect( c, SIGNAL(toggled(bool)), this, SLOT(onDownloadLimitedToggled(bool)) );
|
||||||
|
connect( s, SIGNAL(valueChanged(int)), this, SLOT(onDownloadLimitChanged(int)));
|
||||||
|
|
||||||
c = new QCheckBox( tr( "Limit &upload speed (KB/s)" ) );
|
c = new QCheckBox( tr( "Limit &upload speed (KB/s)" ) );
|
||||||
mySingleUpCheck = c;
|
mySingleUpCheck = c;
|
||||||
|
@ -410,25 +440,34 @@ Details :: createOptionsTab( )
|
||||||
s->setRange( 0, INT_MAX );
|
s->setRange( 0, INT_MAX );
|
||||||
hig->addRow( c, s );
|
hig->addRow( c, s );
|
||||||
enableWhenChecked( c, s );
|
enableWhenChecked( c, s );
|
||||||
|
connect( c, SIGNAL(toggled(bool)), this, SLOT(onUploadLimitedToggled(bool)) );
|
||||||
|
connect( s, SIGNAL(valueChanged(int)), this, SLOT(onUploadLimitChanged(int)));
|
||||||
|
|
||||||
hig->addSectionDivider( );
|
hig->addSectionDivider( );
|
||||||
hig->addSectionTitle( tr( "Seed-Until Ratio" ) );
|
hig->addSectionTitle( tr( "Seed-Until Ratio" ) );
|
||||||
|
|
||||||
r = new QRadioButton( tr( "Use &global setting" ) );
|
r = new QRadioButton( tr( "Use &global setting" ) );
|
||||||
|
r->setProperty( RATIO_KEY, TR_RATIOLIMIT_GLOBAL );
|
||||||
|
connect( r, SIGNAL(toggled(bool)), this, SLOT(onSeedUntilChanged(bool)));
|
||||||
mySeedGlobalRadio = r;
|
mySeedGlobalRadio = r;
|
||||||
hig->addWideControl( r );
|
hig->addWideControl( r );
|
||||||
|
|
||||||
r = new QRadioButton( tr( "Seed ®ardless of ratio" ) );
|
r = new QRadioButton( tr( "Seed ®ardless of ratio" ) );
|
||||||
|
r->setProperty( RATIO_KEY, TR_RATIOLIMIT_UNLIMITED );
|
||||||
|
connect( r, SIGNAL(toggled(bool)), this, SLOT(onSeedUntilChanged(bool)));
|
||||||
mySeedForeverRadio = r;
|
mySeedForeverRadio = r;
|
||||||
hig->addWideControl( r );
|
hig->addWideControl( r );
|
||||||
|
|
||||||
h = new QHBoxLayout( );
|
h = new QHBoxLayout( );
|
||||||
h->setSpacing( HIG :: PAD );
|
h->setSpacing( HIG :: PAD );
|
||||||
r = new QRadioButton( tr( "&Stop seeding when a torrent's ratio reaches" ) );
|
r = new QRadioButton( tr( "&Stop seeding when a torrent's ratio reaches" ) );
|
||||||
|
r->setProperty( RATIO_KEY, TR_RATIOLIMIT_SINGLE );
|
||||||
|
connect( r, SIGNAL(toggled(bool)), this, SLOT(onSeedUntilChanged(bool)));
|
||||||
mySeedCustomRadio = r;
|
mySeedCustomRadio = r;
|
||||||
h->addWidget( r );
|
h->addWidget( r );
|
||||||
ds = new QDoubleSpinBox( );
|
ds = new QDoubleSpinBox( );
|
||||||
ds->setRange( 0.5, INT_MAX );
|
ds->setRange( 0.5, INT_MAX );
|
||||||
|
connect( ds, SIGNAL(valueChanged(double)), this, SLOT(onSeedRatioLimitChanged(double)));
|
||||||
mySeedCustomSpin = ds;
|
mySeedCustomSpin = ds;
|
||||||
h->addWidget( ds );
|
h->addWidget( ds );
|
||||||
hig->addWideControl( h );
|
hig->addWideControl( h );
|
||||||
|
@ -438,6 +477,7 @@ Details :: createOptionsTab( )
|
||||||
|
|
||||||
s = new QSpinBox( );
|
s = new QSpinBox( );
|
||||||
s->setRange( 1, 300 );
|
s->setRange( 1, 300 );
|
||||||
|
connect( s, SIGNAL(valueChanged(int)), this, SLOT(onMaxPeersChanged(int)));
|
||||||
myPeerLimitSpin = s;
|
myPeerLimitSpin = s;
|
||||||
hig->addRow( tr( "&Maximum Peers" ), s );
|
hig->addRow( tr( "&Maximum Peers" ), s );
|
||||||
|
|
||||||
|
|
11
qt/details.h
11
qt/details.h
|
@ -114,11 +114,16 @@ class Details: public QDialog
|
||||||
FileTreeView * myFileTreeView;
|
FileTreeView * myFileTreeView;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onSessionLimitsToggled( bool );
|
|
||||||
void onFilePriorityChanged( const QSet<int>& fileIndices, int );
|
void onFilePriorityChanged( const QSet<int>& fileIndices, int );
|
||||||
void onFileWantedChanged( const QSet<int>& fileIndices, bool );
|
void onFileWantedChanged( const QSet<int>& fileIndices, bool );
|
||||||
|
void onHonorsSessionLimitsToggled( bool );
|
||||||
|
void onDownloadLimitedToggled( bool );
|
||||||
|
void onDownloadLimitChanged( int );
|
||||||
|
void onUploadLimitedToggled( bool );
|
||||||
|
void onUploadLimitChanged( int );
|
||||||
|
void onSeedUntilChanged( bool );
|
||||||
|
void onSeedRatioLimitChanged( double );
|
||||||
|
void onMaxPeersChanged( int );
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
#include <QStyle>
|
#include <QStyle>
|
||||||
|
#include <QTextStream>
|
||||||
|
|
||||||
#include <libtransmission/transmission.h>
|
#include <libtransmission/transmission.h>
|
||||||
#include <libtransmission/bencode.h>
|
#include <libtransmission/bencode.h>
|
||||||
|
@ -86,6 +87,7 @@ Session :: sessionSet( const char * key, const QVariant& value )
|
||||||
case QVariant::String: tr_bencDictAddStr ( args, key, value.toString().toUtf8() ); break;
|
case QVariant::String: tr_bencDictAddStr ( args, key, value.toString().toUtf8() ); break;
|
||||||
default: assert( "unknown type" );
|
default: assert( "unknown type" );
|
||||||
}
|
}
|
||||||
|
std::cerr << tr_bencToJSON(&top) << std::endl;
|
||||||
exec( &top );
|
exec( &top );
|
||||||
tr_bencFree( &top );
|
tr_bencFree( &top );
|
||||||
}
|
}
|
||||||
|
@ -274,17 +276,34 @@ namespace
|
||||||
|
|
||||||
const int Session :: ADD_TORRENT_TAG = TAG_ADD_TORRENT;
|
const int Session :: ADD_TORRENT_TAG = TAG_ADD_TORRENT;
|
||||||
|
|
||||||
|
void
|
||||||
|
Session :: torrentSet( int id, const QString& key, double value )
|
||||||
|
{
|
||||||
|
QString s;
|
||||||
|
QTextStream( &s ) << "{ \"method\": \"torrent-set\", \"arguments\": { \"ids\": "<<id<<", \""<<key<<"\": "<<value<<" } }";
|
||||||
|
std::cerr << qPrintable(s) << std::endl;
|
||||||
|
exec( s.toUtf8().constData() );
|
||||||
|
refreshExtraStats( id );
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Session :: torrentSet( int id, const QString& key, int value )
|
||||||
|
{
|
||||||
|
QString s;
|
||||||
|
QTextStream( &s ) << "{ \"method\": \"torrent-set\", \"arguments\": { \"ids\": "<<id<<", \""<<key<<"\": "<<value<<" } }";
|
||||||
|
std::cerr << qPrintable(s) << std::endl;
|
||||||
|
exec( s.toUtf8().constData() );
|
||||||
|
refreshExtraStats( id );
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Session :: torrentSet( int id, const QString& key, bool value )
|
Session :: torrentSet( int id, const QString& key, bool value )
|
||||||
{
|
{
|
||||||
tr_benc top;
|
QString s;
|
||||||
tr_bencInitDict( &top, 2 );
|
QTextStream( &s ) << "{ \"method\": \"torrent-set\", \"arguments\": { \"ids\": "<<id<<", \""<<key<<"\": "<<(value?"true":"false")<<" } }";
|
||||||
tr_bencDictAddStr( &top, "method", "torrent-set" );
|
std::cerr << qPrintable(s) << std::endl;
|
||||||
tr_benc * args( tr_bencDictAddDict( &top, "arguments", 2 ) );
|
exec( s.toUtf8().constData() );
|
||||||
tr_bencDictAddInt( args, key.toUtf8(), value );
|
refreshExtraStats( id );
|
||||||
tr_bencListAddInt( tr_bencDictAddList( args, "ids", 1 ), id );
|
|
||||||
exec( &top );
|
|
||||||
tr_bencFree( &top );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -295,11 +314,12 @@ Session :: torrentSet( int id, const QString& key, const QList<int>& value )
|
||||||
tr_bencDictAddStr( &top, "method", "torrent-set" );
|
tr_bencDictAddStr( &top, "method", "torrent-set" );
|
||||||
tr_benc * args( tr_bencDictAddDict( &top, "arguments", 2 ) );
|
tr_benc * args( tr_bencDictAddDict( &top, "arguments", 2 ) );
|
||||||
tr_bencListAddInt( tr_bencDictAddList( args, "ids", 1 ), id );
|
tr_bencListAddInt( tr_bencDictAddList( args, "ids", 1 ), id );
|
||||||
tr_benc * list( tr_bencDictAddList( args, key.toUtf8(), value.size( ) ) );
|
tr_benc * list( tr_bencDictAddList( args, key.toUtf8().constData(), value.size( ) ) );
|
||||||
foreach( int i, value )
|
foreach( int i, value )
|
||||||
tr_bencListAddInt( list, i );
|
tr_bencListAddInt( list, i );
|
||||||
exec( &top );
|
exec( &top );
|
||||||
tr_bencFree( &top );
|
tr_bencFree( &top );
|
||||||
|
refreshExtraStats( id );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -74,6 +74,8 @@ class Session: public QObject
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void torrentSet( int id, const QString& key, bool val );
|
void torrentSet( int id, const QString& key, bool val );
|
||||||
|
void torrentSet( int id, const QString& key, int val );
|
||||||
|
void torrentSet( int id, const QString& key, double val );
|
||||||
void torrentSet( int id, const QString& key, const QList<int>& val );
|
void torrentSet( int id, const QString& key, const QList<int>& val );
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
|
@ -25,6 +25,8 @@ TorrentFilter :: TorrentFilter( Prefs& prefs ):
|
||||||
// listen for changes to the preferences to know when to refilter / resort
|
// listen for changes to the preferences to know when to refilter / resort
|
||||||
connect( &myPrefs, SIGNAL(changed(int)), this, SLOT(refreshPref(int)));
|
connect( &myPrefs, SIGNAL(changed(int)), this, SLOT(refreshPref(int)));
|
||||||
|
|
||||||
|
setDynamicSortFilter( true );
|
||||||
|
|
||||||
// initialize our state from the current prefs
|
// initialize our state from the current prefs
|
||||||
QList<int> initKeys;
|
QList<int> initKeys;
|
||||||
initKeys << Prefs :: SORT_MODE
|
initKeys << Prefs :: SORT_MODE
|
||||||
|
|
Loading…
Add table
Reference in a new issue