id | number | tr_torrent
isPrivate | boolean | tr_torrent
leftUntilDone | number | tr_stat
+ magnetLink | number | n/a
manualAnnounceTime | number | tr_stat
maxConnectedPeers | number | tr_torrent
metadataPercentComplete | double | tr_stat
| | NO | torrent-get | removed arg "seeders"
| | NO | torrent-get | removed arg "timesCompleted"
| | NO | torrent-get | removed arg "swarmSpeed"
+ | | yes | torrent-get | new arg "magnetLink"
| | yes | torrent-get | new arg "metadataPercentComplete"
| | yes | torrent-get | new arg "trackerStats"
| | yes | session-set | new arg "incomplete-dir"
tr_bencDictAddInt( d, key, st->manualAnnounceTime );
else if( tr_streq( key, keylen, "maxConnectedPeers" ) )
tr_bencDictAddInt( d, key, tr_torrentGetPeerLimit( tor ) );
+ else if( tr_streq( key, keylen, "magnetLink" ) ) {
+ char * str = tr_torrentGetMagnetLink( tor );
+ tr_bencDictAddStr( d, key, str );
+ tr_free( str );
+ }
else if( tr_streq( key, keylen, "metadataPercentComplete" ) )
tr_bencDictAddReal( d, key, st->metadataPercentComplete );
else if( tr_streq( key, keylen, "name" ) )
connect( ui.action_About, SIGNAL(triggered()), myAboutDialog, SLOT(show()));
connect( ui.action_Contents, SIGNAL(triggered()), this, SLOT(openHelp()));
connect( ui.action_OpenFolder, SIGNAL(triggered()), this, SLOT(openFolder()));
+ connect( ui.action_CopyMagnetToClipboard, SIGNAL(triggered()), this, SLOT(copyMagnetLinkToClipboard()));
connect( ui.action_SetLocation, SIGNAL(triggered()), this, SLOT(setLocation()));
connect( ui.action_Properties, SIGNAL(triggered()), this, SLOT(openProperties()));
connect( ui.action_SessionDialog, SIGNAL(triggered()), mySessionDialog, SLOT(show()));
QAction * sep2 = new QAction( this );
sep2->setSeparator( true );
+ QAction * sep3 = new QAction( this );
+ sep3->setSeparator( true );
// context menu
QList<QAction*> actions;
actions << ui.action_Properties
<< ui.action_OpenFolder
- << ui.action_SetLocation
<< sep2
<< ui.action_Start
+ << ui.action_Announce
<< ui.action_Pause
+ << ui.action_CopyMagnetToClipboard
+ << sep3
<< ui.action_Verify
- << ui.action_Announce
+ << ui.action_SetLocation
<< sep
<< ui.action_Remove
<< ui.action_Delete;
QDesktopServices :: openUrl( QUrl::fromLocalFile( path ) );
}
+void
+TrMainWindow :: copyMagnetLinkToClipboard( )
+{
+ const int id( *getSelectedTorrents().begin() );
+ mySession.copyMagnetLinkToClipboard( id );
+}
+
void
TrMainWindow :: openHelp( )
{
const bool oneSelection( selected == 1 );
ui.action_OpenFolder->setEnabled( oneSelection && mySession.isLocal( ) );
+ ui.action_CopyMagnetToClipboard->setEnabled( oneSelection );
ui.action_SelectAll->setEnabled( selected < rowCount );
ui.action_StartAll->setEnabled( paused > 0 );
void addTorrents( const QStringList& filenames );
void openHelp( );
void openFolder( );
+ void copyMagnetLinkToClipboard( );
void setLocation( );
void openProperties( );
void toggleSpeedMode( );
<x>0</x>
<y>0</y>
<width>792</width>
- <height>25</height>
+ <height>23</height>
</rect>
</property>
<property name="sizePolicy">
<string>&Torrent</string>
</property>
<addaction name="separator"/>
- <addaction name="action_Add"/>
- <addaction name="action_New"/>
- <addaction name="separator"/>
<addaction name="action_Properties"/>
<addaction name="action_OpenFolder"/>
- <addaction name="action_SetLocation"/>
<addaction name="separator"/>
<addaction name="action_Start"/>
<addaction name="action_Announce"/>
<addaction name="action_Pause"/>
+ <addaction name="action_CopyMagnetToClipboard"/>
+ <addaction name="separator"/>
+ <addaction name="action_SetLocation"/>
<addaction name="action_Verify"/>
+ <addaction name="separator"/>
<addaction name="action_Remove"/>
<addaction name="action_Delete"/>
- <addaction name="separator"/>
- <addaction name="action_StartAll"/>
- <addaction name="action_PauseAll"/>
- <addaction name="separator"/>
- <addaction name="action_Quit"/>
</widget>
<widget class="QMenu" name="menuEdit">
<property name="title">
<addaction name="separator"/>
<addaction name="action_ReverseSortOrder"/>
</widget>
- <addaction name="menuTorrent"/>
+ <widget class="QMenu" name="menu_File">
+ <property name="title">
+ <string>&File</string>
+ </property>
+ <addaction name="action_Add"/>
+ <addaction name="action_New"/>
+ <addaction name="separator"/>
+ <addaction name="action_StartAll"/>
+ <addaction name="action_PauseAll"/>
+ <addaction name="separator"/>
+ <addaction name="action_Quit"/>
+ </widget>
+ <addaction name="menu_File"/>
<addaction name="menuEdit"/>
+ <addaction name="menuTorrent"/>
<addaction name="menu_View"/>
<addaction name="menu_Help"/>
</widget>
<string>Set &Location...</string>
</property>
</action>
+ <action name="action_CopyMagnetToClipboard">
+ <property name="text">
+ <string>&Copy Magnet Link to Clipboard</string>
+ </property>
+ </action>
</widget>
<resources>
<include location="application.qrc"/>
#include <QApplication>
#include <QByteArray>
+#include <QClipboard>
#include <QCoreApplication>
#include <QDesktopServices>
#include <QMessageBox>
TAG_BLOCKLIST_UPDATE,
TAG_ADD_TORRENT,
TAG_PORT_TEST,
+ TAG_MAGNET_LINK,
FIRST_UNIQUE_TAG
};
tr_bencFree( &top );
}
+void
+Session :: copyMagnetLinkToClipboard( int torrentId )
+{
+ tr_benc top;
+ tr_bencInitDict( &top, 3 );
+ tr_bencDictAddStr( &top, "method", "torrent-get" );
+ tr_bencDictAddInt( &top, "tag", TAG_MAGNET_LINK );
+ tr_benc * args = tr_bencDictAddDict( &top, "arguments", 2 );
+ tr_bencListAddInt( tr_bencDictAddList( args, "ids", 1 ), torrentId );
+ tr_bencListAddStr( tr_bencDictAddList( args, "fields", 1 ), "magnetLink" );
+
+ exec( &top );
+ tr_bencFree( &top );
+}
+
void
Session :: updatePref( int key )
{
emit portTested( (bool)isOpen );
}
+ case TAG_MAGNET_LINK: {
+ tr_benc * args;
+ tr_benc * torrents;
+ tr_benc * child;
+ const char * str;
+ if( tr_bencDictFindDict( &top, "arguments", &args )
+ && tr_bencDictFindList( args, "torrents", &torrents )
+ && (( child = tr_bencListChild( torrents, 0 )))
+ && tr_bencDictFindStr( child, "magnetLink", &str ) )
+ QApplication::clipboard()->setText( str );
+ break;
+ }
+
case TAG_ADD_TORRENT:
str = "";
if( tr_bencDictFindStr( &top, "result", &str ) && strcmp( str, "success" ) ) {
void setBlocklistSize( int64_t i );
void updateBlocklist( );
void portTest( );
+ void copyMagnetLinkToClipboard( int torrentId );
public: