Add config variable for specifying a default file name for the database

This commit is contained in:
SnipFoo 2022-05-12 12:19:20 +02:00 committed by Jonathan White
parent 7e8a672de4
commit 4d20cb1654
3 changed files with 9 additions and 3 deletions

View file

@ -1980,8 +1980,10 @@ bool DatabaseWidget::saveAs()
QString oldFilePath = m_db->filePath();
if (!QFileInfo::exists(oldFilePath)) {
QString defaultFileName = config()->get(Config::DefaultDatabaseFileName).toString();
oldFilePath =
QDir::toNativeSeparators(config()->get(Config::LastDir).toString() + "/" + tr("Passwords").append(".kdbx"));
QDir::toNativeSeparators(config()->get(Config::LastDir).toString() + "/"
+ (defaultFileName.isEmpty() ? tr("Passwords").append(".kdbx") : defaultFileName));
}
const QString newFilePath = fileDialog()->getSaveFileName(
this, tr("Save database as"), oldFilePath, tr("KeePass 2 Database").append(" (*.kdbx)"), nullptr, nullptr);
@ -2068,8 +2070,10 @@ bool DatabaseWidget::saveBackup()
while (true) {
QString oldFilePath = m_db->filePath();
if (!QFileInfo::exists(oldFilePath)) {
oldFilePath = QDir::toNativeSeparators(config()->get(Config::LastDir).toString() + "/"
+ tr("Passwords").append(".kdbx"));
QString defaultFileName = config()->get(Config::DefaultDatabaseFileName).toString();
oldFilePath = QDir::toNativeSeparators(
config()->get(Config::LastDir).toString() + "/"
+ (defaultFileName.isEmpty() ? tr("Passwords").append(".kdbx") : defaultFileName));
}
const QString newFilePath = fileDialog()->getSaveFileName(this,