From 3df6f0d1c20c2c7ce826dea73e337de333024773 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Thu, 6 Feb 2020 11:49:53 -0500 Subject: [PATCH] Hook up the Send button to send an xtn --- src/mainwindow.cpp | 42 ++++++++++++++++++++++++++++++++++++++++++ src/mainwindow.h | 1 + src/mainwindow.ui | 4 ++-- 3 files changed, 45 insertions(+), 2 deletions(-) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 7f99e0e..5e9c8c7 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -61,6 +61,9 @@ MainWindow::MainWindow(QWidget *parent) : QObject::connect(ui->actionWebsite, &QAction::triggered, this, &MainWindow::website); + // Send button + QObject::connect(ui->sendMemo, &QPushButton::clicked, this, &MainWindow::sendMemo); + // Set up check for updates action QObject::connect(ui->actionCheck_for_Updates, &QAction::triggered, [=] () { // Silent is false, so show notification even if no update was found @@ -144,6 +147,45 @@ MainWindow::MainWindow(QWidget *parent) : } } +// Send button clicked +void MainWindow::sendMemo() { + Tx tx = createTxFromSendPage(); + + QString error = doSendTxValidations(tx); + if (!error.isEmpty()) { + // Something went wrong, so show an error and exit + QMessageBox msg(QMessageBox::Critical, tr("Transaction Error"), error, + QMessageBox::Ok, this); + + msg.exec(); + + // abort the Tx + return; + } + + // Show a dialog to confirm the Tx + if (confirmTx(tx)) { + // And send the Tx + rpc->executeTransaction(tx, + [=] (QString opid) { + ui->statusBar->showMessage(tr("Computing transaction: ") % opid); + qDebug() << "Computing opid: " << opid; + }, + [=] (QString, QString txid) { + ui->statusBar->showMessage(Settings::txidStatusMessage + " " + txid); + }, + [=] (QString opid, QString errStr) { + ui->statusBar->showMessage(QObject::tr(" Transaction ") % opid % QObject::tr(" failed"), 15 * 1000); + + if (!opid.isEmpty()) + errStr = QObject::tr("The transaction with id ") % opid % QObject::tr(" failed. The error was") + ":\n\n" + errStr; + + QMessageBox::critical(this, QObject::tr("Transaction Error"), errStr, QMessageBox::Ok); + } + ); + } +} + void MainWindow::createWebsocket(QString wormholecode) { // Create the websocket server, for listening to direct connections int wsport = 8777; diff --git a/src/mainwindow.h b/src/mainwindow.h index f485b2a..770f3b9 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -100,6 +100,7 @@ private: void cancelButton(); void sendButton(); + void sendMemo(); void inputComboTextChanged(int index); void addAddressSection(); void maxAmountChecked(int checked); diff --git a/src/mainwindow.ui b/src/mainwindow.ui index 7ac4b19..96237ed 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -1031,14 +1031,14 @@ - + Send - + New HushChat