Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix incorrect usage of translation functions #20107

Merged
merged 1 commit into from
Dec 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 40 additions & 38 deletions src/base/bittorrent/torrentimpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1767,53 +1767,55 @@ void TorrentImpl::endReceivedMetadataHandling(const Path &savePath, const PathLi
}

void TorrentImpl::reload()
try
{
m_completedFiles.fill(false);
m_filesProgress.fill(0);
m_pieces.fill(false);
m_nativeStatus.pieces.clear_all();
m_nativeStatus.num_pieces = 0;
try
{
m_completedFiles.fill(false);
m_filesProgress.fill(0);
m_pieces.fill(false);
m_nativeStatus.pieces.clear_all();
m_nativeStatus.num_pieces = 0;

const auto queuePos = m_nativeHandle.queue_position();
const auto queuePos = m_nativeHandle.queue_position();

m_nativeSession->remove_torrent(m_nativeHandle, lt::session::delete_partfile);
m_nativeSession->remove_torrent(m_nativeHandle, lt::session::delete_partfile);

lt::add_torrent_params p = m_ltAddTorrentParams;
p.flags |= lt::torrent_flags::update_subscribe
| lt::torrent_flags::override_trackers
| lt::torrent_flags::override_web_seeds;
lt::add_torrent_params p = m_ltAddTorrentParams;
p.flags |= lt::torrent_flags::update_subscribe
| lt::torrent_flags::override_trackers
| lt::torrent_flags::override_web_seeds;

if (m_isStopped)
{
p.flags |= lt::torrent_flags::paused;
p.flags &= ~lt::torrent_flags::auto_managed;
}
else if (m_operatingMode == TorrentOperatingMode::AutoManaged)
{
p.flags |= (lt::torrent_flags::auto_managed | lt::torrent_flags::paused);
}
else
{
p.flags &= ~(lt::torrent_flags::auto_managed | lt::torrent_flags::paused);
}
if (m_isStopped)
{
p.flags |= lt::torrent_flags::paused;
p.flags &= ~lt::torrent_flags::auto_managed;
}
else if (m_operatingMode == TorrentOperatingMode::AutoManaged)
{
p.flags |= (lt::torrent_flags::auto_managed | lt::torrent_flags::paused);
}
else
{
p.flags &= ~(lt::torrent_flags::auto_managed | lt::torrent_flags::paused);
}

auto *const extensionData = new ExtensionData;
p.userdata = LTClientData(extensionData);
m_nativeHandle = m_nativeSession->add_torrent(p);
auto *const extensionData = new ExtensionData;
p.userdata = LTClientData(extensionData);
m_nativeHandle = m_nativeSession->add_torrent(p);

m_nativeStatus = extensionData->status;
m_nativeStatus = extensionData->status;

if (queuePos >= lt::queue_position_t {})
m_nativeHandle.queue_position_set(queuePos);
m_nativeStatus.queue_position = queuePos;
if (queuePos >= lt::queue_position_t {})
m_nativeHandle.queue_position_set(queuePos);
m_nativeStatus.queue_position = queuePos;

updateState();
}
catch (const lt::system_error &err)
{
throw RuntimeError(tr("Failed to reload torrent. Torrent: %1. Reason: %2")
.arg(id().toString(), QString::fromLocal8Bit(err.what())));
updateState();
}
catch (const lt::system_error &err)
{
throw RuntimeError(tr("Failed to reload torrent. Torrent: %1. Reason: %2")
.arg(id().toString(), QString::fromLocal8Bit(err.what())));
}
}

void TorrentImpl::pause()
Expand Down
34 changes: 17 additions & 17 deletions src/gui/trackerlist/trackerlistmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@
using namespace std::chrono_literals;
using namespace boost::multi_index;

const std::chrono::milliseconds ANNOUNCE_TIME_REFRESH_INTERVAL = 4s;

