mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2026-12-01 14:22:51 -08:00
Enhance last used directory settings
* Use hash based storage for last used directories instead of a key/value for each type * Explicitly declare certain operations as sensitive and follow the "Remember Last Database" setting for those. * Introduce database backup directory location (close #6619)
This commit is contained in:
1 parent
5e68cd2fa2
commit
746276edea
13 files changed
+92
-107
No files matched your search
@@ -133,12 +133,7 @@ void EntryAttachmentsWidget::insertAttachments()
|
||||
return;
|
||||
}
|
||||
|
||||
QString defaultDirPath = config()->get(Config::LastAttachmentDir).toString();
|
||||
const bool dirExists = !defaultDirPath.isEmpty() && QDir(defaultDirPath).exists();
|
||||
if (!dirExists) {
|
||||
defaultDirPath = QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation).first();
|
||||
}
|
||||
|
||||
QString defaultDirPath = FileDialog::getLastDir("attachments");
|
||||
const auto filenames = fileDialog()->getOpenFileNames(this, tr("Select files"), defaultDirPath);
|
||||
if (filenames.isEmpty()) {
|
||||
return;
|
||||
@@ -147,7 +142,8 @@ void EntryAttachmentsWidget::insertAttachments()
|
||||
if (confirmedFileNames.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
config()->set(Config::LastAttachmentDir, QFileInfo(filenames.first()).absolutePath());
|
||||
// Save path to first filename
|
||||
FileDialog::saveLastDir("attachments", filenames[0]);
|
||||
QString errorMessage;
|
||||
if (!insertAttachments(confirmedFileNames, errorMessage)) {
|
||||
errorOccurred(errorMessage);
|
||||
@@ -195,12 +191,7 @@ void EntryAttachmentsWidget::saveSelectedAttachments()
|
||||
return;
|
||||
}
|
||||
|
||||
QString defaultDirPath = config()->get(Config::LastAttachmentDir).toString();
|
||||
const bool dirExists = !defaultDirPath.isEmpty() && QDir(defaultDirPath).exists();
|
||||
if (!dirExists) {
|
||||
defaultDirPath = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
|
||||
}
|
||||
|
||||
QString defaultDirPath = FileDialog::getLastDir("attachments");
|
||||
const QString saveDirPath = fileDialog()->getExistingDirectory(this, tr("Save attachments"), defaultDirPath);
|
||||
if (saveDirPath.isEmpty()) {
|
||||
return;
|
||||
@@ -213,7 +204,7 @@ void EntryAttachmentsWidget::saveSelectedAttachments()
|
||||
return;
|
||||
}
|
||||
}
|
||||
config()->set(Config::LastAttachmentDir, QFileInfo(saveDir.absolutePath()).absolutePath());
|
||||
FileDialog::saveLastDir("attachments", saveDirPath);
|
||||
|
||||
QStringList errors;
|
||||
for (const QModelIndex& index : indexes) {
|
||||
|
||||
Reference in new issue
Block a user