1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2025-03-10 06:02:57 +00:00

Define QT_NO_CAST_FROM_ASCII (Qt client)

Use latin1 encoding most of the time where default encoding was used
before. Qt 4 assumes latin1 by default while Qt 5 uses utf-8 which is
not what we want.

Use utf-8 encoding in some places where default encoding was used before.
This includes strings coming from RPC.

Fix an issue with SortMode::names[] (filters.cc) where missing comma
between "sort-by-queue" and "sort-by-ratio" resulted in two array entries
being merged into solid "sort-by-queuesort-by-ratio" string and all the
following items being shifted compared to their enum counterparts.
This commit is contained in:
Mike Gelfand 2015-01-29 21:53:05 +00:00
parent ae72695d0c
commit d96ef13a89
22 changed files with 165 additions and 159 deletions

View file

@ -164,6 +164,7 @@ include_directories(
add_definitions(
"-DTRANSLATIONS_DIR=\"${CMAKE_INSTALL_FULL_DATADIR}/${TR_NAME}/translations\""
-DQT_NO_CAST_FROM_ASCII
)
add_executable(${TR_NAME}-qt WIN32

View file

@ -106,18 +106,18 @@ MyApp::MyApp (int& argc, char ** argv):
if (loadTranslation (qtTranslator, QLatin1String ("qt"), localeName, QStringList ()
<< QLibraryInfo::location (QLibraryInfo::TranslationsPath)
#ifdef TRANSLATIONS_DIR
<< TRANSLATIONS_DIR
<< QString::fromUtf8 (TRANSLATIONS_DIR)
#endif
<< (applicationDirPath () + "/translations")
<< (applicationDirPath () + QLatin1String ("/translations"))
))
installTranslator (&qtTranslator);
// install the transmission translator
if (loadTranslation (appTranslator, MY_CONFIG_NAME, localeName, QStringList ()
#ifdef TRANSLATIONS_DIR
<< TRANSLATIONS_DIR
<< QString::fromUtf8 (TRANSLATIONS_DIR)
#endif
<< (applicationDirPath () + "/translations")
<< (applicationDirPath () + QLatin1String ("/translations"))
))
installTranslator (&appTranslator);
@ -125,17 +125,17 @@ MyApp::MyApp (int& argc, char ** argv):
#if defined (_WIN32) || defined (__APPLE__)
if (QIcon::themeName ().isEmpty ())
QIcon::setThemeName ("Faenza");
QIcon::setThemeName (QLatin1String ("Faenza"));
#endif
// set the default icon
QIcon icon = QIcon::fromTheme ("transmission");
QIcon icon = QIcon::fromTheme (QLatin1String ("transmission"));
if (icon.isNull ())
{
QList<int> sizes;
sizes << 16 << 22 << 24 << 32 << 48 << 64 << 72 << 96 << 128 << 192 << 256;
foreach (int size, sizes)
icon.addPixmap (QPixmap (QString::fromUtf8 (":/icons/transmission-%1.png").arg (size)));
icon.addPixmap (QPixmap (QString::fromLatin1 (":/icons/transmission-%1.png").arg (size)));
}
setWindowIcon (icon);
@ -192,8 +192,8 @@ MyApp::MyApp (int& argc, char ** argv):
{
case AddData::URL: arguments.push_back (a.url.toString ()); break;
case AddData::MAGNET: arguments.push_back (a.magnet); break;
case AddData::FILENAME: arguments.push_back (a.toBase64 ().constData ()); break;
case AddData::METAINFO: arguments.push_back (a.toBase64 ().constData ()); break;
case AddData::FILENAME: arguments.push_back (QString::fromLatin1 (a.toBase64 ())); break;
case AddData::METAINFO: arguments.push_back (QString::fromLatin1 (a.toBase64 ())); break;
default: break;
}
request.setArguments (arguments);
@ -222,7 +222,7 @@ MyApp::MyApp (int& argc, char ** argv):
dir.mkpath (configDir);
// is this the first time we've run transmission?
const bool firstTime = !dir.exists ("settings.json");
const bool firstTime = !dir.exists (QLatin1String ("settings.json"));
// initialize the prefs
myPrefs = new Prefs (configDir);

View file

@ -869,19 +869,19 @@ Details::refresh ()
foreach (const Peer& peer, peers)
{
const QString key = idStr + ":" + peer.address;
const QString key = idStr + QLatin1Char (':') + peer.address;
PeerItem * item = static_cast<PeerItem*> (myPeers.value (key, 0));
if (item == 0) // new peer has connected
{
static const QIcon myEncryptionIcon (":/icons/encrypted.png");
static const QIcon myEncryptionIcon (QLatin1String (":/icons/encrypted.png"));
static const QIcon myEmptyIcon;
item = new PeerItem (peer);
item->setTextAlignment (COL_UP, Qt::AlignRight|Qt::AlignVCenter);
item->setTextAlignment (COL_DOWN, Qt::AlignRight|Qt::AlignVCenter);
item->setTextAlignment (COL_PERCENT, Qt::AlignRight|Qt::AlignVCenter);
item->setIcon (COL_LOCK, peer.isEncrypted ? myEncryptionIcon : myEmptyIcon);
item->setToolTip (COL_LOCK, peer.isEncrypted ? tr ("Encrypted connection") : "");
item->setToolTip (COL_LOCK, peer.isEncrypted ? tr ("Encrypted connection") : QString ());
item->setText (COL_ADDRESS, peer.address);
item->setText (COL_CLIENT, peer.clientName);
newItems << item;
@ -918,9 +918,9 @@ Details::refresh ()
if (!codeTip.isEmpty ())
codeTip.resize (codeTip.size ()-1); // eat the trailing linefeed
item->setText (COL_UP, peer.rateToPeer.isZero () ? "" : Formatter::speedToString (peer.rateToPeer));
item->setText (COL_DOWN, peer.rateToClient.isZero () ? "" : Formatter::speedToString (peer.rateToClient));
item->setText (COL_PERCENT, peer.progress > 0 ? QString::fromLatin1 ("%1%").arg ( (int) (peer.progress * 100.0)) : "");
item->setText (COL_UP, peer.rateToPeer.isZero () ? QString () : Formatter::speedToString (peer.rateToPeer));
item->setText (COL_DOWN, peer.rateToClient.isZero () ? QString () : Formatter::speedToString (peer.rateToClient));
item->setText (COL_PERCENT, peer.progress > 0 ? QString::fromLatin1 ("%1%").arg ( (int) (peer.progress * 100.0)) : QString ());
item->setText (COL_STATUS, code);
item->setToolTip (COL_STATUS, codeTip);
@ -1219,9 +1219,9 @@ Details::initTrackerTab ()
ui.trackersView->setModel (myTrackerFilter);
ui.trackersView->setItemDelegate (myTrackerDelegate);
ui.addTrackerButton->setIcon (getStockIcon ("list-add", QStyle::SP_DialogOpenButton));
ui.editTrackerButton->setIcon (getStockIcon ("document-properties", QStyle::SP_DesktopIcon));
ui.removeTrackerButton->setIcon (getStockIcon ("list-remove", QStyle::SP_TrashIcon));
ui.addTrackerButton->setIcon (getStockIcon (QLatin1String ("list-add"), QStyle::SP_DialogOpenButton));
ui.editTrackerButton->setIcon (getStockIcon (QLatin1String ("document-properties"), QStyle::SP_DesktopIcon));
ui.removeTrackerButton->setIcon (getStockIcon (QLatin1String ("list-remove"), QStyle::SP_TrashIcon));
ui.showTrackerScrapesCheck->setChecked (myPrefs.getBool (Prefs::SHOW_TRACKER_SCRAPES));
ui.showBackupTrackersCheck->setChecked (myPrefs.getBool (Prefs::SHOW_BACKUP_TRACKERS));
@ -1251,11 +1251,11 @@ Details::initPeersTab ()
ui.peersView->sortByColumn (COL_ADDRESS, Qt::AscendingOrder);
ui.peersView->setColumnWidth (COL_LOCK, 20);
ui.peersView->setColumnWidth (COL_UP, measureViewItem (ui.peersView, "1024 MiB/s"));
ui.peersView->setColumnWidth (COL_DOWN, measureViewItem (ui.peersView, "1024 MiB/s"));
ui.peersView->setColumnWidth (COL_PERCENT, measureViewItem (ui.peersView, "100%"));
ui.peersView->setColumnWidth (COL_STATUS, measureViewItem (ui.peersView, "ODUK?EXI"));
ui.peersView->setColumnWidth (COL_ADDRESS, measureViewItem (ui.peersView, "888.888.888.888"));
ui.peersView->setColumnWidth (COL_UP, measureViewItem (ui.peersView, QLatin1String ("1024 MiB/s")));
ui.peersView->setColumnWidth (COL_DOWN, measureViewItem (ui.peersView, QLatin1String ("1024 MiB/s")));
ui.peersView->setColumnWidth (COL_PERCENT, measureViewItem (ui.peersView, QLatin1String ("100%")));
ui.peersView->setColumnWidth (COL_STATUS, measureViewItem (ui.peersView, QLatin1String ("ODUK?EXI")));
ui.peersView->setColumnWidth (COL_ADDRESS, measureViewItem (ui.peersView, QLatin1String ("888.888.888.888")));
}
/***
@ -1321,7 +1321,7 @@ Details::onOpenRequested (const QString& path)
if (tor == NULL)
continue;
const QString localFilePath = tor->getPath () + "/" + path;
const QString localFilePath = tor->getPath () + QLatin1Char ('/') + path;
if (!QFile::exists (localFilePath))
continue;

View file

@ -49,7 +49,7 @@ Favicons::getCacheDir ()
QStandardPaths::writableLocation (QStandardPaths::CacheLocation);
#endif
return QDir(base).absoluteFilePath ("favicons");
return QDir(base).absoluteFilePath (QLatin1String ("favicons"));
}
void
@ -79,8 +79,8 @@ QString
Favicons::getHost (const QUrl& url)
{
QString host = url.host ();
const int first_dot = host.indexOf ('.');
const int last_dot = host.lastIndexOf ('.');
const int first_dot = host.indexOf (QLatin1Char ('.'));
const int last_dot = host.lastIndexOf (QLatin1Char ('.'));
if ((first_dot != -1) && (last_dot != -1) && (first_dot != last_dot))
host.remove (0, first_dot + 1);
@ -123,9 +123,9 @@ Favicons::add (const QUrl& url)
myPixmaps.insert (host, QPixmap ());
// try to download the favicon
const QString path = "http://" + host + "/favicon.";
const QString path = QLatin1String ("http://") + host + QLatin1String ("/favicon.");
QStringList suffixes;
suffixes << "ico" << "png" << "gif" << "jpg";
suffixes << QLatin1String ("ico") << QLatin1String ("png") << QLatin1String ("gif") << QLatin1String ("jpg");
foreach (QString suffix, suffixes)
myNAM->get (QNetworkRequest (path + suffix));
}

View file

@ -139,7 +139,7 @@ FileTreeItem::data (int column, int role) const
break;
case COL_SIZE:
value.setValue (sizeString() + " ");
value.setValue (sizeString() + QLatin1String (" "));
break;
case COL_PROGRESS:
@ -395,7 +395,7 @@ FileTreeItem::path () const
if (itemPath.isEmpty())
itemPath = item->name();
else
itemPath = item->name() + "/" + itemPath;
itemPath = item->name() + QLatin1Char ('/') + itemPath;
item = item->parent ();
}
@ -966,10 +966,10 @@ FileTreeView::eventFilter (QObject * o, QEvent * event)
QString header;
if (column == COL_SIZE)
header = "999.9 KiB";
header = QLatin1String ("999.9 KiB");
else
header = myModel.headerData (column, Qt::Horizontal).toString();
header += " ";
header += QLatin1String (" ");
const int width = fontMetrics.size (0, header).width();
setColumnWidth (column, width);
left -= width;

View file

@ -41,7 +41,7 @@ class FileTreeItem: public QObject
virtual ~FileTreeItem();
FileTreeItem (const QString& name="", int fileIndex=-1, uint64_t size=0):
FileTreeItem (const QString& name=QString (), int fileIndex=-1, uint64_t size=0):
myFileIndex (fileIndex),
myParent (0),
myName (name),

View file

@ -286,7 +286,7 @@ FilterBarLineEdit::FilterBarLineEdit (QWidget * parent):
myClearButton (nullptr)
{
#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0)
const QIcon icon = QIcon::fromTheme ("edit-clear", style ()->standardIcon (QStyle::SP_DialogCloseButton));
const QIcon icon = QIcon::fromTheme (QLatin1String ("edit-clear"), style ()->standardIcon (QStyle::SP_DialogCloseButton));
const int iconSize = style ()->pixelMetric (QStyle::PM_SmallIconSize);
myClearButton = new QToolButton (this);
@ -363,31 +363,31 @@ FilterBar::createActivityCombo ()
model->appendRow (new QStandardItem); // separator
delegate->setSeparator (model, model->index (1, 0));
row = new QStandardItem (QIcon::fromTheme ("system-run"), tr ("Active"));
row = new QStandardItem (QIcon::fromTheme (QLatin1String ("system-run")), tr ("Active"));
row->setData (FilterMode::SHOW_ACTIVE, ActivityRole);
model->appendRow (row);
row = new QStandardItem (QIcon::fromTheme ("go-down"), tr ("Downloading"));
row = new QStandardItem (QIcon::fromTheme (QLatin1String ("go-down")), tr ("Downloading"));
row->setData (FilterMode::SHOW_DOWNLOADING, ActivityRole);
model->appendRow (row);
row = new QStandardItem (QIcon::fromTheme ("go-up"), tr ("Seeding"));
row = new QStandardItem (QIcon::fromTheme (QLatin1String ("go-up")), tr ("Seeding"));
row->setData (FilterMode::SHOW_SEEDING, ActivityRole);
model->appendRow (row);
row = new QStandardItem (QIcon::fromTheme ("media-playback-pause"), tr ("Paused"));
row = new QStandardItem (QIcon::fromTheme (QLatin1String ("media-playback-pause")), tr ("Paused"));
row->setData (FilterMode::SHOW_PAUSED, ActivityRole);
model->appendRow (row);
row = new QStandardItem (QIcon::fromTheme ("dialog-ok"), tr ("Finished"));
row = new QStandardItem (QIcon::fromTheme (QLatin1String ("dialog-ok")), tr ("Finished"));
row->setData (FilterMode::SHOW_FINISHED, ActivityRole);
model->appendRow (row);
row = new QStandardItem (QIcon::fromTheme ("view-refresh"), tr ("Verifying"));
row = new QStandardItem (QIcon::fromTheme (QLatin1String ("view-refresh")), tr ("Verifying"));
row->setData (FilterMode::SHOW_VERIFYING, ActivityRole);
model->appendRow (row);
row = new QStandardItem (QIcon::fromTheme ("process-stop"), tr ("Error"));
row = new QStandardItem (QIcon::fromTheme (QLatin1String ("process-stop")), tr ("Error"));
row->setData (FilterMode::SHOW_ERROR, ActivityRole);
model->appendRow (row);
@ -407,7 +407,7 @@ namespace
{
// get the readable name...
QString name = host;
const int pos = name.lastIndexOf ('.');
const int pos = name.lastIndexOf (QLatin1Char ('.'));
if (pos >= 0)
name.truncate (pos);
if (!name.isEmpty ())
@ -517,7 +517,7 @@ FilterBar::createTrackerCombo (QStandardItemModel * model)
c->setItemDelegate (delegate);
QStandardItem * row = new QStandardItem (tr ("All"));
row->setData ("", TrackerRole);
row->setData (QString (), TrackerRole);
const int count = myTorrents.rowCount ();
row->setData (count, TorrentCountRole);
row->setData (getCountString (count), TorrentCountStringRole);
@ -644,14 +644,14 @@ FilterBar::onTrackerIndexChanged (int i)
{
QString str;
const bool isTracker = !myTrackerCombo->itemData (i,TrackerRole).toString ().isEmpty ();
if (!isTracker) // show all
if (!isTracker)
{
str = "";
// show all
}
else
{
str = myTrackerCombo->itemData (i,TrackerRole).toString ();
const int pos = str.lastIndexOf ('.');
const int pos = str.lastIndexOf (QLatin1Char ('.'));
if (pos >= 0)
str.truncate (pos+1);
}

View file

@ -11,14 +11,14 @@
const QString FilterMode::names[NUM_MODES] =
{
"show-all",
"show-active",
"show-downloading",
"show-seeding",
"show-paused",
"show-finished",
"show-verifying",
"show-error",
QLatin1String ("show-all"),
QLatin1String ("show-active"),
QLatin1String ("show-downloading"),
QLatin1String ("show-seeding"),
QLatin1String ("show-paused"),
QLatin1String ("show-finished"),
QLatin1String ("show-verifying"),
QLatin1String ("show-error")
};
int
@ -33,16 +33,16 @@ FilterMode::modeFromName (const QString& name)
const QString SortMode::names[NUM_MODES] =
{
"sort-by-activity",
"sort-by-age",
"sort-by-eta",
"sort-by-name",
"sort-by-progress",
"sort-by-queue"
"sort-by-ratio",
"sort-by-size",
"sort-by-state",
"sort-by-id"
QLatin1String ("sort-by-activity"),
QLatin1String ("sort-by-age"),
QLatin1String ("sort-by-eta"),
QLatin1String ("sort-by-name"),
QLatin1String ("sort-by-progress"),
QLatin1String ("sort-by-queue"),
QLatin1String ("sort-by-ratio"),
QLatin1String ("sort-by-size"),
QLatin1String ("sort-by-state"),
QLatin1String ("sort-by-id")
};
int

View file

@ -91,7 +91,7 @@ FreespaceLabel::onSessionExecuted (int64_t tag, const QString& result, tr_varian
if (bytes >= 0)
setText (tr("%1 free").arg(Formatter::sizeToString (bytes)));
else
setText ("");
setText (QString ());
// update the tooltip
size_t len = 0;

View file

@ -51,7 +51,7 @@ HIG::addSectionTitle (const QString& title)
{
QLabel * label = new QLabel (this);
label->setText (title);
label->setStyleSheet ("font: bold");
label->setStyleSheet (QLatin1String ("font: bold"));
label->setAlignment (Qt::AlignLeft|Qt::AlignVCenter);
addSectionTitle (label);
}

View file

@ -22,7 +22,7 @@ LicenseDialog::LicenseDialog (QWidget * parent):
QPlainTextEdit * t = new QPlainTextEdit (this);
t->setReadOnly (true);
t->setPlainText (
t->setPlainText (QLatin1String (
"Copyright 2005-2014. All code is copyrighted by the respective authors.\n"
"\n"
"Transmission can be redistributed and/or modified under the terms of the "
@ -35,7 +35,7 @@ LicenseDialog::LicenseDialog (QWidget * parent):
"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
"\n"
"Some of Transmission's source files have more permissive licenses. "
"Those files may, of course, be used on their own under their own terms.\n");
"Those files may, of course, be used on their own under their own terms.\n"));
v->addWidget (t);
QDialogButtonBox * box = new QDialogButtonBox;

View file

@ -114,28 +114,28 @@ TrMainWindow::TrMainWindow (Session& session, Prefs& prefs, TorrentModel& model,
ui.listView->setStyle (new ListViewProxyStyle);
// icons
ui.action_OpenFile->setIcon (getStockIcon ("document-open", QStyle::SP_DialogOpenButton));
ui.action_New->setIcon (getStockIcon ("document-new", QStyle::SP_DesktopIcon));
ui.action_Properties->setIcon (getStockIcon ("document-properties", QStyle::SP_DesktopIcon));
ui.action_OpenFolder->setIcon (getStockIcon ("folder-open", QStyle::SP_DirOpenIcon));
ui.action_Start->setIcon (getStockIcon ("media-playback-start", QStyle::SP_MediaPlay));
ui.action_StartNow->setIcon (getStockIcon ("media-playback-start", QStyle::SP_MediaPlay));
ui.action_Announce->setIcon (getStockIcon ("network-transmit-receive"));
ui.action_Pause->setIcon (getStockIcon ("media-playback-pause", QStyle::SP_MediaPause));
ui.action_Remove->setIcon (getStockIcon ("list-remove", QStyle::SP_TrashIcon));
ui.action_Delete->setIcon (getStockIcon ("edit-delete", QStyle::SP_TrashIcon));
ui.action_StartAll->setIcon (getStockIcon ("media-playback-start", QStyle::SP_MediaPlay));
ui.action_PauseAll->setIcon (getStockIcon ("media-playback-pause", QStyle::SP_MediaPause));
ui.action_Quit->setIcon (getStockIcon ("application-exit"));
ui.action_SelectAll->setIcon (getStockIcon ("edit-select-all"));
ui.action_ReverseSortOrder->setIcon (getStockIcon ("view-sort-ascending", QStyle::SP_ArrowDown));
ui.action_Preferences->setIcon (getStockIcon ("preferences-system"));
ui.action_Contents->setIcon (getStockIcon ("help-contents", QStyle::SP_DialogHelpButton));
ui.action_About->setIcon (getStockIcon ("help-about"));
ui.action_QueueMoveTop->setIcon (getStockIcon ("go-top"));
ui.action_QueueMoveUp->setIcon (getStockIcon ("go-up", QStyle::SP_ArrowUp));
ui.action_QueueMoveDown->setIcon (getStockIcon ("go-down", QStyle::SP_ArrowDown));
ui.action_QueueMoveBottom->setIcon (getStockIcon ("go-bottom"));
ui.action_OpenFile->setIcon (getStockIcon (QLatin1String ("document-open"), QStyle::SP_DialogOpenButton));
ui.action_New->setIcon (getStockIcon (QLatin1String ("document-new"), QStyle::SP_DesktopIcon));
ui.action_Properties->setIcon (getStockIcon (QLatin1String ("document-properties"), QStyle::SP_DesktopIcon));
ui.action_OpenFolder->setIcon (getStockIcon (QLatin1String ("folder-open"), QStyle::SP_DirOpenIcon));
ui.action_Start->setIcon (getStockIcon (QLatin1String ("media-playback-start"), QStyle::SP_MediaPlay));
ui.action_StartNow->setIcon (getStockIcon (QLatin1String ("media-playback-start"), QStyle::SP_MediaPlay));
ui.action_Announce->setIcon (getStockIcon (QLatin1String ("network-transmit-receive")));
ui.action_Pause->setIcon (getStockIcon (QLatin1String ("media-playback-pause"), QStyle::SP_MediaPause));
ui.action_Remove->setIcon (getStockIcon (QLatin1String ("list-remove"), QStyle::SP_TrashIcon));
ui.action_Delete->setIcon (getStockIcon (QLatin1String ("edit-delete"), QStyle::SP_TrashIcon));
ui.action_StartAll->setIcon (getStockIcon (QLatin1String ("media-playback-start"), QStyle::SP_MediaPlay));
ui.action_PauseAll->setIcon (getStockIcon (QLatin1String ("media-playback-pause"), QStyle::SP_MediaPause));
ui.action_Quit->setIcon (getStockIcon (QLatin1String ("application-exit")));
ui.action_SelectAll->setIcon (getStockIcon (QLatin1String ("edit-select-all")));
ui.action_ReverseSortOrder->setIcon (getStockIcon (QLatin1String ("view-sort-ascending"), QStyle::SP_ArrowDown));
ui.action_Preferences->setIcon (getStockIcon (QLatin1String ("preferences-system")));
ui.action_Contents->setIcon (getStockIcon (QLatin1String ("help-contents"), QStyle::SP_DialogHelpButton));
ui.action_About->setIcon (getStockIcon (QLatin1String ("help-about")));
ui.action_QueueMoveTop->setIcon (getStockIcon (QLatin1String ("go-top")));
ui.action_QueueMoveUp->setIcon (getStockIcon (QLatin1String ("go-up"), QStyle::SP_ArrowUp));
ui.action_QueueMoveDown->setIcon (getStockIcon (QLatin1String ("go-down"), QStyle::SP_ArrowDown));
ui.action_QueueMoveBottom->setIcon (getStockIcon (QLatin1String ("go-bottom")));
// ui signals
connect (ui.action_Toolbar, SIGNAL (toggled (bool)), this, SLOT (setToolbarVisible (bool)));
@ -230,7 +230,7 @@ TrMainWindow::TrMainWindow (Session& session, Prefs& prefs, TorrentModel& model,
menu->addSeparator ();
menu->addAction (ui.action_Quit);
myTrayIcon.setContextMenu (menu);
myTrayIcon.setIcon (QIcon::fromTheme ("transmission-tray-icon", qApp->windowIcon ()));
myTrayIcon.setIcon (QIcon::fromTheme (QLatin1String ("transmission-tray-icon"), qApp->windowIcon ()));
connect (&myPrefs, SIGNAL (changed (int)), this, SLOT (refreshPref (int)));
connect (ui.action_ShowMainWindow, SIGNAL (triggered (bool)), this, SLOT (toggleWindows (bool)));
@ -583,7 +583,7 @@ void openSelect (const QString& path)
scriptArgs.clear ();
scriptArgs << QLatin1String ("-e")
<< QLatin1String ("tell application \"Finder\" to activate");
QProcess::execute ("/usr/bin/osascript", scriptArgs);
QProcess::execute (QLatin1String ("/usr/bin/osascript"), scriptArgs);
}
#endif
@ -595,15 +595,15 @@ TrMainWindow::openFolder ()
QString path (tor->getPath ());
const FileList files = tor->files ();
const QString firstfile = files.at (0).filename;
int slashIndex = firstfile.indexOf ('/');
int slashIndex = firstfile.indexOf (QLatin1Char ('/'));
if (slashIndex > -1)
{
path = path + "/" + firstfile.left (slashIndex);
path = path + QLatin1Char ('/') + firstfile.left (slashIndex);
}
#ifdef HAVE_OPEN_SELECT
else
{
openSelect (path + "/" + firstfile);
openSelect (path + QLatin1Char ('/') + firstfile);
return;
}
#endif
@ -620,7 +620,7 @@ TrMainWindow::copyMagnetLinkToClipboard ()
void
TrMainWindow::openDonate ()
{
QDesktopServices::openUrl (QUrl ("http://www.transmissionbt.com/donate.php"));
QDesktopServices::openUrl (QUrl (QLatin1String ("http://www.transmissionbt.com/donate.php")));
}
void
@ -633,7 +633,7 @@ TrMainWindow::openHelp ()
void
TrMainWindow::refreshTitle ()
{
QString title ("Transmission");
QString title (QLatin1String ("Transmission"));
const QUrl url (mySession.getRemoteUrl ());
if (!url.isEmpty ())
//: Second (optional) part of main window title "Transmission - host:port" (added when connected to remote session);
@ -699,17 +699,17 @@ TrMainWindow::refreshStatusBar ()
const QString mode (myPrefs.getString (Prefs::STATUSBAR_STATS));
QString str;
if (mode == "session-ratio")
if (mode == QLatin1String ("session-ratio"))
{
str = tr ("Ratio: %1").arg (Formatter::ratioToString (mySession.getStats ().ratio));
}
else if (mode == "session-transfer")
else if (mode == QLatin1String ("session-transfer"))
{
const tr_session_stats& stats (mySession.getStats ());
str = tr ("Down: %1, Up: %2").arg (Formatter::sizeToString (stats.downloadedBytes))
.arg (Formatter::sizeToString (stats.uploadedBytes));
}
else if (mode == "total-transfer")
else if (mode == QLatin1String ("total-transfer"))
{
const tr_session_stats& stats (mySession.getCumulativeStats ());
str = tr ("Down: %1, Up: %2").arg (Formatter::sizeToString (stats.downloadedBytes))
@ -973,10 +973,10 @@ TrMainWindow::refreshPref (int key)
{
case Prefs::STATUSBAR_STATS:
str = myPrefs.getString (key);
ui.action_TotalRatio->setChecked (str == "total-ratio");
ui.action_TotalTransfer->setChecked (str == "total-transfer");
ui.action_SessionRatio->setChecked (str == "session-ratio");
ui.action_SessionTransfer->setChecked (str == "session-transfer");
ui.action_TotalRatio->setChecked (str == QLatin1String ("total-ratio"));
ui.action_TotalTransfer->setChecked (str == QLatin1String ("total-transfer"));
ui.action_SessionRatio->setChecked (str == QLatin1String ("session-ratio"));
ui.action_SessionTransfer->setChecked (str == QLatin1String ("session-transfer"));
refreshStatusBar ();
break;
@ -1096,7 +1096,10 @@ TrMainWindow::refreshPref (int key)
****
***/
#define SHOW_OPTIONS_CHECKBOX_NAME "show-options-checkbox"
namespace
{
const QLatin1String SHOW_OPTIONS_CHECKBOX_NAME ("show-options-checkbox");
}
void
TrMainWindow::newTorrent ()
@ -1250,7 +1253,7 @@ TrMainWindow::removeTorrents (const bool deleteFiles)
if (connected && incomplete)
{
secondary_text += "\n";
secondary_text += QLatin1Char ('\n');
}
if (incomplete)
@ -1309,7 +1312,7 @@ TrMainWindow::updateNetworkIcon ()
key = "network-receive";
else
key = "network-idle";
const QIcon icon = getStockIcon (key, QStyle::SP_DriveNetIcon);
const QIcon icon = getStockIcon (QLatin1String (key), QStyle::SP_DriveNetIcon);
const QPixmap pixmap = icon.pixmap (16, 16);
QString tip;
@ -1387,10 +1390,10 @@ TrMainWindow::dragEnterEvent (QDragEnterEvent * event)
{
const QMimeData * mime = event->mimeData ();
if (mime->hasFormat ("application/x-bittorrent")
if (mime->hasFormat (QLatin1String ("application/x-bittorrent"))
|| mime->hasUrls()
|| mime->text ().trimmed ().endsWith (".torrent", Qt::CaseInsensitive)
|| mime->text ().startsWith ("magnet:", Qt::CaseInsensitive))
|| mime->text ().trimmed ().endsWith (QLatin1String (".torrent"), Qt::CaseInsensitive)
|| mime->text ().startsWith (QLatin1String ("magnet:"), Qt::CaseInsensitive))
event->acceptProposedAction ();
}
@ -1401,7 +1404,7 @@ TrMainWindow::dropEvent (QDropEvent * event)
if (event->mimeData()->hasText())
{
list = event->mimeData()->text().trimmed().split('\n');
list = event->mimeData()->text().trimmed().split(QLatin1Char ('\n'));
}
else if (event->mimeData()->hasUrls())
{
@ -1417,7 +1420,7 @@ TrMainWindow::dropEvent (QDropEvent * event)
{
const QUrl url (key);
if (url.scheme () == "file")
if (url.scheme () == QLatin1String ("file"))
key = QUrl::fromPercentEncoding (url.path().toUtf8());
qApp->addTorrent (key);

View file

@ -132,7 +132,7 @@ MakeDialog::makeTorrent ()
// get the tiers
int tier = 0;
QVector<tr_tracker_info> trackers;
foreach (QString line, ui.trackersEdit->toPlainText ().split ("\n"))
foreach (QString line, ui.trackersEdit->toPlainText ().split (QLatin1Char ('\n')))
{
line = line.trimmed ();
if (line.isEmpty ())
@ -150,7 +150,7 @@ MakeDialog::makeTorrent ()
// the file to create
const QString path = QString::fromUtf8 (myBuilder->top);
const QString torrentName = QFileInfo (path).completeBaseName () + ".torrent";
const QString torrentName = QFileInfo (path).completeBaseName () + QLatin1String (".torrent");
const QString target = QDir (ui.destinationButton->path ()).filePath (torrentName);
// comment

View file

@ -438,7 +438,7 @@ OptionsDialog::onTimeout ()
if (!have) // everything failed
{
// did the user accidentally specify the child directory instead of the parent?
const QStringList tokens = QString::fromUtf8 (file->name).split ('/');
const QStringList tokens = QString::fromUtf8 (file->name).split (QLatin1Char ('/'));
if (!tokens.empty () && myLocalDestination.dirName () == tokens.at (0))
{
// move up one directory and try again

View file

@ -162,12 +162,12 @@ Prefs::Prefs (const QString& configDir):
case TrTypes::SortModeType:
if (tr_variantGetStr (b, &str, NULL))
myValues[i] = QVariant::fromValue (SortMode (str));
myValues[i] = QVariant::fromValue (SortMode (QString::fromUtf8 (str)));
break;
case TrTypes::FilterModeType:
if (tr_variantGetStr (b, &str, NULL))
myValues[i] = QVariant::fromValue (FilterMode (str));
myValues[i] = QVariant::fromValue (FilterMode (QString::fromUtf8 (str)));
break;
case QVariant::String:
@ -257,7 +257,7 @@ Prefs::~Prefs ()
// update settings.json with our settings
tr_variant file_settings;
const QFile file (QDir(myConfigDir).absoluteFilePath("settings.json"));
const QFile file (QDir(myConfigDir).absoluteFilePath(QLatin1String ("settings.json")));
if (tr_variantFromFile (&file_settings, TR_VARIANT_FMT_JSON, file.fileName().toUtf8().constData()))
tr_variantInitDict (&file_settings, PREFS_COUNT);
tr_variantMergeDicts (&file_settings, &current_settings);

View file

@ -19,6 +19,9 @@ greaterThan(QT_MAJOR_VERSION, 4) {
QT += widgets
}
DEFINES += QT_NO_CAST_FROM_ASCII
win32:DEFINES += QT_DBUS
TRANSMISSION_TOP = ..
include(config.pri)
@ -32,7 +35,6 @@ LIBS += $${LIBB64_LIBS}
LIBS += $${LIBUPNP_LIBS}
LIBS += $${LIBNATPMP_LIBS}
unix: LIBS += -L$${EVENT_TOP}/lib -lz -lrt
win32:DEFINES += QT_DBUS
win32:LIBS += -levent-2.0 -lws2_32 -lintl
win32:LIBS += -lidn -liconv -lwldap32 -liphlpapi

View file

@ -70,8 +70,8 @@ RpcClient::isLocal () const
return true;
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
if (myUrl.host () == "127.0.0.1" ||
myUrl.host ().compare ("localhost", Qt::CaseInsensitive) == 0)
if (myUrl.host () == QLatin1String ("127.0.0.1") ||
myUrl.host ().compare (QLatin1String ("localhost"), Qt::CaseInsensitive) == 0)
return true;
#else
if (QHostAddress (myUrl.host ()).isLoopback ())
@ -123,7 +123,7 @@ RpcClient::sendRequest (const QByteArray& json)
{
QNetworkRequest request;
request.setUrl (myUrl);
request.setRawHeader ("User-Agent", (qApp->applicationName () + "/" + LONG_VERSION_STRING).toUtf8 ());
request.setRawHeader ("User-Agent", (qApp->applicationName () + QLatin1Char ('/') + QString::fromUtf8 (LONG_VERSION_STRING)).toUtf8 ());
request.setRawHeader ("Content-Type", "application/json; charset=UTF-8");
if (!mySessionId.isEmpty ())

View file

@ -81,7 +81,7 @@ FileAdded::executed (int64_t tag, const QString& result, tr_variant * arguments)
if (tag != myTag)
return;
if (result == "success")
if (result == QLatin1String ("success"))
{
tr_variant * dup;
const char * str;
@ -218,13 +218,13 @@ Session::updatePref (int key)
switch (i)
{
case 0:
sessionSet (myPrefs.getKey (key), "tolerated");
sessionSet (myPrefs.getKey (key), QLatin1String ("tolerated"));
break;
case 1:
sessionSet (myPrefs.getKey (key), "preferred");
sessionSet (myPrefs.getKey (key), QLatin1String ("preferred"));
break;
case 2:
sessionSet (myPrefs.getKey (key), "required");
sessionSet (myPrefs.getKey (key), QLatin1String ("required"));
break;
}
break;
@ -334,10 +334,10 @@ Session::start ()
if (myPrefs.get<bool> (Prefs::SESSION_IS_REMOTE))
{
QUrl url;
url.setScheme ("http");
url.setScheme (QLatin1String ("http"));
url.setHost (myPrefs.get<QString> (Prefs::SESSION_REMOTE_HOST));
url.setPort (myPrefs.get<int> (Prefs::SESSION_REMOTE_PORT));
url.setPath ("/transmission/rpc");
url.setPath (QLatin1String ("/transmission/rpc"));
if (myPrefs.get<bool> (Prefs::SESSION_REMOTE_AUTH))
{
url.setUserName (myPrefs.get<QString> (Prefs::SESSION_REMOTE_USERNAME));
@ -660,7 +660,7 @@ Session::responseReceived (int64_t tag, const QString& result, tr_variant * args
tr_variantDictFindStr (args, TR_KEY_path, &path, 0);
tr_variantDictFindStr (args, TR_KEY_name, &name, 0);
const QString title = tr ("Error Renaming Path");
const QString text = tr ("<p><b>Unable to rename \"%1\" as \"%2\": %3.</b></p> <p>Please correct the errors and try again.</p>").arg (path).arg (name).arg (result);
const QString text = tr ("<p><b>Unable to rename \"%1\" as \"%2\": %3.</b></p> <p>Please correct the errors and try again.</p>").arg (QString::fromUtf8 (path)).arg (QString::fromUtf8 (name)).arg (result);
QMessageBox * d = new QMessageBox (QMessageBox::Information, title, text,
QMessageBox::Close,
qApp->activeWindow ());
@ -698,7 +698,7 @@ Session::responseReceived (int64_t tag, const QString& result, tr_variant * args
&& tr_variantDictFindList (args, TR_KEY_torrents, &torrents)
&& ( (child = tr_variantListChild (torrents, 0)))
&& tr_variantDictFindStr (child, TR_KEY_magnetLink, &str, NULL))
qApp->clipboard ()->setText (str);
qApp->clipboard ()->setText (QString::fromUtf8 (str));
break;
}
@ -842,8 +842,8 @@ Session::updateInfo (tr_variant * d)
if (tr_variantDictFindInt (d, TR_KEY_blocklist_size, &i) && i!=blocklistSize ())
setBlocklistSize (i);
if (tr_variantDictFindStr (d, TR_KEY_version, &str, NULL) && (mySessionVersion != str))
mySessionVersion = str;
if (tr_variantDictFindStr (d, TR_KEY_version, &str, NULL) && (mySessionVersion != QString::fromUtf8 (str)))
mySessionVersion = QString::fromUtf8 (str);
//std::cerr << "Session::updateInfo end" << std::endl;
connect (&myPrefs, SIGNAL (changed (int)), this, SLOT (updatePref (int)));
@ -978,12 +978,12 @@ Session::launchWebInterface ()
if (!mySession) // remote session
{
url = myRpc.url ();
url.setPath ("/transmission/web/");
url.setPath (QLatin1String ("/transmission/web/"));
}
else // local session
{
url.setScheme ("http");
url.setHost ("localhost");
url.setScheme (QLatin1String ("http"));
url.setHost (QLatin1String ("localhost"));
url.setPort (myPrefs.getInt (Prefs::RPC_PORT));
}

View file

@ -180,7 +180,7 @@ TorrentDelegateMin::drawTorrent (QPainter * painter,
progressBarState |= QStyle::State_Small;
const QIcon::Mode emblemIm = isItemSelected ? QIcon::Selected : QIcon::Normal;
const QIcon emblemIcon = tor.hasError () ? QIcon::fromTheme ("emblem-important", style->standardIcon (QStyle::SP_MessageBoxWarning)) : QIcon ();
const QIcon emblemIcon = tor.hasError () ? QIcon::fromTheme (QLatin1String ("emblem-important"), style->standardIcon (QStyle::SP_MessageBoxWarning)) : QIcon ();
// layout
const QSize m (margin (*style));

View file

@ -485,7 +485,7 @@ TorrentDelegate::drawTorrent (QPainter * painter,
progressBarState |= QStyle::State_Small;
const QIcon::Mode emblemIm = isItemSelected ? QIcon::Selected : QIcon::Normal;
const QIcon emblemIcon = tor.hasError () ? QIcon::fromTheme ("emblem-important", style->standardIcon (QStyle::SP_MessageBoxWarning)) : QIcon ();
const QIcon emblemIcon = tor.hasError () ? QIcon::fromTheme (QLatin1String ("emblem-important"), style->standardIcon (QStyle::SP_MessageBoxWarning)) : QIcon ();
// layout
const QSize m (margin (*style));

View file

@ -246,7 +246,7 @@ Torrent::setString (int i, const char * value)
assert (0<=i && i<PROPERTY_COUNT);
assert (myProperties[i].type == QVariant::String);
if (myValues[i].isNull() || myValues[i].toString()!=value)
if (myValues[i].isNull() || myValues[i].toString() != QString::fromUtf8 (value))
{
myValues[i].setValue (QString::fromUtf8 (value));
changed = true;

View file

@ -173,22 +173,22 @@ TrackerDelegate::getText (const TrackerInfo& inf) const
QString key;
QString str;
const time_t now (time (0));
const QString err_markup_begin = "<span style=\"color:red\">";
const QString err_markup_end = "</span>";
const QString timeout_markup_begin = "<span style=\"color:#224466\">";
const QString timeout_markup_end = "</span>";
const QString success_markup_begin = "<span style=\"color:#008B00\">";
const QString success_markup_end = "</span>";
const QString err_markup_begin = QLatin1String ("<span style=\"color:red\">");
const QString err_markup_end = QLatin1String ("</span>");
const QString timeout_markup_begin = QLatin1String ("<span style=\"color:#224466\">");
const QString timeout_markup_end = QLatin1String ("</span>");
const QString success_markup_begin = QLatin1String ("<span style=\"color:#008B00\">");
const QString success_markup_end = QLatin1String ("</span>");
// hostname
str += inf.st.isBackup ? "<i>" : "<b>";
str += inf.st.isBackup ? QLatin1String ("<i>") : QLatin1String ("<b>");
char * host = NULL;
int port = 0;
tr_urlParse (inf.st.announce.toUtf8().constData(), -1, NULL, &host, &port, NULL);
str += QString::fromLatin1 ("%1:%2").arg (host).arg (port);
str += QString::fromLatin1 ("%1:%2").arg (QString::fromUtf8 (host)).arg (port);
tr_free (host);
if (!key.isEmpty()) str += " - " + key;
str += inf.st.isBackup ? "</i>" : "</b>";
if (!key.isEmpty()) str += QLatin1String (" - ") + key;
str += inf.st.isBackup ? QLatin1String ("</i>") : QLatin1String ("</b>");
// announce & scrape info
if (!inf.st.isBackup)
@ -196,7 +196,7 @@ TrackerDelegate::getText (const TrackerInfo& inf) const
if (inf.st.hasAnnounced && inf.st.announceState != TR_TRACKER_INACTIVE)
{
const QString tstr (timeToStringRounded (now - inf.st.lastAnnounceTime));
str += "<br/>\n";
str += QLatin1String ("<br/>\n");
if (inf.st.lastAnnounceSucceeded)
{
//: %1 and %2 are replaced with HTML markup, %3 is duration
@ -227,27 +227,27 @@ TrackerDelegate::getText (const TrackerInfo& inf) const
switch (inf.st.announceState)
{
case TR_TRACKER_INACTIVE:
str += "<br/>\n";
str += QLatin1String ("<br/>\n");
str += tr ("No updates scheduled");
break;
case TR_TRACKER_WAITING:
{
const QString tstr (timeToStringRounded (inf.st.nextAnnounceTime - now));
str += "<br/>\n";
str += QLatin1String ("<br/>\n");
//: %1 is duration
str += tr ("Asking for more peers in %1").arg (tstr);
break;
}
case TR_TRACKER_QUEUED:
str += "<br/>\n";
str += QLatin1String ("<br/>\n");
str += tr ("Queued to ask for more peers");
break;
case TR_TRACKER_ACTIVE: {
const QString tstr (timeToStringRounded (now - inf.st.lastAnnounceStartTime));
str += "<br/>\n";
str += QLatin1String ("<br/>\n");
//: %1 is duration
str += tr ("Asking for more peers now... <small>%1</small>").arg (tstr);
break;
@ -258,7 +258,7 @@ TrackerDelegate::getText (const TrackerInfo& inf) const
{
if (inf.st.hasScraped)
{
str += "<br/>\n";
str += QLatin1String ("<br/>\n");
const QString tstr (timeToStringRounded (now - inf.st.lastScrapeTime));
if (inf.st.lastScrapeSucceeded)
{
@ -304,7 +304,7 @@ TrackerDelegate::getText (const TrackerInfo& inf) const
case TR_TRACKER_WAITING:
{
str += "<br/>\n";
str += QLatin1String ("<br/>\n");
const QString tstr (timeToStringRounded (inf.st.nextScrapeTime - now));
//: %1 is duration
str += tr ("Asking for peer counts in %1").arg (tstr);
@ -313,14 +313,14 @@ TrackerDelegate::getText (const TrackerInfo& inf) const
case TR_TRACKER_QUEUED:
{
str += "<br/>\n";
str += QLatin1String ("<br/>\n");
str += tr ("Queued to ask for peer counts");
break;
}
case TR_TRACKER_ACTIVE:
{
str += "<br/>\n";
str += QLatin1String ("<br/>\n");
const QString tstr (timeToStringRounded (now - inf.st.lastScrapeStartTime));
//: %1 is duration
str += tr ("Asking for peer counts now... <small>%1</small>").arg (tstr);