mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-10-01 01:26:01 -04:00
Merge pull request #1053 from alterratz/feature/autoopen
added autoopen functionality (#477)
This commit is contained in:
commit
fb6636d182
@ -624,6 +624,36 @@ void DatabaseTabWidget::updateTabNameFromDbWidgetSender()
|
||||
|
||||
DatabaseWidget* dbWidget = static_cast<DatabaseWidget*>(sender());
|
||||
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)
|
||||
|
@ -950,8 +950,13 @@ void DatabaseWidget::switchToDatabaseSettings()
|
||||
void DatabaseWidget::switchToOpenDatabase(const QString& fileName)
|
||||
{
|
||||
updateFilename(fileName);
|
||||
m_databaseOpenWidget->load(fileName);
|
||||
setCurrentWidget(m_databaseOpenWidget);
|
||||
if (m_databaseOpenWidget) {
|
||||
m_databaseOpenWidget->load(fileName);
|
||||
setCurrentWidget(m_databaseOpenWidget);
|
||||
} else if (m_unlockDatabaseWidget) {
|
||||
m_unlockDatabaseWidget->load(fileName);
|
||||
setCurrentWidget(m_unlockDatabaseWidget);
|
||||
}
|
||||
}
|
||||
|
||||
void DatabaseWidget::switchToOpenDatabase(const QString& fileName, const QString& password,
|
||||
@ -959,7 +964,11 @@ void DatabaseWidget::switchToOpenDatabase(const QString& fileName, const QString
|
||||
{
|
||||
updateFilename(fileName);
|
||||
switchToOpenDatabase(fileName);
|
||||
m_databaseOpenWidget->enterKey(password, keyFile);
|
||||
if (m_databaseOpenWidget) {
|
||||
m_databaseOpenWidget->enterKey(password, keyFile);
|
||||
} else if (m_unlockDatabaseWidget) {
|
||||
m_unlockDatabaseWidget->enterKey(password, keyFile);
|
||||
}
|
||||
}
|
||||
|
||||
void DatabaseWidget::switchToImportCsv(const QString& fileName)
|
||||
|
Loading…
Reference in New Issue
Block a user