namespace
{
const QString STR_WORKING = TrackerListModel::tr("Working");
const QString STR_DISABLED = TrackerListModel::tr("Disabled");
const QString STR_TORRENT_DISABLED = TrackerListModel::tr("Disabled for this torrent");
const QString STR_PRIVATE_MSG = TrackerListModel::tr("This torrent is private");
const std::chrono::milliseconds ANNOUNCE_TIME_REFRESH_INTERVAL = 4s;

const char STR_WORKING[] = QT_TRANSLATE_NOOP("TrackerListModel", "Working");
const char STR_DISABLED[] = QT_TRANSLATE_NOOP("TrackerListModel", "Disabled");
const char STR_TORRENT_DISABLED[] = QT_TRANSLATE_NOOP("TrackerListModel", "Disabled for this torrent");
const char STR_PRIVATE_MSG[] = QT_TRANSLATE_NOOP("TrackerListModel", "This torrent is private");

QString prettyCount(const int val)
{
Expand All @@ -73,7 +73,7 @@ namespace
switch (status)
{
case BitTorrent::TrackerEntryStatus::Working:
return TrackerListModel::tr("Working");
return TrackerListModel::tr(STR_WORKING);
case BitTorrent::TrackerEntryStatus::Updating:
return TrackerListModel::tr("Updating...");
case BitTorrent::TrackerEntryStatus::NotWorking:
Expand All @@ -91,34 +91,34 @@ namespace
QString statusDHT(const BitTorrent::Torrent *torrent)
{
if (!torrent->session()->isDHTEnabled())
return STR_DISABLED;
return TrackerListModel::tr(STR_DISABLED);

if (torrent->isPrivate() || torrent->isDHTDisabled())
return STR_TORRENT_DISABLED;
return TrackerListModel::tr(STR_TORRENT_DISABLED);

return STR_WORKING;
return TrackerListModel::tr(STR_WORKING);
}

QString statusPeX(const BitTorrent::Torrent *torrent)
{
if (!torrent->session()->isPeXEnabled())
return STR_DISABLED;
return TrackerListModel::tr(STR_DISABLED);

if (torrent->isPrivate() || torrent->isPEXDisabled())
return STR_TORRENT_DISABLED;
return TrackerListModel::tr(STR_TORRENT_DISABLED);

return STR_WORKING;
return TrackerListModel::tr(STR_WORKING);
}

QString statusLSD(const BitTorrent::Torrent *torrent)
{
if (!torrent->session()->isLSDEnabled())
return STR_DISABLED;
return TrackerListModel::tr(STR_DISABLED);

if (torrent->isPrivate() || torrent->isLSDDisabled())
return STR_TORRENT_DISABLED;
return TrackerListModel::tr(STR_TORRENT_DISABLED);

return STR_WORKING;
return TrackerListModel::tr(STR_WORKING);
}
}

Expand Down Expand Up @@ -299,7 +299,7 @@ void TrackerListModel::populate()
const QList<BitTorrent::TrackerEntry> trackerEntries = m_torrent->trackers();
m_items->reserve(trackerEntries.size() + STICKY_ROW_COUNT);

const QString &privateTorrentMessage = m_torrent->isPrivate() ? STR_PRIVATE_MSG : u""_s;
const QString &privateTorrentMessage = m_torrent->isPrivate() ? tr(STR_PRIVATE_MSG) : u""_s;
m_items->emplace_back(std::make_shared<Item>(u"** [DHT] **", privateTorrentMessage));
m_items->emplace_back(std::make_shared<Item>(u"** [PeX] **", privateTorrentMessage));
m_items->emplace_back(std::make_shared<Item>(u"** [LSD] **", privateTorrentMessage));
Expand Down
2 changes: 2 additions & 0 deletions src/gui/uithemedialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ namespace
class ColorWidget final : public QFrame
{
Q_DISABLE_COPY_MOVE(ColorWidget)
Q_DECLARE_TR_FUNCTIONS(ColorWidget)

public:
explicit ColorWidget(const QColor &currentColor, const QColor &defaultColor, QWidget *parent = nullptr)
Expand Down Expand Up @@ -140,6 +141,7 @@ class ColorWidget final : public QFrame
class IconWidget final : public QLabel
{
Q_DISABLE_COPY_MOVE(IconWidget)
Q_DECLARE_TR_FUNCTIONS(IconWidget)

public:
explicit IconWidget(const Path &currentPath, const Path &defaultPath, QWidget *parent = nullptr)
Expand Down
4 changes: 4 additions & 0 deletions src/gui/uithemesource.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ class UIThemeSource

class DefaultThemeSource final : public UIThemeSource
{
Q_DECLARE_TR_FUNCTIONS(DefaultThemeSource)

public:
DefaultThemeSource();

Expand All @@ -78,6 +80,8 @@ class DefaultThemeSource final : public UIThemeSource

class CustomThemeSource : public UIThemeSource
{
Q_DECLARE_TR_FUNCTIONS(CustomThemeSource)

public:
QColor getColor(const QString &colorId, ColorMode colorMode) const override;
Path getIconPath(const QString &iconId, ColorMode colorMode) const override;
Expand Down