Browse Source

Hook up the Send button to send an xtn

chat
Duke Leto 4 years ago
parent
commit
3df6f0d1c2
  1. 42
      src/mainwindow.cpp
  2. 1
      src/mainwindow.h
  3. 4
      src/mainwindow.ui

42
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;

1
src/mainwindow.h

@ -100,6 +100,7 @@ private:
void cancelButton();
void sendButton();
void sendMemo();
void inputComboTextChanged(int index);
void addAddressSection();
void maxAmountChecked(int checked);

4
src/mainwindow.ui

@ -1031,14 +1031,14 @@
<widget class="QListView" name="chatView"/>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="pushButton">
<widget class="QPushButton" name="sendMemo">
<property name="text">
<string>Send</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="pushButton_2">
<widget class="QPushButton" name="newHushChat">
<property name="text">
<string>New HushChat</string>
</property>

Loading…
Cancel
Save