diff --git a/src/base/bittorrent/torrentimpl.cpp b/src/base/bittorrent/torrentimpl.cpp index 1c7bc88f209f..c7ed105a534a 100644 --- a/src/base/bittorrent/torrentimpl.cpp +++ b/src/base/bittorrent/torrentimpl.cpp @@ -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() diff --git a/src/gui/trackerlist/trackerlistmodel.cpp b/src/gui/trackerlist/trackerlistmodel.cpp index 3ac377327e89..4b4c6e42ba9a 100644 --- a/src/gui/trackerlist/trackerlistmodel.cpp +++ b/src/gui/trackerlist/trackerlistmodel.cpp @@ -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) { @@ -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: @@ -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); } } @@ -299,7 +299,7 @@ void TrackerListModel::populate() const QList 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(u"** [DHT] **", privateTorrentMessage)); m_items->emplace_back(std::make_shared(u"** [PeX] **", privateTorrentMessage)); m_items->emplace_back(std::make_shared(u"** [LSD] **", privateTorrentMessage)); diff --git a/src/gui/uithemedialog.cpp b/src/gui/uithemedialog.cpp index 3187a0f1542d..ef2b5626d765 100644 --- a/src/gui/uithemedialog.cpp +++ b/src/gui/uithemedialog.cpp @@ -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 ¤tColor, const QColor &defaultColor, QWidget *parent = nullptr) @@ -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 ¤tPath, const Path &defaultPath, QWidget *parent = nullptr) diff --git a/src/gui/uithemesource.h b/src/gui/uithemesource.h index cb2afbbeb9f2..cd7870595102 100644 --- a/src/gui/uithemesource.h +++ b/src/gui/uithemesource.h @@ -61,6 +61,8 @@ class UIThemeSource class DefaultThemeSource final : public UIThemeSource { + Q_DECLARE_TR_FUNCTIONS(DefaultThemeSource) + public: DefaultThemeSource(); @@ -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;