dbhub: Automatically switch to the correct identity when opening file

When opening a local clone of a remote database, make sure the current
identity is set to the identity used for cloning this file. This avoids
possible confusion and can simplify the workflow a bit.
This commit is contained in:
Martin Kleusberg
2020-07-10 22:28:24 +02:00
parent 8428c934a3
commit 635dba93c2
+9 -1
View File
@@ -231,7 +231,15 @@ void RemoteDock::fileOpened(const QString& filename)
ui->labelDatabaseFile->setText(QString::fromStdString(info.name));
ui->labelDatabaseBranch->setText(QString::fromStdString(info.branch));
// Switch to "Current Database" tab when we have information on this database
// Is this actually a clone of a remote database?
if(!info.file.empty())
{
// Make sure the current identity matches the identity used to clone this file in the first place.
// A mismatch is possible when the local database file has been opened using a recent files menu item or some similar technique.
if(QString::fromStdString(info.identity) != QFileInfo(remoteModel->currentClientCertificate()).fileName())
ui->comboUser->setCurrentIndex(ui->comboUser->findData("/" + QString::fromStdString(info.identity), Qt::UserRole, Qt::MatchEndsWith));
// Switch to "Current Database" tab
ui->tabs->setCurrentIndex(2);
}
}