mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-04-05 13:37:43 +03:00
Ask for save location when creating new DB and change default name to 'Passwords.kdbx', resolves #285
This commit is contained in:
parent
012d0ee885
commit
ec17199feb
1 changed files with 71 additions and 65 deletions
|
@ -90,8 +90,16 @@ void DatabaseTabWidget::newDatabase()
|
|||
db->rootGroup()->setName(tr("Root"));
|
||||
dbStruct.dbWidget = new DatabaseWidget(db, this);
|
||||
|
||||
CompositeKey emptyKey;
|
||||
db->setKey(emptyKey);
|
||||
|
||||
insertDatabase(db, dbStruct);
|
||||
|
||||
if (!saveDatabaseAs(db)) {
|
||||
closeDatabase(db);
|
||||
return;
|
||||
}
|
||||
|
||||
dbStruct.dbWidget->switchToMasterKeyChange();
|
||||
}
|
||||
|
||||
|
@ -348,13 +356,13 @@ bool DatabaseTabWidget::saveDatabase(Database* db)
|
|||
|
||||
bool DatabaseTabWidget::saveDatabaseAs(Database* db)
|
||||
{
|
||||
while (true) {
|
||||
DatabaseManagerStruct& dbStruct = m_dbList[db];
|
||||
QString oldFileName;
|
||||
if (dbStruct.saveToFilename) {
|
||||
oldFileName = dbStruct.filePath;
|
||||
}
|
||||
else {
|
||||
oldFileName = tr("New database").append(".kdbx");
|
||||
} else {
|
||||
oldFileName = tr("Passwords").append(".kdbx");
|
||||
}
|
||||
QString fileName = fileDialog()->getSaveFileName(this, tr("Save database as"),
|
||||
oldFileName, tr("KeePass 2 Database").append(" (*.kdbx)"),
|
||||
|
@ -365,8 +373,7 @@ bool DatabaseTabWidget::saveDatabaseAs(Database* db)
|
|||
if (fileInfo.exists()) {
|
||||
// returns empty string when file doesn't exist
|
||||
lockFilePath = fileInfo.canonicalPath();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
lockFilePath = fileInfo.absolutePath();
|
||||
}
|
||||
QString lockFileName = QString("%1/.%2.lock").arg(lockFilePath, fileInfo.fileName());
|
||||
|
@ -383,8 +390,7 @@ bool DatabaseTabWidget::saveDatabaseAs(Database* db)
|
|||
|
||||
if (result == QMessageBox::No) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// take over the lock file if possible
|
||||
if (lockFile->removeStaleLockFile()) {
|
||||
lockFile->tryLock();
|
||||
|
@ -401,7 +407,7 @@ bool DatabaseTabWidget::saveDatabaseAs(Database* db)
|
|||
// failed to save, revert back
|
||||
dbStruct.saveToFilename = false;
|
||||
dbStruct.canonicalFilePath = oldFileName;
|
||||
return false;
|
||||
continue;
|
||||
}
|
||||
|
||||
// refresh fileinfo since the file didn't exist before
|
||||
|
@ -419,11 +425,11 @@ bool DatabaseTabWidget::saveDatabaseAs(Database* db)
|
|||
updateTabName(db);
|
||||
updateLastDatabases(dbStruct.filePath);
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool DatabaseTabWidget::closeDatabase(int index)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue