From 420fa82e8dd3923a6bf782c894c34622c84a9d85 Mon Sep 17 00:00:00 2001 From: Gabriele Date: Sat, 8 Aug 2015 15:19:46 +0200 Subject: [PATCH 1/3] Put some string placeholders between quotes --- src/app/application.cpp | 2 +- src/core/bittorrent/session.cpp | 20 ++++++++++---------- src/core/bittorrent/torrenthandle.cpp | 4 ++-- src/gui/addnewtorrentdialog.cpp | 2 +- src/gui/deletionconfirmationdlg.h | 2 +- src/gui/mainwindow.cpp | 10 +++++----- src/gui/properties/peerlistwidget.cpp | 6 +++--- src/gui/properties/peersadditiondlg.cpp | 2 +- src/gui/rss/automatedrssdownloader.cpp | 2 +- src/gui/rss/rssfeed.cpp | 4 ++-- src/gui/rss/rssparser.cpp | 2 +- src/gui/torrentimportdlg.cpp | 4 ++-- src/gui/transferlistfilterswidget.cpp | 6 +++--- src/searchengine/engineselectdlg.cpp | 12 ++++++------ 14 files changed, 39 insertions(+), 39 deletions(-) diff --git a/src/app/application.cpp b/src/app/application.cpp index 9620ec24d..414984366 100644 --- a/src/app/application.cpp +++ b/src/app/application.cpp @@ -131,7 +131,7 @@ void Application::sendNotificationEmail(BitTorrent::TorrentHandle *const torrent Net::Smtp *sender = new Net::Smtp; sender->sendMail("notification@qbittorrent.org", Preferences::instance()->getMailNotificationEmail(), - QObject::tr("[qBittorrent] %1 has finished downloading").arg(torrent->name()), + QObject::tr("[qBittorrent] '%1' has finished downloading").arg(torrent->name()), content); } diff --git a/src/core/bittorrent/session.cpp b/src/core/bittorrent/session.cpp index d94c58c03..9a866e288 100644 --- a/src/core/bittorrent/session.cpp +++ b/src/core/bittorrent/session.cpp @@ -351,7 +351,7 @@ void Session::setSessionSettings() libt::session_settings sessionSettings = m_nativeSession->settings(); sessionSettings.user_agent = "qBittorrent " VERSION; //std::cout << "HTTP User-Agent is " << sessionSettings.user_agent << std::endl; - logger->addMessage(tr("HTTP User-Agent is %1").arg(Utils::String::fromStdString(sessionSettings.user_agent))); + logger->addMessage(tr("HTTP User-Agent is '%1'").arg(Utils::String::fromStdString(sessionSettings.user_agent))); sessionSettings.upnp_ignore_nonrouters = true; sessionSettings.use_dht_as_fallback = false; @@ -721,13 +721,13 @@ void Session::processBigRatios() if ((ratio <= TorrentHandle::MAX_RATIO) && (ratio >= ratioLimit)) { Logger* const logger = Logger::instance(); if (m_highRatioAction == MaxRatioAction::Remove) { - logger->addMessage(tr("%1 reached the maximum ratio you set. Removing...").arg(torrent->name())); + logger->addMessage(tr("'%1' reached the maximum ratio you set. Removing...").arg(torrent->name())); deleteTorrent(torrent->hash()); } else { // Pause it if (!torrent->isPaused()) { - logger->addMessage(tr("%1 reached the maximum ratio you set. Pausing...").arg(torrent->name())); + logger->addMessage(tr("'%1' reached the maximum ratio you set. Pausing...").arg(torrent->name())); torrent->pause(); } } @@ -1212,7 +1212,7 @@ void Session::exportTorrentFiles(QString path) QDir exportDir(path); if (!exportDir.exists()) { if (!exportDir.mkpath(exportDir.absolutePath())) { - Logger::instance()->addMessage(tr("Error: Could not create torrent export directory: %1").arg(exportDir.absolutePath()), Log::CRITICAL); + Logger::instance()->addMessage(tr("Error: Could not create torrent export directory: '%1'").arg(exportDir.absolutePath()), Log::CRITICAL); return; } } @@ -1240,7 +1240,7 @@ void Session::exportTorrentFiles(QString path) QFile::copy(srcPath, dstPath); } else { - Logger::instance()->addMessage(tr("Error: could not export torrent %1, maybe it has not metadata yet.").arg(torrent->hash()), Log::CRITICAL); + Logger::instance()->addMessage(tr("Error: could not export torrent '%1', maybe it has not metadata yet.").arg(torrent->hash()), Log::CRITICAL); } } } @@ -1691,7 +1691,7 @@ void Session::handleTorrentFinished(TorrentHandle *const torrent) } else { qDebug("Caught error loading torrent"); - Logger::instance()->addMessage(tr("Unable to decode %1 torrent file.").arg(Utils::Fs::toNativePath(torrentFullpath)), Log::CRITICAL); + Logger::instance()->addMessage(tr("Unable to decode '%1' torrent file.").arg(Utils::Fs::toNativePath(torrentFullpath)), Log::CRITICAL); } } } @@ -1797,8 +1797,8 @@ void Session::recursiveTorrentDownload(const InfoHash &hash) const QString torrentRelpath = torrent->filePath(i); if (torrentRelpath.endsWith(".torrent")) { Logger::instance()->addMessage( - tr("Recursive download of file %1 embedded in torrent %2" - , "Recursive download of test.torrent embedded in torrent test2") + tr("Recursive download of file '%1' embedded in torrent '%2'" + , "Recursive download of 'test.torrent' embedded in torrent 'test2'") .arg(Utils::Fs::toNativePath(torrentRelpath)).arg(torrent->name())); const QString torrentFullpath = torrent->savePath() + "/" + torrentRelpath; @@ -2106,7 +2106,7 @@ void Session::handleAddTorrentAlert(libtorrent::add_torrent_alert *p) exportTorrentFile(torrent); } else { - logger->addMessage(tr("Couldn't save %1.torrent").arg(torrent->hash()), Log::CRITICAL); + logger->addMessage(tr("Couldn't save '%1.torrent'").arg(torrent->hash()), Log::CRITICAL); } } @@ -2223,7 +2223,7 @@ void Session::handlePeerBanAlert(libt::peer_ban_alert *p) void Session::handleUrlSeedAlert(libt::url_seed_alert *p) { - Logger::instance()->addMessage(tr("URL seed lookup failed for url: %1, message: %2").arg(Utils::String::fromStdString(p->url)).arg(Utils::String::fromStdString(p->message())), Log::CRITICAL); + Logger::instance()->addMessage(tr("URL seed lookup failed for URL: '%1', message: %2").arg(Utils::String::fromStdString(p->url)).arg(Utils::String::fromStdString(p->message())), Log::CRITICAL); } void Session::handleListenSucceededAlert(libt::listen_succeeded_alert *p) diff --git a/src/core/bittorrent/torrenthandle.cpp b/src/core/bittorrent/torrenthandle.cpp index 4aa12cf5c..996160a37 100644 --- a/src/core/bittorrent/torrenthandle.cpp +++ b/src/core/bittorrent/torrenthandle.cpp @@ -1491,13 +1491,13 @@ void TorrentHandle::handleFastResumeRejectedAlert(libtorrent::fastresume_rejecte updateStatus(); if (p->error.value() == libt::errors::mismatching_file_size) { // Mismatching file size (files were probably moved) - logger->addMessage(tr("File sizes mismatch for torrent %1, pausing it.").arg(name()), Log::CRITICAL); + logger->addMessage(tr("File sizes mismatch for torrent '%1', pausing it.").arg(name()), Log::CRITICAL); m_hasMissingFiles = true; if (!isPaused()) pause(); } else { - logger->addMessage(tr("Fast resume data was rejected for torrent %1. Reason: %2. Checking again...") + logger->addMessage(tr("Fast resume data was rejected for torrent '%1'. Reason: %2. Checking again...") .arg(name()).arg(Utils::String::fromStdString(p->message())), Log::CRITICAL); } } diff --git a/src/gui/addnewtorrentdialog.cpp b/src/gui/addnewtorrentdialog.cpp index 3597ed503..a2662ea92 100644 --- a/src/gui/addnewtorrentdialog.cpp +++ b/src/gui/addnewtorrentdialog.cpp @@ -706,7 +706,7 @@ void AddNewTorrentDialog::setupTreeview() void AddNewTorrentDialog::handleDownloadFailed(const QString &url, const QString &reason) { - MessageBoxRaised::critical(0, tr("Download Error"), QString("Cannot download %1: %2").arg(url).arg(reason)); + MessageBoxRaised::critical(0, tr("Download Error"), QString("Cannot download '%1': %2").arg(url).arg(reason)); this->deleteLater(); } diff --git a/src/gui/deletionconfirmationdlg.h b/src/gui/deletionconfirmationdlg.h index 551ac08bd..6356dfc2d 100644 --- a/src/gui/deletionconfirmationdlg.h +++ b/src/gui/deletionconfirmationdlg.h @@ -45,7 +45,7 @@ class DeletionConfirmationDlg : public QDialog, private Ui::confirmDeletionDlg { DeletionConfirmationDlg(QWidget *parent, const int &size, const QString &name): QDialog(parent) { setupUi(this); if (size == 1) - label->setText(tr("Are you sure you want to delete \"%1\" from the transfer list?", "Are you sure you want to delete \"ubuntu-linux-iso\" from the transfer list?").arg(name)); + label->setText(tr("Are you sure you want to delete '%1' from the transfer list?", "Are you sure you want to delete 'ubuntu-linux-iso' from the transfer list?").arg(name)); else label->setText(tr("Are you sure you want to delete these %1 torrents from the transfer list?", "Are you sure you want to delete these 5 torrents from the transfer list?").arg(QString::number(size))); // Icons diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index 9749c2fec..c85cb2f45 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -634,13 +634,13 @@ void MainWindow::addTorrentFailed(const QString &error) const // called when a torrent has finished void MainWindow::finishedTorrent(BitTorrent::TorrentHandle *const torrent) const { - showNotificationBaloon(tr("Download completion"), tr("%1 has finished downloading.", "e.g: xxx.avi has finished downloading.").arg(torrent->name())); + showNotificationBaloon(tr("Download completion"), tr("'%1' has finished downloading.", "e.g: xxx.avi has finished downloading.").arg(torrent->name())); } // Notification when disk is full void MainWindow::fullDiskError(BitTorrent::TorrentHandle *const torrent, QString msg) const { - showNotificationBaloon(tr("I/O Error", "i.e: Input/Output Error"), tr("An I/O error occurred for torrent %1.\n Reason: %2", "e.g: An error occurred for torrent xxx.avi.\n Reason: disk is full.").arg(torrent->name()).arg(msg)); + showNotificationBaloon(tr("I/O Error", "i.e: Input/Output Error"), tr("An I/O error occurred for torrent '%1'.\n Reason: %2", "e.g: An error occurred for torrent 'xxx.avi'.\n Reason: disk is full.").arg(torrent->name()).arg(msg)); } void MainWindow::createKeyboardShortcuts() @@ -701,7 +701,7 @@ void MainWindow::askRecursiveTorrentDownloadConfirmation(BitTorrent::TorrentHand if (pref->recursiveDownloadDisabled()) return; // Get Torrent name QString torrent_name = torrent->name(); - QMessageBox confirmBox(QMessageBox::Question, tr("Recursive download confirmation"), tr("The torrent %1 contains torrent files, do you want to proceed with their download?").arg(torrent_name)); + QMessageBox confirmBox(QMessageBox::Question, tr("Recursive download confirmation"), tr("The torrent '%1' contains torrent files, do you want to proceed with their download?").arg(torrent_name)); QPushButton *yes = confirmBox.addButton(tr("Yes"), QMessageBox::YesRole); /*QPushButton *no = */ confirmBox.addButton(tr("No"), QMessageBox::NoRole); QPushButton *never = confirmBox.addButton(tr("Never"), QMessageBox::NoRole); @@ -716,7 +716,7 @@ void MainWindow::askRecursiveTorrentDownloadConfirmation(BitTorrent::TorrentHand void MainWindow::handleDownloadFromUrlFailure(QString url, QString reason) const { // Display a message box - showNotificationBaloon(tr("URL download error"), tr("Couldn't download file at URL: %1, reason: %2.").arg(url).arg(reason)); + showNotificationBaloon(tr("URL download error"), tr("Couldn't download file at URL '%1', reason: %2.").arg(url).arg(reason)); } void MainWindow::on_actionSet_global_upload_limit_triggered() @@ -1589,7 +1589,7 @@ bool MainWindow::addPythonPathToEnv() return true; QString python_path = Preferences::getPythonPath(); if (!python_path.isEmpty()) { - Logger::instance()->addMessage(tr("Python found in %1").arg(Utils::Fs::toNativePath(python_path)), Log::INFO); + Logger::instance()->addMessage(tr("Python found in '%1'").arg(Utils::Fs::toNativePath(python_path)), Log::INFO); // Add it to PATH envvar QString path_envar = QString::fromLocal8Bit(qgetenv("PATH").constData()); if (path_envar.isNull()) diff --git a/src/gui/properties/peerlistwidget.cpp b/src/gui/properties/peerlistwidget.cpp index 3e2e0d747..1dabf529d 100644 --- a/src/gui/properties/peerlistwidget.cpp +++ b/src/gui/properties/peerlistwidget.cpp @@ -182,11 +182,11 @@ void PeerListWidget::showPeerListMenu(const QPoint&) foreach (const BitTorrent::PeerAddress &addr, peersList) { if (torrent->connectPeer(addr)) { qDebug("Adding peer %s...", qPrintable(addr.ip.toString())); - Logger::instance()->addMessage(tr("Manually adding peer %1...").arg(addr.ip.toString())); + Logger::instance()->addMessage(tr("Manually adding peer '%1'...").arg(addr.ip.toString())); peerCount++; } else { - Logger::instance()->addMessage(tr("The peer %1 could not be added to this torrent.").arg(addr.ip.toString()), Log::WARNING); + Logger::instance()->addMessage(tr("The peer '%1' could not be added to this torrent.").arg(addr.ip.toString()), Log::WARNING); } } if (peerCount < peersList.length()) @@ -219,7 +219,7 @@ void PeerListWidget::banSelectedPeers() int row = m_proxyModel->mapToSource(index).row(); QString ip = m_listModel->data(m_listModel->index(row, PeerListDelegate::IP_HIDDEN)).toString(); qDebug("Banning peer %s...", ip.toLocal8Bit().data()); - Logger::instance()->addMessage(tr("Manually banning peer %1...").arg(ip)); + Logger::instance()->addMessage(tr("Manually banning peer '%1'...").arg(ip)); BitTorrent::Session::instance()->banIP(ip); } // Refresh list diff --git a/src/gui/properties/peersadditiondlg.cpp b/src/gui/properties/peersadditiondlg.cpp index 3dd1f7737..172c8d671 100644 --- a/src/gui/properties/peersadditiondlg.cpp +++ b/src/gui/properties/peersadditiondlg.cpp @@ -67,7 +67,7 @@ void PeersAdditionDlg::validateInput() } else { QMessageBox::warning(this, tr("Invalid peer"), - tr("The peer %1 is invalid.").arg(peer), + tr("The peer '%1' is invalid.").arg(peer), QMessageBox::Ok); m_peersList.clear(); return; diff --git a/src/gui/rss/automatedrssdownloader.cpp b/src/gui/rss/automatedrssdownloader.cpp index c18cdd935..6d6a16237 100644 --- a/src/gui/rss/automatedrssdownloader.cpp +++ b/src/gui/rss/automatedrssdownloader.cpp @@ -377,7 +377,7 @@ void AutomatedRssDownloader::on_removeRuleBtn_clicked() // Ask for confirmation QString confirm_text; if (selection.count() == 1) - confirm_text = tr("Are you sure you want to remove the download rule named %1?").arg(selection.first()->text()); + confirm_text = tr("Are you sure you want to remove the download rule named '%1'?").arg(selection.first()->text()); else confirm_text = tr("Are you sure you want to remove the selected download rules?"); if (QMessageBox::question(this, tr("Rule deletion confirmation"), confirm_text, QMessageBox::Yes, QMessageBox::No) != QMessageBox::Yes) diff --git a/src/gui/rss/rssfeed.cpp b/src/gui/rss/rssfeed.cpp index 6587e9123..9a81223ce 100644 --- a/src/gui/rss/rssfeed.cpp +++ b/src/gui/rss/rssfeed.cpp @@ -365,12 +365,12 @@ void RssFeed::downloadArticleTorrentIfMatching(RssDownloadRuleList* rules, const // Download the torrent const QString& torrent_url = article->torrentUrl(); if (torrent_url.isEmpty()) { - Logger::instance()->addMessage(tr("Automatic download %1 from %2 RSS feed failed because it doesn't contain a torrent or a magnet link...").arg(article->title()).arg(displayName()), Log::WARNING); + Logger::instance()->addMessage(tr("Automatic download of '%1' from '%2' RSS feed failed because it doesn't contain a torrent or a magnet link...").arg(article->title()).arg(displayName()), Log::WARNING); article->markAsRead(); return; } - Logger::instance()->addMessage(tr("Automatically downloading %1 torrent from %2 RSS feed...").arg(article->title()).arg(displayName())); + Logger::instance()->addMessage(tr("Automatically downloading '%1' torrent from '%2' RSS feed...").arg(article->title()).arg(displayName())); connect(BitTorrent::Session::instance(), SIGNAL(downloadFromUrlFinished(QString)), article.data(), SLOT(handleTorrentDownloadSuccess(const QString&)), Qt::UniqueConnection); connect(article.data(), SIGNAL(articleWasRead()), SLOT(handleArticleStateChanged()), Qt::UniqueConnection); diff --git a/src/gui/rss/rssparser.cpp b/src/gui/rss/rssparser.cpp index fb0932d59..b3a1cac37 100644 --- a/src/gui/rss/rssparser.cpp +++ b/src/gui/rss/rssparser.cpp @@ -498,7 +498,7 @@ void RssParser::parseFeed(const ParsingJob& job) } if (!found_channel) { - reportFailure(job, tr("Invalid RSS feed at %1.").arg(job.feedUrl)); + reportFailure(job, tr("Invalid RSS feed at '%1'.").arg(job.feedUrl)); return; } diff --git a/src/gui/torrentimportdlg.cpp b/src/gui/torrentimportdlg.cpp index 798925f5e..a28a6145b 100644 --- a/src/gui/torrentimportdlg.cpp +++ b/src/gui/torrentimportdlg.cpp @@ -86,9 +86,9 @@ void TorrentImportDlg::on_browseContentBtn_clicked() QString filter; if (!extension.isEmpty()) { extension = extension.toUpper(); - filter = tr("%1 Files", "%1 is a file extension (e.g. PDF)").arg(extension) + " (*." + extension + ")"; + filter = tr("'%1' Files", "%1 is a file extension (e.g. PDF)").arg(extension) + " (*." + extension + ")"; } - m_contentPath = QFileDialog::getOpenFileName(this, tr("Please provide the location of %1", "%1 is a file name").arg(file_name), default_dir, filter); + m_contentPath = QFileDialog::getOpenFileName(this, tr("Please provide the location of '%1'", "%1 is a file name").arg(file_name), default_dir, filter); if (m_contentPath.isEmpty() || !QFile(m_contentPath).exists()) { m_contentPath = QString::null; ui->importBtn->setEnabled(false); diff --git a/src/gui/transferlistfilterswidget.cpp b/src/gui/transferlistfilterswidget.cpp index b5797675a..8d58dddf9 100644 --- a/src/gui/transferlistfilterswidget.cpp +++ b/src/gui/transferlistfilterswidget.cpp @@ -630,12 +630,12 @@ void TrackerFiltersList::handleFavicoDownload(const QString& url, const QString& bool invalid = (sizes.size() > 0 ? icon.pixmap(sizes.first()).isNull() : true); if (invalid) { if (url.endsWith(".ico", Qt::CaseInsensitive)) { - Logger::instance()->addMessage(tr("Couldn't decode favicon for URL `%1`. Trying to download favicon in PNG format.").arg(url), + Logger::instance()->addMessage(tr("Couldn't decode favicon for URL '%1'. Trying to download favicon in PNG format.").arg(url), Log::WARNING); downloadFavicon(url.left(url.size() - 4) + ".png"); } else { - Logger::instance()->addMessage(tr("Couldn't decode favicon for URL `%1`.").arg(url), Log::WARNING); + Logger::instance()->addMessage(tr("Couldn't decode favicon for URL '%1'.").arg(url), Log::WARNING); } Utils::Fs::forceRemove(filePath); } @@ -649,7 +649,7 @@ void TrackerFiltersList::handleFavicoFailure(const QString& url, const QString& { // Don't use getHost() on the url here. Print the full url. The error might relate to // that. - Logger::instance()->addMessage(tr("Couldn't download favicon for URL `%1`. Reason: `%2`").arg(url).arg(error), + Logger::instance()->addMessage(tr("Couldn't download favicon for URL '%1'. Reason: %2").arg(url).arg(error), Log::WARNING); if (url.endsWith(".ico", Qt::CaseInsensitive)) downloadFavicon(url.left(url.size() - 4) + ".png"); diff --git a/src/searchengine/engineselectdlg.cpp b/src/searchengine/engineselectdlg.cpp index a6e191626..2841aed12 100644 --- a/src/searchengine/engineselectdlg.cpp +++ b/src/searchengine/engineselectdlg.cpp @@ -251,7 +251,7 @@ void engineSelectDlg::installPlugin(QString path, QString plugin_name) { qDebug("Version to be installed: %.2f", new_version); if (!isUpdateNeeded(plugin_name, new_version)) { qDebug("Apparently update is not needed, we have a more recent version"); - QMessageBox::information(this, tr("Search plugin install"), tr("A more recent version of %1 search engine plugin is already installed.", "%1 is the name of the search engine").arg(plugin_name)); + QMessageBox::information(this, tr("Search plugin install"), tr("A more recent version of '%1' search engine plugin is already installed.", "%1 is the name of the search engine").arg(plugin_name)); return; } // Process with install @@ -276,12 +276,12 @@ void engineSelectDlg::installPlugin(QString path, QString plugin_name) { // restore backup QFile::copy(dest_path+".bak", dest_path); Utils::Fs::forceRemove(dest_path+".bak"); - QMessageBox::warning(this, tr("Search plugin install"), tr("%1 search engine plugin could not be updated, keeping old version.", "%1 is the name of the search engine").arg(plugin_name)); + QMessageBox::warning(this, tr("Search plugin install"), tr("'%1' search engine plugin could not be updated, keeping old version.", "%1 is the name of the search engine").arg(plugin_name)); return; } else { // Remove broken file Utils::Fs::forceRemove(dest_path); - QMessageBox::warning(this, tr("Search plugin install"), tr("%1 search engine plugin could not be installed.", "%1 is the name of the search engine").arg(plugin_name)); + QMessageBox::warning(this, tr("Search plugin install"), tr("'%1' search engine plugin could not be installed.", "%1 is the name of the search engine").arg(plugin_name)); return; } } @@ -291,10 +291,10 @@ void engineSelectDlg::installPlugin(QString path, QString plugin_name) { qreal version = SearchEngine::getPluginVersion(Utils::Fs::searchEngineLocation() + "/engines/" + plugin_name + ".py"); QTreeWidgetItem *item = findItemWithID(plugin_name); item->setText(ENGINE_VERSION, QString::number(version, 'f', 2)); - QMessageBox::information(this, tr("Search plugin install"), tr("%1 search engine plugin was successfully updated.", "%1 is the name of the search engine").arg(plugin_name)); + QMessageBox::information(this, tr("Search plugin install"), tr("'%1' search engine plugin was successfully updated.", "%1 is the name of the search engine").arg(plugin_name)); return; } else { - QMessageBox::information(this, tr("Search plugin install"), tr("%1 search engine plugin was successfully installed.", "%1 is the name of the search engine").arg(plugin_name)); + QMessageBox::information(this, tr("Search plugin install"), tr("'%1' search engine plugin was successfully installed.", "%1 is the name of the search engine").arg(plugin_name)); return; } } @@ -491,6 +491,6 @@ void engineSelectDlg::handleDownloadFailure(const QString &url, const QString &r // a plugin update download has been failed QString plugin_name = url.split('/').last(); plugin_name.replace(".py", "", Qt::CaseInsensitive); - QMessageBox::warning(this, tr("Search plugin update"), tr("Sorry, %1 search plugin installation failed.", "%1 is the name of the search engine").arg(plugin_name)); + QMessageBox::warning(this, tr("Search plugin update"), tr("Sorry, '%1' search plugin installation failed.", "%1 is the name of the search engine").arg(plugin_name)); } } From 42c74f95537f769d8ee33694e5eff8db681d04c3 Mon Sep 17 00:00:00 2001 From: Gabriele Date: Sat, 8 Aug 2015 15:21:41 +0200 Subject: [PATCH 2/3] Avoid concatenation when dealing with translatable strings Concatenation could be problematic with RTL languages. --- src/gui/properties/peerlistdelegate.h | 2 +- src/gui/properties/propertieswidget.cpp | 51 ++++++++++----- src/gui/rss/automatedrssdownloader.cpp | 6 +- src/gui/torrentcreatordlg.cpp | 4 +- src/gui/transferlistdelegate.cpp | 10 +-- src/webui/www/public/scripts/prop-general.js | 66 +++++++++++++++----- 6 files changed, 101 insertions(+), 38 deletions(-) diff --git a/src/gui/properties/peerlistdelegate.h b/src/gui/properties/peerlistdelegate.h index eb68fb1d6..21a0d3b57 100644 --- a/src/gui/properties/peerlistdelegate.h +++ b/src/gui/properties/peerlistdelegate.h @@ -62,7 +62,7 @@ public: QItemDelegate::drawBackground(painter, opt, index); qreal speed = index.data().toDouble(); if (speed > 0.0) - QItemDelegate::drawDisplay(painter, opt, opt.rect, Utils::Misc::friendlyUnit(speed)+tr("/s", "/second (i.e. per second)")); + QItemDelegate::drawDisplay(painter, opt, opt.rect, Utils::Misc::friendlyUnit(speed, true)); break; } case PROGRESS: diff --git a/src/gui/properties/propertieswidget.cpp b/src/gui/properties/propertieswidget.cpp index 27d063f4a..ebf0a45c9 100644 --- a/src/gui/properties/propertieswidget.cpp +++ b/src/gui/properties/propertieswidget.cpp @@ -358,17 +358,30 @@ void PropertiesWidget::loadDynamicData() { switch(stackedProperties->currentIndex()) { case PropTabBar::MAIN_TAB: { wasted->setText(Utils::Misc::friendlyUnit(m_torrent->wastedSize())); - upTotal->setText(Utils::Misc::friendlyUnit(m_torrent->totalUpload()) + " ("+Utils::Misc::friendlyUnit(m_torrent->totalPayloadUpload())+" "+tr("this session")+")"); - dlTotal->setText(Utils::Misc::friendlyUnit(m_torrent->totalDownload()) + " ("+Utils::Misc::friendlyUnit(m_torrent->totalPayloadDownload())+" "+tr("this session")+")"); - lbl_uplimit->setText(m_torrent->uploadLimit() <= 0 ? QString::fromUtf8(C_INFINITY) : Utils::Misc::friendlyUnit(m_torrent->uploadLimit())+tr("/s", "/second (i.e. per second)")); - lbl_dllimit->setText(m_torrent->downloadLimit() <= 0 ? QString::fromUtf8(C_INFINITY) : Utils::Misc::friendlyUnit(m_torrent->downloadLimit())+tr("/s", "/second (i.e. per second)")); - QString elapsed_txt = Utils::Misc::userFriendlyDuration(m_torrent->activeTime()); - if (m_torrent->isSeed()) - elapsed_txt += " ("+tr("seeded for %1", "e.g. seeded for 3m10s").arg(Utils::Misc::userFriendlyDuration(m_torrent->seedingTime()))+")"; + upTotal->setText(tr("%1 (%2 this session)").arg(Utils::Misc::friendlyUnit(m_torrent->totalUpload())) + .arg(Utils::Misc::friendlyUnit(m_torrent->totalPayloadUpload()))); + + dlTotal->setText(tr("%1 (%2 this session)").arg(Utils::Misc::friendlyUnit(m_torrent->totalDownload())) + .arg(Utils::Misc::friendlyUnit(m_torrent->totalPayloadDownload()))); + + lbl_uplimit->setText(m_torrent->uploadLimit() <= 0 ? QString::fromUtf8(C_INFINITY) : Utils::Misc::friendlyUnit(m_torrent->uploadLimit(), true)); + + lbl_dllimit->setText(m_torrent->downloadLimit() <= 0 ? QString::fromUtf8(C_INFINITY) : Utils::Misc::friendlyUnit(m_torrent->downloadLimit(), true)); + + QString elapsed_txt; + if (m_torrent->isSeed()) + elapsed_txt = tr("%1 (seeded for %2)", "e.g. 4m39s (seeded for 3m10s)") + .arg(Utils::Misc::userFriendlyDuration(m_torrent->activeTime())) + .arg(Utils::Misc::userFriendlyDuration(m_torrent->seedingTime())); + else + elapsed_txt = Utils::Misc::userFriendlyDuration(m_torrent->activeTime()); lbl_elapsed->setText(elapsed_txt); - lbl_connections->setText(QString::number(m_torrent->connectionsCount()) + " (" + tr("%1 max", "e.g. 10 max").arg(QString::number(m_torrent->connectionsLimit())) + ")"); + lbl_connections->setText(tr("%1 (%2 max)", "%1 and %2 are numbers, e.g. 3 (10 max)") + .arg(QString::number(m_torrent->connectionsCount())) + .arg(QString::number(m_torrent->connectionsLimit()))); + label_eta_val->setText(Utils::Misc::userFriendlyDuration(m_torrent->eta())); // Update next announce time @@ -378,16 +391,26 @@ void PropertiesWidget::loadDynamicData() { const qreal ratio = m_torrent->realRatio(); shareRatio->setText(ratio > BitTorrent::TorrentHandle::MAX_RATIO ? QString::fromUtf8(C_INFINITY) : Utils::String::fromDouble(ratio, 2)); - label_seeds_val->setText(QString::number(m_torrent->seedsCount()) + " " + tr("(%1 total)","e.g. (10 total)").arg(QString::number(m_torrent->totalSeedsCount()))); - label_peers_val->setText(QString::number(m_torrent->leechsCount()) + " " + tr("(%1 total)","e.g. (10 total)").arg(QString::number(m_torrent->totalLeechersCount()))); + label_seeds_val->setText(tr("%1 (%2 total)", "%1 and %2 are numbers, e.g. 3 (10 total)") + .arg(QString::number(m_torrent->seedsCount())) + .arg(QString::number(m_torrent->totalSeedsCount()))); + + label_peers_val->setText(tr("%1 (%2 total)", "%1 and %2 are numbers, e.g. 3 (10 total)") + .arg(QString::number(m_torrent->leechsCount())) + .arg(QString::number(m_torrent->totalLeechersCount()))); + + label_dl_speed_val->setText(tr("%1 (%2 avg.)", "%1 and %2 are speed rates, e.g. 200KiB/s (100KiB/s avg.)") + .arg(Utils::Misc::friendlyUnit(m_torrent->downloadPayloadRate(), true)) + .arg(m_torrent->totalDownload() / (1 + m_torrent->activeTime() - m_torrent->finishedTime()), true)); - label_dl_speed_val->setText(Utils::Misc::friendlyUnit(m_torrent->downloadPayloadRate()) + tr("/s", "/second (i.e. per second)") + " " - + tr("(%1/s avg.)","e.g. (100KiB/s avg.)").arg(Utils::Misc::friendlyUnit(m_torrent->totalDownload() / (1 + m_torrent->activeTime() - m_torrent->finishedTime())))); - label_upload_speed_val->setText(Utils::Misc::friendlyUnit(m_torrent->uploadPayloadRate()) + tr("/s", "/second (i.e. per second)") + " " - + tr("(%1/s avg.)", "e.g. (100KiB/s avg.)").arg(Utils::Misc::friendlyUnit(m_torrent->totalUpload() / (1 + m_torrent->activeTime())))); + label_upload_speed_val->setText(tr("%1 (%2 avg.)", "%1 and %2 are speed rates, e.g. 200KiB/s (100KiB/s avg.)") + .arg(Utils::Misc::friendlyUnit(m_torrent->uploadPayloadRate(), true)) + .arg(Utils::Misc::friendlyUnit(m_torrent->totalUpload() / (1 + m_torrent->activeTime())), true)); label_last_complete_val->setText(m_torrent->lastSeenComplete().isValid() ? m_torrent->lastSeenComplete().toString(Qt::DefaultLocaleShortDate) : tr("Never")); + label_completed_on_val->setText(m_torrent->completedTime().isValid() ? m_torrent->completedTime().toString(Qt::DefaultLocaleShortDate) : ""); + label_added_on_val->setText(m_torrent->addedTime().toString(Qt::DefaultLocaleShortDate)); if (m_torrent->hasMetadata()) { diff --git a/src/gui/rss/automatedrssdownloader.cpp b/src/gui/rss/automatedrssdownloader.cpp index 6d6a16237..1fede2666 100644 --- a/src/gui/rss/automatedrssdownloader.cpp +++ b/src/gui/rss/automatedrssdownloader.cpp @@ -258,11 +258,11 @@ void AutomatedRssDownloader::updateRuleDefinitionBox() ui->comboAddPaused->setCurrentIndex(rule->addPaused()); ui->spinIgnorePeriod->setValue(rule->ignoreDays()); QDateTime dateTime = rule->lastMatch(); - QString lMatch = tr("Last match: "); + QString lMatch; if (dateTime.isValid()) - lMatch += QString::number(dateTime.daysTo(QDateTime::currentDateTime())) + tr(" days ago."); + lMatch = tr("Last match: %1 days ago").arg(dateTime.daysTo(QDateTime::currentDateTime())); else - lMatch += tr("Unknown"); + lMatch = tr("Last match: Unknown"); ui->lblLastMatch->setText(lMatch); updateMustLineValidity(); updateMustNotLineValidity(); diff --git a/src/gui/torrentcreatordlg.cpp b/src/gui/torrentcreatordlg.cpp index ae1e91abb..a8b522316 100644 --- a/src/gui/torrentcreatordlg.cpp +++ b/src/gui/torrentcreatordlg.cpp @@ -121,7 +121,7 @@ void TorrentCreatorDlg::on_createButton_clicked() Preferences* const pref = Preferences::instance(); QString lastPath = pref->getCreateTorLastSavePath(); - QString destination = QFileDialog::getSaveFileName(this, tr("Select destination torrent file"), lastPath, tr("Torrent Files")+QString::fromUtf8(" (*.torrent)")); + QString destination = QFileDialog::getSaveFileName(this, tr("Select destination torrent file"), lastPath, tr("Torrent Files (*.torrent)")); if (destination.isEmpty()) return; @@ -173,7 +173,7 @@ void TorrentCreatorDlg::handleCreationSuccess(QString path, QString branch_path) BitTorrent::Session::instance()->addTorrent(t, params); } - QMessageBox::information(0, tr("Torrent creation"), tr("Torrent was created successfully:")+" "+Utils::Fs::toNativePath(path)); + QMessageBox::information(0, tr("Torrent creation"), tr("Torrent was created successfully: %1", "%1 is the path of the torrent").arg(Utils::Fs::toNativePath(path))); close(); } diff --git a/src/gui/transferlistdelegate.cpp b/src/gui/transferlistdelegate.cpp index 9ffa5dc15..aeaf59b1e 100644 --- a/src/gui/transferlistdelegate.cpp +++ b/src/gui/transferlistdelegate.cpp @@ -150,7 +150,7 @@ void TransferListDelegate::paint(QPainter * painter, const QStyleOptionViewItem QItemDelegate::drawBackground(painter, opt, index); const qulonglong speed = index.data().toULongLong(); opt.displayAlignment = Qt::AlignRight | Qt::AlignVCenter; - QItemDelegate::drawDisplay(painter, opt, opt.rect, Utils::Misc::friendlyUnit(speed)+tr("/s", "/second (.i.e per second)")); + QItemDelegate::drawDisplay(painter, opt, opt.rect, Utils::Misc::friendlyUnit(speed, true)); break; } case TorrentModel::TR_UPLIMIT: @@ -158,15 +158,17 @@ void TransferListDelegate::paint(QPainter * painter, const QStyleOptionViewItem QItemDelegate::drawBackground(painter, opt, index); const qlonglong limit = index.data().toLongLong(); opt.displayAlignment = Qt::AlignRight | Qt::AlignVCenter; - QItemDelegate::drawDisplay(painter, opt, opt.rect, limit > 0 ? Utils::String::fromDouble(limit/1024., 1) + " " + tr("KiB/s", "KiB/second (.i.e per second)") : QString::fromUtf8(C_INFINITY)); + QItemDelegate::drawDisplay(painter, opt, opt.rect, limit > 0 ? Utils::Misc::friendlyUnit(limit, true) : QString::fromUtf8(C_INFINITY)); break; } case TorrentModel::TR_TIME_ELAPSED: { QItemDelegate::drawBackground(painter, opt, index); - QString txt = Utils::Misc::userFriendlyDuration(index.data().toLongLong()); qlonglong seeding_time = index.data(Qt::UserRole).toLongLong(); + QString txt; if (seeding_time > 0) - txt += " ("+tr("seeded for %1", "e.g. seeded for 3m10s").arg(Utils::Misc::userFriendlyDuration(seeding_time))+")"; + txt += tr("%1 (seeded for %2)", "e.g. 4m39s (seeded for 3m10s)") + .arg(Utils::Misc::userFriendlyDuration(index.data().toLongLong())) + .arg(Utils::Misc::userFriendlyDuration(seeding_time)); QItemDelegate::drawDisplay(painter, opt, opt.rect, txt); break; } diff --git a/src/webui/www/public/scripts/prop-general.js b/src/webui/www/public/scripts/prop-general.js index e7070c8cc..b9c95a59e 100644 --- a/src/webui/www/public/scripts/prop-general.js +++ b/src/webui/www/public/scripts/prop-general.js @@ -56,64 +56,102 @@ var loadTorrentData = function() { if (data) { var temp; // Update Torrent data - temp = friendlyDuration(data.time_elapsed) if (data.seeding_time > 0) - temp += " (" + "QBT_TR(seeded for %1)QBT_TR".replace("%1", friendlyDuration(data.seeding_time)) + ")"; + temp = "QBT_TR(%1 (%2 this session))QBT_TR" + .replace("%1", friendlyDuration(data.time_elapsed)) + .replace("%2", friendlyDuration(data.seeding_time)) + else + temp = friendlyDuration(data.time_elapsed) $('time_elapsed').set('html', temp); + $('eta').set('html', friendlyDuration(data.eta)); - temp = data.nb_connections + " (" + "QBT_TR(%1 max)QBT_TR".replace("%1", data.nb_connections_limit) + ")"; + + temp = "QBT_TR(%1 (%2 max))QBT_TR" + .replace("%1", data.nb_connections) + .replace("%2", data.nb_connections_limit) $('nb_connections').set('html', temp); - temp = friendlyUnit(data.total_downloaded) + - " (" + friendlyUnit(data.total_downloaded_session) + - " QBT_TR(this session)QBT_TR" + ")"; + + temp = "QBT_TR(%1 (%2 this session))QBT_TR" + .replace("%1", friendlyUnit(data.total_downloaded)) + .replace("%2", friendlyUnit(data.total_downloaded_session)) $('total_downloaded').set('html', temp); - temp = friendlyUnit(data.total_uploaded) + - " (" + friendlyUnit(data.total_uploaded_session) + - " QBT_TR(this session)QBT_TR" + ")"; + + temp = "QBT_TR(%1 (%2 this session))QBT_TR" + .replace("%1", friendlyUnit(data.total_uploaded)) + .replace("%2", friendlyUnit(data.total_uploaded_session)) $('total_uploaded').set('html', temp); - temp = friendlyUnit(data.dl_speed, true) + " QBT_TR((%1/s avg.))QBT_TR".replace("%1", friendlyUnit(data.dl_speed_avg)); + + temp = "QBT_TR(%1 (%2 avg.))QBT_TR" + .replace("%1", friendlyUnit(data.dl_speed, true)) + .replace("%2", friendlyUnit(data.dl_speed_avg, true)); $('dl_speed').set('html', temp); - temp = friendlyUnit(data.up_speed, true) + " QBT_TR((%1/s avg.))QBT_TR".replace("%1", friendlyUnit(data.up_speed_avg)); + + temp = "QBT_TR(%1 (%2 avg.))QBT_TR" + .replace("%1", friendlyUnit(data.up_speed, true)) + .replace("%2", friendlyUnit(data.up_speed_avg, true)); $('up_speed').set('html', temp); + temp = (data.dl_limit == -1 ? "∞" : friendlyUnit(data.dl_limit, true)); $('dl_limit').set('html', temp); + temp = (data.up_limit == -1 ? "∞" : friendlyUnit(data.up_limit, true)); $('up_limit').set('html', temp); + $('total_wasted').set('html', friendlyUnit(data.total_wasted)); - temp = data.seeds + " QBT_TR((%1 total))QBT_TR".replace("%1", data.seeds_total); + + temp = "QBT_TR(%1 (%2 total))QBT_TR" + .replace("%1", data.seeds) + .replace("%2", data.seeds_total); $('seeds').set('html', temp); - temp = data.peers + " QBT_TR((%1 total))QBT_TR".replace("%1", data.peers_total); + + temp = "QBT_TR(%1 (%2 total))QBT_TR" + .replace("%1", data.peers) + .replace("%2", data.peers_total); $('peers').set('html', temp); + $('share_ratio').set('html', data.share_ratio.toFixed(2)); + $('reannounce').set('html', friendlyDuration(data.reannounce)); + if (data.last_seen != -1) temp = new Date(data.last_seen * 1000).toLocaleString(); else temp = "QBT_TR(Never)QBT_TR"; $('last_seen').set('html', temp); + $('total_size').set('html', friendlyUnit(data.total_size)); + if (data.pieces_num != -1) - temp = "QBT_TR(%1 x %2 (have %3))QBT_TR".replace("%1", data.pieces_num).replace("%2", friendlyUnit(data.piece_size)).replace("%3", data.pieces_have); + temp = "QBT_TR(%1 x %2 (have %3))QBT_TR" + .replace("%1", data.pieces_num) + .replace("%2", friendlyUnit(data.piece_size)) + .replace("%3", data.pieces_have); else temp = "QBT_TR(Unknown)QBT_TR"; $('pieces').set('html', temp); + $('created_by').set('html', data.created_by); if (data.addition_date != -1) temp = new Date(data.addition_date * 1000).toLocaleString(); else temp = "QBT_TR(Unknown)QBT_TR"; + $('addition_date').set('html', temp); if (data.completion_date != -1) temp = new Date(data.completion_date * 1000).toLocaleString(); else temp = ""; + $('completion_date').set('html', temp); + if (data.creation_date != -1) temp = new Date(data.creation_date * 1000).toLocaleString(); else temp = "QBT_TR(Unknown)QBT_TR"; $('creation_date').set('html', temp); + $('save_path').set('html', data.save_path); + $('comment').set('html', parseHtmlLinks(data.comment)); } else { From 5cc5552d9b994ede4fb44def755576d0ffaa6d92 Mon Sep 17 00:00:00 2001 From: Gabriele Date: Sat, 8 Aug 2015 16:23:30 +0200 Subject: [PATCH 3/3] Use infinity symbol rather than -1 for nb_connections --- src/gui/properties/propertieswidget.cpp | 2 +- src/webui/www/public/scripts/prop-general.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/properties/propertieswidget.cpp b/src/gui/properties/propertieswidget.cpp index ebf0a45c9..a7451e545 100644 --- a/src/gui/properties/propertieswidget.cpp +++ b/src/gui/properties/propertieswidget.cpp @@ -379,7 +379,7 @@ void PropertiesWidget::loadDynamicData() { lbl_elapsed->setText(elapsed_txt); lbl_connections->setText(tr("%1 (%2 max)", "%1 and %2 are numbers, e.g. 3 (10 max)") - .arg(QString::number(m_torrent->connectionsCount())) + .arg(m_torrent->connectionsCount() < 0 ? QString::fromUtf8(C_INFINITY) : QString::number(m_torrent->connectionsCount())) .arg(QString::number(m_torrent->connectionsLimit()))); label_eta_val->setText(Utils::Misc::userFriendlyDuration(m_torrent->eta())); diff --git a/src/webui/www/public/scripts/prop-general.js b/src/webui/www/public/scripts/prop-general.js index b9c95a59e..4e80ee15d 100644 --- a/src/webui/www/public/scripts/prop-general.js +++ b/src/webui/www/public/scripts/prop-general.js @@ -68,7 +68,7 @@ var loadTorrentData = function() { temp = "QBT_TR(%1 (%2 max))QBT_TR" .replace("%1", data.nb_connections) - .replace("%2", data.nb_connections_limit) + .replace("%2", data.nb_connections_limit < 0 ? "∞" : data.nb_connections_limit) $('nb_connections').set('html', temp); temp = "QBT_TR(%1 (%2 this session))QBT_TR"