Add 'Moving' state for torrents being relocated/moved

This is another indication to the user that something is happening
behind the scenes.
Uses the same icon/color as "Checking" status.
Torrents in the `Moving` state are considered as "Active". This should
prevent accidental program exit from the user and inhibit system sleep.
This commit is contained in:
sledgehammer999 2018-04-09 18:19:33 +03:00
parent 5df42420cb
commit 97b8e02bf5
No known key found for this signature in database
GPG key ID: 6E4A2D025B7CC9A2
6 changed files with 24 additions and 3 deletions

View file

@ -734,7 +734,8 @@ bool TorrentHandle::isActive() const
|| m_state == TorrentState::Downloading
|| m_state == TorrentState::ForcedDownloading
|| m_state == TorrentState::Uploading
|| m_state == TorrentState::ForcedUploading;
|| m_state == TorrentState::ForcedUploading
|| m_state == TorrentState::Moving;
}
bool TorrentHandle::isInactive() const
@ -807,7 +808,10 @@ TorrentState TorrentHandle::state() const
void TorrentHandle::updateState()
{
if (isPaused()) {
if (isMoveInProgress()) {
m_state = TorrentState::Moving;
}
else if (isPaused()) {
if (hasMissingFiles())
m_state = TorrentState::MissingFiles;
else if (hasError())
@ -1374,6 +1378,7 @@ void TorrentHandle::moveStorage(const QString &newPath, bool overwrite)
, (overwrite ? libt::always_replace_files : libt::dont_replace));
m_moveStorageInfo.oldPath = oldPath;
m_moveStorageInfo.newPath = newPath;
updateState();
}
}
@ -1450,9 +1455,10 @@ void TorrentHandle::handleStorageMovedAlert(const libtorrent::storage_moved_aler
qDebug() << "Removing torrent temp folder:" << m_moveStorageInfo.oldPath;
Utils::Fs::smartRemoveEmptyFolderTree(m_moveStorageInfo.oldPath);
}
updateStatus();
m_moveStorageInfo.newPath.clear();
updateStatus();
if (!m_moveStorageInfo.queuedPath.isEmpty()) {
moveStorage(m_moveStorageInfo.queuedPath, m_moveStorageInfo.queuedOverwrite);
m_moveStorageInfo.queuedPath.clear();
@ -1478,6 +1484,8 @@ void TorrentHandle::handleStorageMovedFailedAlert(const libtorrent::storage_move
.arg(name(), QString::fromStdString(p->message())), Log::CRITICAL);
m_moveStorageInfo.newPath.clear();
updateStatus();
if (!m_moveStorageInfo.queuedPath.isEmpty()) {
moveStorage(m_moveStorageInfo.queuedPath, m_moveStorageInfo.queuedOverwrite);
m_moveStorageInfo.queuedPath.clear();

View file

@ -149,6 +149,8 @@ namespace BitTorrent
PausedDownloading,
PausedUploading,
Moving,
MissingFiles,
Error
};

View file

@ -349,6 +349,7 @@ QIcon getIconByState(BitTorrent::TorrentState state)
case BitTorrent::TorrentState::QueuedForChecking:
#endif
case BitTorrent::TorrentState::CheckingResumeData:
case BitTorrent::TorrentState::Moving:
return getCheckingIcon();
case BitTorrent::TorrentState::Unknown:
case BitTorrent::TorrentState::MissingFiles:
@ -404,6 +405,7 @@ QColor getColorByState(BitTorrent::TorrentState state)
case BitTorrent::TorrentState::QueuedForChecking:
#endif
case BitTorrent::TorrentState::CheckingResumeData:
case BitTorrent::TorrentState::Moving:
if (!dark)
return QColor(0, 128, 128); // Teal
else

View file

@ -272,6 +272,9 @@ QString TransferListDelegate::getStatusString(const BitTorrent::TorrentState sta
case BitTorrent::TorrentState::PausedUploading:
str = tr("Completed");
break;
case BitTorrent::TorrentState::Moving:
str = tr("Moving", "Torrent local data are being moved/relocated");
break;
case BitTorrent::TorrentState::MissingFiles:
str = tr("Missing Files");
break;

View file

@ -76,6 +76,8 @@ namespace
#endif
case BitTorrent::TorrentState::CheckingResumeData:
return QLatin1String("checkingResumeData");
case BitTorrent::TorrentState::Moving:
return QLatin1String("moving");
default:
return QLatin1String("unknown");
}

View file

@ -814,6 +814,7 @@ var TorrentsTable = new Class({
case "checkingUP":
case "queuedForChecking":
case "checkingResumeData":
case "moving":
state = "checking";
break;
case "unknown":
@ -887,6 +888,9 @@ var TorrentsTable = new Class({
case "pausedUP":
status = "Completed";
break;
case "moving":
status = "Moving";
break;
case "missingFiles":
status = "Missing Files";
break;