Browse Source

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

adaptive-webui-19844
sledgehammer999 8 years ago
parent
commit
829425831f
  1. 16
      src/gui/addnewtorrentdialog.cpp
  2. 1
      src/gui/addnewtorrentdialog.h

16
src/gui/addnewtorrentdialog.cpp

@ -58,7 +58,6 @@
#define SETTINGS_KEY(name) "AddNewTorrentDialog/" name #define SETTINGS_KEY(name) "AddNewTorrentDialog/" name
const QString KEY_ENABLED = SETTINGS_KEY("Enabled"); const QString KEY_ENABLED = SETTINGS_KEY("Enabled");
const QString KEY_DEFAULTSAVEPATH = SETTINGS_KEY("DefaultSavePath");
const QString KEY_DEFAULTCATEGORY = SETTINGS_KEY("DefaultCategory"); const QString KEY_DEFAULTCATEGORY = SETTINGS_KEY("DefaultCategory");
const QString KEY_TREEHEADERSTATE = SETTINGS_KEY("TreeHeaderState"); const QString KEY_TREEHEADERSTATE = SETTINGS_KEY("TreeHeaderState");
const QString KEY_WIDTH = SETTINGS_KEY("Width"); const QString KEY_WIDTH = SETTINGS_KEY("Width");
@ -394,7 +393,7 @@ void AddNewTorrentDialog::onSavePathChanged(int index)
ui->defaultSavePathCheckBox->setChecked(false); ui->defaultSavePathCheckBox->setChecked(false);
ui->defaultSavePathCheckBox->setVisible( ui->defaultSavePathCheckBox->setVisible(
QDir(ui->savePathComboBox->itemData(ui->savePathComboBox->currentIndex()).toString()) QDir(ui->savePathComboBox->itemData(ui->savePathComboBox->currentIndex()).toString())
!= QDir(defaultSavePath())); != QDir(BitTorrent::Session::instance()->defaultSavePath()));
// Remember index // Remember index
m_oldIndex = index; m_oldIndex = index;
@ -567,7 +566,7 @@ void AddNewTorrentDialog::setdialogPosition()
void AddNewTorrentDialog::populateSavePathComboBox() void AddNewTorrentDialog::populateSavePathComboBox()
{ {
QString defSavePath = defaultSavePath(); QString defSavePath = BitTorrent::Session::instance()->defaultSavePath();
ui->savePathComboBox->clear(); ui->savePathComboBox->clear();
ui->savePathComboBox->addItem(Utils::Fs::toNativePath(defSavePath), defSavePath); 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. 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; params.savePath = savePath;
saveSavePathHistory(); saveSavePathHistory();
if (ui->defaultSavePathCheckBox->isChecked()) { if (ui->defaultSavePathCheckBox->isChecked())
settings()->storeValue(KEY_DEFAULTSAVEPATH, savePath);
BitTorrent::Session::instance()->setDefaultSavePath(savePath); BitTorrent::Session::instance()->setDefaultSavePath(savePath);
} }
}
setEnabled(!ui->never_show_cb->isChecked()); setEnabled(!ui->never_show_cb->isChecked());
@ -746,13 +743,6 @@ void AddNewTorrentDialog::setupTreeview()
setdialogPosition(); 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) void AddNewTorrentDialog::handleDownloadFailed(const QString &url, const QString &reason)
{ {
MessageBoxRaised::critical(0, tr("Download Error"), QString("Cannot download '%1': %2").arg(url).arg(reason)); MessageBoxRaised::critical(0, tr("Download Error"), QString("Cannot download '%1': %2").arg(url).arg(reason));

1
src/gui/addnewtorrentdialog.h

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

Loading…
Cancel
Save