1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-27 01:57:52 +00:00

(qt) #5219 'QPrintable and non Latin-1 symbols on Ubuntu' -- clean fix by rb07

This commit is contained in:
Jordan Lee 2013-01-17 18:11:55 +00:00
parent 4d627b79c2
commit 9d6db0da15
2 changed files with 17 additions and 16 deletions

View file

@ -41,10 +41,10 @@ Formatter :: initUnits( )
unitStrings[SPEED][GB] = tr( "GB/s" ); unitStrings[SPEED][GB] = tr( "GB/s" );
unitStrings[SPEED][TB] = tr( "TB/s" ); unitStrings[SPEED][TB] = tr( "TB/s" );
tr_formatter_speed_init( speed_K, tr_formatter_speed_init( speed_K,
qPrintable( unitStrings[SPEED][KB] ), unitStrings[SPEED][KB].toUtf8().constData(),
qPrintable( unitStrings[SPEED][MB] ), unitStrings[SPEED][MB].toUtf8().constData(),
qPrintable( unitStrings[SPEED][GB] ), unitStrings[SPEED][GB].toUtf8().constData(),
qPrintable( unitStrings[SPEED][TB] ) ); unitStrings[SPEED][TB].toUtf8().constData() );
size_K = 1000; size_K = 1000;
unitStrings[SIZE][B] = tr( "B" ); unitStrings[SIZE][B] = tr( "B" );
@ -53,10 +53,10 @@ Formatter :: initUnits( )
unitStrings[SIZE][GB] = tr( "GB" ); unitStrings[SIZE][GB] = tr( "GB" );
unitStrings[SIZE][TB] = tr( "TB" ); unitStrings[SIZE][TB] = tr( "TB" );
tr_formatter_size_init( size_K, tr_formatter_size_init( size_K,
qPrintable( unitStrings[SIZE][KB] ), unitStrings[SIZE][KB].toUtf8().constData(),
qPrintable( unitStrings[SIZE][MB] ), unitStrings[SIZE][MB].toUtf8().constData(),
qPrintable( unitStrings[SIZE][GB] ), unitStrings[SIZE][GB].toUtf8().constData(),
qPrintable( unitStrings[SIZE][TB] ) ); unitStrings[SIZE][TB].toUtf8().constData() );
mem_K = 1024; mem_K = 1024;
unitStrings[MEM][B] = tr( "B" ); unitStrings[MEM][B] = tr( "B" );
@ -65,10 +65,10 @@ Formatter :: initUnits( )
unitStrings[MEM][GB] = tr( "GiB" ); unitStrings[MEM][GB] = tr( "GiB" );
unitStrings[MEM][TB] = tr( "TiB" ); unitStrings[MEM][TB] = tr( "TiB" );
tr_formatter_mem_init( mem_K, tr_formatter_mem_init( mem_K,
qPrintable( unitStrings[MEM][KB] ), unitStrings[MEM][KB].toUtf8().constData(),
qPrintable( unitStrings[MEM][MB] ), unitStrings[MEM][MB].toUtf8().constData(),
qPrintable( unitStrings[MEM][GB] ), unitStrings[MEM][GB].toUtf8().constData(),
qPrintable( unitStrings[MEM][TB] ) ); unitStrings[MEM][TB].toUtf8().constData() );
} }
/*** /***
@ -101,7 +101,7 @@ Formatter :: memToString( int64_t bytes )
else { else {
char buf[128]; char buf[128];
tr_formatter_mem_B( buf, bytes, sizeof( buf ) ); tr_formatter_mem_B( buf, bytes, sizeof( buf ) );
return buf; return QString::fromUtf8( buf );
} }
} }
@ -115,7 +115,7 @@ Formatter :: sizeToString( int64_t bytes )
else { else {
char buf[128]; char buf[128];
tr_formatter_size_B( buf, bytes, sizeof( buf ) ); tr_formatter_size_B( buf, bytes, sizeof( buf ) );
return buf; return QString::fromUtf8( buf );
} }
} }
@ -127,7 +127,7 @@ Formatter :: speedToString( const Speed& speed )
else { else {
char buf[128]; char buf[128];
tr_formatter_speed_KBps( buf, speed.KBps( ), sizeof( buf ) ); tr_formatter_speed_KBps( buf, speed.KBps( ), sizeof( buf ) );
return buf; return QString::fromUtf8( buf );
} }
} }

View file

@ -969,12 +969,13 @@ void
Session :: addNewlyCreatedTorrent( const QString& filename, const QString& localPath ) Session :: addNewlyCreatedTorrent( const QString& filename, const QString& localPath )
{ {
const QByteArray b64 = AddData(filename).toBase64(); const QByteArray b64 = AddData(filename).toBase64();
const QByteArray localPathUtf8 = localPath.toUtf8();
tr_variant top, *args; tr_variant top, *args;
tr_variantInitDict( &top, 2 ); tr_variantInitDict( &top, 2 );
tr_variantDictAddStr( &top, TR_KEY_method, "torrent-add" ); tr_variantDictAddStr( &top, TR_KEY_method, "torrent-add" );
args = tr_variantDictAddDict( &top, TR_KEY_arguments, 3 ); args = tr_variantDictAddDict( &top, TR_KEY_arguments, 3 );
tr_variantDictAddStr( args, TR_KEY_download_dir, qPrintable(localPath) ); tr_variantDictAddStr( args, TR_KEY_download_dir, localPathUtf8.constData() );
tr_variantDictAddBool( args, TR_KEY_paused, !myPrefs.getBool( Prefs::START ) ); tr_variantDictAddBool( args, TR_KEY_paused, !myPrefs.getBool( Prefs::START ) );
tr_variantDictAddRaw( args, TR_KEY_metainfo, b64.constData(), b64.size() ); tr_variantDictAddRaw( args, TR_KEY_metainfo, b64.constData(), b64.size() );
exec( &top ); exec( &top );