mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-12 16:23:07 -07:00
Added command line arguments for specifying options when adding torrents
Arguments include adding torrents as paused/started, skiping hash check, setting category, downloading in sequential order, downloading first and last pieces first, and skipping the 'add new torrent' dialog. Added TriStateBoolOption class for specifying options that don't have a default value when unused (e.g. add-paused). Also improved command line usage text to include more information, have better organization, and not exceed 80 columns in width. Also also added firstLastPiecePriority field to BitTorrent::AddTorrentData, and modified TorrentHandle so that if first/last piece priority should be on, it will be toggled on after the torrent's metadata has loaded.
This commit is contained in:
parent
172991e068
commit
eba41978b0
12 changed files with 375 additions and 90 deletions
|
@ -407,15 +407,63 @@ void Application::processParams(const QStringList ¶ms)
|
|||
return;
|
||||
}
|
||||
#endif
|
||||
BitTorrent::AddTorrentParams torrentParams;
|
||||
TriStateBool skipTorrentDialog;
|
||||
|
||||
foreach (QString param, params) {
|
||||
param = param.trimmed();
|
||||
|
||||
// Process strings indicating options specified by the user.
|
||||
|
||||
if (param.startsWith(QLatin1String("@savePath="))) {
|
||||
torrentParams.savePath = param.mid(10);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (param.startsWith(QLatin1String("@addPaused="))) {
|
||||
torrentParams.addPaused = param.mid(11).toInt() ? TriStateBool::True : TriStateBool::False;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (param == QLatin1String("@skipChecking")) {
|
||||
torrentParams.skipChecking = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (param.startsWith(QLatin1String("@category="))) {
|
||||
torrentParams.category = param.mid(10);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (param == QLatin1String("@sequential")) {
|
||||
torrentParams.sequential = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (param == QLatin1String("@firstLastPiecePriority")) {
|
||||
torrentParams.firstLastPiecePriority = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (param.startsWith(QLatin1String("@skipDialog="))) {
|
||||
skipTorrentDialog = param.mid(12).toInt() ? TriStateBool::True : TriStateBool::False;
|
||||
continue;
|
||||
}
|
||||
|
||||
#ifndef DISABLE_GUI
|
||||
if (AddNewTorrentDialog::isEnabled())
|
||||
AddNewTorrentDialog::show(param, m_window);
|
||||
// There are two circumstances in which we want to show the torrent
|
||||
// dialog. One is when the application settings specify that it should
|
||||
// be shown and skipTorrentDialog is undefined. The other is when
|
||||
// skipTorrentDialog is false, meaning that the application setting
|
||||
// should be overridden.
|
||||
const bool showDialogForThisTorrent =
|
||||
((AddNewTorrentDialog::isEnabled() && skipTorrentDialog == TriStateBool::Undefined)
|
||||
|| skipTorrentDialog == TriStateBool::False);
|
||||
if (showDialogForThisTorrent)
|
||||
AddNewTorrentDialog::show(param, torrentParams, m_window);
|
||||
else
|
||||
#endif
|
||||
BitTorrent::Session::instance()->addTorrent(param);
|
||||
BitTorrent::Session::instance()->addTorrent(param, torrentParams);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue