activate contact request hm, for testing
This commit is contained in:
@@ -377,12 +377,28 @@ QString MainWindow::doSendChatTxValidations(Tx tx) {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a Contact Request.
|
|
||||||
|
// Create a Tx from the current state of the Chat page.
|
||||||
Tx MainWindow::createTxForSafeContactRequest() {
|
Tx MainWindow::createTxForSafeContactRequest() {
|
||||||
Tx tx;
|
|
||||||
CAmount totalAmt;
|
Ui_Dialog request;
|
||||||
{
|
QDialog dialog(this);
|
||||||
|
request.setupUi(&dialog);
|
||||||
|
Settings::saveRestore(&dialog);
|
||||||
|
dialog.exec();
|
||||||
|
|
||||||
|
Tx tx;
|
||||||
|
|
||||||
|
QObject::connect(request.cancel, &QPushButton::clicked, [&] () {
|
||||||
|
|
||||||
|
dialog.close();
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
QObject::connect(request.sendRequestButton, &QPushButton::clicked, this, &MainWindow::ContactRequest);
|
||||||
|
// For each addr/amt in the Chat tab
|
||||||
|
{
|
||||||
|
CAmount totalAmt;
|
||||||
QString amtStr = "0";
|
QString amtStr = "0";
|
||||||
CAmount amt;
|
CAmount amt;
|
||||||
|
|
||||||
@@ -392,48 +408,46 @@ Tx MainWindow::createTxForSafeContactRequest() {
|
|||||||
|
|
||||||
|
|
||||||
for(auto &c : AddressBook::getInstance()->getAllAddressLabels())
|
for(auto &c : AddressBook::getInstance()->getAllAddressLabels())
|
||||||
|
if (request.zaddr->text().trimmed() != c.getPartnerAddress()) {
|
||||||
|
|
||||||
if (ui->contactNameMemo->text().trimmed() == c.getName()) {
|
|
||||||
|
|
||||||
// QString cid = c.getCid(); // This has to be a new cid for the contact
|
|
||||||
// QString myAddr = c.getMyAddress(); // this should be a new HushChat zaddr
|
|
||||||
// QString addr = c.getPartnerAddress(); // this address will be insert by the user
|
|
||||||
QString cid = c.getCid();
|
|
||||||
QString myAddr = c.getMyAddress();
|
|
||||||
QString addr = c.getPartnerAddress();
|
|
||||||
QString type = "cont";
|
|
||||||
|
|
||||||
|
QString cid = c.getCid();
|
||||||
|
QString myAddr = c.getMyAddress();
|
||||||
|
QString type = "cont";
|
||||||
|
QString addr = request.zaddr->text();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
QString hmemo= createHeaderMemo(type,cid,myAddr);
|
QString hmemo= createHeaderMemo(type,cid,myAddr,0,0);
|
||||||
|
QString memo = request.requestmemo->toPlainText().trimmed();
|
||||||
tx.toAddrs.push_back(ToFields{addr, amt, hmemo}) ;
|
|
||||||
|
|
||||||
qDebug() << "pushback chattx";
|
|
||||||
}
|
tx.toAddrs.push_back(ToFields{addr, amt, hmemo});
|
||||||
}
|
tx.toAddrs.push_back(ToFields{addr, amt, memo});
|
||||||
|
|
||||||
|
qDebug() << "pushback chattx";
|
||||||
tx.fee = Settings::getMinerFee();
|
tx.fee = Settings::getMinerFee();
|
||||||
|
|
||||||
return tx;
|
return tx;
|
||||||
|
|
||||||
qDebug() << "ChatTx created";
|
qDebug() << "ChatTx created";
|
||||||
|
} if (request.zaddr->text().trimmed().isEmpty() == false){
|
||||||
|
|
||||||
|
QMessageBox msg(QMessageBox::Critical, tr("Please insert a contact Address"), request.zaddr->text(),
|
||||||
|
QMessageBox::Ok, this);
|
||||||
|
|
||||||
|
msg.exec();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
//////////////////De-activated for now///////////////////
|
void MainWindow::ContactRequest() {
|
||||||
void MainWindow::safeContactRequest() {
|
|
||||||
|
|
||||||
|
|
||||||
// Ui_ContactRequest contactRequest;
|
|
||||||
// QDialog dialog(this);
|
|
||||||
// contactRequest.setupUi(&dialog);
|
|
||||||
// Settings::saveRestore(&dialog);
|
|
||||||
|
|
||||||
// memoDialog.memoTxt->setLenDisplayLabel(memoDialog.memoSize);
|
////////////////////////////Todo: Check if a Contact is selected//////////
|
||||||
// memoDialog.memoTxt->setAcceptButton(memoDialog.buttonBox->button(QDialogButtonBox::Ok));
|
|
||||||
|
|
||||||
////////////////////////////Todo: Check if its a zaddr//////////
|
|
||||||
|
|
||||||
// Create a Tx from the values on the send tab. Note that this Tx object
|
// Create a Tx from the values on the send tab. Note that this Tx object
|
||||||
// might not be valid yet.
|
// might not be valid yet.
|
||||||
@@ -441,21 +455,24 @@ void MainWindow::safeContactRequest() {
|
|||||||
// Memos can only be used with zAddrs. So check that first
|
// Memos can only be used with zAddrs. So check that first
|
||||||
// for(auto &c : AddressBook::getInstance()->getAllAddressLabels())
|
// for(auto &c : AddressBook::getInstance()->getAllAddressLabels())
|
||||||
|
|
||||||
// if (ui->ContactZaddr->text().trimmed() == c.getName()) {
|
// if (ui->contactNameMemo->text().trimmed().isEmpty() || ui->memoTxtChat->toPlainText().trimmed().isEmpty()) {
|
||||||
|
|
||||||
// auto addr = "";
|
// auto addr = "";
|
||||||
// if (! Settings::isZAddress(AddressBook::addressFromAddressLabel(addr->text()))) {
|
// if (! Settings::isZAddress(AddressBook::addressFromAddressLabel(addr->text()))) {
|
||||||
// QMessageBox msg(QMessageBox::Critical, tr("Contact requests can only be used with z-addresses"),
|
// QMessageBox msg(QMessageBox::Critical, tr("You have to select a contact and insert a Memo"),
|
||||||
// tr("The memo field can only be used with a z-address.\n") + addr->text() + tr("\ndoesn't look like a z-address"),
|
// tr("You have selected no Contact from Contactlist,\n") + tr("\nor your Memo is empty"),
|
||||||
// QMessageBox::Ok, this);
|
// QMessageBox::Ok, this);
|
||||||
|
|
||||||
// msg.exec();
|
// msg.exec();
|
||||||
// return;
|
// return;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
Tx tx = createTxForSafeContactRequest();
|
|
||||||
|
//};
|
||||||
|
|
||||||
QString error = doSendRequestTxValidations(tx);
|
Tx tx = createTxForSafeContactRequest();
|
||||||
|
|
||||||
|
QString error = doSendChatTxValidations(tx);
|
||||||
|
|
||||||
if (!error.isEmpty()) {
|
if (!error.isEmpty()) {
|
||||||
// Something went wrong, so show an error and exit
|
// Something went wrong, so show an error and exit
|
||||||
@@ -469,7 +486,6 @@ void MainWindow::safeContactRequest() {
|
|||||||
qDebug() << "Tx aborted";
|
qDebug() << "Tx aborted";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a new Dialog to show that we are computing/sending the Tx
|
|
||||||
// Create a new Dialog to show that we are computing/sending the Tx
|
// Create a new Dialog to show that we are computing/sending the Tx
|
||||||
auto d = new QDialog(this);
|
auto d = new QDialog(this);
|
||||||
auto connD = new Ui_ConnectionDialog();
|
auto connD = new Ui_ConnectionDialog();
|
||||||
@@ -488,9 +504,10 @@ void MainWindow::safeContactRequest() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
connD->status->setText(tr("Please wait..."));
|
connD->status->setText(tr("Please wait..."));
|
||||||
connD->statusDetail->setText(tr("Your Contact Request will be send"));
|
connD->statusDetail->setText(tr("Your Message will be send"));
|
||||||
|
|
||||||
d->show();
|
d->show();
|
||||||
|
ui->memoTxtChat->clear();
|
||||||
|
|
||||||
// And send the Tx
|
// And send the Tx
|
||||||
rpc->executeTransaction(tx,
|
rpc->executeTransaction(tx,
|
||||||
@@ -509,7 +526,8 @@ void MainWindow::safeContactRequest() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Force a UI update so we get the unconfirmed Tx
|
// Force a UI update so we get the unconfirmed Tx
|
||||||
rpc->refresh(true);
|
// rpc->refresh(true);
|
||||||
|
ui->memoTxtChat->clear();
|
||||||
|
|
||||||
},
|
},
|
||||||
// Errored out
|
// Errored out
|
||||||
@@ -527,7 +545,8 @@ void MainWindow::safeContactRequest() {
|
|||||||
QMessageBox::critical(this, QObject::tr("Transaction Error"), errStr, QMessageBox::Ok);
|
QMessageBox::critical(this, QObject::tr("Transaction Error"), errStr, QMessageBox::Ok);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QString MainWindow::doSendRequestTxValidations(Tx tx) {
|
QString MainWindow::doSendRequestTxValidations(Tx tx) {
|
||||||
@@ -558,4 +577,4 @@ QString MainWindow::doSendRequestTxValidations(Tx tx) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
@@ -1,72 +1,165 @@
|
|||||||
<ui version="4.0" >
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<author></author>
|
<ui version="4.0">
|
||||||
<comment></comment>
|
|
||||||
<exportmacro></exportmacro>
|
|
||||||
<class>Dialog</class>
|
<class>Dialog</class>
|
||||||
<widget class="QDialog" name="Dialog" >
|
<widget class="QDialog" name="Dialog">
|
||||||
<property name="geometry" >
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>400</width>
|
<width>780</width>
|
||||||
<height>300</height>
|
<height>416</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle" >
|
<property name="windowTitle">
|
||||||
<string>Dialog</string>
|
<string>Dialog</string>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QDialogButtonBox" name="buttonBox" >
|
<widget class="QLabel" name="label">
|
||||||
<property name="geometry" >
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>30</x>
|
<x>0</x>
|
||||||
<y>240</y>
|
<y>100</y>
|
||||||
<width>341</width>
|
<width>351</width>
|
||||||
<height>32</height>
|
<height>17</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="orientation" >
|
<property name="text">
|
||||||
<enum>Qt::Horizontal</enum>
|
<string><html><head/><body><p>Please insert the Address of your contact :</p></body></html></string>
|
||||||
</property>
|
</property>
|
||||||
<property name="standardButtons" >
|
</widget>
|
||||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
<widget class="QLabel" name="label_2">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>10</x>
|
||||||
|
<y>190</y>
|
||||||
|
<width>461</width>
|
||||||
|
<height>17</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string><html><head/><body><p>Insert a Message, and ask your friend for the contact request : </p><p><br/></p></body></html></string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QTextEdit" name="requestmemo">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>240</y>
|
||||||
|
<width>591</width>
|
||||||
|
<height>101</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLineEdit" name="zaddr">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>140</y>
|
||||||
|
<width>591</width>
|
||||||
|
<height>25</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QPushButton" name="sendRequestButton">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>490</x>
|
||||||
|
<y>360</y>
|
||||||
|
<width>114</width>
|
||||||
|
<height>25</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="baseSize">
|
||||||
|
<size>
|
||||||
|
<width>100</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Send</string>
|
||||||
|
</property>
|
||||||
|
<property name="flat">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QPushButton" name="cancel">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>320</x>
|
||||||
|
<y>360</y>
|
||||||
|
<width>114</width>
|
||||||
|
<height>25</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="baseSize">
|
||||||
|
<size>
|
||||||
|
<width>100</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Cancel</string>
|
||||||
|
</property>
|
||||||
|
<property name="flat">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLabel" name="label_3">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>10</y>
|
||||||
|
<width>351</width>
|
||||||
|
<height>17</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string><html><head/><body><p>Please insert a Nickname for your contact :</p></body></html></string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLineEdit" name="labelRequest">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>50</y>
|
||||||
|
<width>591</width>
|
||||||
|
<height>25</height>
|
||||||
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
<pixmapfunction></pixmapfunction>
|
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections>
|
<connections>
|
||||||
<connection>
|
<connection>
|
||||||
<sender>buttonBox</sender>
|
<sender>sendRequestButton</sender>
|
||||||
<signal>accepted()</signal>
|
<signal>clicked()</signal>
|
||||||
<receiver>Dialog</receiver>
|
<receiver>Dialog</receiver>
|
||||||
<slot>accept()</slot>
|
<slot>accept()</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel" >
|
<hint type="sourcelabel">
|
||||||
<x>248</x>
|
<x>536</x>
|
||||||
<y>254</y>
|
<y>262</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel" >
|
<hint type="destinationlabel">
|
||||||
<x>157</x>
|
<x>389</x>
|
||||||
<y>274</y>
|
<y>207</y>
|
||||||
</hint>
|
</hint>
|
||||||
</hints>
|
</hints>
|
||||||
</connection>
|
</connection>
|
||||||
<connection>
|
<connection>
|
||||||
<sender>buttonBox</sender>
|
<sender>cancel</sender>
|
||||||
<signal>rejected()</signal>
|
<signal>clicked()</signal>
|
||||||
<receiver>Dialog</receiver>
|
<receiver>Dialog</receiver>
|
||||||
<slot>reject()</slot>
|
<slot>reject()</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel" >
|
<hint type="sourcelabel">
|
||||||
<x>316</x>
|
<x>396</x>
|
||||||
<y>260</y>
|
<y>262</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel" >
|
<hint type="destinationlabel">
|
||||||
<x>286</x>
|
<x>389</x>
|
||||||
<y>274</y>
|
<y>207</y>
|
||||||
</hint>
|
</hint>
|
||||||
</hints>
|
</hints>
|
||||||
</connection>
|
</connection>
|
||||||
</connections>
|
</connections>
|
||||||
</ui>
|
</ui>
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
#include "connection.h"
|
#include "connection.h"
|
||||||
|
#include "ui_contactrequest.h"
|
||||||
#include "requestdialog.h"
|
#include "requestdialog.h"
|
||||||
#include "websockets.h"
|
#include "websockets.h"
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
@@ -1006,7 +1007,8 @@ void MainWindow::setupchatTab() {
|
|||||||
|
|
||||||
// Send button
|
// Send button
|
||||||
QObject::connect(ui->sendChatButton, &QPushButton::clicked, this, &MainWindow::sendChatButton);
|
QObject::connect(ui->sendChatButton, &QPushButton::clicked, this, &MainWindow::sendChatButton);
|
||||||
QObject::connect(ui->safeContactRequest, &QPushButton::clicked, this, &MainWindow::safeContactRequest);
|
QObject::connect(ui->safeContactRequest, &QPushButton::clicked, this, &MainWindow::ContactRequest);
|
||||||
|
|
||||||
|
|
||||||
///////// Set selected Zaddr for Chat with Doubleklick
|
///////// Set selected Zaddr for Chat with Doubleklick
|
||||||
|
|
||||||
@@ -1032,6 +1034,7 @@ void MainWindow::setupchatTab() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ChatMemoEdit::ChatMemoEdit(QWidget* parent) : QPlainTextEdit(parent) {
|
ChatMemoEdit::ChatMemoEdit(QWidget* parent) : QPlainTextEdit(parent) {
|
||||||
QObject::connect(this, &QPlainTextEdit::textChanged, this, &ChatMemoEdit::updateDisplay);
|
QObject::connect(this, &QPlainTextEdit::textChanged, this, &ChatMemoEdit::updateDisplay);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -108,13 +108,14 @@ private:
|
|||||||
Tx createTxFromChatPage();
|
Tx createTxFromChatPage();
|
||||||
Tx createTxForSafeContactRequest();
|
Tx createTxForSafeContactRequest();
|
||||||
|
|
||||||
|
|
||||||
void encryptWallet();
|
void encryptWallet();
|
||||||
void removeWalletEncryption();
|
void removeWalletEncryption();
|
||||||
|
|
||||||
void cancelButton();
|
void cancelButton();
|
||||||
void sendButton();
|
void sendButton();
|
||||||
void sendChatButton();
|
void sendChatButton();
|
||||||
void safeContactRequest();
|
void ContactRequest();
|
||||||
void addAddressSection();
|
void addAddressSection();
|
||||||
void maxAmountChecked(int checked);
|
void maxAmountChecked(int checked);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user