Qt: show username for current SSH keys (#20508)

* Show username for current SSH keys

* Update ssh_keys.cc

* Update ssh_keys.cc

* Update selfdrive/ui/qt/widgets/ssh_keys.cc

Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>

* rename param

* cleanup

Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
old-commit-hash: 5cd676797a
commatwo_master
Dean Lee 4 years ago committed by GitHub
parent 40f5b22071
commit c5194fcb85
  1. 1
      common/params_pyx.pyx
  2. 13
      selfdrive/ui/qt/widgets/ssh_keys.cc
  3. 1
      selfdrive/ui/qt/widgets/ssh_keys.hpp

@ -36,6 +36,7 @@ keys = {
b"GitCommit": [TxType.PERSISTENT],
b"GitRemote": [TxType.PERSISTENT],
b"GithubSshKeys": [TxType.PERSISTENT],
b"GithubUsername": [TxType.PERSISTENT],
b"HardwareSerial": [TxType.PERSISTENT],
b"HasAcceptedTerms": [TxType.PERSISTENT],
b"HasCompletedSetup": [TxType.PERSISTENT],

@ -1,12 +1,19 @@
#include <QNetworkReply>
#include <QHBoxLayout>
#include "widgets/input.hpp"
#include "widgets/ssh_keys.hpp"
#include "common/params.h"
SshControl::SshControl() : AbstractControl("SSH Keys", "Warning: This grants SSH access to all public keys in your GitHub settings. Never enter a GitHub username other than your own. A comma employee will NEVER ask you to add their GitHub username.", "") {
// setup widget
hlayout->addStretch(1);
username_label.setAlignment(Qt::AlignVCenter);
username_label.setStyleSheet("color: #aaaaaa");
hlayout->addWidget(&username_label);
btn.setStyleSheet(R"(
padding: 0;
border-radius: 50px;
@ -27,6 +34,7 @@ SshControl::SshControl() : AbstractControl("SSH Keys", "Warning: This grants SSH
getUserKeys(username);
}
} else {
Params().delete_db_value("GithubUsername");
Params().delete_db_value("GithubSshKeys");
refresh();
}
@ -45,8 +53,10 @@ SshControl::SshControl() : AbstractControl("SSH Keys", "Warning: This grants SSH
void SshControl::refresh() {
QString param = QString::fromStdString(Params().get("GithubSshKeys"));
if (param.length()) {
username_label.setText(QString::fromStdString(Params().get("GithubUsername")));
btn.setText("REMOVE");
} else {
username_label.setText("");
btn.setText("ADD");
}
btn.setEnabled(true);
@ -79,6 +89,7 @@ void SshControl::parseResponse(){
networkTimer->stop();
QString response = reply->readAll();
if (reply->error() == QNetworkReply::NoError && response.length()) {
Params().write_db_value("GithubUsername", username.toStdString());
Params().write_db_value("GithubSshKeys", response.toStdString());
} else if(reply->error() == QNetworkReply::NoError){
err = "Username '" + username + "' has no keys on GitHub";

@ -29,6 +29,7 @@ public:
private:
QPushButton btn;
QString username;
QLabel username_label;
// networking
QTimer* networkTimer;

Loading…
Cancel
Save