Browse Source

Now qbt remembers the last used folder. Fixes #799697.

Conflicts:

	src/preferences/options.ui
adaptive-webui-19844
sledgehammer_999 13 years ago
parent
commit
a82ccd8e95
  1. 3
      src/preferences/options_imp.cpp
  2. 16
      src/preferences/preferences.h
  3. 19
      src/torrentadditiondlg.cpp

3
src/preferences/options_imp.cpp

@ -155,6 +155,7 @@ options_imp::options_imp(QWidget *parent):
connect(textSavePath, SIGNAL(textChanged(QString)), this, SLOT(enableApplyButton())); connect(textSavePath, SIGNAL(textChanged(QString)), this, SLOT(enableApplyButton()));
connect(textTempPath, SIGNAL(textChanged(QString)), this, SLOT(enableApplyButton())); connect(textTempPath, SIGNAL(textChanged(QString)), this, SLOT(enableApplyButton()));
connect(checkAppendLabel, SIGNAL(toggled(bool)), 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(checkAppendqB, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
connect(checkPreallocateAll, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton())); connect(checkPreallocateAll, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
connect(checkAdditionDialog, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton())); connect(checkAdditionDialog, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
@ -391,6 +392,7 @@ void options_imp::saveOptions(){
#endif #endif
pref.setTempPath(temp_path); pref.setTempPath(temp_path);
pref.setAppendTorrentLabel(checkAppendLabel->isChecked()); pref.setAppendTorrentLabel(checkAppendLabel->isChecked());
pref.setRememberLastLocation(checkLastLocation->isChecked());
#if LIBTORRENT_VERSION_MINOR > 14 #if LIBTORRENT_VERSION_MINOR > 14
pref.useIncompleteFilesExtension(checkAppendqB->isChecked()); pref.useIncompleteFilesExtension(checkAppendqB->isChecked());
#endif #endif
@ -568,6 +570,7 @@ void options_imp::loadOptions(){
#endif #endif
textTempPath->setText(temp_path); textTempPath->setText(temp_path);
checkAppendLabel->setChecked(pref.appendTorrentLabel()); checkAppendLabel->setChecked(pref.appendTorrentLabel());
checkLastLocation->setChecked(pref.rememberLastLocation());
#if LIBTORRENT_VERSION_MINOR > 14 #if LIBTORRENT_VERSION_MINOR > 14
checkAppendqB->setChecked(pref.useIncompleteFilesExtension()); checkAppendqB->setChecked(pref.useIncompleteFilesExtension());
#endif #endif

16
src/preferences/preferences.h

@ -229,6 +229,22 @@ public:
setValue("Preferences/Downloads/AppendLabel", b); 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 { bool preAllocateAllFiles() const {
return value(QString::fromUtf8("Preferences/Downloads/PreAllocation"), false).toBool(); return value(QString::fromUtf8("Preferences/Downloads/PreAllocation"), false).toBool();
} }

19
src/torrentadditiondlg.cpp

@ -60,7 +60,7 @@ using namespace libtorrent;
torrentAdditionDialog::torrentAdditionDialog(QWidget *parent) : torrentAdditionDialog::torrentAdditionDialog(QWidget *parent) :
QDialog(parent), old_label(""), hidden_height(0), m_showContentList(true) { QDialog(parent), old_label(""), hidden_height(0), m_showContentList(true) {
const Preferences pref; Preferences pref;
setupUi(this); setupUi(this);
setAttribute(Qt::WA_DeleteOnClose); setAttribute(Qt::WA_DeleteOnClose);
setMinimumSize(0, 0); setMinimumSize(0, 0);
@ -87,7 +87,18 @@ torrentAdditionDialog::torrentAdditionDialog(QWidget *parent) :
// Important: as a default, it inserts at the bottom which is not desirable // Important: as a default, it inserts at the bottom which is not desirable
savePathTxt->setInsertPolicy(QComboBox::InsertAtCurrent); savePathTxt->setInsertPolicy(QComboBox::InsertAtCurrent);
//torrentContentList->header()->setResizeMode(0, QHeaderView::Stretch); //torrentContentList->header()->setResizeMode(0, QHeaderView::Stretch);
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(); defaultSavePath = pref.getSavePath();
//In case of the LastLocationPath doesn't exist anymore, empty the string
pref.setLastLocationPath(QString());
}
appendLabelToSavePath = pref.appendTorrentLabel(); appendLabelToSavePath = pref.appendTorrentLabel();
QString display_path = defaultSavePath.replace("\\", "/"); QString display_path = defaultSavePath.replace("\\", "/");
if(!display_path.endsWith("/")) if(!display_path.endsWith("/"))
@ -685,6 +696,12 @@ void torrentAdditionDialog::on_OkButton_clicked(){
QMessageBox::critical(0, tr("Save path creation error"), tr("Could not create the save path")); QMessageBox::critical(0, tr("Save path creation error"), tr("Could not create the save path"));
return; return;
} }
}
//Save last location path
{//limit the scope of pref
Preferences pref;
if (pref.rememberLastLocation())
pref.setLastLocationPath(save_path);
} }
// save filtered files // save filtered files
if(!is_magnet && t->num_files() > 1) if(!is_magnet && t->num_files() > 1)

Loading…
Cancel
Save