mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-12-21 08:09:35 +08:00
Add option to remember last used save path
Replace in "Add new torrent" dialog confusing "Set as default save path" option with "Remember last used save path" option that affects only selected value in "Save path" combo box. Closes #7323.
This commit is contained in:
parent
e3ce9b2645
commit
71e5a40857
@ -70,6 +70,7 @@ namespace
|
||||
const QString KEY_TOPLEVEL = SETTINGS_KEY("TopLevel");
|
||||
const QString KEY_SAVEPATHHISTORY = SETTINGS_KEY("SavePathHistory");
|
||||
const char KEY_SAVEPATHHISTORYLENGTH[] = SETTINGS_KEY("SavePathHistoryLength");
|
||||
const QString KEY_REMEMBERLASTSAVEPATH = SETTINGS_KEY("RememberLastSavePath");
|
||||
|
||||
// just a shortcut
|
||||
inline SettingsStorage *settings()
|
||||
@ -114,7 +115,9 @@ AddNewTorrentDialog::AddNewTorrentDialog(const BitTorrent::AddTorrentParams &inP
|
||||
m_ui->comboTTM->blockSignals(false);
|
||||
populateSavePathComboBox();
|
||||
connect(m_ui->savePath, &FileSystemPathEdit::selectedPathChanged, this, &AddNewTorrentDialog::onSavePathChanged);
|
||||
m_ui->defaultSavePathCheckBox->setVisible(false); // Default path is selected by default
|
||||
|
||||
const bool rememberLastSavePath = settings()->loadValue(KEY_REMEMBERLASTSAVEPATH, false).toBool();
|
||||
m_ui->checkBoxRememberLastSavePath->setChecked(rememberLastSavePath);
|
||||
|
||||
if (m_torrentParams.createSubfolder == TriStateBool::True)
|
||||
m_ui->createSubfolderCheckBox->setChecked(true);
|
||||
@ -453,9 +456,7 @@ void AddNewTorrentDialog::updateDiskSpaceLabel()
|
||||
|
||||
void AddNewTorrentDialog::onSavePathChanged(const QString &newPath)
|
||||
{
|
||||
// Toggle default save path setting checkbox visibility
|
||||
m_ui->defaultSavePathCheckBox->setChecked(false);
|
||||
m_ui->defaultSavePathCheckBox->setVisible(QDir(newPath) != QDir(BitTorrent::Session::instance()->defaultSavePath()));
|
||||
Q_UNUSED(newPath);
|
||||
// Remember index
|
||||
m_oldIndex = m_ui->savePath->currentIndex();
|
||||
updateDiskSpaceLabel();
|
||||
@ -586,18 +587,21 @@ void AddNewTorrentDialog::renameSelectedFile()
|
||||
|
||||
void AddNewTorrentDialog::populateSavePathComboBox()
|
||||
{
|
||||
QString defSavePath = BitTorrent::Session::instance()->defaultSavePath();
|
||||
|
||||
m_ui->savePath->clear();
|
||||
m_ui->savePath->addItem(defSavePath);
|
||||
QDir defaultSaveDir(defSavePath);
|
||||
|
||||
// Load save path history
|
||||
foreach (const QString &savePath, settings()->loadValue(KEY_SAVEPATHHISTORY).toStringList())
|
||||
if (QDir(savePath) != defaultSaveDir)
|
||||
m_ui->savePath->addItem(savePath);
|
||||
const QStringList savePathHistory {settings()->loadValue(KEY_SAVEPATHHISTORY).toStringList()};
|
||||
for (const QString &savePath : savePathHistory)
|
||||
m_ui->savePath->addItem(savePath);
|
||||
|
||||
const bool rememberLastSavePath {settings()->loadValue(KEY_REMEMBERLASTSAVEPATH, false).toBool()};
|
||||
const QString defSavePath {BitTorrent::Session::instance()->defaultSavePath()};
|
||||
|
||||
if (!m_torrentParams.savePath.isEmpty())
|
||||
setSavePath(m_torrentParams.savePath);
|
||||
else if (!rememberLastSavePath)
|
||||
setSavePath(defSavePath);
|
||||
// else last used save path will be selected since it is the first in the list
|
||||
}
|
||||
|
||||
void AddNewTorrentDialog::displayContentTreeMenu(const QPoint &)
|
||||
@ -650,10 +654,11 @@ void AddNewTorrentDialog::accept()
|
||||
|
||||
// Category
|
||||
m_torrentParams.category = m_ui->categoryComboBox->currentText();
|
||||
|
||||
if (m_ui->defaultCategoryCheckbox->isChecked())
|
||||
settings()->storeValue(KEY_DEFAULTCATEGORY, m_torrentParams.category);
|
||||
|
||||
settings()->storeValue(KEY_REMEMBERLASTSAVEPATH, m_ui->checkBoxRememberLastSavePath->isChecked());
|
||||
|
||||
// Save file priorities
|
||||
if (m_contentModel)
|
||||
m_torrentParams.filePriorities = m_contentModel->model()->getFilePriorities();
|
||||
@ -666,8 +671,6 @@ void AddNewTorrentDialog::accept()
|
||||
m_torrentParams.useAutoTMM = TriStateBool::False;
|
||||
m_torrentParams.savePath = savePath;
|
||||
saveSavePathHistory();
|
||||
if (m_ui->defaultSavePathCheckBox->isChecked())
|
||||
BitTorrent::Session::instance()->setDefaultSavePath(savePath);
|
||||
}
|
||||
else {
|
||||
m_torrentParams.useAutoTMM = TriStateBool::True;
|
||||
@ -807,7 +810,6 @@ void AddNewTorrentDialog::TMMChanged(int index)
|
||||
m_ui->savePath->clear();
|
||||
QString savePath = BitTorrent::Session::instance()->categorySavePath(m_ui->categoryComboBox->currentText());
|
||||
m_ui->savePath->addItem(savePath);
|
||||
m_ui->defaultSavePathCheckBox->setVisible(false);
|
||||
m_ui->adv_button->setChecked(true);
|
||||
m_ui->adv_button->setEnabled(false);
|
||||
showAdvancedSettings(true);
|
||||
|
@ -59,12 +59,12 @@
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="FileSystemPathComboEdit" name="savePath" native="true"/>
|
||||
<widget class="FileSystemPathComboEdit" name="savePath" native="true"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="defaultSavePathCheckBox">
|
||||
<widget class="QCheckBox" name="checkBoxRememberLastSavePath">
|
||||
<property name="text">
|
||||
<string>Set as default save path</string>
|
||||
<string>Remember last used save path</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -393,7 +393,7 @@
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>savePath</tabstop>
|
||||
<tabstop>defaultSavePathCheckBox</tabstop>
|
||||
<tabstop>checkBoxRememberLastSavePath</tabstop>
|
||||
<tabstop>never_show_cb</tabstop>
|
||||
<tabstop>adv_button</tabstop>
|
||||
<tabstop>startTorrentCheckBox</tabstop>
|
||||
|
Loading…
Reference in New Issue
Block a user