From 71941224494bf0f39224b7b8361b150682d07b4f Mon Sep 17 00:00:00 2001 From: DenioD <41270280+DenioD@users.noreply.github.com> Date: Thu, 30 Apr 2020 22:58:35 +0200 Subject: [PATCH] change some gui elements, deactivate contact request for now --- src/chatmodel.cpp | 21 +++++++++++---------- src/controller.cpp | 42 ++++++++++++++++++++++-------------------- src/mainwindow.cpp | 2 +- src/mainwindow.ui | 10 +++++----- src/sendtab.cpp | 20 ++++++++++---------- 5 files changed, 49 insertions(+), 46 deletions(-) diff --git a/src/chatmodel.cpp b/src/chatmodel.cpp index 1c43495..e95aff7 100644 --- a/src/chatmodel.cpp +++ b/src/chatmodel.cpp @@ -36,6 +36,7 @@ void ChatModel::setItems(std::vector items) for(ChatItem c : items) { this->chatItems[c.getTimestamp()] = c; + } } @@ -95,7 +96,7 @@ void ChatModel::renderChatBox(Ui::MainWindow* ui, QListWidget *view) line += QString(c.second.getMemo()) + QString("\n"); view->addItem(line); line =""; - } + }else{} if ((ui->MyZaddr->text().trimmed() == c.second.getAddress()) && (c.second.getMemo().startsWith("{") == false) && (c.second.getMemo().isEmpty() == false)){ line += QString("[") + myDateTime.toString("dd.MM.yyyy hh:mm:ss ") + QString("] "); @@ -321,7 +322,7 @@ Tx MainWindow::createTxForSafeContactRequest() { QString hmemo= createHeaderMemo(type,cid,myAddr); - tx.toAddrs.push_back(ToFields{addr, amt, hmemo}) ; + // tx.toAddrs.push_back(ToFields{addr, amt, hmemo}) ; qDebug() << "pushback chattx"; } @@ -334,7 +335,7 @@ Tx MainWindow::createTxForSafeContactRequest() { qDebug() << "ChatTx created"; } - +//////////////////De-activated for now/////////////////// void MainWindow::safeContactRequest() { ////////////////////////////Todo: Check if its a zaddr////////// @@ -357,9 +358,9 @@ void MainWindow::safeContactRequest() { // return; // } - Tx tx = createTxForSafeContactRequest(); + /* Tx tx = createTxForSafeContactRequest(); - QString error = doSendChatTxValidations(tx); + QString error = doSendRequestTxValidations(tx); if (!error.isEmpty()) { // Something went wrong, so show an error and exit @@ -419,14 +420,14 @@ void MainWindow::safeContactRequest() { QMessageBox::critical(this, QObject::tr("Transaction Error"), errStr, QMessageBox::Ok); } - ); - } + );*/ + } QString MainWindow::doSendRequestTxValidations(Tx tx) { // Check to see if we have enough verified funds to send the Tx. - CAmount total; + /* CAmount total; for (auto toAddr : tx.toAddrs) { if (!Settings::isValidAddress(toAddr.addr)) { QString addr = (toAddr.addr.length() > 100 ? toAddr.addr.left(100) + "..." : toAddr.addr); @@ -450,5 +451,5 @@ QString MainWindow::doSendRequestTxValidations(Tx tx) { .arg(available.toDecimalhushString(), total.toDecimalhushString()); } - return ""; -} \ No newline at end of file + return "";*/ +} diff --git a/src/controller.cpp b/src/controller.cpp index 644fdfb..e6b6b37 100644 --- a/src/controller.cpp +++ b/src/controller.cpp @@ -879,37 +879,40 @@ void Controller::refreshTransactions() { QString memo; if (!o["memo"].is_null()) { memo = QString::fromStdString(o["memo"]); - } - ChatItem item = ChatItem( + + ChatItem item = ChatItem( datetime, address, QString(""), - memo, - true // is an outgoing message + memo + // true // is an outgoing message ); chatModel->addMessage(item); + } + items.push_back(TransactionItemDetail{address, amount, memo}); total_amount = total_amount + amount; - } + // } - { + // { // Concat all the addresses - QList addresses; - for (auto item : items) { + // QList addresses; + // for (auto item : items) { - addresses.push_back(item.address); + // addresses.push_back(item.address); - address = addresses.join(","); + - } + // } - } + // } txdata.push_back(TransactionItem{ "send", datetime, address, txid,confirmations, items }); + } } else { // Incoming Transaction address = (it["address"].is_null() ? "" : QString::fromStdString(it["address"])); @@ -919,8 +922,14 @@ void Controller::refreshTransactions() { if (!it["memo"].is_null()) { memo = QString::fromStdString(it["memo"]); } + + TransactionItem tx{ + "Receive", datetime, address, txid,confirmations, items + }; + + txdata.push_back(tx); - ChatItem item = ChatItem( + ChatItem item = ChatItem( datetime, address, QString(""), @@ -933,13 +942,6 @@ void Controller::refreshTransactions() { CAmount::fromqint64(it["amount"].get()), memo }); - - - TransactionItem tx{ - "Receive", datetime, address, txid,confirmations, items - }; - - txdata.push_back(tx); } } diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index ce474cc..76cd090 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -974,7 +974,7 @@ void MainWindow::setupTransactionsTab() { qApp->processEvents(); // Click the memo button - this->memoButtonClicked(1, true); + this->memoButtonClicked(1, true); }); } } diff --git a/src/mainwindow.ui b/src/mainwindow.ui index 2de859e..e5eb12e 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -1460,7 +1460,7 @@ - To: + <html><head/><body><p>Send to :</p></body></html> @@ -1468,18 +1468,18 @@ 340 490 - 161 + 81 17 - Your HushChat zaddr: + <html><head/><body><p>My zaddr :</p></body></html> - 370 + 420 460 691 20 @@ -1514,7 +1514,7 @@ - 490 + 420 490 691 20 diff --git a/src/sendtab.cpp b/src/sendtab.cpp index 6d4ba38..67f6553 100644 --- a/src/sendtab.cpp +++ b/src/sendtab.cpp @@ -35,7 +35,7 @@ void MainWindow::setupSendTab() { }); // The first Memo button - QObject::connect(ui->MemoBtn1, &QPushButton::clicked, [=] () { + QObject::connect(ui->MemoBtn1, &QPushButton::clicked, [=] () { this->memoButtonClicked(1); }); setMemoEnabled(1, false); @@ -377,15 +377,15 @@ void MainWindow::setMemoEnabled(int number, bool enabled) { void MainWindow::memoButtonClicked(int number, bool includeReplyTo) { // Memos can only be used with zAddrs. So check that first - auto addr = ui->sendToWidgets->findChild(QString("Address") + QString::number(number)); - if (! Settings::isZAddress(AddressBook::addressFromAddressLabel(addr->text()))) { - QMessageBox msg(QMessageBox::Critical, tr("Memos can only be used with z-addresses"), - tr("The memo field can only be used with a z-address.\n") + addr->text() + tr("\ndoesn't look like a z-address"), - QMessageBox::Ok, this); - - msg.exec(); - return; - } + // auto addr = ui->sendToWidgets->findChild(QString("Address") + QString::number(number)); + //if (! Settings::isZAddress(AddressBook::addressFromAddressLabel(addr->text()))) { + // QMessageBox msg(QMessageBox::Critical, tr("Memos can only be used with z-addresses"), + // tr("The memo field can only be used with a z-address.\n") + addr->text() + tr("\ndoesn't look like a z-address"), + // QMessageBox::Ok, this); + + // msg.exec(); + // return; + // } // Get the current memo if it exists auto memoTxt = ui->sendToWidgets->findChild(QString("MemoTxt") + QString::number(number));