From a82ccd8e95cf96c43d8bc1ce8242c2d9280e6f1b Mon Sep 17 00:00:00 2001 From: sledgehammer_999 Date: Tue, 6 Sep 2011 22:13:02 +0300 Subject: [PATCH 1/2] Now qbt remembers the last used folder. Fixes #799697. Conflicts: src/preferences/options.ui --- src/preferences/options_imp.cpp | 3 +++ src/preferences/preferences.h | 16 ++++++++++++++++ src/torrentadditiondlg.cpp | 21 +++++++++++++++++++-- 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/src/preferences/options_imp.cpp b/src/preferences/options_imp.cpp index 977bf3d63..0bbaf92e1 100644 --- a/src/preferences/options_imp.cpp +++ b/src/preferences/options_imp.cpp @@ -155,6 +155,7 @@ options_imp::options_imp(QWidget *parent): connect(textSavePath, SIGNAL(textChanged(QString)), this, SLOT(enableApplyButton())); connect(textTempPath, SIGNAL(textChanged(QString)), this, SLOT(enableApplyButton())); connect(checkAppendLabel, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton())); + connect(checkLastLocation, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton())); connect(checkAppendqB, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton())); connect(checkPreallocateAll, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton())); connect(checkAdditionDialog, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton())); @@ -391,6 +392,7 @@ void options_imp::saveOptions(){ #endif pref.setTempPath(temp_path); pref.setAppendTorrentLabel(checkAppendLabel->isChecked()); + pref.setRememberLastLocation(checkLastLocation->isChecked()); #if LIBTORRENT_VERSION_MINOR > 14 pref.useIncompleteFilesExtension(checkAppendqB->isChecked()); #endif @@ -568,6 +570,7 @@ void options_imp::loadOptions(){ #endif textTempPath->setText(temp_path); checkAppendLabel->setChecked(pref.appendTorrentLabel()); + checkLastLocation->setChecked(pref.rememberLastLocation()); #if LIBTORRENT_VERSION_MINOR > 14 checkAppendqB->setChecked(pref.useIncompleteFilesExtension()); #endif diff --git a/src/preferences/preferences.h b/src/preferences/preferences.h index afb85944d..a77bb2a6d 100644 --- a/src/preferences/preferences.h +++ b/src/preferences/preferences.h @@ -229,6 +229,22 @@ public: setValue("Preferences/Downloads/AppendLabel", b); } + bool rememberLastLocation() const { + return value(QString::fromUtf8("Preferences/Downloads/RememberLastLocation"), false).toBool(); + } + + void setRememberLastLocation(bool b) { + setValue("Preferences/Downloads/RememberLastLocation", b); + } + + QString lastLocationPath() const { + return value(QString::fromUtf8("Preferences/Downloads/LastLocationPath"), QString()).toString(); +} + + void setLastLocationPath(const QString &path) { + setValue(QString::fromUtf8("Preferences/Downloads/LastLocationPath"), path); + } + bool preAllocateAllFiles() const { return value(QString::fromUtf8("Preferences/Downloads/PreAllocation"), false).toBool(); } diff --git a/src/torrentadditiondlg.cpp b/src/torrentadditiondlg.cpp index 907d19127..5e880ef49 100644 --- a/src/torrentadditiondlg.cpp +++ b/src/torrentadditiondlg.cpp @@ -60,7 +60,7 @@ using namespace libtorrent; torrentAdditionDialog::torrentAdditionDialog(QWidget *parent) : QDialog(parent), old_label(""), hidden_height(0), m_showContentList(true) { - const Preferences pref; + Preferences pref; setupUi(this); setAttribute(Qt::WA_DeleteOnClose); setMinimumSize(0, 0); @@ -87,7 +87,18 @@ torrentAdditionDialog::torrentAdditionDialog(QWidget *parent) : // Important: as a default, it inserts at the bottom which is not desirable savePathTxt->setInsertPolicy(QComboBox::InsertAtCurrent); //torrentContentList->header()->setResizeMode(0, QHeaderView::Stretch); - defaultSavePath = pref.getSavePath(); + QString lastLocation = pref.lastLocationPath(); + //lastLocation will always have '/' as separator since it is saved in + //::on_OkButton_clicked() after the conversion is done. + if (pref.rememberLastLocation() && !lastLocation.isEmpty() && QFile(lastLocation).exists()) + defaultSavePath = lastLocation; + else + { + defaultSavePath = pref.getSavePath(); + //In case of the LastLocationPath doesn't exist anymore, empty the string + pref.setLastLocationPath(QString()); + } + appendLabelToSavePath = pref.appendTorrentLabel(); QString display_path = defaultSavePath.replace("\\", "/"); if(!display_path.endsWith("/")) @@ -686,6 +697,12 @@ void torrentAdditionDialog::on_OkButton_clicked(){ return; } } + //Save last location path + {//limit the scope of pref + Preferences pref; + if (pref.rememberLastLocation()) + pref.setLastLocationPath(save_path); +} // save filtered files if(!is_magnet && t->num_files() > 1) savePiecesPriorities(); From 7c29e613f031cdb29ac252163dcd2fd463459101 Mon Sep 17 00:00:00 2001 From: sledgehammer_999 Date: Wed, 21 Sep 2011 02:21:14 +0300 Subject: [PATCH 2/2] Now qbt remembers the last used folder. Fixes #799697. ver2 --- src/preferences/options_imp.cpp | 3 --- src/torrentadditiondlg.cpp | 5 ++++- src/torrentadditiondlg.ui | 25 +++++++++++++++++++++++++ 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/src/preferences/options_imp.cpp b/src/preferences/options_imp.cpp index 0bbaf92e1..977bf3d63 100644 --- a/src/preferences/options_imp.cpp +++ b/src/preferences/options_imp.cpp @@ -155,7 +155,6 @@ options_imp::options_imp(QWidget *parent): connect(textSavePath, SIGNAL(textChanged(QString)), this, SLOT(enableApplyButton())); connect(textTempPath, SIGNAL(textChanged(QString)), this, SLOT(enableApplyButton())); connect(checkAppendLabel, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton())); - connect(checkLastLocation, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton())); connect(checkAppendqB, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton())); connect(checkPreallocateAll, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton())); connect(checkAdditionDialog, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton())); @@ -392,7 +391,6 @@ void options_imp::saveOptions(){ #endif pref.setTempPath(temp_path); pref.setAppendTorrentLabel(checkAppendLabel->isChecked()); - pref.setRememberLastLocation(checkLastLocation->isChecked()); #if LIBTORRENT_VERSION_MINOR > 14 pref.useIncompleteFilesExtension(checkAppendqB->isChecked()); #endif @@ -570,7 +568,6 @@ void options_imp::loadOptions(){ #endif textTempPath->setText(temp_path); checkAppendLabel->setChecked(pref.appendTorrentLabel()); - checkLastLocation->setChecked(pref.rememberLastLocation()); #if LIBTORRENT_VERSION_MINOR > 14 checkAppendqB->setChecked(pref.useIncompleteFilesExtension()); #endif diff --git a/src/torrentadditiondlg.cpp b/src/torrentadditiondlg.cpp index 5e880ef49..b63561a82 100644 --- a/src/torrentadditiondlg.cpp +++ b/src/torrentadditiondlg.cpp @@ -88,6 +88,7 @@ torrentAdditionDialog::torrentAdditionDialog(QWidget *parent) : savePathTxt->setInsertPolicy(QComboBox::InsertAtCurrent); //torrentContentList->header()->setResizeMode(0, QHeaderView::Stretch); QString lastLocation = pref.lastLocationPath(); + checkLastFolder->setChecked(pref.rememberLastLocation()); //lastLocation will always have '/' as separator since it is saved in //::on_OkButton_clicked() after the conversion is done. if (pref.rememberLastLocation() && !lastLocation.isEmpty() && QFile(lastLocation).exists()) @@ -700,7 +701,9 @@ void torrentAdditionDialog::on_OkButton_clicked(){ //Save last location path {//limit the scope of pref Preferences pref; - if (pref.rememberLastLocation()) + bool isChecked = checkLastFolder->isChecked(); + if (pref.rememberLastLocation() != isChecked) pref.setRememberLastLocation(isChecked); + if (pref.rememberLastLocation() && save_path != pref.lastLocationPath()) pref.setLastLocationPath(save_path); } // save filtered files diff --git a/src/torrentadditiondlg.ui b/src/torrentadditiondlg.ui index 6353a698c..b91efd640 100644 --- a/src/torrentadditiondlg.ui +++ b/src/torrentadditiondlg.ui @@ -190,6 +190,12 @@ Qt::Horizontal + + + 0 + 0 + + @@ -217,6 +223,12 @@ Qt::Horizontal + + + 0 + 0 + + @@ -238,6 +250,12 @@ Qt::Horizontal + + + 0 + 0 + + @@ -263,6 +281,13 @@ + + + + Remember last used folder + + +