diff options
Diffstat (limited to 'src/gui/DatabaseTabWidget.cpp')
-rw-r--r-- | src/gui/DatabaseTabWidget.cpp | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/gui/DatabaseTabWidget.cpp b/src/gui/DatabaseTabWidget.cpp index c908a82ec..313bfabb1 100644 --- a/src/gui/DatabaseTabWidget.cpp +++ b/src/gui/DatabaseTabWidget.cpp @@ -137,25 +137,29 @@ void DatabaseTabWidget::openDatabase() * database has been opened already. * * @param filePath database file path - * @param password optional, password to unlock database * @param inBackground optional, don't focus tab after opening + * @param password optional, password to unlock database + * @param keyfile optional, path to keyfile to unlock database + * */ -void DatabaseTabWidget::addDatabaseTab(const QString& filePath, bool inBackground, const QString& password) +void DatabaseTabWidget::addDatabaseTab(const QString& filePath, + bool inBackground, + const QString& password, + const QString& keyfile) { QFileInfo fileInfo(filePath); QString canonicalFilePath = fileInfo.canonicalFilePath(); if (canonicalFilePath.isEmpty()) { - emit messageGlobal(tr("The database file does not exist or is not accessible."), MessageWidget::Error); + emit messageGlobal(tr("Failed to open %1. It either does not exist or is not accessible.").arg(filePath), + MessageWidget::Error); return; } for (int i = 0, c = count(); i < c; ++i) { auto* dbWidget = databaseWidgetFromIndex(i); Q_ASSERT(dbWidget); - if (dbWidget && dbWidget->database()->filePath() == canonicalFilePath) { - if (!password.isEmpty()) { - dbWidget->performUnlockDatabase(password); - } + if (dbWidget && dbWidget->database()->canonicalFilePath() == canonicalFilePath) { + dbWidget->performUnlockDatabase(password, keyfile); if (!inBackground) { // switch to existing tab if file is already open setCurrentIndex(indexOf(dbWidget)); @@ -166,9 +170,7 @@ void DatabaseTabWidget::addDatabaseTab(const QString& filePath, bool inBackgroun auto* dbWidget = new DatabaseWidget(QSharedPointer<Database>::create(filePath), this); addDatabaseTab(dbWidget, inBackground); - if (!password.isEmpty()) { - dbWidget->performUnlockDatabase(password); - } + dbWidget->performUnlockDatabase(password, keyfile); updateLastDatabases(filePath); } |