mirror of
https://github.com/transmission/transmission
synced 2025-03-03 10:15:45 +00:00
(trunk qt) #4428 "Conversion to QString in "New torrent" dialog assumes the input string is ASCII" -- fix many ascii-to-QString assumptions in the code.
This commit is contained in:
parent
7430e474e0
commit
5b53b62773
13 changed files with 116 additions and 94 deletions
14
qt/about.cc
14
qt/about.cc
|
@ -37,21 +37,21 @@ AboutDialog :: AboutDialog( QWidget * parent ):
|
|||
QVBoxLayout * v = new QVBoxLayout( this );
|
||||
|
||||
l = new QLabel;
|
||||
l->setPixmap( QPixmap( ":/icons/transmission-48.png" ) );
|
||||
l->setPixmap( QPixmap( QString::fromAscii( ":/icons/transmission-48.png" ) ) );
|
||||
l->setAlignment( Qt::AlignCenter );
|
||||
v->addWidget( l );
|
||||
|
||||
QFont f( font( ) );
|
||||
f.setWeight( QFont::Bold );
|
||||
f.setPointSize( int( f.pointSize( ) * 1.2 ) );
|
||||
l = new QLabel( "<big>Transmission " LONG_VERSION_STRING "</big>" );
|
||||
l = new QLabel( tr( "<big>Transmission %1</big>" ).arg( QString::fromAscii( LONG_VERSION_STRING ) ) );
|
||||
l->setAlignment( Qt::AlignCenter );
|
||||
l->setFont( f );
|
||||
l->setMargin( 8 );
|
||||
v->addWidget( l );
|
||||
|
||||
l = new QLabel( tr( "A fast and easy BitTorrent client" ) );
|
||||
l->setStyleSheet( "text-align: center" );
|
||||
l->setStyleSheet( QString::fromAscii( "text-align: center" ) );
|
||||
l->setAlignment( Qt::AlignCenter );
|
||||
v->addWidget( l );
|
||||
|
||||
|
@ -59,7 +59,7 @@ AboutDialog :: AboutDialog( QWidget * parent ):
|
|||
l->setAlignment( Qt::AlignCenter );
|
||||
v->addWidget( l );
|
||||
|
||||
l = new QLabel( "<a href=\"http://www.transmissionbt.com/\">http://www.transmissionbt.com/</a>" );
|
||||
l = new QLabel( QString::fromAscii( "<a href=\"http://www.transmissionbt.com/\">http://www.transmissionbt.com/</a>" ) );
|
||||
l->setOpenExternalLinks( true );
|
||||
l->setAlignment( Qt::AlignCenter );
|
||||
v->addWidget( l );
|
||||
|
@ -87,8 +87,8 @@ void
|
|||
AboutDialog :: showCredits( )
|
||||
{
|
||||
QMessageBox::about( this, tr( "Credits" ),
|
||||
"Jordan Lee (Backend; Daemon; GTK+; Qt)\n"
|
||||
"Michell Livingston (Backend; OS X)\n"
|
||||
"Kevin Glowacz (Web client)" );
|
||||
QString::fromAscii( "Jordan Lee (Backend; Daemon; GTK+; Qt)\n"
|
||||
"Michell Livingston (Backend; OS X)\n"
|
||||
"Kevin Glowacz (Web client)" ) );
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ AddData :: set( const QString& key )
|
|||
magnet = key;
|
||||
type = MAGNET;
|
||||
}
|
||||
else if ( Utils::isURL( key ) )
|
||||
else if ( Utils::isUriWithSupportedScheme( key ) )
|
||||
{
|
||||
url = key;
|
||||
type = URL;
|
||||
|
@ -44,7 +44,7 @@ AddData :: set( const QString& key )
|
|||
}
|
||||
else if( Utils::isHexHashcode( key ) )
|
||||
{
|
||||
magnet = QString("magnet:?xt=urn:btih:") + key;
|
||||
magnet = QString::fromAscii("magnet:?xt=urn:btih:") + key;
|
||||
type = MAGNET;
|
||||
}
|
||||
else
|
||||
|
@ -96,7 +96,7 @@ AddData :: readableName( ) const
|
|||
tr_ctor * ctor = tr_ctorNew( NULL );
|
||||
tr_ctorSetMetainfo( ctor, (const uint8_t*)metainfo.constData(), metainfo.size() );
|
||||
if( tr_torrentParse( ctor, &inf ) == TR_PARSE_OK ) {
|
||||
ret = inf.name;
|
||||
ret = QString::fromUtf8( inf.name ); // metainfo is required to be UTF-8
|
||||
tr_metainfoFree( &inf );
|
||||
}
|
||||
tr_ctorFree( ctor );
|
||||
|
|
51
qt/app.cc
51
qt/app.cc
|
@ -45,14 +45,12 @@
|
|||
|
||||
namespace
|
||||
{
|
||||
const char * DBUS_SERVICE ( "com.transmissionbt.Transmission" );
|
||||
const char * DBUS_OBJECT_PATH ( "/com/transmissionbt/Transmission" );
|
||||
const char * DBUS_INTERFACE ( "com.transmissionbt.Transmission" );
|
||||
const QString DBUS_SERVICE = QString::fromAscii( "com.transmissionbt.Transmission" );
|
||||
const QString DBUS_OBJECT_PATH = QString::fromAscii( "/com/transmissionbt/Transmission" );
|
||||
const QString DBUS_INTERFACE = QString::fromAscii( "com.transmissionbt.Transmission" );
|
||||
|
||||
const char * MY_CONFIG_NAME( "transmission" );
|
||||
const char * MY_READABLE_NAME( "transmission-qt" );
|
||||
|
||||
|
||||
const tr_option opts[] =
|
||||
{
|
||||
{ 'g', "config-dir", "Where to look for configuration files", "g", 1, "<path>" },
|
||||
|
@ -91,6 +89,8 @@ MyApp :: MyApp( int& argc, char ** argv ):
|
|||
QApplication( argc, argv ),
|
||||
myLastFullUpdateTime( 0 )
|
||||
{
|
||||
const QString MY_CONFIG_NAME = QString::fromAscii( "transmission" );
|
||||
|
||||
setApplicationName( MY_CONFIG_NAME );
|
||||
|
||||
// install the qt translator
|
||||
|
@ -109,11 +109,10 @@ MyApp :: MyApp( int& argc, char ** argv ):
|
|||
|
||||
// set the default icon
|
||||
QIcon icon;
|
||||
icon.addPixmap( QPixmap( ":/icons/transmission-16.png" ) );
|
||||
icon.addPixmap( QPixmap( ":/icons/transmission-22.png" ) );
|
||||
icon.addPixmap( QPixmap( ":/icons/transmission-24.png" ) );
|
||||
icon.addPixmap( QPixmap( ":/icons/transmission-32.png" ) );
|
||||
icon.addPixmap( QPixmap( ":/icons/transmission-48.png" ) );
|
||||
QList<int> sizes;
|
||||
sizes << 16 << 22 << 24 << 32 << 48;
|
||||
foreach( int size, sizes )
|
||||
icon.addPixmap( QPixmap( QString::fromAscii(":/icons/transmission-%1.png" ).arg(size) ) );
|
||||
setWindowIcon( icon );
|
||||
|
||||
// parse the command-line arguments
|
||||
|
@ -142,7 +141,7 @@ MyApp :: MyApp( int& argc, char ** argv ):
|
|||
|
||||
// set the fallback config dir
|
||||
if( configDir == 0 )
|
||||
configDir = tr_getDefaultConfigDir( MY_CONFIG_NAME );
|
||||
configDir = tr_getDefaultConfigDir( "transmission" );
|
||||
|
||||
// ensure our config directory exists
|
||||
QDir dir( configDir );
|
||||
|
@ -249,9 +248,9 @@ MyApp :: MyApp( int& argc, char ** argv ):
|
|||
new TrDBusAdaptor( this );
|
||||
QDBusConnection bus = QDBusConnection::sessionBus();
|
||||
if( !bus.registerService( DBUS_SERVICE ) )
|
||||
std::cerr << "couldn't register " << DBUS_SERVICE << std::endl;
|
||||
std::cerr << "couldn't register " << qPrintable(DBUS_SERVICE) << std::endl;
|
||||
if( !bus.registerObject( DBUS_OBJECT_PATH, this ) )
|
||||
std::cerr << "couldn't register " << DBUS_OBJECT_PATH << std::endl;
|
||||
std::cerr << "couldn't register " << qPrintable(DBUS_OBJECT_PATH) << std::endl;
|
||||
}
|
||||
|
||||
/* these functions are for popping up desktop notifications */
|
||||
|
@ -443,20 +442,20 @@ MyApp :: raise( )
|
|||
bool
|
||||
MyApp :: notify( const QString& title, const QString& body ) const
|
||||
{
|
||||
const QString dbusServiceName = "org.freedesktop.Notifications";
|
||||
const QString dbusInterfaceName = "org.freedesktop.Notifications";
|
||||
const QString dbusPath = "/org/freedesktop/Notifications";
|
||||
const QString dbusServiceName = QString::fromAscii( "org.freedesktop.Notifications" );
|
||||
const QString dbusInterfaceName = QString::fromAscii( "org.freedesktop.Notifications" );
|
||||
const QString dbusPath = QString::fromAscii( "/org/freedesktop/Notifications" );
|
||||
|
||||
QDBusMessage m = QDBusMessage::createMethodCall(dbusServiceName, dbusPath, dbusInterfaceName, "Notify");
|
||||
QDBusMessage m = QDBusMessage::createMethodCall(dbusServiceName, dbusPath, dbusInterfaceName, QString::fromAscii("Notify"));
|
||||
QList<QVariant> args;
|
||||
args.append( "Transmission" ); // app_name
|
||||
args.append( 0U ); // replaces_id
|
||||
args.append( "transmission" ); // icon
|
||||
args.append( title ); // summary
|
||||
args.append( body ); // body
|
||||
args.append( QStringList( ) ); // actions - unused for plain passive popups
|
||||
args.append( QVariantMap( ) ); // hints - unused atm
|
||||
args.append( int32_t(-1) ); // use the default timeout period
|
||||
args.append( QString::fromAscii( "Transmission" ) ); // app_name
|
||||
args.append( 0U ); // replaces_id
|
||||
args.append( QString::fromAscii( "transmission" ) ); // icon
|
||||
args.append( title ); // summary
|
||||
args.append( body ); // body
|
||||
args.append( QStringList( ) ); // actions - unused for plain passive popups
|
||||
args.append( QVariantMap( ) ); // hints - unused atm
|
||||
args.append( int32_t(-1) ); // use the default timeout period
|
||||
m.setArguments( args );
|
||||
QDBusMessage replyMsg = QDBusConnection::sessionBus().call(m);
|
||||
//std::cerr << qPrintable(replyMsg.errorName()) << std::endl;
|
||||
|
@ -489,7 +488,7 @@ main( int argc, char * argv[] )
|
|||
QDBusMessage request = QDBusMessage::createMethodCall( DBUS_SERVICE,
|
||||
DBUS_OBJECT_PATH,
|
||||
DBUS_INTERFACE,
|
||||
"AddMetainfo" );
|
||||
QString::fromAscii("AddMetainfo") );
|
||||
QList<QVariant> arguments;
|
||||
AddData a( addme[i] );
|
||||
switch( a.type ) {
|
||||
|
|
|
@ -420,7 +420,7 @@ FileTreeModel :: addFile( int index,
|
|||
{
|
||||
FileTreeItem * i( rootItem );
|
||||
|
||||
foreach( QString token, filename.split( "/" ) )
|
||||
foreach( QString token, filename.split( QChar::fromAscii('/') ) )
|
||||
{
|
||||
FileTreeItem * child( i->child( token ) );
|
||||
if( !child )
|
||||
|
|
|
@ -56,10 +56,12 @@ MakeDialog :: onNewButtonBoxClicked( QAbstractButton * button )
|
|||
{
|
||||
switch( myNewButtonBox->standardButton( button ) )
|
||||
{
|
||||
case QDialogButtonBox::Open:
|
||||
std::cerr << "calling mySession.addTorrent( " << qPrintable(myTarget) << ", " << qPrintable(QFileInfo(myBuilder->top).dir().path()) << ')' << std::endl;
|
||||
mySession.addNewlyCreatedTorrent( myTarget, QFileInfo(myBuilder->top).dir().path() );
|
||||
case QDialogButtonBox::Open: {
|
||||
const QString top = QString::fromLocal8Bit( myBuilder->top );
|
||||
std::cerr << "calling mySession.addTorrent( " << qPrintable(myTarget) << ", " << qPrintable(QFileInfo(top).dir().path()) << ')' << std::endl;
|
||||
mySession.addNewlyCreatedTorrent( myTarget, QFileInfo(top).dir().path() );
|
||||
break;
|
||||
}
|
||||
case QDialogButtonBox::Abort:
|
||||
myBuilder->abortFlag = true;
|
||||
break;
|
||||
|
@ -79,20 +81,21 @@ MakeDialog :: onProgress( )
|
|||
myNewProgress->setValue( (int) ((100.0 * b->pieceIndex) / denom ) );
|
||||
|
||||
// progress label
|
||||
const QString base( QFileInfo(b->top).baseName() );
|
||||
const QString top = QString::fromLocal8Bit( myBuilder->top );
|
||||
const QString base( QFileInfo(top).baseName() );
|
||||
QString str;
|
||||
if( !b->isDone )
|
||||
str = tr( "Creating \"%1\"" ).arg( base );
|
||||
else if( b->result == TR_MAKEMETA_OK )
|
||||
str = tr( "Created \"%1\"!" ).arg( base );
|
||||
else if( b->result == TR_MAKEMETA_URL )
|
||||
str = tr( "Error: invalid announce URL \"%1\"" ).arg( b->errfile );
|
||||
str = tr( "Error: invalid announce URL \"%1\"" ).arg( QString::fromLocal8Bit( b->errfile ) );
|
||||
else if( b->result == TR_MAKEMETA_CANCELLED )
|
||||
str = tr( "Cancelled" );
|
||||
else if( b->result == TR_MAKEMETA_IO_READ )
|
||||
str = tr( "Error reading \"%1\": %2" ).arg( b->errfile ).arg( strerror(b->my_errno) );
|
||||
str = tr( "Error reading \"%1\": %2" ).arg( QString::fromLocal8Bit(b->errfile) ).arg( QString::fromLocal8Bit(strerror(b->my_errno)) );
|
||||
else if( b->result == TR_MAKEMETA_IO_WRITE )
|
||||
str = tr( "Error writing \"%1\": %2" ).arg( b->errfile ).arg( strerror(b->my_errno) );
|
||||
str = tr( "Error writing \"%1\": %2" ).arg( QString::fromLocal8Bit(b->errfile) ).arg( QString::fromLocal8Bit(strerror(b->my_errno)) );
|
||||
myNewLabel->setText( str );
|
||||
|
||||
// buttons
|
||||
|
@ -111,7 +114,7 @@ MakeDialog :: makeTorrent( )
|
|||
// get the tiers
|
||||
int tier = 0;
|
||||
QList<tr_tracker_info> trackers;
|
||||
foreach( QString line, myTrackerEdit->toPlainText().split("\n") ) {
|
||||
foreach( QString line, myTrackerEdit->toPlainText().split(QChar::fromAscii('\n')) ) {
|
||||
line = line.trimmed( );
|
||||
if( line.isEmpty( ) )
|
||||
++tier;
|
||||
|
@ -144,13 +147,15 @@ MakeDialog :: makeTorrent( )
|
|||
myTimer.start( 100 );
|
||||
|
||||
// the file to create
|
||||
myTarget = QDir( myDestination ).filePath( QFileInfo(myBuilder->top).baseName() + ".torrent" );
|
||||
const QString path = QString::fromLocal8Bit( myBuilder->top );
|
||||
const QString torrentName = QFileInfo(path).baseName() + QString::fromAscii(".torrent");
|
||||
myTarget = QDir( myDestination ).filePath( torrentName );
|
||||
std::cerr << qPrintable(myTarget) << std::endl;
|
||||
|
||||
// comment
|
||||
QString comment;
|
||||
if( myCommentCheck->isChecked() )
|
||||
comment = myCommentEdit->text().toUtf8().constData();
|
||||
comment = myCommentEdit->text();
|
||||
|
||||
// start making the torrent
|
||||
tr_makeMetaInfo( myBuilder,
|
||||
|
@ -333,7 +338,7 @@ MakeDialog :: MakeDialog( Session & session, QWidget * parent ):
|
|||
const QPixmap folderPixmap = folderIcon.pixmap( iconSize );
|
||||
QPushButton * b = new QPushButton;
|
||||
b->setIcon( folderPixmap );
|
||||
b->setStyleSheet( "text-align: left; padding-left: 5; padding-right: 5" );
|
||||
b->setStyleSheet( QString::fromAscii( "text-align: left; padding-left: 5; padding-right: 5" ) );
|
||||
myDestination = QDir::homePath();
|
||||
b->setText( myDestination );
|
||||
connect( b, SIGNAL(clicked(bool)),
|
||||
|
@ -347,7 +352,7 @@ MakeDialog :: MakeDialog( Session & session, QWidget * parent ):
|
|||
myFolderButton = new QPushButton;
|
||||
myFolderButton->setIcon( folderPixmap );
|
||||
myFolderButton->setText( tr( "(None)" ) );
|
||||
myFolderButton->setStyleSheet( "text-align: left; padding-left: 5; padding-right: 5" );
|
||||
myFolderButton->setStyleSheet( QString::fromAscii( "text-align: left; padding-left: 5; padding-right: 5" ) );
|
||||
connect( myFolderButton, SIGNAL(clicked(bool)),
|
||||
this, SLOT(onFolderClicked(void)) );
|
||||
hig->addRow( myFolderRadio, myFolderButton );
|
||||
|
@ -362,7 +367,7 @@ MakeDialog :: MakeDialog( Session & session, QWidget * parent ):
|
|||
myFileButton = new QPushButton;
|
||||
myFileButton->setText( tr( "(None)" ) );
|
||||
myFileButton->setIcon( filePixmap );
|
||||
myFileButton->setStyleSheet( "text-align: left; padding-left: 5; padding-right: 5" );
|
||||
myFileButton->setStyleSheet( QString::fromAscii( "text-align: left; padding-left: 5; padding-right: 5" ) );
|
||||
connect( myFileButton, SIGNAL(clicked(bool)),
|
||||
this, SLOT(onFileClicked(void)) );
|
||||
hig->addRow( myFileRadio, myFileButton );
|
||||
|
@ -375,7 +380,7 @@ MakeDialog :: MakeDialog( Session & session, QWidget * parent ):
|
|||
hig->addSectionTitle( tr( "Properties" ) );
|
||||
|
||||
hig->addWideControl( myTrackerEdit = new ShortPlainTextEdit );
|
||||
const int height = fontMetrics().size( 0, "\n\n\n\n" ).height( );
|
||||
const int height = fontMetrics().size( 0, QString::fromAscii("\n\n\n\n") ).height( );
|
||||
myTrackerEdit->setMinimumHeight( height );
|
||||
hig->addTallRow( tr( "&Trackers:" ), myTrackerEdit );
|
||||
QLabel * l = new QLabel( tr( "To add a backup URL, add it on the line after the primary URL.\nTo add another primary URL, add it after a blank line." ) );
|
||||
|
|
|
@ -97,13 +97,13 @@ Options :: Options( Session& session, const Prefs& prefs, const AddData& addme,
|
|||
const QPixmap filePixmap = fileIcon.pixmap( iconSize );
|
||||
|
||||
QPushButton * p;
|
||||
int width = fontMetrics.size( 0, "This is a pretty long torrent filename indeed.torrent" ).width( );
|
||||
int width = fontMetrics.size( 0, QString::fromAscii( "This is a pretty long torrent filename indeed.torrent" ) ).width( );
|
||||
QLabel * l = new QLabel( tr( "&Torrent file:" ) );
|
||||
layout->addWidget( l, row, 0, Qt::AlignLeft );
|
||||
p = myFileButton = new QPushButton;
|
||||
p->setIcon( filePixmap );
|
||||
p->setMinimumWidth( width );
|
||||
p->setStyleSheet( "text-align: left; padding-left: 5; padding-right: 5" );
|
||||
p->setStyleSheet( QString::fromAscii( "text-align: left; padding-left: 5; padding-right: 5" ) );
|
||||
p->installEventFilter( this );
|
||||
|
||||
layout->addWidget( p, row, 1 );
|
||||
|
|
|
@ -134,7 +134,7 @@ PrefsDialog :: timeEditNew( int key )
|
|||
{
|
||||
const int minutes( myPrefs.getInt( key ) );
|
||||
QTimeEdit * e = new QTimeEdit( );
|
||||
e->setDisplayFormat( "hh:mm" );
|
||||
e->setDisplayFormat( QString::fromAscii( "hh:mm" ) );
|
||||
e->setProperty( PREF_KEY, key );
|
||||
e->setTime( QTime().addSecs( minutes * 60 ) );
|
||||
myWidgets.insert( key, e );
|
||||
|
@ -232,11 +232,11 @@ PrefsDialog :: createSpeedTab( )
|
|||
QHBoxLayout * h = new QHBoxLayout;
|
||||
h->setSpacing( HIG :: PAD );
|
||||
QLabel * label = new QLabel;
|
||||
label->setPixmap( QPixmap( ":/icons/alt-limit-off.png" ) );
|
||||
label->setPixmap( QPixmap( QString::fromAscii( ":/icons/alt-limit-off.png" ) ) );
|
||||
label->setAlignment( Qt::AlignLeft|Qt::AlignVCenter );
|
||||
h->addWidget( label );
|
||||
label = new QLabel( tr( "Temporary Speed Limits" ) );
|
||||
label->setStyleSheet( "font: bold" );
|
||||
label->setStyleSheet( QString::fromAscii( "font: bold" ) );
|
||||
label->setAlignment( Qt::AlignLeft|Qt::AlignVCenter );
|
||||
h->addWidget( label );
|
||||
hig->addSectionTitle( h );
|
||||
|
@ -346,7 +346,7 @@ PrefsDialog :: createNetworkTab( )
|
|||
connect( &mySession, SIGNAL(portTested(bool)), this, SLOT(onPortTested(bool)));
|
||||
|
||||
hig->addRow( tr( "&Port for incoming connections:" ), s );
|
||||
hig->addRow( "", h, 0 );
|
||||
hig->addRow( QString(), h, 0 );
|
||||
hig->addWideControl( checkBoxNew( tr( "Pick a &random port every time Transmission is started" ), Prefs :: PEER_PORT_RANDOM_ON_START ) );
|
||||
hig->addWideControl( checkBoxNew( tr( "Use UPnP or NAT-PMP port &forwarding from my router" ), Prefs::PORT_FORWARDING ) );
|
||||
|
||||
|
@ -396,7 +396,7 @@ void
|
|||
PrefsDialog :: onUpdateBlocklistClicked( )
|
||||
{
|
||||
myBlocklistDialog = new QMessageBox( QMessageBox::Information,
|
||||
"",
|
||||
QString(),
|
||||
tr( "<b>Update Blocklist</b><p>Getting new blocklist..." ),
|
||||
QMessageBox::Close,
|
||||
this );
|
||||
|
@ -426,7 +426,7 @@ PrefsDialog :: createPrivacyTab( )
|
|||
myBlockWidgets << e;
|
||||
hig->addRow( l, e );
|
||||
|
||||
l = myBlocklistLabel = new QLabel( "" );
|
||||
l = myBlocklistLabel = new QLabel( );
|
||||
myBlockWidgets << l;
|
||||
w = new QPushButton( tr( "&Update" ) );
|
||||
connect( w, SIGNAL(clicked(bool)), this, SLOT(onUpdateBlocklistClicked()));
|
||||
|
@ -539,7 +539,7 @@ PrefsDialog :: createTorrentsTab( )
|
|||
l = checkBoxNew( tr( "Automatically &add torrents from:" ), Prefs::DIR_WATCH_ENABLED );
|
||||
QPushButton * b = myWatchButton = new QPushButton;
|
||||
b->setIcon( folderPixmap );
|
||||
b->setStyleSheet( "text-align: left; padding-left: 5; padding-right: 5" );
|
||||
b->setStyleSheet( QString::fromAscii( "text-align: left; padding-left: 5; padding-right: 5" ) );
|
||||
connect( b, SIGNAL(clicked(bool)), this, SLOT(onWatchClicked(void)) );
|
||||
hig->addRow( l, b );
|
||||
enableBuddyWhenChecked( qobject_cast<QCheckBox*>(l), b );
|
||||
|
@ -577,7 +577,7 @@ PrefsDialog :: createDownloadTab( )
|
|||
|
||||
QPushButton * b = myDestinationButton = new QPushButton;
|
||||
b->setIcon( folderPixmap );
|
||||
b->setStyleSheet( "text-align: left; padding-left: 5; padding-right: 5" );
|
||||
b->setStyleSheet( QString::fromAscii( "text-align: left; padding-left: 5; padding-right: 5" ) );
|
||||
connect( b, SIGNAL(clicked(bool)), this, SLOT(onDestinationClicked(void)) );
|
||||
hig->addRow( tr( "Save to &Location:" ), b );
|
||||
|
||||
|
@ -595,7 +595,7 @@ PrefsDialog :: createDownloadTab( )
|
|||
l = myIncompleteCheckbox = checkBoxNew( tr( "Keep &incomplete files in:" ), Prefs::INCOMPLETE_DIR_ENABLED );
|
||||
b = myIncompleteButton = new QPushButton;
|
||||
b->setIcon( folderPixmap );
|
||||
b->setStyleSheet( "text-align: left; padding-left: 5; padding-right: 5" );
|
||||
b->setStyleSheet( QString::fromAscii( "text-align: left; padding-left: 5; padding-right: 5" ) );
|
||||
connect( b, SIGNAL(clicked(bool)), this, SLOT(onIncompleteClicked(void)) );
|
||||
hig->addRow( myIncompleteCheckbox, b );
|
||||
enableBuddyWhenChecked( qobject_cast<QCheckBox*>(l), b );
|
||||
|
@ -603,7 +603,7 @@ PrefsDialog :: createDownloadTab( )
|
|||
l = myTorrentDoneScriptCheckbox = checkBoxNew( tr( "Call scrip&t when torrent is completed:" ), Prefs::SCRIPT_TORRENT_DONE_ENABLED );
|
||||
b = myTorrentDoneScriptButton = new QPushButton;
|
||||
b->setIcon( filePixmap );
|
||||
b->setStyleSheet( "text-align: left; padding-left: 5; padding-right: 5" );
|
||||
b->setStyleSheet( QString::fromAscii( "text-align: left; padding-left: 5; padding-right: 5" ) );
|
||||
connect( b, SIGNAL(clicked(bool)), this, SLOT(onScriptClicked(void)) );
|
||||
hig->addRow( myTorrentDoneScriptCheckbox, b );
|
||||
enableBuddyWhenChecked( qobject_cast<QCheckBox*>(l), b );
|
||||
|
|
|
@ -84,7 +84,7 @@ RelocateDialog :: RelocateDialog( Session& session, TorrentModel& model, const Q
|
|||
if( mySession.isServer() )
|
||||
myPath = QDir::homePath( );
|
||||
else
|
||||
myPath = QString( "/" );
|
||||
myPath = QDir::rootPath( );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -246,7 +246,7 @@ TorrentDelegate :: statusString( const Torrent& tor ) const
|
|||
break;
|
||||
|
||||
default:
|
||||
str = "Error";
|
||||
str = tr( "Error" );
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -564,7 +564,7 @@ Torrent :: update( tr_benc * d )
|
|||
tr_benc * child;
|
||||
while(( child = tr_bencListChild( trackers, i++ ))) {
|
||||
if( tr_bencDictFindStr( child, "announce", &str )) {
|
||||
dynamic_cast<MyApp*>(QApplication::instance())->favicons.add( QUrl(str) );
|
||||
dynamic_cast<MyApp*>(QApplication::instance())->favicons.add( QUrl(QString::fromUtf8(str)) );
|
||||
list.append( QString::fromUtf8( str ) );
|
||||
}
|
||||
}
|
||||
|
@ -605,7 +605,7 @@ Torrent :: update( tr_benc * d )
|
|||
if( tr_bencDictFindInt( child, "lastAnnouncePeerCount", &i ) )
|
||||
trackerStat.lastAnnouncePeerCount = i;
|
||||
if( tr_bencDictFindStr( child, "lastAnnounceResult", &str ) )
|
||||
trackerStat.lastAnnounceResult = str;
|
||||
trackerStat.lastAnnounceResult = QString::fromUtf8(str);
|
||||
if( tr_bencDictFindInt( child, "lastAnnounceStartTime", &i ) )
|
||||
trackerStat.lastAnnounceStartTime = i;
|
||||
if( tr_bencDictFindBool( child, "lastAnnounceSucceeded", &b ) )
|
||||
|
|
55
qt/utils.cc
55
qt/utils.cc
|
@ -67,33 +67,46 @@ Utils :: guessMimeIcon( const QString& filename )
|
|||
{
|
||||
fallback = QApplication::style()->standardIcon( QStyle :: SP_FileIcon );
|
||||
|
||||
fileIcons[DISK]= QIcon::fromTheme( "media-optical", fallback );
|
||||
suffixes[DISK] << "iso";
|
||||
suffixes[DISK] << QString::fromAscii("iso");
|
||||
fileIcons[DISK]= QIcon::fromTheme( QString::fromAscii("media-optical"), fallback );
|
||||
|
||||
fileIcons[DOCUMENT] = QIcon::fromTheme( "text-x-generic", fallback );
|
||||
suffixes[DOCUMENT] << "abw" << "csv" << "doc" << "dvi" << "htm" << "html" << "ini" << "log"
|
||||
<< "odp" << "ods" << "odt" << "pdf" << "ppt" << "ps" << "rtf" << "tex"
|
||||
<< "txt" << "xml";
|
||||
const char * doc_types[] = {
|
||||
"abw", "csv", "doc", "dvi", "htm", "html", "ini", "log", "odp",
|
||||
"ods", "odt", "pdf", "ppt", "ps", "rtf", "tex", "txt", "xml" };
|
||||
for( int i=0, n=sizeof(doc_types)/sizeof(doc_types[0]); i<n; ++i )
|
||||
suffixes[DOCUMENT] << QString::fromAscii(doc_types[i] );
|
||||
fileIcons[DOCUMENT] = QIcon::fromTheme( QString::fromAscii("text-x-generic"), fallback );
|
||||
|
||||
fileIcons[PICTURE] = QIcon::fromTheme( "image-x-generic", fallback );
|
||||
suffixes[PICTURE] << "bmp" << "gif" << "jpg" << "jpeg" << "pcx" << "png" << "psd" << "raw"
|
||||
<< "tga" << "tiff";
|
||||
const char * pic_types[] = {
|
||||
"bmp", "gif", "jpg", "jpeg", "pcx", "png", "psd", "ras", "tga", "tiff" };
|
||||
for( int i=0, n=sizeof(pic_types)/sizeof(pic_types[0]); i<n; ++i )
|
||||
suffixes[PICTURE] << QString::fromAscii(pic_types[i]);
|
||||
fileIcons[PICTURE] = QIcon::fromTheme( QString::fromAscii("image-x-generic"), fallback );
|
||||
|
||||
fileIcons[VIDEO] = QIcon::fromTheme( "video-x-generic", fallback );
|
||||
suffixes[VIDEO] << "3gp" << "asf" << "avi" << "mov" << "mpeg" << "mpg" << "mp4" << "mkv"
|
||||
<< "mov" << "ogm" << "ogv" << "qt" << "rm" << "wmv";
|
||||
const char * vid_types[] = {
|
||||
"3gp", "asf", "avi", "mov", "mpeg", "mpg", "mp4" "mkv", "mov",
|
||||
"ogm", "ogv", "qt", "rm", "wmv" };
|
||||
for( int i=0, n=sizeof(vid_types)/sizeof(vid_types[0]); i<n; ++i )
|
||||
suffixes[VIDEO] << QString::fromAscii(vid_types[i]);
|
||||
fileIcons[VIDEO] = QIcon::fromTheme( QString::fromAscii("video-x-generic"), fallback );
|
||||
|
||||
fileIcons[ARCHIVE] = QIcon::fromTheme( "package-x-generic", fallback );
|
||||
suffixes[ARCHIVE] << "7z" << "ace" << "bz2" << "cbz" << "gz" << "gzip" << "lzma" << "rar"
|
||||
<< "sft" << "tar" << "zip";
|
||||
const char * arc_types[] = {
|
||||
"7z", "ace", "bz2", "cbz", "gz", "gzip", "lzma", "rar", "sft", "tar", "zip" };
|
||||
for( int i=0, n=sizeof(arc_types)/sizeof(arc_types[0]); i<n; ++i )
|
||||
suffixes[VIDEO] << QString::fromAscii(arc_types[i]);
|
||||
fileIcons[ARCHIVE] = QIcon::fromTheme( QString::fromAscii("package-x-generic"), fallback );
|
||||
|
||||
fileIcons[AUDIO] = QIcon::fromTheme( "audio-x-generic", fallback );
|
||||
suffixes[AUDIO] << "aac" << "ac3" << "aiff" << "ape" << "au" << "flac" << "m3u" << "m4a"
|
||||
<< "mid" << "midi" << "mp2" << "mp3" << "mpc" << "nsf" << "oga" << "ogg"
|
||||
<< "ra" << "ram" << "shn" << "voc" << "wav" << "wma";
|
||||
const char * aud_types[] = {
|
||||
"aac", "ac3", "aiff", "ape", "au", "flac", "m3u", "m4a", "mid", "midi", "mp2",
|
||||
"mp3", "mpc", "nsf", "oga", "ogg", "ra", "ram", "shn", "voc", "wav", "wma" };
|
||||
for( int i=0, n=sizeof(aud_types)/sizeof(aud_types[0]); i<n; ++i )
|
||||
suffixes[AUDIO] << QString::fromAscii(aud_types[i]);
|
||||
fileIcons[AUDIO] = QIcon::fromTheme( QString::fromAscii("audio-x-generic"), fallback );
|
||||
|
||||
fileIcons[APP] = QIcon::fromTheme( "application-x-executable", fallback );
|
||||
suffixes[APP] << "bat" << "cmd" << "com" << "exe";
|
||||
const char * exe_types[] = { "bat", "cmd", "com", "exe" };
|
||||
for( int i=0, n=sizeof(exe_types)/sizeof(exe_types[0]); i<n; ++i )
|
||||
suffixes[APP] << QString::fromAscii(exe_types[i]);
|
||||
fileIcons[APP] = QIcon::fromTheme( QString::fromAscii("application-x-executable"), fallback );
|
||||
}
|
||||
|
||||
QString suffix( QFileInfo( filename ).suffix( ).toLower( ) );
|
||||
|
|
12
qt/utils.h
12
qt/utils.h
|
@ -40,7 +40,7 @@ class Utils: public QObject
|
|||
/// URLs
|
||||
///
|
||||
|
||||
static bool isMagnetLink( const QString& s ) { return s.startsWith( "magnet:?" ); }
|
||||
static bool isMagnetLink( const QString& s ) { return s.startsWith( QString::fromAscii( "magnet:?" ) ); }
|
||||
|
||||
static bool isHexHashcode( const QString& s )
|
||||
{
|
||||
|
@ -49,9 +49,13 @@ class Utils: public QObject
|
|||
return true;
|
||||
}
|
||||
|
||||
static bool isURL( const QString& s ) { return s.startsWith( "http://" )
|
||||
|| s.startsWith( "https://" )
|
||||
|| s.startsWith( "ftp://" ); }
|
||||
static bool isUriWithSupportedScheme( const QString& s )
|
||||
{
|
||||
static const QString ftp = QString::fromAscii( "ftp://" );
|
||||
static const QString http = QString::fromAscii( "http://" );
|
||||
static const QString https = QString::fromAscii( "https://" );
|
||||
return s.startsWith(http) || s.startsWith(https) || s.startsWith(ftp);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ WatchDir :: metainfoTest( const QString& filename ) const
|
|||
const int err = tr_torrentParse( ctor, &inf );
|
||||
if( err )
|
||||
ret = ERROR;
|
||||
else if( myModel.hasTorrent( inf.hashString ) )
|
||||
else if( myModel.hasTorrent( QString::fromAscii( inf.hashString ) ) )
|
||||
ret = DUPLICATE;
|
||||
else
|
||||
ret = OK;
|
||||
|
@ -106,8 +106,9 @@ WatchDir :: watcherActivated( const QString& path )
|
|||
|
||||
// try to add any new files which end in .torrent
|
||||
const QSet<QString> newFiles( files - myWatchDirFiles );
|
||||
const QString torrentSuffix = QString::fromAscii( ".torrent" );
|
||||
foreach( QString name, newFiles ) {
|
||||
if( name.endsWith( ".torrent", Qt::CaseInsensitive ) ) {
|
||||
if( name.endsWith( torrentSuffix, Qt::CaseInsensitive ) ) {
|
||||
const QString filename = dir.absoluteFilePath( name );
|
||||
switch( metainfoTest( filename ) ) {
|
||||
case OK:
|
||||
|
|
Loading…
Reference in a new issue