mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-19 21:03:30 -07:00
parent
88ef8a51dd
commit
cc563d9f78
4 changed files with 67 additions and 59 deletions
|
@ -1767,53 +1767,55 @@ void TorrentImpl::endReceivedMetadataHandling(const Path &savePath, const PathLi
|
||||||
}
|
}
|
||||||
|
|
||||||
void TorrentImpl::reload()
|
void TorrentImpl::reload()
|
||||||
try
|
|
||||||
{
|
{
|
||||||
m_completedFiles.fill(false);
|
try
|
||||||
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();
|
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
if (m_isStopped)
|
|
||||||
{
|
{
|
||||||
p.flags |= lt::torrent_flags::paused;
|
m_completedFiles.fill(false);
|
||||||
p.flags &= ~lt::torrent_flags::auto_managed;
|
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();
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
m_nativeStatus = extensionData->status;
|
||||||
|
|
||||||
|
if (queuePos >= lt::queue_position_t {})
|
||||||
|
m_nativeHandle.queue_position_set(queuePos);
|
||||||
|
m_nativeStatus.queue_position = queuePos;
|
||||||
|
|
||||||
|
updateState();
|
||||||
}
|
}
|
||||||
else if (m_operatingMode == TorrentOperatingMode::AutoManaged)
|
catch (const lt::system_error &err)
|
||||||
{
|
{
|
||||||
p.flags |= (lt::torrent_flags::auto_managed | lt::torrent_flags::paused);
|
throw RuntimeError(tr("Failed to reload torrent. Torrent: %1. Reason: %2")
|
||||||
|
.arg(id().toString(), QString::fromLocal8Bit(err.what())));
|
||||||
}
|
}
|
||||||
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);
|
|
||||||
|
|
||||||
m_nativeStatus = extensionData->status;
|
|
||||||
|
|
||||||
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())));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TorrentImpl::pause()
|
void TorrentImpl::pause()
|
||||||
|
|
|
@ -54,14 +54,14 @@
|
||||||
using namespace std::chrono_literals;
|
using namespace std::chrono_literals;
|
||||||
using namespace boost::multi_index;
|
using namespace boost::multi_index;
|
||||||
|
|
||||||
const std::chrono::milliseconds ANNOUNCE_TIME_REFRESH_INTERVAL = 4s;
|
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
const QString STR_WORKING = TrackerListModel::tr("Working");
|
const std::chrono::milliseconds ANNOUNCE_TIME_REFRESH_INTERVAL = 4s;
|
||||||
const QString STR_DISABLED = TrackerListModel::tr("Disabled");
|
|
||||||
const QString STR_TORRENT_DISABLED = TrackerListModel::tr("Disabled for this torrent");
|
const char STR_WORKING[] = QT_TRANSLATE_NOOP("TrackerListModel", "Working");
|
||||||
const QString STR_PRIVATE_MSG = TrackerListModel::tr("This torrent is private");
|
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)
|
QString prettyCount(const int val)
|
||||||
{
|
{
|
||||||
|
@ -73,7 +73,7 @@ namespace
|
||||||
switch (status)
|
switch (status)
|
||||||
{
|
{
|
||||||
case BitTorrent::TrackerEntryStatus::Working:
|
case BitTorrent::TrackerEntryStatus::Working:
|
||||||
return TrackerListModel::tr("Working");
|
return TrackerListModel::tr(STR_WORKING);
|
||||||
case BitTorrent::TrackerEntryStatus::Updating:
|
case BitTorrent::TrackerEntryStatus::Updating:
|
||||||
return TrackerListModel::tr("Updating...");
|
return TrackerListModel::tr("Updating...");
|
||||||
case BitTorrent::TrackerEntryStatus::NotWorking:
|
case BitTorrent::TrackerEntryStatus::NotWorking:
|
||||||
|
@ -91,34 +91,34 @@ namespace
|
||||||
QString statusDHT(const BitTorrent::Torrent *torrent)
|
QString statusDHT(const BitTorrent::Torrent *torrent)
|
||||||
{
|
{
|
||||||
if (!torrent->session()->isDHTEnabled())
|
if (!torrent->session()->isDHTEnabled())
|
||||||
return STR_DISABLED;
|
return TrackerListModel::tr(STR_DISABLED);
|
||||||
|
|
||||||
if (torrent->isPrivate() || torrent->isDHTDisabled())
|
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)
|
QString statusPeX(const BitTorrent::Torrent *torrent)
|
||||||
{
|
{
|
||||||
if (!torrent->session()->isPeXEnabled())
|
if (!torrent->session()->isPeXEnabled())
|
||||||
return STR_DISABLED;
|
return TrackerListModel::tr(STR_DISABLED);
|
||||||
|
|
||||||
if (torrent->isPrivate() || torrent->isPEXDisabled())
|
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)
|
QString statusLSD(const BitTorrent::Torrent *torrent)
|
||||||
{
|
{
|
||||||
if (!torrent->session()->isLSDEnabled())
|
if (!torrent->session()->isLSDEnabled())
|
||||||
return STR_DISABLED;
|
return TrackerListModel::tr(STR_DISABLED);
|
||||||
|
|
||||||
if (torrent->isPrivate() || torrent->isLSDDisabled())
|
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<BitTorrent::TrackerEntry> trackerEntries = m_torrent->trackers();
|
const QList<BitTorrent::TrackerEntry> trackerEntries = m_torrent->trackers();
|
||||||
m_items->reserve(trackerEntries.size() + STICKY_ROW_COUNT);
|
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"** [DHT] **", privateTorrentMessage));
|
||||||
m_items->emplace_back(std::make_shared<Item>(u"** [PeX] **", privateTorrentMessage));
|
m_items->emplace_back(std::make_shared<Item>(u"** [PeX] **", privateTorrentMessage));
|
||||||
m_items->emplace_back(std::make_shared<Item>(u"** [LSD] **", privateTorrentMessage));
|
m_items->emplace_back(std::make_shared<Item>(u"** [LSD] **", privateTorrentMessage));
|
||||||
|
|
|
@ -67,6 +67,7 @@ namespace
|
||||||
class ColorWidget final : public QFrame
|
class ColorWidget final : public QFrame
|
||||||
{
|
{
|
||||||
Q_DISABLE_COPY_MOVE(ColorWidget)
|
Q_DISABLE_COPY_MOVE(ColorWidget)
|
||||||
|
Q_DECLARE_TR_FUNCTIONS(ColorWidget)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ColorWidget(const QColor ¤tColor, const QColor &defaultColor, QWidget *parent = nullptr)
|
explicit ColorWidget(const QColor ¤tColor, const QColor &defaultColor, QWidget *parent = nullptr)
|
||||||
|
@ -140,6 +141,7 @@ private:
|
||||||
class IconWidget final : public QLabel
|
class IconWidget final : public QLabel
|
||||||
{
|
{
|
||||||
Q_DISABLE_COPY_MOVE(IconWidget)
|
Q_DISABLE_COPY_MOVE(IconWidget)
|
||||||
|
Q_DECLARE_TR_FUNCTIONS(IconWidget)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit IconWidget(const Path ¤tPath, const Path &defaultPath, QWidget *parent = nullptr)
|
explicit IconWidget(const Path ¤tPath, const Path &defaultPath, QWidget *parent = nullptr)
|
||||||
|
|
|
@ -61,6 +61,8 @@ public:
|
||||||
|
|
||||||
class DefaultThemeSource final : public UIThemeSource
|
class DefaultThemeSource final : public UIThemeSource
|
||||||
{
|
{
|
||||||
|
Q_DECLARE_TR_FUNCTIONS(DefaultThemeSource)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DefaultThemeSource();
|
DefaultThemeSource();
|
||||||
|
|
||||||
|
@ -78,6 +80,8 @@ private:
|
||||||
|
|
||||||
class CustomThemeSource : public UIThemeSource
|
class CustomThemeSource : public UIThemeSource
|
||||||
{
|
{
|
||||||
|
Q_DECLARE_TR_FUNCTIONS(CustomThemeSource)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QColor getColor(const QString &colorId, ColorMode colorMode) const override;
|
QColor getColor(const QString &colorId, ColorMode colorMode) const override;
|
||||||
Path getIconPath(const QString &iconId, ColorMode colorMode) const override;
|
Path getIconPath(const QString &iconId, ColorMode colorMode) const override;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue