mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-20 05:13:30 -07:00
Use std::optional<bool> instead of custom TriStateBool
This commit is contained in:
parent
d0cac421bb
commit
531ae501ad
17 changed files with 75 additions and 235 deletions
|
@ -107,12 +107,7 @@ AddNewTorrentDialog::AddNewTorrentDialog(const BitTorrent::AddTorrentParams &inP
|
|||
|
||||
const auto *session = BitTorrent::Session::instance();
|
||||
|
||||
if (m_torrentParams.addPaused == TriStateBool::True)
|
||||
m_ui->startTorrentCheckBox->setChecked(false);
|
||||
else if (m_torrentParams.addPaused == TriStateBool::False)
|
||||
m_ui->startTorrentCheckBox->setChecked(true);
|
||||
else
|
||||
m_ui->startTorrentCheckBox->setChecked(!session->isAddTorrentPaused());
|
||||
m_ui->startTorrentCheckBox->setChecked(!m_torrentParams.addPaused.value_or(session->isAddTorrentPaused()));
|
||||
|
||||
m_ui->comboTTM->blockSignals(true); // the TreeView size isn't correct if the slot does it job at this point
|
||||
m_ui->comboTTM->setCurrentIndex(!session->isAutoTMMDisabledByDefault());
|
||||
|
@ -573,7 +568,7 @@ void AddNewTorrentDialog::accept()
|
|||
if (m_contentModel)
|
||||
m_torrentParams.filePriorities = m_contentModel->model()->getFilePriorities();
|
||||
|
||||
m_torrentParams.addPaused = TriStateBool(!m_ui->startTorrentCheckBox->isChecked());
|
||||
m_torrentParams.addPaused = !m_ui->startTorrentCheckBox->isChecked();
|
||||
m_torrentParams.contentLayout = static_cast<BitTorrent::TorrentContentLayout>(m_ui->contentLayoutComboBox->currentIndex());
|
||||
|
||||
m_torrentParams.sequential = m_ui->sequentialCheckBox->isChecked();
|
||||
|
@ -582,13 +577,13 @@ void AddNewTorrentDialog::accept()
|
|||
QString savePath = m_ui->savePath->selectedPath();
|
||||
if (m_ui->comboTTM->currentIndex() != 1)
|
||||
{ // 0 is Manual mode and 1 is Automatic mode. Handle all non 1 values as manual mode.
|
||||
m_torrentParams.useAutoTMM = TriStateBool::False;
|
||||
m_torrentParams.useAutoTMM = false;
|
||||
m_torrentParams.savePath = savePath;
|
||||
saveSavePathHistory();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_torrentParams.useAutoTMM = TriStateBool::True;
|
||||
m_torrentParams.useAutoTMM = true;
|
||||
}
|
||||
|
||||
setEnabled(!m_ui->checkBoxNeverShow->isChecked());
|
||||
|
|
|
@ -269,10 +269,8 @@ void AutomatedRssDownloader::updateRuleDefinitionBox()
|
|||
if (m_currentRule.assignedCategory().isEmpty())
|
||||
m_ui->comboCategory->clearEditText();
|
||||
int index = 0;
|
||||
if (m_currentRule.addPaused() == TriStateBool::True)
|
||||
index = 1;
|
||||
else if (m_currentRule.addPaused() == TriStateBool::False)
|
||||
index = 2;
|
||||
if (m_currentRule.addPaused().has_value())
|
||||
index = (*m_currentRule.addPaused() ? 1 : 2);
|
||||
m_ui->comboAddPaused->setCurrentIndex(index);
|
||||
index = 0;
|
||||
if (m_currentRule.torrentContentLayout())
|
||||
|
@ -347,11 +345,11 @@ void AutomatedRssDownloader::updateEditedRule()
|
|||
m_currentRule.setEpisodeFilter(m_ui->lineEFilter->text());
|
||||
m_currentRule.setSavePath(m_ui->checkBoxSaveDiffDir->isChecked() ? m_ui->lineSavePath->selectedPath() : "");
|
||||
m_currentRule.setCategory(m_ui->comboCategory->currentText());
|
||||
TriStateBool addPaused; // Undefined by default
|
||||
std::optional<bool> addPaused;
|
||||
if (m_ui->comboAddPaused->currentIndex() == 1)
|
||||
addPaused = TriStateBool::True;
|
||||
addPaused = true;
|
||||
else if (m_ui->comboAddPaused->currentIndex() == 2)
|
||||
addPaused = TriStateBool::False;
|
||||
addPaused = false;
|
||||
m_currentRule.setAddPaused(addPaused);
|
||||
|
||||
std::optional<BitTorrent::TorrentContentLayout> contentLayout;
|
||||
|
|
|
@ -249,7 +249,7 @@ void TorrentCreatorDialog::handleCreationSuccess(const QString &path, const QStr
|
|||
params.ratioLimit = BitTorrent::TorrentHandle::NO_RATIO_LIMIT;
|
||||
params.seedingTimeLimit = BitTorrent::TorrentHandle::NO_SEEDING_TIME_LIMIT;
|
||||
}
|
||||
params.useAutoTMM = TriStateBool::False; // otherwise if it is on by default, it will overwrite `savePath` to the default save path
|
||||
params.useAutoTMM = false; // otherwise if it is on by default, it will overwrite `savePath` to the default save path
|
||||
|
||||
BitTorrent::Session::instance()->addTorrent(info, params);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue