Update QR code on connection
This commit is contained in:
@@ -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">
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user