mirror of
https://github.com/transmission/transmission
synced 2024-12-24 08:43:27 +00:00
(trunk qt) #3863 "accept info hash in 'Add url...' dialog, not just magnet uris" -- added.
This commit is contained in:
parent
7760be2c45
commit
5ccbb741b0
2 changed files with 14 additions and 0 deletions
|
@ -40,6 +40,11 @@ AddData :: set( const QString& key )
|
||||||
metainfo = file.readAll( );
|
metainfo = file.readAll( );
|
||||||
file.close( );
|
file.close( );
|
||||||
}
|
}
|
||||||
|
else if( Utils::isHexHashcode( key ) )
|
||||||
|
{
|
||||||
|
magnet = QString("magnet:?xt=urn:btih:") + key;
|
||||||
|
type = MAGNET;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
|
|
|
@ -17,6 +17,8 @@
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
|
|
||||||
|
#include <cctype> // isxdigit()
|
||||||
|
|
||||||
#include "speed.h"
|
#include "speed.h"
|
||||||
|
|
||||||
class Utils: public QObject
|
class Utils: public QObject
|
||||||
|
@ -40,6 +42,13 @@ class Utils: public QObject
|
||||||
|
|
||||||
static bool isMagnetLink( const QString& s ) { return s.startsWith( "magnet:?" ); }
|
static bool isMagnetLink( const QString& s ) { return s.startsWith( "magnet:?" ); }
|
||||||
|
|
||||||
|
static bool isHexHashcode( const QString& s )
|
||||||
|
{
|
||||||
|
if( s.length() != 40 ) return false;
|
||||||
|
foreach( QChar ch, s ) if( !isxdigit( ch.toAscii() ) ) return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
static bool isURL( const QString& s ) { return s.startsWith( "http://" )
|
static bool isURL( const QString& s ) { return s.startsWith( "http://" )
|
||||||
|| s.startsWith( "https://" )
|
|| s.startsWith( "https://" )
|
||||||
|| s.startsWith( "ftp://" ); }
|
|| s.startsWith( "ftp://" ); }
|
||||||
|
|
Loading…
Reference in a new issue