Scan Folder dialog now remembers last location

Also fix fs_utils spacing
This commit is contained in:
Bryan Roscoe
2014-07-13 11:56:27 -05:00
parent 27afbaf7e7
commit f6a324a1bd
4 changed files with 30 additions and 18 deletions

View File

@@ -1056,7 +1056,9 @@ int options_imp::getActionOnDblClOnTorrentFn() const {
}
void options_imp::on_addScanFolderButton_clicked() {
const QString dir = QFileDialog::getExistingDirectory(this, tr("Add directory to scan"));
Preferences pref;
const QString dir = QFileDialog::getExistingDirectory(this, tr("Add directory to scan"),
fsutils::toNativePath(fsutils::folderName(pref.getScanDirsLastPath())));
if (!dir.isEmpty()) {
const ScanFoldersModel::PathStatus status = ScanFoldersModel::instance()->addPath(dir, false);
QString error;
@@ -1071,6 +1073,7 @@ void options_imp::on_addScanFolderButton_clicked() {
error = tr("Folder is not readable.");
break;
default:
pref.setScanDirsLastPath(dir);
addedScanDirs << dir;
scanFoldersView->resizeColumnsToContents();
enableApplyButton();

View File

@@ -256,7 +256,7 @@ public:
QString lastLocationPath() const {
return fsutils::fromNativePath(value(QString::fromUtf8("Preferences/Downloads/LastLocationPath"), QString()).toString());
}
}
void setLastLocationPath(const QString &path) {
setValue(QString::fromUtf8("Preferences/Downloads/LastLocationPath"), fsutils::fromNativePath(path));
@@ -325,6 +325,14 @@ public:
setValue(QString::fromUtf8("Preferences/Downloads/DownloadInScanDirs"), misc::toStringList(list));
}
QString getScanDirsLastPath() const {
return fsutils::fromNativePath(value(QString::fromUtf8("Preferences/Downloads/ScanDirsLastPath"), QString()).toString());
}
void setScanDirsLastPath(const QString &path) {
setValue(QString::fromUtf8("Preferences/Downloads/ScanDirsLastPath"), fsutils::fromNativePath(path));
}
bool isTorrentExportEnabled() const {
return !value(QString::fromUtf8("Preferences/Downloads/TorrentExportDir"), QString()).toString().isEmpty();
}