Update QR code on connection

This commit is contained in:
Aditya Kulkarni
2019-01-31 10:37:23 -08:00
parent 97a2fa22f5
commit 1b938928e2
3 changed files with 25 additions and 28 deletions

View File

@@ -43,16 +43,6 @@
<string>QR Code</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="1" column="0">
<widget class="QLabel" name="lblConnStr">
<property name="text">
<string>Connection URI String</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QRCodeLabel" name="qrcode">
<property name="sizePolicy">

View File

@@ -95,6 +95,26 @@ void AppDataServer::connectAppDialog(QWidget* parent) {
ui->setupUi(&d);
Settings::saveRestore(&d);
updateUIWithNewQRCode();
updateConnectedUI();
QObject::connect(ui->btnDisconnect, &QPushButton::clicked, [=] () {
QSettings().setValue("mobileapp/connectedname", "");
saveNewSecret("");
updateConnectedUI();
});
d.exec();
// Cleanup
tempSecret = "";
delete ui;
ui = nullptr;
}
void AppDataServer::updateUIWithNewQRCode() {
// Get the address of the localhost
auto addrList = QNetworkInterface::allAddresses();
@@ -124,25 +144,7 @@ void AppDataServer::connectAppDialog(QWidget* parent) {
QString codeStr = uri + "," + secretStr;
ui->lblConnStr->setText(codeStr);
ui->qrcode->setQrcodeString(codeStr);
updateConnectedUI();
QObject::connect(ui->btnDisconnect, &QPushButton::clicked, [=] () {
QSettings().setValue("mobileapp/connectedname", "");
saveNewSecret("");
updateConnectedUI();
});
d.exec();
// Cleanup
tempSecret = "";
delete ui;
ui = nullptr;
}
void AppDataServer::updateConnectedUI() {
@@ -337,7 +339,11 @@ void AppDataServer::processMessage(QString message, MainWindow* mainWindow, QWeb
// If the Connection UI is showing, we have to update the UI as well
if (ui != nullptr) {
// Update the connected phone information
updateConnectedUI();
// Update with a new QR Code for safety, so this secret isn't used by anyone else
updateUIWithNewQRCode();
}
}
}

View File

@@ -42,6 +42,7 @@ class AppDataServer {
public:
static void connectAppDialog(QWidget* parent);
static void updateConnectedUI();
static void updateUIWithNewQRCode();
static void processSendTx(QJsonObject sendTx, MainWindow* mainwindow, QWebSocket* pClient);
static void processMessage(QString message, MainWindow* mainWindow, QWebSocket* pClient);