dbhub: Remove remote menu, add push button to remote dock

This commit removes the File -> Remote menu entirely. The only menu item
that was left was the Save to Remote item which is replaces by a button
in the remote dock.

The button is only enabled when a database file is opened and the user
has logged in using a certificate.

Clicking the button opens the same dialog and performs the same actions
as before. The only difference is that we don't use the first client
certificate - no matter which one it is - but instead use the client
certificate that was used for logging in.
This commit is contained in:
Martin Kleusberg
2017-08-03 17:35:36 +02:00
parent dfa9ad7c03
commit d14fb1fbb1
9 changed files with 57 additions and 27 deletions

View File

@@ -1,4 +1,5 @@
#include <QSslCertificate>
#include <QInputDialog>
#include "RemoteDock.h"
#include "ui_RemoteDock.h"
@@ -10,6 +11,7 @@
RemoteDock::RemoteDock(MainWindow* parent)
: QDialog(parent),
ui(new Ui::RemoteDock),
mainWindow(parent),
remoteDatabase(parent->getRemote()),
remoteModel(new RemoteModel(this, parent->getRemote()))
{
@@ -58,6 +60,9 @@ void RemoteDock::setNewIdentity()
if(cn_parts.size() < 2)
return;
remoteModel->setNewRootDir(QString("https://%1:5550/").arg(cn_parts.last()), cert);
// Enable buttons if necessary
enableButtons();
}
void RemoteDock::fetchDatabase(const QModelIndex& idx)
@@ -72,3 +77,18 @@ void RemoteDock::fetchDatabase(const QModelIndex& idx)
if(item->value(RemoteModelColumnType).toString() == "database")
remoteDatabase.fetch(item->value(RemoteModelColumnUrl).toString(), RemoteDatabase::RequestTypeDatabase, remoteModel->currentClientCertificate());
}
void RemoteDock::enableButtons()
{
bool db_opened = mainWindow->getDb().isOpen();
bool logged_in = !remoteModel->currentClientCertificate().isEmpty();
ui->buttonPushDatabase->setEnabled(db_opened && logged_in);
}
void RemoteDock::pushDatabase()
{
QString url = QInputDialog::getText(this, qApp->applicationName(), tr("Please enter the URL of the database file to save."));
if(!url.isEmpty())
remoteDatabase.push(mainWindow->getDb().currentFile(), url, remoteModel->currentClientCertificate());
}