dbhub: Log in by only selecting an identity, no need to press a button

This removes the login button from the dbhub dock. Instead of selecting
an identity and then clicking the login button, you are now logged in by
just selecting an identity.
This commit is contained in:
Martin Kleusberg
2020-06-13 11:37:30 +02:00
parent fa3a0f5756
commit 5cdda28608
5 changed files with 25 additions and 25 deletions
+13 -6
View File
@@ -24,7 +24,7 @@ RemoteDock::RemoteDock(MainWindow* parent)
ui->treeStructure->setModel(remoteModel);
// Reload the directory tree when a database upload has finished
connect(&remoteDatabase, &RemoteDatabase::uploadFinished, this, &RemoteDock::setNewIdentity);
connect(&remoteDatabase, &RemoteDatabase::uploadFinished, remoteModel, &RemoteModel::refresh);
// Whenever a new directory listing has been parsed, check if it was a new root dir and, if so, open the user's directory
connect(remoteModel, &RemoteModel::directoryListingParsed, this, &RemoteDock::newDirectoryNode);
@@ -53,8 +53,12 @@ RemoteDock::~RemoteDock()
void RemoteDock::reloadSettings()
{
// Load list of client certs
// Clear list of client certificates and add a dummy entry which does nothing except serve as
// an explanation to the user.
ui->comboUser->clear();
ui->comboUser->addItem(tr("Select an identity to connect"), "dummy");
// Load list of client certs
QStringList client_certs = Settings::getValue("remote", "client_certificates").toStringList();
for(const QString& file : client_certs)
{
@@ -67,13 +71,16 @@ void RemoteDock::reloadSettings()
ui->comboUser->addItem(tr("Public"), ":/user_certs/public.cert.pem");
}
void RemoteDock::setNewIdentity()
void RemoteDock::setNewIdentity(const QString& identity)
{
// Get identity
QString identity = ui->comboUser->currentText();
if(identity.isEmpty())
// Do nothing if the dummy entry was selected
if(ui->comboUser->currentData() == "dummy")
return;
// Check if the dummy item is still there and remove it if it is
if(ui->comboUser->itemData(0) == "dummy")
ui->comboUser->removeItem(0);
// Get certificate file name
QString cert = ui->comboUser->itemData(ui->comboUser->findText(identity), Qt::UserRole).toString();
if(cert.isEmpty())
+1 -1
View File
@@ -26,7 +26,7 @@ public slots:
void reject() override;
private slots:
void setNewIdentity();
void setNewIdentity(const QString& identity);
void fetchDatabase(const QModelIndex& idx);
void pushDatabase();
void newDirectoryNode(const QModelIndex& parent);
+4 -18
View File
@@ -40,20 +40,6 @@
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="buttonLogin">
<property name="toolTip">
<string>Connect to the remote server using the currently selected identity. The correct server is taken from the identity as well.</string>
</property>
<property name="text">
<string>Go</string>
</property>
<property name="icon">
<iconset resource="icons/icons.qrc">
<normaloff>:/icons/cog_go.png</normaloff>:/icons/cog_go.png</iconset>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
@@ -179,10 +165,10 @@
</resources>
<connections>
<connection>
<sender>buttonLogin</sender>
<signal>clicked()</signal>
<sender>comboUser</sender>
<signal>currentTextChanged(QString)</signal>
<receiver>RemoteDock</receiver>
<slot>setNewIdentity()</slot>
<slot>setNewIdentity(QString)</slot>
<hints>
<hint type="sourcelabel">
<x>551</x>
@@ -244,7 +230,7 @@
</connection>
</connections>
<slots>
<slot>setNewIdentity()</slot>
<slot>setNewIdentity(QString)</slot>
<slot>fetchDatabase(QModelIndex)</slot>
<slot>pushDatabase()</slot>
<slot>switchToMainView()</slot>
+6
View File
@@ -122,6 +122,12 @@ void RemoteModel::setNewRootDir(const QString& url, const QString& cert)
currentRootDirectory = url;
currentClientCert = cert;
// Fetch root directory
refresh();
}
void RemoteModel::refresh()
{
// Fetch root directory and put the reply data under the root item
remoteDatabase.fetch(currentRootDirectory, RemoteDatabase::RequestTypeDirectory, currentClientCert, QModelIndex());
}
+1
View File
@@ -65,6 +65,7 @@ public:
~RemoteModel() override;
void setNewRootDir(const QString& url, const QString& cert);
void refresh();
QModelIndex index(int row, int column,const QModelIndex& parent = QModelIndex()) const override;
QModelIndex parent(const QModelIndex& index) const override;