mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-01-27 14:57:09 -05:00
parent
3404b4ac58
commit
28a3824d2d
@ -137,10 +137,15 @@ void DatabaseTabWidget::openDatabase()
|
|||||||
* database has been opened already.
|
* database has been opened already.
|
||||||
*
|
*
|
||||||
* @param filePath database file path
|
* @param filePath database file path
|
||||||
* @param password optional, password to unlock database
|
|
||||||
* @param inBackground optional, don't focus tab after opening
|
* @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);
|
QFileInfo fileInfo(filePath);
|
||||||
QString canonicalFilePath = fileInfo.canonicalFilePath();
|
QString canonicalFilePath = fileInfo.canonicalFilePath();
|
||||||
@ -154,7 +159,7 @@ void DatabaseTabWidget::addDatabaseTab(const QString& filePath, bool inBackgroun
|
|||||||
Q_ASSERT(dbWidget);
|
Q_ASSERT(dbWidget);
|
||||||
if (dbWidget && dbWidget->database()->filePath() == canonicalFilePath) {
|
if (dbWidget && dbWidget->database()->filePath() == canonicalFilePath) {
|
||||||
if (!password.isEmpty()) {
|
if (!password.isEmpty()) {
|
||||||
dbWidget->performUnlockDatabase(password);
|
dbWidget->performUnlockDatabase(password, keyfile);
|
||||||
}
|
}
|
||||||
if (!inBackground) {
|
if (!inBackground) {
|
||||||
// switch to existing tab if file is already open
|
// switch to existing tab if file is already open
|
||||||
@ -167,7 +172,7 @@ void DatabaseTabWidget::addDatabaseTab(const QString& filePath, bool inBackgroun
|
|||||||
auto* dbWidget = new DatabaseWidget(QSharedPointer<Database>::create(filePath), this);
|
auto* dbWidget = new DatabaseWidget(QSharedPointer<Database>::create(filePath), this);
|
||||||
addDatabaseTab(dbWidget, inBackground);
|
addDatabaseTab(dbWidget, inBackground);
|
||||||
if (!password.isEmpty()) {
|
if (!password.isEmpty()) {
|
||||||
dbWidget->performUnlockDatabase(password);
|
dbWidget->performUnlockDatabase(password, keyfile);
|
||||||
}
|
}
|
||||||
updateLastDatabases(filePath);
|
updateLastDatabases(filePath);
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,10 @@ public:
|
|||||||
bool hasLockableDatabases() const;
|
bool hasLockableDatabases() const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void addDatabaseTab(const QString& filePath, bool inBackground = false, const QString& password = {});
|
void addDatabaseTab(const QString& filePath,
|
||||||
|
bool inBackground = false,
|
||||||
|
const QString& password = {},
|
||||||
|
const QString& keyfile = {});
|
||||||
void addDatabaseTab(DatabaseWidget* dbWidget, bool inBackground = false);
|
void addDatabaseTab(DatabaseWidget* dbWidget, bool inBackground = false);
|
||||||
bool closeDatabaseTab(int index);
|
bool closeDatabaseTab(int index);
|
||||||
bool closeDatabaseTab(DatabaseWidget* dbWidget);
|
bool closeDatabaseTab(DatabaseWidget* dbWidget);
|
||||||
|
@ -496,28 +496,9 @@ void MainWindow::clearLastDatabases()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::openDatabase(const QString& filePath, const QString& pw, const QString& keyFile)
|
void MainWindow::openDatabase(const QString& filePath, const QString& password, const QString& keyfile)
|
||||||
{
|
{
|
||||||
if (pw.isEmpty() && keyFile.isEmpty()) {
|
m_ui->tabWidget->addDatabaseTab(filePath, false, password, keyfile);
|
||||||
m_ui->tabWidget->addDatabaseTab(filePath);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto db = QSharedPointer<Database>::create();
|
|
||||||
auto key = QSharedPointer<CompositeKey>::create();
|
|
||||||
if (!pw.isEmpty()) {
|
|
||||||
key->addKey(QSharedPointer<PasswordKey>::create(pw));
|
|
||||||
}
|
|
||||||
if (!keyFile.isEmpty()) {
|
|
||||||
auto fileKey = QSharedPointer<FileKey>::create();
|
|
||||||
fileKey->load(keyFile);
|
|
||||||
key->addKey(fileKey);
|
|
||||||
}
|
|
||||||
if (db->open(filePath, key, nullptr, false)) {
|
|
||||||
auto* dbWidget = new DatabaseWidget(db, this);
|
|
||||||
m_ui->tabWidget->addDatabaseTab(dbWidget);
|
|
||||||
dbWidget->switchToMainView(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::setMenuActionState(DatabaseWidget::Mode mode)
|
void MainWindow::setMenuActionState(DatabaseWidget::Mode mode)
|
||||||
|
@ -56,7 +56,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void openDatabase(const QString& filePath, const QString& pw = {}, const QString& keyFile = {});
|
void openDatabase(const QString& filePath, const QString& password = {}, const QString& keyfile = {});
|
||||||
void appExit();
|
void appExit();
|
||||||
void displayGlobalMessage(const QString& text,
|
void displayGlobalMessage(const QString& text,
|
||||||
MessageWidget::MessageType type,
|
MessageWidget::MessageType type,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user