From: Jordan Lee Date: Sat, 27 Jul 2013 21:58:14 +0000 (+0000) Subject: support qt5 in transmission-qt X-Git-Tag: 2.82~9 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1c7917345903ad153d52d4802e094549b7df0c0f;p=transmission support qt5 in transmission-qt --- diff --git a/qt/README.txt b/qt/README.txt index 0053274a9..b0efa35c8 100644 --- a/qt/README.txt +++ b/qt/README.txt @@ -36,9 +36,9 @@ BUILDING ON OS X BUILDING ON UNIX - 1. Prerequisites: Qt >= 4.6 and its development packages + 1. Prerequisites: Qt >= 5 and its development packages 2. Build Transmission as normal - 3. In the qt/ directory, type "qmake qtr.pro" or "qmake-qt4 qtr.pro" + 3. In the qt/ directory, type "qmake qtr.pro" or "qmake-qt5 qtr.pro" 4. In the qt/ directory, type "make" 5. In the qt/ directory, as root, type "INSTALL_ROOT=/usr make install" (Feel free to replace /usr with /usr/local or /opt or whatever) diff --git a/qt/about.cc b/qt/about.cc index bf9a79ede..43326bc09 100644 --- a/qt/about.cc +++ b/qt/about.cc @@ -37,21 +37,21 @@ AboutDialog :: AboutDialog (QWidget * parent): QVBoxLayout * v = new QVBoxLayout (this); l = new QLabel; - l->setPixmap (QPixmap (QString::fromAscii (":/icons/transmission-48.png"))); + l->setPixmap (QPixmap (QString::fromUtf8 (":/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 (tr ("Transmission %1").arg (QString::fromAscii (LONG_VERSION_STRING))); + l = new QLabel (tr ("Transmission %1").arg (QString::fromUtf8 (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 (QString::fromAscii ("text-align: center")); + l->setStyleSheet (QString::fromUtf8 ("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 (QString::fromAscii ("http://www.transmissionbt.com/")); + l = new QLabel (QString::fromUtf8 ("http://www.transmissionbt.com/")); l->setOpenExternalLinks (true); l->setAlignment (Qt::AlignCenter); v->addWidget (l); @@ -89,7 +89,7 @@ AboutDialog :: showCredits () QMessageBox::about ( this, tr ("Credits"), - QString::fromAscii ("Jordan Lee (Backend; Daemon; GTK+; Qt)\n" + QString::fromUtf8 ("Jordan Lee (Backend; Daemon; GTK+; Qt)\n" "Michell Livingston (OS X)\n")); } diff --git a/qt/add-data.cc b/qt/add-data.cc index 68af961ad..f52cbf795 100644 --- a/qt/add-data.cc +++ b/qt/add-data.cc @@ -43,7 +43,7 @@ AddData :: set( const QString& key ) } else if( Utils::isHexHashcode( key ) ) { - magnet = QString::fromAscii("magnet:?xt=urn:btih:") + key; + magnet = QString::fromUtf8("magnet:?xt=urn:btih:") + key; type = MAGNET; } else diff --git a/qt/app.cc b/qt/app.cc index f6381febb..139a64777 100644 --- a/qt/app.cc +++ b/qt/app.cc @@ -45,9 +45,9 @@ namespace { - 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 QString DBUS_SERVICE = QString::fromUtf8 ("com.transmissionbt.Transmission" ); + const QString DBUS_OBJECT_PATH = QString::fromUtf8 ("/com/transmissionbt/Transmission"); + const QString DBUS_INTERFACE = QString::fromUtf8 ("com.transmissionbt.Transmission" ); const char * MY_READABLE_NAME ("transmission-qt"); @@ -89,7 +89,7 @@ MyApp :: MyApp (int& argc, char ** argv): QApplication (argc, argv), myLastFullUpdateTime (0) { - const QString MY_CONFIG_NAME = QString::fromAscii ("transmission"); + const QString MY_CONFIG_NAME = QString::fromUtf8 ("transmission"); setApplicationName (MY_CONFIG_NAME); @@ -108,7 +108,7 @@ MyApp :: MyApp (int& argc, char ** argv): QList sizes; sizes << 16 << 22 << 24 << 32 << 48 << 64 << 72 << 96 << 128 << 192 << 256; foreach (int size, sizes) - icon.addPixmap (QPixmap (QString::fromAscii (":/icons/transmission-%1.png").arg (size))); + icon.addPixmap (QPixmap (QString::fromUtf8 (":/icons/transmission-%1.png").arg (size))); setWindowIcon (icon); // parse the command-line arguments @@ -464,15 +464,15 @@ MyApp :: raise () bool MyApp :: notify (const QString& title, const QString& body) const { - const QString dbusServiceName = QString::fromAscii ("org.freedesktop.Notifications"); - const QString dbusInterfaceName = QString::fromAscii ("org.freedesktop.Notifications"); - const QString dbusPath = QString::fromAscii ("/org/freedesktop/Notifications"); + const QString dbusServiceName = QString::fromUtf8 ("org.freedesktop.Notifications"); + const QString dbusInterfaceName = QString::fromUtf8 ("org.freedesktop.Notifications"); + const QString dbusPath = QString::fromUtf8 ("/org/freedesktop/Notifications"); - QDBusMessage m = QDBusMessage::createMethodCall (dbusServiceName, dbusPath, dbusInterfaceName, QString::fromAscii ("Notify")); + QDBusMessage m = QDBusMessage::createMethodCall (dbusServiceName, dbusPath, dbusInterfaceName, QString::fromUtf8 ("Notify")); QList args; - args.append (QString::fromAscii ("Transmission")); // app_name + args.append (QString::fromUtf8 ("Transmission")); // app_name args.append (0U); // replaces_id - args.append (QString::fromAscii ("transmission")); // icon + args.append (QString::fromUtf8 ("transmission")); // icon args.append (title); // summary args.append (body); // body args.append (QStringList ()); // actions - unused for plain passive popups @@ -510,7 +510,7 @@ main (int argc, char * argv[]) QDBusMessage request = QDBusMessage::createMethodCall (DBUS_SERVICE, DBUS_OBJECT_PATH, DBUS_INTERFACE, - QString::fromAscii ("AddMetainfo")); + QString::fromUtf8 ("AddMetainfo")); QList arguments; AddData a (addme[i]); switch (a.type) diff --git a/qt/details.cc b/qt/details.cc index 19f01a5b8..3d384c7a8 100644 --- a/qt/details.cc +++ b/qt/details.cc @@ -867,7 +867,7 @@ Details :: refresh () foreach (QChar ch, code) { QString txt; - switch (ch.toAscii ()) + switch (ch.unicode ()) { case 'O': txt = tr ("Optimistic unchoke"); break; case 'D': txt = tr ("Downloading from this peer"); break; diff --git a/qt/favicon.cc b/qt/favicon.cc index 41b6f3f10..6390bea1f 100644 --- a/qt/favicon.cc +++ b/qt/favicon.cc @@ -10,11 +10,11 @@ * $Id$ */ -#include #include #include #include #include +#include #include "favicon.h" @@ -40,7 +40,7 @@ Favicons :: ~Favicons( ) QString Favicons :: getCacheDir( ) { - const QString base = QDesktopServices::storageLocation( QDesktopServices::CacheLocation ); + const QString base = QStandardPaths::writableLocation (QStandardPaths::CacheLocation); return QDir( base ).absoluteFilePath( "favicons" ); } diff --git a/qt/file-tree.cc b/qt/file-tree.cc index d46f83963..62cf870ea 100644 --- a/qt/file-tree.cc +++ b/qt/file-tree.cc @@ -436,7 +436,6 @@ FileTreeModel :: setData (const QModelIndex& index, const QVariant& newname, int if (role == Qt::EditRole) { QString oldpath; - QModelIndex walk = index; FileTreeItem * item = itemFromIndex (index); while (item && !item->name().isEmpty()) @@ -575,9 +574,9 @@ FileTreeModel :: clearSubtree (const QModelIndex& top) void FileTreeModel :: clear () { + beginResetModel (); clearSubtree (QModelIndex()); - - reset (); + endResetModel (); } FileTreeItem * @@ -613,7 +612,7 @@ FileTreeModel :: addFile (int fileIndex, { bool added = false; FileTreeItem * item; - QStringList tokens = filename.split (QChar::fromAscii('/')); + QStringList tokens = filename.split (QChar::fromLatin1('/')); item = findItemForFileIndex (fileIndex); @@ -886,7 +885,7 @@ FileTreeView :: FileTreeView (QWidget * parent, bool isEditable): for (int i=0; isetResizeMode(i, QHeaderView::Interactive); + header()->setSectionResizeMode(i, QHeaderView::Interactive); } connect (this, SIGNAL(clicked(const QModelIndex&)), diff --git a/qt/filterbar.cc b/qt/filterbar.cc index 397cd59fd..483427c2d 100644 --- a/qt/filterbar.cc +++ b/qt/filterbar.cc @@ -10,6 +10,12 @@ * $Id$ */ +#include +#include +#include +#include +#include +#include #include #include diff --git a/qt/freespace-label.cc b/qt/freespace-label.cc index ec98576c3..3a612d3c2 100644 --- a/qt/freespace-label.cc +++ b/qt/freespace-label.cc @@ -73,6 +73,8 @@ FreespaceLabel :: onTimer () void FreespaceLabel :: onSessionExecuted (int64_t tag, const QString& result, struct tr_variant * arguments) { + Q_UNUSED (result); + if (tag != myTag) return; diff --git a/qt/freespace-label.h b/qt/freespace-label.h index d280ed2e8..e79cc9c46 100644 --- a/qt/freespace-label.h +++ b/qt/freespace-label.h @@ -16,7 +16,7 @@ #include #include -#include +#include class Session; diff --git a/qt/mainwin.cc b/qt/mainwin.cc index aa31133e7..cb93aeef2 100644 --- a/qt/mainwin.cc +++ b/qt/mainwin.cc @@ -14,6 +14,10 @@ #include #include +#include +#include +#include +#include #include #include diff --git a/qt/make-dialog.cc b/qt/make-dialog.cc index 6e61566fb..1432a41e7 100644 --- a/qt/make-dialog.cc +++ b/qt/make-dialog.cc @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -342,7 +343,7 @@ MakeDialog :: MakeDialog( Session & session, QWidget * parent ): const QPixmap folderPixmap = folderIcon.pixmap( iconSize ); QPushButton * b = new QPushButton; b->setIcon( folderPixmap ); - b->setStyleSheet( QString::fromAscii( "text-align: left; padding-left: 5; padding-right: 5" ) ); + b->setStyleSheet( QString::fromUtf8( "text-align: left; padding-left: 5; padding-right: 5" ) ); myDestination = QDir::homePath(); b->setText( myDestination ); connect( b, SIGNAL(clicked(bool)), @@ -356,7 +357,7 @@ MakeDialog :: MakeDialog( Session & session, QWidget * parent ): myFolderButton = new QPushButton; myFolderButton->setIcon( folderPixmap ); myFolderButton->setText( tr( "(None)" ) ); - myFolderButton->setStyleSheet( QString::fromAscii( "text-align: left; padding-left: 5; padding-right: 5" ) ); + myFolderButton->setStyleSheet( QString::fromUtf8( "text-align: left; padding-left: 5; padding-right: 5" ) ); connect( myFolderButton, SIGNAL(clicked(bool)), this, SLOT(onFolderClicked(void)) ); hig->addRow( myFolderRadio, myFolderButton ); @@ -371,7 +372,7 @@ MakeDialog :: MakeDialog( Session & session, QWidget * parent ): myFileButton = new QPushButton; myFileButton->setText( tr( "(None)" ) ); myFileButton->setIcon( filePixmap ); - myFileButton->setStyleSheet( QString::fromAscii( "text-align: left; padding-left: 5; padding-right: 5" ) ); + myFileButton->setStyleSheet( QString::fromUtf8( "text-align: left; padding-left: 5; padding-right: 5" ) ); connect( myFileButton, SIGNAL(clicked(bool)), this, SLOT(onFileClicked(void)) ); hig->addRow( myFileRadio, myFileButton ); @@ -384,7 +385,7 @@ MakeDialog :: MakeDialog( Session & session, QWidget * parent ): hig->addSectionTitle( tr( "Properties" ) ); hig->addWideControl( myTrackerEdit = new ShortPlainTextEdit ); - const int height = fontMetrics().size( 0, QString::fromAscii("\n\n\n\n") ).height( ); + const int height = fontMetrics().size( 0, QString::fromUtf8("\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." ) ); diff --git a/qt/options.cc b/qt/options.cc index 9e79826e8..6984ff488 100644 --- a/qt/options.cc +++ b/qt/options.cc @@ -124,7 +124,7 @@ Options :: Options (Session& session, const Prefs& prefs, const AddData& addme, { p = mySourceButton = new QPushButton; p->setIcon (filePixmap); - p->setStyleSheet (QString::fromAscii ("text-align: left; padding-left: 5; padding-right: 5")); + p->setStyleSheet (QString::fromUtf8 ("text-align: left; padding-left: 5; padding-right: 5")); p->installEventFilter (this); w = p; connect (p, SIGNAL (clicked (bool)), this, SLOT (onFilenameClicked ())); @@ -139,7 +139,7 @@ Options :: Options (Session& session, const Prefs& prefs, const AddData& addme, connect (e, SIGNAL(editingFinished()), this, SLOT(onSourceEditingFinished())); } - const int width = fontMetrics.size (0, QString::fromAscii ("This is a pretty long torrent filename indeed.torrent")).width (); + const int width = fontMetrics.size (0, QString::fromUtf8 ("This is a pretty long torrent filename indeed.torrent")).width (); w->setMinimumWidth (width); layout->addWidget (w, row, 1); l->setBuddy (w); diff --git a/qt/prefs-dialog.cc b/qt/prefs-dialog.cc index f41fad414..4474a97bc 100644 --- a/qt/prefs-dialog.cc +++ b/qt/prefs-dialog.cc @@ -21,7 +21,6 @@ #include #include #include -#include #include #include #include @@ -135,7 +134,7 @@ PrefsDialog :: timeEditNew( int key ) { const int minutes( myPrefs.getInt( key ) ); QTimeEdit * e = new QTimeEdit( ); - e->setDisplayFormat( QString::fromAscii( "hh:mm" ) ); + e->setDisplayFormat( QString::fromUtf8( "hh:mm" ) ); e->setProperty( PREF_KEY, key ); e->setTime( QTime().addSecs( minutes * 60 ) ); myWidgets.insert( key, e ); @@ -233,11 +232,11 @@ PrefsDialog :: createSpeedTab( ) QHBoxLayout * h = new QHBoxLayout; h->setSpacing( HIG :: PAD ); QLabel * label = new QLabel; - label->setPixmap( QPixmap( QString::fromAscii( ":/icons/alt-limit-off.png" ) ) ); + label->setPixmap( QPixmap( QString::fromUtf8( ":/icons/alt-limit-off.png" ) ) ); label->setAlignment( Qt::AlignLeft|Qt::AlignVCenter ); h->addWidget( label ); label = new QLabel( tr( "Alternative Speed Limits" ) ); - label->setStyleSheet( QString::fromAscii( "font: bold" ) ); + label->setStyleSheet( QString::fromUtf8( "font: bold" ) ); label->setAlignment( Qt::AlignLeft|Qt::AlignVCenter ); h->addWidget( label ); hig->addSectionTitle( h ); @@ -572,7 +571,7 @@ PrefsDialog :: createDownloadingTab( ) l = checkBoxNew( tr( "Automatically add .torrent files &from:" ), Prefs::DIR_WATCH_ENABLED ); b = myWatchButton = new QPushButton; b->setIcon( folderPixmap ); - b->setStyleSheet( QString::fromAscii( "text-align: left; padding-left: 5; padding-right: 5" ) ); + b->setStyleSheet( QString::fromUtf8( "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(l), b ); @@ -585,7 +584,7 @@ PrefsDialog :: createDownloadingTab( ) b = myDestinationButton = new QPushButton; b->setIcon( folderPixmap ); - b->setStyleSheet( QString::fromAscii( "text-align: left; padding-left: 5; padding-right: 5" ) ); + b->setStyleSheet( QString::fromUtf8( "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 ); @@ -610,7 +609,7 @@ PrefsDialog :: createDownloadingTab( ) l = myIncompleteCheckbox = checkBoxNew( tr( "Keep &incomplete files in:" ), Prefs::INCOMPLETE_DIR_ENABLED ); b = myIncompleteButton = new QPushButton; b->setIcon( folderPixmap ); - b->setStyleSheet( QString::fromAscii( "text-align: left; padding-left: 5; padding-right: 5" ) ); + b->setStyleSheet( QString::fromUtf8( "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(l), b ); @@ -618,7 +617,7 @@ PrefsDialog :: createDownloadingTab( ) 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( QString::fromAscii( "text-align: left; padding-left: 5; padding-right: 5" ) ); + b->setStyleSheet( QString::fromUtf8( "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(l), b ); diff --git a/qt/qtr.pro b/qt/qtr.pro index aaae24441..27dc22b9d 100644 --- a/qt/qtr.pro +++ b/qt/qtr.pro @@ -1,7 +1,7 @@ TARGET = transmission-qt NAME = "Transmission" DESCRIPTION = "Transmission: a fast, easy, and free BitTorrent client" -VERSION = 2.00 +VERSION = 2.81 LICENSE = "GPL" target.path = /bin @@ -11,8 +11,8 @@ unix: INSTALLS += man man.path = /share/man/man1/ man.files = transmission-qt.1 -CONFIG += qt qdbus thread debug link_pkgconfig -QT += network +CONFIG += qt thread debug link_pkgconfig +QT += network dbus widgets PKGCONFIG = fontconfig libcurl openssl libevent TRANSMISSION_TOP = .. diff --git a/qt/session.cc b/qt/session.cc index 092c57904..374ec9c99 100644 --- a/qt/session.cc +++ b/qt/session.cc @@ -690,11 +690,11 @@ Session :: exec (const char * json) { QNetworkRequest request; request.setUrl (myUrl); - request.setRawHeader ("User-Agent", QString (QCoreApplication::instance ()->applicationName () + "/" + LONG_VERSION_STRING).toAscii ()); + request.setRawHeader ("User-Agent", QString (QCoreApplication::instance ()->applicationName () + "/" + LONG_VERSION_STRING).toUtf8 ()); request.setRawHeader ("Content-Type", "application/json; charset=UTF-8"); if (!mySessionId.isEmpty ()) - request.setRawHeader (TR_RPC_SESSION_ID_HEADER, mySessionId.toAscii ()); + request.setRawHeader (TR_RPC_SESSION_ID_HEADER, mySessionId.toUtf8 ()); const QByteArray requestData (json); QNetworkReply * reply = networkAccessManager ()->post (request, requestData); diff --git a/qt/squeezelabel.h b/qt/squeezelabel.h index 3c254702d..b5c0b7b28 100644 --- a/qt/squeezelabel.h +++ b/qt/squeezelabel.h @@ -42,7 +42,7 @@ #ifndef SQUEEZELABEL_H #define SQUEEZELABEL_H -#include +#include class SqueezeLabel : public QLabel { diff --git a/qt/torrent-model.cc b/qt/torrent-model.cc index c99ea833b..fe347ce8e 100644 --- a/qt/torrent-model.cc +++ b/qt/torrent-model.cc @@ -22,11 +22,14 @@ void TorrentModel :: clear( ) { + beginResetModel (); + myIdToRow.clear( ); myIdToTorrent.clear( ); foreach( Torrent * tor, myTorrents ) delete tor; myTorrents.clear( ); - reset( ); + + endResetModel (); } int diff --git a/qt/utils.h b/qt/utils.h index 9af8100f0..6bf739aa2 100644 --- a/qt/utils.h +++ b/qt/utils.h @@ -42,20 +42,20 @@ class Utils: public QObject /// URLs /// - static bool isMagnetLink( const QString& s ) { return s.startsWith( QString::fromAscii( "magnet:?" ) ); } + static bool isMagnetLink( const QString& s ) { return s.startsWith( QString::fromUtf8( "magnet:?" ) ); } static bool isHexHashcode( const QString& s ) { if( s.length() != 40 ) return false; - foreach( QChar ch, s ) if( !isxdigit( ch.toAscii() ) ) return false; + foreach( QChar ch, s ) if( !isxdigit( ch.unicode() ) ) return false; return true; } 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://" ); + static const QString ftp = QString::fromUtf8( "ftp://" ); + static const QString http = QString::fromUtf8( "http://" ); + static const QString https = QString::fromUtf8( "https://" ); return s.startsWith(http) || s.startsWith(https) || s.startsWith(ftp); } diff --git a/qt/watchdir.cc b/qt/watchdir.cc index a7b5aa45f..5f73e69b4 100644 --- a/qt/watchdir.cc +++ b/qt/watchdir.cc @@ -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( QString::fromAscii( inf.hashString ) ) ) + else if( myModel.hasTorrent( QString::fromUtf8( inf.hashString ) ) ) ret = DUPLICATE; else ret = OK; @@ -106,7 +106,7 @@ WatchDir :: watcherActivated( const QString& path ) // try to add any new files which end in .torrent const QSet newFiles( files - myWatchDirFiles ); - const QString torrentSuffix = QString::fromAscii( ".torrent" ); + const QString torrentSuffix = QString::fromUtf8( ".torrent" ); foreach( QString name, newFiles ) { if( name.endsWith( torrentSuffix, Qt::CaseInsensitive ) ) { const QString filename = dir.absoluteFilePath( name );