32 #include <QPushButton>
37 #include "ui_watchedfolderoptionsdialog.h"
40 #define SETTINGS_KEY(name) "WatchedFolderOptionsDialog/" name
46 , m_savePath {watchedFolderOptions.addTorrentParams.savePath}
47 , m_downloadPath {watchedFolderOptions.addTorrentParams.downloadPath}
53 m_ui->savePath->setDialogCaption(tr(
"Choose save path"));
58 m_ui->downloadPath->setDialogCaption(tr(
"Choose save path"));
68 m_ui->startTorrentCheckBox->setChecked(!torrentParams.
addPaused.value_or(session->isAddTorrentPaused()));
70 m_ui->comboTTM->setCurrentIndex(torrentParams.
useAutoTMM.value_or(!session->isAutoTMMDisabledByDefault()));
71 m_ui->contentLayoutComboBox->setCurrentIndex(
72 static_cast<int>(torrentParams.
contentLayout.value_or(session->torrentContentLayout())));
75 QStringList categories = session->categories();
78 if (!torrentParams.
category.isEmpty())
80 m_ui->categoryComboBox->addItem(
"");
82 for (
const QString &category :
asConst(categories))
84 if (category != torrentParams.
category)
85 m_ui->categoryComboBox->addItem(category);
90 m_ui->buttonBox->button(QDialogButtonBox::Ok)->setFocus();
105 const bool useAutoTMM = (
m_ui->comboTTM->currentIndex() == 1);
114 params.
category =
m_ui->categoryComboBox->currentText();
136 if (
m_ui->comboTTM->currentIndex() == 1)
139 const QString categoryName =
m_ui->categoryComboBox->currentText();
141 const QString savePath = btSession->categorySavePath(categoryName);
144 const QString finishedSavePath = btSession->categoryDownloadPath(categoryName);
147 m_ui->groupBoxDownloadPath->setChecked(!finishedSavePath.isEmpty());
155 const QString defaultSavePath {btSession->savePath()};
158 const QString defaultFinishedSavePath {btSession->downloadPath()};
169 m_ui->groupBoxSavePath->setEnabled(
true);
170 m_ui->savePath->blockSignals(
false);
171 m_ui->downloadPath->blockSignals(
false);
175 m_ui->groupBoxSavePath->setEnabled(
false);
179 m_ui->savePath->blockSignals(
true);
181 const QString savePath = btSession->categorySavePath(
m_ui->categoryComboBox->currentText());
182 m_ui->savePath->setSelectedPath(savePath);
184 m_ui->downloadPath->blockSignals(
true);
186 const QString finishedSavePath = btSession->categoryDownloadPath(
m_ui->categoryComboBox->currentText());
187 m_ui->downloadPath->setSelectedPath(finishedSavePath);
190 m_ui->groupBoxDownloadPath->setChecked(!finishedSavePath.isEmpty());
static Session * instance()
@ DirectorySave
selecting directories for saving
Ui::WatchedFolderOptionsDialog * m_ui
void onTMMChanged(int index)
~WatchedFolderOptionsDialog() override
void onCategoryChanged(int index)
SettingValue< QSize > m_storeDialogSize
TorrentFilesWatcher::WatchedFolderOptions watchedFolderOptions() const
WatchedFolderOptionsDialog(const TorrentFilesWatcher::WatchedFolderOptions &watchedFolderOptions, QWidget *parent)
constexpr std::add_const_t< T > & asConst(T &t) noexcept
QString toNativePath(const QString &path)
void resize(QWidget *widget, const QSize &newSize={})
std::optional< bool > useDownloadPath
std::optional< bool > useAutoTMM
std::optional< bool > addPaused
std::optional< BitTorrent::TorrentContentLayout > contentLayout
BitTorrent::AddTorrentParams addTorrentParams
#define SETTINGS_KEY(name)