Properly fix the handling of default save path store/load. Bug introduced in dd34663224

This commit is contained in:
sledgehammer999 2016-10-06 16:53:43 +03:00
parent 4f17364305
commit 498b7c2436
2 changed files with 3 additions and 14 deletions

View file

@ -58,7 +58,6 @@
#define SETTINGS_KEY(name) "AddNewTorrentDialog/" name
const QString KEY_ENABLED = SETTINGS_KEY("Enabled");
const QString KEY_DEFAULTSAVEPATH = SETTINGS_KEY("DefaultSavePath");
const QString KEY_DEFAULTCATEGORY = SETTINGS_KEY("DefaultCategory");
const QString KEY_TREEHEADERSTATE = SETTINGS_KEY("TreeHeaderState");
const QString KEY_WIDTH = SETTINGS_KEY("Width");
@ -394,7 +393,7 @@ void AddNewTorrentDialog::onSavePathChanged(int index)
ui->defaultSavePathCheckBox->setChecked(false);
ui->defaultSavePathCheckBox->setVisible(
QDir(ui->savePathComboBox->itemData(ui->savePathComboBox->currentIndex()).toString())
!= QDir(defaultSavePath()));
!= QDir(BitTorrent::Session::instance()->defaultSavePath()));
// Remember index
m_oldIndex = index;
@ -567,7 +566,7 @@ void AddNewTorrentDialog::setdialogPosition()
void AddNewTorrentDialog::populateSavePathComboBox()
{
QString defSavePath = defaultSavePath();
QString defSavePath = BitTorrent::Session::instance()->defaultSavePath();
ui->savePathComboBox->clear();
ui->savePathComboBox->addItem(Utils::Fs::toNativePath(defSavePath), defSavePath);
@ -645,11 +644,9 @@ void AddNewTorrentDialog::accept()
if (ui->comboTTM->currentIndex() != 1) { // 0 is Manual mode and 1 is Automatic mode. Handle all non 1 values as manual mode.
params.savePath = savePath;
saveSavePathHistory();
if (ui->defaultSavePathCheckBox->isChecked()) {
settings()->storeValue(KEY_DEFAULTSAVEPATH, savePath);
if (ui->defaultSavePathCheckBox->isChecked())
BitTorrent::Session::instance()->setDefaultSavePath(savePath);
}
}
setEnabled(!ui->never_show_cb->isChecked());
@ -746,13 +743,6 @@ void AddNewTorrentDialog::setupTreeview()
setdialogPosition();
}
QString AddNewTorrentDialog::defaultSavePath() const
{
return Utils::Fs::fromNativePath(
settings()->loadValue(KEY_DEFAULTSAVEPATH,
BitTorrent::Session::instance()->defaultSavePath()).toString());
}
void AddNewTorrentDialog::handleDownloadFailed(const QString &url, const QString &reason)
{
MessageBoxRaised::critical(0, tr("Download Error"), QString("Cannot download '%1': %2").arg(url).arg(reason));

View file

@ -97,7 +97,6 @@ private:
void saveState();
void setMetadataProgressIndicator(bool visibleIndicator, const QString &labelText = QString());
void setupTreeview();
QString defaultSavePath() const;
void setCommentText(const QString &str) const;
void showEvent(QShowEvent *event) override;