From 9a442e4a9940bcff7b3e4d8f422dc7fb1d28625b Mon Sep 17 00:00:00 2001 From: Morten Kristensen Date: Mon, 25 Jun 2018 19:41:58 +0200 Subject: [PATCH 1/5] If mc-agent isn't bundled then show error and go back to locked screen --- src/SSHManagement.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/SSHManagement.cpp b/src/SSHManagement.cpp index 43a63fb1..a935c8ba 100644 --- a/src/SSHManagement.cpp +++ b/src/SSHManagement.cpp @@ -97,19 +97,27 @@ void SSHManagement::onServiceExists(const QString service, bool exists) if (exists) { sshProcess = new QProcess(this); - QString program = QCoreApplication::applicationDirPath () + "/mc-agent"; + const auto program = QCoreApplication::applicationDirPath () + "/mc-agent"; + if (!QFile::exists(program)) + { + QMessageBox::critical(this, "Moolticute", + tr("mc-agent isn't bundled with the Moolticute app!\n\nCannot manage SSH keys.")); + ui->stackedWidget->setCurrentWidget(ui->pageLocked); + return; + } + QStringList arguments; arguments << "--output_progress" << "cli" << "-c" << "list"; - qInfo() << "Running " << program << " " << arguments; + qInfo() << "Running" << program << arguments; connect(sshProcess, static_cast(&QProcess::finished), [=](int exitCode, QProcess::ExitStatus exitStatus) { if (exitStatus != QProcess::NormalExit) - qWarning() << "SSH agent exits with exit code " << exitCode << " Exit Status : " << exitStatus; + qWarning() << "SSH agent exits with exit code" << exitCode << "Exit Status:" << exitStatus; if (loaded) ui->stackedWidget->setCurrentWidget(ui->pageEditSsh); From 5c676028fb2c874f23d32d3dc7705edfb90e9907 Mon Sep 17 00:00:00 2001 From: Morten Kristensen Date: Mon, 25 Jun 2018 19:57:33 +0200 Subject: [PATCH 2/5] SSH text fixes --- src/SSHManagement.ui | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/SSHManagement.ui b/src/SSHManagement.ui index ec2b641a..e84e53f3 100644 --- a/src/SSHManagement.ui +++ b/src/SSHManagement.ui @@ -51,7 +51,7 @@ border-right: none; - SSH Keys management + SSH Keys Management FrameTitle @@ -91,7 +91,7 @@ border-right: none; - <html><head/><body><p><span style=" font-size:12pt; font-weight:600;">SSH is locked.</span></p><p>Press the unlock button to load SSH keys from the device.</p></body></html> + <html><head/><body><p><span style=" font-weight:600;">SSH Keys Not Loaded</span></p><p>Press the load keys button to load SSH keys from your device.</p></body></html> @@ -114,7 +114,7 @@ border-right: none; - Unlock + Load Keys @@ -266,13 +266,20 @@ border-right: none; - SSH Keys management + SSH Keys Management FrameTitle + + + + Only passphrase-free OpenSSH keys are supported at this moment. + + + @@ -284,7 +291,7 @@ border-right: none; - Import a key + Import A Key @@ -323,7 +330,7 @@ border-right: none; - Export selected + Export Selected @@ -336,7 +343,7 @@ border-right: none; - Delete selected + Delete Selected @@ -380,7 +387,7 @@ border-right: none; - Quit SSH Management + Leave SSH Keys Management From 42e827d18a7ff861f649dc33265431a6fe517ee8 Mon Sep 17 00:00:00 2001 From: Morten Kristensen Date: Mon, 25 Jun 2018 19:59:52 +0200 Subject: [PATCH 3/5] Moved import button to the layout to the right beneath --- src/SSHManagement.ui | 43 +++++++++++++------------------------------ 1 file changed, 13 insertions(+), 30 deletions(-) diff --git a/src/SSHManagement.ui b/src/SSHManagement.ui index e84e53f3..16d05558 100644 --- a/src/SSHManagement.ui +++ b/src/SSHManagement.ui @@ -280,36 +280,6 @@ border-right: none; - - - - - - - 150 - 0 - - - - Import A Key - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - @@ -321,6 +291,19 @@ border-right: none; + + + + + 150 + 0 + + + + Import A Key + + + From 3f4d47d1e59b8d63b761a10624a16ab90632a8b0 Mon Sep 17 00:00:00 2001 From: Morten Kristensen Date: Mon, 25 Jun 2018 20:18:12 +0200 Subject: [PATCH 4/5] Only enable export and delete buttons when key is selected --- src/SSHManagement.cpp | 7 +++++++ src/SSHManagement.ui | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/src/SSHManagement.cpp b/src/SSHManagement.cpp index a935c8ba..8738ab8b 100644 --- a/src/SSHManagement.cpp +++ b/src/SSHManagement.cpp @@ -50,6 +50,13 @@ SSHManagement::SSHManagement(QWidget *parent) : keysModel = new QStandardItemModel(this); ui->listViewKeys->setModel(keysModel); + // Enable button when a key is selected. + connect(ui->listViewKeys, &QListWidget::clicked, this, [this](const QModelIndex &/*index*/) + { + ui->pushButtonExport->setEnabled(true); + ui->pushButtonDelete->setEnabled(true); + }); + QMenu *menu = new QMenu(this); QAction *action; action = menu->addAction(tr("Export public key")); diff --git a/src/SSHManagement.ui b/src/SSHManagement.ui index 16d05558..2e73b9f1 100644 --- a/src/SSHManagement.ui +++ b/src/SSHManagement.ui @@ -306,6 +306,9 @@ border-right: none; + + false + 200 @@ -319,6 +322,9 @@ border-right: none; + + false + 200 From d05dd797aa1e5c483db818cae9b3517c8d846fff Mon Sep 17 00:00:00 2001 From: Morten Kristensen Date: Mon, 25 Jun 2018 21:34:20 +0200 Subject: [PATCH 5/5] Clear selection and buttons after loading keys This happens on initialize, import, and delete. --- src/SSHManagement.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/SSHManagement.cpp b/src/SSHManagement.cpp index 8738ab8b..b649cfd0 100644 --- a/src/SSHManagement.cpp +++ b/src/SSHManagement.cpp @@ -214,6 +214,11 @@ void SSHManagement::readStdOutLoadKeys() } } } + + // Clear selection and buttons after loading keys. + ui->listViewKeys->clearSelection(); + ui->pushButtonExport->setEnabled(false); + ui->pushButtonDelete->setEnabled(false); } void SSHManagement::progressChanged(int total, int current)