Use std::optional<bool> instead of custom TriStateBool

This commit is contained in:
Vladimir Golovnev (Glassez) 2021-01-02 16:55:17 +03:00
parent d0cac421bb
commit 531ae501ad
No known key found for this signature in database
GPG key ID: 52A2C7DEE2DFA6F7
17 changed files with 75 additions and 235 deletions

View file

@ -505,7 +505,7 @@ void Application::processParams(const QStringList &params)
}
#endif
BitTorrent::AddTorrentParams torrentParams;
TriStateBool skipTorrentDialog;
std::optional<bool> skipTorrentDialog;
for (QString param : params)
{
@ -521,7 +521,7 @@ void Application::processParams(const QStringList &params)
if (param.startsWith(QLatin1String("@addPaused=")))
{
torrentParams.addPaused = param.midRef(11).toInt() ? TriStateBool::True : TriStateBool::False;
torrentParams.addPaused = (param.midRef(11).toInt() != 0);
continue;
}
@ -551,7 +551,7 @@ void Application::processParams(const QStringList &params)
if (param.startsWith(QLatin1String("@skipDialog=")))
{
skipTorrentDialog = param.midRef(12).toInt() ? TriStateBool::True : TriStateBool::False;
skipTorrentDialog = (param.midRef(12).toInt() != 0);
continue;
}
@ -561,9 +561,7 @@ void Application::processParams(const QStringList &params)
// 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);
const bool showDialogForThisTorrent = !skipTorrentDialog.value_or(!AddNewTorrentDialog::isEnabled());
if (showDialogForThisTorrent)
AddNewTorrentDialog::show(param, torrentParams, m_window);
else