mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-11-22 16:00:38 -05:00
added autoopen functionality (#477)
This commit is contained in:
parent
549fef8eb5
commit
6d569a86f9
2 changed files with 52 additions and 4 deletions
|
|
@ -129,7 +129,13 @@ void DatabaseTabWidget::openDatabase(const QString& fileName, const QString& pw,
|
||||||
while (i.hasNext()) {
|
while (i.hasNext()) {
|
||||||
i.next();
|
i.next();
|
||||||
if (i.value().canonicalFilePath == canonicalFilePath) {
|
if (i.value().canonicalFilePath == canonicalFilePath) {
|
||||||
|
if (pw.isEmpty() && keyFile.isEmpty()) {
|
||||||
setCurrentIndex(databaseIndex(i.key()));
|
setCurrentIndex(databaseIndex(i.key()));
|
||||||
|
} else {
|
||||||
|
if (!i.key()->hasKey()) {
|
||||||
|
i.value().dbWidget->switchToOpenDatabase(canonicalFilePath, pw, keyFile);
|
||||||
|
}
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -607,6 +613,39 @@ void DatabaseTabWidget::updateTabNameFromDbWidgetSender()
|
||||||
|
|
||||||
DatabaseWidget* dbWidget = static_cast<DatabaseWidget*>(sender());
|
DatabaseWidget* dbWidget = static_cast<DatabaseWidget*>(sender());
|
||||||
updateTabName(databaseFromDatabaseWidget(dbWidget));
|
updateTabName(databaseFromDatabaseWidget(dbWidget));
|
||||||
|
|
||||||
|
Database* db = dbWidget->database();
|
||||||
|
Group *autoload = db->rootGroup()->findChildByName("AutoOpen");
|
||||||
|
if (autoload)
|
||||||
|
{
|
||||||
|
const DatabaseManagerStruct& dbStruct = m_dbList.value(db);
|
||||||
|
QFileInfo dbpath(dbStruct.canonicalFilePath);
|
||||||
|
QDir dbFolder(dbpath.canonicalPath());
|
||||||
|
|
||||||
|
for (auto entry : autoload->entries()) {
|
||||||
|
|
||||||
|
if (entry->url().isEmpty() || entry->password().isEmpty())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
QFileInfo filepath;
|
||||||
|
if (entry->url().startsWith("file:/")) {
|
||||||
|
QUrl url(entry->url());
|
||||||
|
filepath.setFile(url.toLocalFile());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
filepath.setFile(entry->url());
|
||||||
|
if (filepath.isRelative()) {
|
||||||
|
filepath.setFile(dbFolder, entry->url());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!filepath.isFile())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
openDatabase(filepath.canonicalFilePath(), entry->password(), "");
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int DatabaseTabWidget::databaseIndex(Database* db)
|
int DatabaseTabWidget::databaseIndex(Database* db)
|
||||||
|
|
|
||||||
|
|
@ -897,8 +897,13 @@ void DatabaseWidget::switchToDatabaseSettings()
|
||||||
void DatabaseWidget::switchToOpenDatabase(const QString& fileName)
|
void DatabaseWidget::switchToOpenDatabase(const QString& fileName)
|
||||||
{
|
{
|
||||||
updateFilename(fileName);
|
updateFilename(fileName);
|
||||||
|
if (m_databaseOpenWidget) {
|
||||||
m_databaseOpenWidget->load(fileName);
|
m_databaseOpenWidget->load(fileName);
|
||||||
setCurrentWidget(m_databaseOpenWidget);
|
setCurrentWidget(m_databaseOpenWidget);
|
||||||
|
} else if (m_unlockDatabaseWidget) {
|
||||||
|
m_unlockDatabaseWidget->load(fileName);
|
||||||
|
setCurrentWidget(m_unlockDatabaseWidget);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DatabaseWidget::switchToOpenDatabase(const QString& fileName, const QString& password,
|
void DatabaseWidget::switchToOpenDatabase(const QString& fileName, const QString& password,
|
||||||
|
|
@ -906,7 +911,11 @@ void DatabaseWidget::switchToOpenDatabase(const QString& fileName, const QString
|
||||||
{
|
{
|
||||||
updateFilename(fileName);
|
updateFilename(fileName);
|
||||||
switchToOpenDatabase(fileName);
|
switchToOpenDatabase(fileName);
|
||||||
|
if (m_databaseOpenWidget) {
|
||||||
m_databaseOpenWidget->enterKey(password, keyFile);
|
m_databaseOpenWidget->enterKey(password, keyFile);
|
||||||
|
} else if (m_unlockDatabaseWidget) {
|
||||||
|
m_unlockDatabaseWidget->enterKey(password, keyFile);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DatabaseWidget::switchToImportCsv(const QString& fileName)
|
void DatabaseWidget::switchToImportCsv(const QString& fileName)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue