diff --git a/application.qrc b/application.qrc index d323bff..7ab9af5 100644 --- a/application.qrc +++ b/application.qrc @@ -41,6 +41,15 @@ res/lock_green.svg res/lock_blue.svg res/unlocked.svg + res/getAddrWhite.png + res/send-white.png + res/requestWhite.png + res/addContactWhite.png + res/getAddrBlack.png + res/sendBlack.png + res/requestBlack.png + res/addContactBlack.png + res/hushdlogo.gif diff --git a/res/addContactBlack.png b/res/addContactBlack.png new file mode 100644 index 0000000..984c6e3 Binary files /dev/null and b/res/addContactBlack.png differ diff --git a/res/addContactWhite.png b/res/addContactWhite.png new file mode 100644 index 0000000..fea4efc Binary files /dev/null and b/res/addContactWhite.png differ diff --git a/res/getAddrBlack.png b/res/getAddrBlack.png new file mode 100644 index 0000000..2ede956 Binary files /dev/null and b/res/getAddrBlack.png differ diff --git a/res/getAddrWhite.png b/res/getAddrWhite.png new file mode 100644 index 0000000..6caeeae Binary files /dev/null and b/res/getAddrWhite.png differ diff --git a/res/lock_green.png b/res/lock_green.png new file mode 100644 index 0000000..cd7c2ab Binary files /dev/null and b/res/lock_green.png differ diff --git a/res/requestBlack.png b/res/requestBlack.png new file mode 100644 index 0000000..f46f9c2 Binary files /dev/null and b/res/requestBlack.png differ diff --git a/res/requestWhite.png b/res/requestWhite.png new file mode 100644 index 0000000..851a750 Binary files /dev/null and b/res/requestWhite.png differ diff --git a/res/send-white.png b/res/send-white.png new file mode 100644 index 0000000..96c7621 Binary files /dev/null and b/res/send-white.png differ diff --git a/res/sendBlack.png b/res/sendBlack.png new file mode 100644 index 0000000..62d9d1e Binary files /dev/null and b/res/sendBlack.png differ diff --git a/res/unlocked.png b/res/unlocked.png new file mode 100644 index 0000000..d6e6c90 Binary files /dev/null and b/res/unlocked.png differ diff --git a/src/DataStore/ChatDataStore.cpp b/src/DataStore/ChatDataStore.cpp index 22c10f5..2ede26d 100644 --- a/src/DataStore/ChatDataStore.cpp +++ b/src/DataStore/ChatDataStore.cpp @@ -2,6 +2,7 @@ // GPLv3 #include "ChatDataStore.h" +#include "addressbook.h" ChatDataStore* ChatDataStore::getInstance() { @@ -48,15 +49,15 @@ std::map ChatDataStore::getAllRawChatItems() return this->data; } -std::map ChatDataStore::getAllContactRequests() +std::map ChatDataStore::getAllNewContactRequests() { std::map filteredItems; for(auto &c: this->data) { if ( (c.second.isOutgoing() == false) && - (c.second.getType() == "cont") && - (c.second.getMemo().startsWith("{")) + (c.second.getType() == "cont") + ) { filteredItems[c.first] = c.second; @@ -65,6 +66,23 @@ std::map ChatDataStore::getAllContactRequests() return filteredItems; } +std::map ChatDataStore::getAllOldContactRequests() +{ + std::map filteredItems; + for(auto &p : AddressBook::getInstance()->getAllAddressLabels()) + for(auto &c: this->data) + { + if ( + (c.second.isOutgoing() == false) && + (c.second.getType() == "cont") && + (p.getPartnerAddress() == c.second.getRequestZaddr()) + ) + { + filteredItems[c.first] = c.second; + } + } + return filteredItems; +} std::map ChatDataStore::getAllMemos() { diff --git a/src/DataStore/ChatDataStore.h b/src/DataStore/ChatDataStore.h index 444c704..7fb0998 100644 --- a/src/DataStore/ChatDataStore.h +++ b/src/DataStore/ChatDataStore.h @@ -22,7 +22,8 @@ class ChatDataStore void setData(QString key, ChatItem value); ChatItem getData(QString key); std::map getAllRawChatItems(); - std::map getAllContactRequests(); + std::map getAllNewContactRequests(); + std::map getAllOldContactRequests(); std::map getAllMemos(); QString dump(); diff --git a/src/chatmodel.cpp b/src/chatmodel.cpp index 1e72714..b669302 100644 --- a/src/chatmodel.cpp +++ b/src/chatmodel.cpp @@ -10,7 +10,6 @@ #include "addressbook.h" #include "ui_memodialog.h" #include "ui_contactrequest.h" -#include "addressbook.h" #include #include #include "DataStore/DataStore.h" @@ -97,7 +96,7 @@ void MainWindow::renderContactRequest(){ QStandardItemModel* contactRequest = new QStandardItemModel(); { - for (auto &c : DataStore::getChatDataStore()->getAllContactRequests()) + for (auto &c : DataStore::getChatDataStore()->getAllOldContactRequests()) { QStandardItem* Items = new QStandardItem(c.second.getAddress()); @@ -109,18 +108,17 @@ void MainWindow::renderContactRequest(){ QObject::connect(requestContact.requestContact, &QTableView::clicked, [&] () { - for (auto &c : DataStore::getChatDataStore()->getAllRawChatItems()){//this->chatItems){ + for (auto &c : DataStore::getChatDataStore()->getAllRawChatItems()){ QModelIndex index = requestContact.requestContact->currentIndex(); QString label_contact = index.data(Qt::DisplayRole).toString(); QStandardItemModel* contactMemo = new QStandardItemModel(); - if (c.second.isOutgoing() == false) { - if (label_contact == c.second.getAddress()) { - if(c.second.getMemo().startsWith("{")){ + if ((c.second.isOutgoing() == false) && (label_contact == c.second.getAddress()) && (c.second.getType() == "cont")) + + { - }else{ QStandardItem* Items = new QStandardItem(c.second.getMemo()); - contactMemo->appendRow(Items); + contactMemo->appendRow(Items); requestContact.requestMemo->setModel(contactMemo); requestContact.requestMemo->show(); @@ -128,11 +126,11 @@ void MainWindow::renderContactRequest(){ requestContact.requestZaddr->setText(c.second.getRequestZaddr()); requestContact.requestCID->setText(c.second.getCid()); requestContact.requestMyAddr->setText(c.second.getAddress()); - } + }else{} } - } - } + + }); QObject::connect(requestContact.pushButton, &QPushButton::clicked, [&] () { @@ -173,7 +171,6 @@ void MainWindow::renderContactRequest(){ QMessageBox::information(this, "Added Contact","successfully added your new contact. You can now Chat with this contact"); }); - dialog.exec(); } @@ -425,7 +422,8 @@ QString MainWindow::doSendChatTxValidations(Tx tx) { } void::MainWindow::addContact() { - + + Ui_Dialog request; QDialog dialog(this); request.setupUi(&dialog); @@ -434,24 +432,31 @@ void::MainWindow::addContact() { bool sapling = true; rpc->createNewZaddr(sapling, [=] (json reply) { QString myAddr = QString::fromStdString(reply.get()[0]); - QString cid = QUuid::createUuid().toString(QUuid::WithoutBraces); + request.myzaddr->setText(myAddr); ui->listReceiveAddresses->insertItem(0, myAddr); ui->listReceiveAddresses->setCurrentIndex(0); - qDebug() << "new generated myAddr" << myAddr; - request.myzaddr->setText(myAddr); + }); + + QString cid = QUuid::createUuid().toString(QUuid::WithoutBraces); request.cid->setText(cid); - }); + + QObject::connect(request.sendRequestButton, &QPushButton::clicked, [&] () { + QString cid = request.cid->text(); auto addr = request.zaddr->text().trimmed(); QString newLabel = request.labelRequest->text().trimmed(); auto myAddr = request.myzaddr->text().trimmed(); + // ChatModel->addSendRequest(myAddr, cid, addr); + + + QString avatar = QString(":/icons/res/") + request.comboBoxAvatar->currentText() + QString(".png"); if (addr.isEmpty() || newLabel.isEmpty()) @@ -490,15 +495,24 @@ void::MainWindow::addContact() { return; }); - dialog.exec(); } + + // Create a Tx for a contact Request Tx MainWindow::createTxForSafeContactRequest() { - Tx tx; + Ui_Dialog request; + QDialog dialog(this); + request.setupUi(&dialog); + Settings::saveRestore(&dialog); + +Tx tx; + +{ + // For each addr/amt in the Chat tab { @@ -510,18 +524,14 @@ Tx MainWindow::createTxForSafeContactRequest() { amt = CAmount::fromDecimalString("0"); totalAmt = totalAmt + amt; - - for(auto &c : AddressBook::getInstance()->getAllAddressLabels()) - if (ui->contactNameMemo->text().trimmed() == c.getName()) { - - - QString cid = c.getCid(); - QString myAddr = c.getMyAddress(); + + QString cid = request.cid->text(); + QString myAddr = request.myzaddr->text().trimmed(); QString type = "cont"; - QString addr = c.getPartnerAddress(); + QString addr = request.zaddr->text().trimmed(); QString hmemo= createHeaderMemo(type,cid,myAddr); - QString memo = ui->memoTxtChat->toPlainText().trimmed(); + QString memo = request.memorequest->toPlainText().trimmed(); tx.toAddrs.push_back(ToFields{addr, amt, memo}); tx.toAddrs.push_back(ToFields{addr, amt, hmemo}); @@ -532,19 +542,16 @@ Tx MainWindow::createTxForSafeContactRequest() { } tx.fee = Settings::getMinerFee(); - +} return tx; qDebug() << "RequestTx created"; - - } - } void MainWindow::ContactRequest() { - if (ui->contactNameMemo->text().trimmed().isEmpty() || ui->memoTxtChat->toPlainText().trimmed().isEmpty()) { + /* if (request.labelRequest->text().trimmed().isEmpty() || request.memorequest->toPlainText().trimmed().isEmpty()) { // auto addr = ""; // if (! Settings::isZAddress(AddressBook::addressFromAddressLabel(addr->text()))) { @@ -554,7 +561,7 @@ void MainWindow::ContactRequest() { msg.exec(); return; - } + }*/ Tx tx = createTxForSafeContactRequest(); @@ -632,7 +639,7 @@ void MainWindow::ContactRequest() { QMessageBox::critical(this, QObject::tr("Transaction Error"), errStr, QMessageBox::Ok); } ); - + } diff --git a/src/chatmodel.h b/src/chatmodel.h index bf3e255..a96f3bd 100644 --- a/src/chatmodel.h +++ b/src/chatmodel.h @@ -19,6 +19,9 @@ #include "Chat/Helper/ChatDelegator.h" #include "Chat/Helper/ChatIDGenerator.h" +namespace Ui { + class MainWindow; +} class ChatModel { private: @@ -28,6 +31,7 @@ class ChatModel MainWindow* main; std::map cidMap; std::map requestZaddrMap; + std::map> sendrequestMap; public: ChatModel() {}; @@ -44,6 +48,7 @@ class ChatModel void addMessage(QString timestamp, ChatItem item); void addCid(QString tx, QString cid); void addrequestZaddr(QString tx, QString requestZaddr); + void addSendRequest(int i, QString myAddr, QString cid, QString addr ); QString getCidByTx(QString tx); QString getrequestZaddrByTx(QString tx); void killCidCache(); diff --git a/src/contactrequest.ui b/src/contactrequest.ui index d2ae8ef..9ce3c22 100644 --- a/src/contactrequest.ui +++ b/src/contactrequest.ui @@ -14,7 +14,7 @@ Send a contact request - + <html><head/><body><p align="right">Choose a avatar for your contact :</p></body></html> @@ -28,7 +28,7 @@ - + @@ -185,6 +185,9 @@ + + + @@ -192,7 +195,7 @@ - + @@ -231,6 +234,13 @@ + + + + Send Contact + + + @@ -255,7 +265,7 @@ sendRequestButton clicked() Dialog - accept() + update() 536 diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index de034ac..b3868d4 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1011,52 +1011,45 @@ void MainWindow::setupchatTab() { auto theme = Settings::getInstance()->get_theme_name(); if (theme == "dark" || theme == "midnight") { - QPixmap send(":/icons/res/send-new-white.png"); + QPixmap send(":/icons/res/send-white.png"); QIcon sendIcon(send); ui->sendChatButton->setIcon(sendIcon); - QPixmap notification(":/icons/res/notification.png"); + QPixmap notification(":/icons/res/requestWhite.png"); QIcon notificationIcon(notification); ui->pushContact->setIcon(notificationIcon); - QPixmap addContact(":/icons/res/add_contact.png"); + QPixmap addContact(":/icons/res/addContactWhite.png"); QIcon addContactIcon(addContact); ui->safeContactRequest->setIcon(addContactIcon); - QPixmap newAddr(":/icons/res/add_contact.png"); + QPixmap newAddr(":/icons/res/getAddrWhite.png"); QIcon addnewAddrIcon(newAddr); ui->givemeZaddr->setIcon(addnewAddrIcon); - QPixmap sendContact(":/icons/res/upload.png"); - QIcon addSendContactIcon(sendContact); - ui->sendContact->setIcon(addSendContactIcon); }else{ - QPixmap pixmap(":/icons/res/send-new.svg"); - QIcon sendIcon(pixmap); + + QPixmap send(":/icons/res/sendBlack.png"); + QIcon sendIcon(send); ui->sendChatButton->setIcon(sendIcon); - QPixmap notification(":/icons/res/notification.svg"); + QPixmap notification(":/icons/res/requestBlack.png"); QIcon notificationIcon(notification); ui->pushContact->setIcon(notificationIcon); - QPixmap addContact(":/icons/res/add_contact.svg"); + QPixmap addContact(":/icons/res/addContactBlack.png"); QIcon addContactIcon(addContact); - ui->safeContactRequest->setIcon(addContact); + ui->safeContactRequest->setIcon(addContactIcon); - QPixmap newAddr(":/icons/res/add_contact.svg"); + QPixmap newAddr(":/icons/res/getAddrBlack.png"); QIcon addnewAddrIcon(newAddr); ui->givemeZaddr->setIcon(addnewAddrIcon); - - QPixmap sendContact(":/icons/res/upload.svg"); - QIcon addSendContactIcon(sendContact); - ui->sendContact->setIcon(addSendContactIcon); } QObject::connect(ui->sendChatButton, &QPushButton::clicked, this, &MainWindow::sendChatButton); - QObject::connect(ui->sendContact, &QPushButton::clicked, this, &MainWindow::ContactRequest); QObject::connect(ui->safeContactRequest, &QPushButton::clicked, this, &MainWindow::addContact); QObject::connect(ui->pushContact, &QPushButton::clicked, this , &MainWindow::renderContactRequest); diff --git a/src/mainwindow.h b/src/mainwindow.h index ff4b76a..ea0a3a4 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -62,12 +62,7 @@ public: void updateLabels(); void updateTAddrCombo(bool checked); - // void renderContactRequest(); - // void setChatItem(ChatItem* item); - //void ChatItem* getChatItem(); - - // Disable recurring on mainnet void disableRecurring(); diff --git a/src/mainwindow.ui b/src/mainwindow.ui index 3e82d7a..82b4260 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -1409,9 +1409,21 @@ 81 + + false + font: 11pt "Noto Color Emoji"; + + QTextEdit::AutoNone + + + QTextEdit::FixedColumnWidth + + + 80 + @@ -1435,7 +1447,7 @@ - 1170 + 1160 560 91 81 @@ -1455,12 +1467,12 @@ - :/icons/res/send-new-white.png + :/icons/res/sendBlack.png - 41 + 50 49 @@ -1533,18 +1545,21 @@ 0 + + Add a new contact + - :/icons/res/add_contact.png + :/icons/res/addContactBlack.png - 43 - 49 + 50 + 45 @@ -1554,10 +1569,10 @@ - 10 - 30 - 41 - 41 + 50 + 20 + 61 + 51 @@ -1566,6 +1581,9 @@ 0 + + Incoming contact request + false @@ -1574,71 +1592,41 @@ - :/icons/res/notification.png:/icons/res/notification.png + :/icons/res/requestBlack.png:/icons/res/requestBlack.png - 33 - 35 + 50 + 45 true - + - 270 - 510 - 51 + 210 + 20 + 61 51 - - - 100 - 0 - + + Get a new Address - - - :/icons/res/add_contact.png - - - - - 43 - 49 - - - - true - - - - - - 60 - 30 - 111 - 41 - - - - New Addr - - :/icons/res/add_contact.png:/icons/res/add_contact.png + :/icons/res/getAddrBlack.png:/icons/res/getAddrBlack.png - 33 - 35 + 50 + 45 @@ -1648,8 +1636,8 @@ - 40 - 20 + 90 + 10 21 16 @@ -2042,7 +2030,7 @@ AddressCombo QComboBox -
addresscombo.h
+
addresscombo.h
QRCodeLabel