diff --git a/application.qrc b/application.qrc index 62ceb1d..09ec74c 100644 --- a/application.qrc +++ b/application.qrc @@ -21,7 +21,7 @@ res/Popey.png res/Garfield.png res/Pinguin.png - res/Hirsch.png + res/Stag.png res/hushdlogo.gif diff --git a/res/Hirsch.png b/res/Stag.png similarity index 100% rename from res/Hirsch.png rename to res/Stag.png diff --git a/src/addressbook.cpp b/src/addressbook.cpp index 6f209d1..d318f35 100644 --- a/src/addressbook.cpp +++ b/src/addressbook.cpp @@ -335,34 +335,11 @@ void AddressBook::open(MainWindow* parent, QLineEdit* target) } }; - // Get Avatar Data - - - // int avatar_index = ab.comboBoxAvatar->findText(AddressBook::getInstance()->get_avatar_name(), Qt::MatchExactly); - // ab.comboBoxAvatar->setCurrentIndex(avatar_index); - - // QObject::connect(ab.comboBoxAvatar, &QComboBox::currentTextChanged, [=] (QString avatar_name) { - // parent->slot_change_avatar(avatar_name); - // rpc->refresh(true); - // }); - // Refresh after the dialog is closed to update the labels everywhere. parent->getRPC()->refresh(true); model.updateUi(); //todo fix updating gui after adding } -QString AddressBook::get_avatar_name() { - // Load from the QT Settings. - // QString avatar = ab.comboBoxAvatar.text(); - // return QString() -} - -void AddressBook::set_avatar_name(QString avatar_name) { - avatar_name = "abs.comboBoxAvatar.text()"; -} - - - //============= // AddressBook singleton class //============= diff --git a/src/addressbook.ui b/src/addressbook.ui index 4cec4b1..b6d8d0a 100644 --- a/src/addressbook.ui +++ b/src/addressbook.ui @@ -69,7 +69,7 @@ - :/icons/res/Hirsch.png + :/icons/res/Stag.png diff --git a/src/chatmodel.cpp b/src/chatmodel.cpp index 550081c..e80c436 100644 --- a/src/chatmodel.cpp +++ b/src/chatmodel.cpp @@ -164,7 +164,7 @@ QString ChatModel::getCidByTx(QString tx) { for(auto& pair : this->cidMap) { - // qDebug() << "TXID=" << pair.first << " CID=" << pair.second; + } if(this->cidMap.count(tx) > 0) @@ -247,9 +247,7 @@ Tx MainWindow::createTxFromChatPage() { void MainWindow::sendChatButton() { - - - ////////////////////////////Todo: Check if a Contact is selected////////// +////////////////////////////Todo: Check if a Contact is selected////////// // Create a Tx from the values on the send tab. Note that this Tx object // might not be valid yet. @@ -377,25 +375,80 @@ QString MainWindow::doSendChatTxValidations(Tx tx) { return ""; } +void::MainWindow::addContact() { -// Create a Tx from the current state of the Chat page. -Tx MainWindow::createTxForSafeContactRequest() { - - Ui_Dialog request; + Ui_Dialog request; QDialog dialog(this); request.setupUi(&dialog); Settings::saveRestore(&dialog); -dialog.exec(); - - Tx tx; - QObject::connect(request.cancel, &QPushButton::clicked, [&] () { + bool sapling = true; + rpc->createNewZaddr(sapling, [=] (json reply) { + QString myAddr = QString::fromStdString(reply.get()[0]); + QString cid = QUuid::createUuid().toString(QUuid::WithoutBraces); + ui->listReceiveAddresses->insertItem(0, myAddr); + ui->listReceiveAddresses->setCurrentIndex(0); + + qDebug() << "new generated myAddr" << myAddr; + request.myzaddr->setText(myAddr); + 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(); + + QString avatar = QString("res/") + request.comboBoxAvatar->currentText() + QString(".png"); + + if (addr.isEmpty() || newLabel.isEmpty()) + { + QMessageBox::critical( + this, + QObject::tr("Address or Label Error"), + QObject::tr("Address or Label cannot be empty"), + QMessageBox::Ok + ); + return; + } + + // Test if address is valid. + if (!Settings::isValidAddress(addr)) + { + QMessageBox::critical( + this, + QObject::tr("Address Format Error"), + QObject::tr("%1 doesn't seem to be a valid hush address.").arg(addr), + QMessageBox::Ok + ); + return; + } + + ////// We need a better popup here. + AddressBook::getInstance()->addAddressLabel(newLabel, addr, myAddr, cid, avatar); + QMessageBox::critical( + this, + QObject::tr("Add Successfully"), + QObject::tr("juhu").arg(newLabel), + QMessageBox::Ok + ); + return; - dialog.close(); }); + + dialog.exec(); +} - QObject::connect(request.sendRequestButton, &QPushButton::clicked, this, &MainWindow::ContactRequest); +// Create a Tx for a contact Request +Tx MainWindow::createTxForSafeContactRequest() { + + Tx tx; + // For each addr/amt in the Chat tab { CAmount totalAmt; @@ -408,71 +461,41 @@ dialog.exec(); for(auto &c : AddressBook::getInstance()->getAllAddressLabels()) - if (request.zaddr->text().trimmed() != c.getPartnerAddress()) { + if (ui->contactNameMemo->text().trimmed() == c.getName()) { QString cid = c.getCid(); QString myAddr = c.getMyAddress(); QString type = "cont"; - QString addr = request.zaddr->text(); - - + QString addr = c.getPartnerAddress(); - QString hmemo= createHeaderMemo(type,cid,myAddr,0,0); - QString memo = request.requestmemo->toPlainText().trimmed(); + QString hmemo= createHeaderMemo(type,cid,myAddr); + QString memo = ui->memoTxtChat->toPlainText().trimmed(); 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; - qDebug() << "ChatTx created"; - } if (request.zaddr->text().trimmed().isEmpty() == false){ + qDebug() << "RequestTx created"; - QMessageBox msg(QMessageBox::Critical, tr("Please insert a contact Address"), request.zaddr->text(), - QMessageBox::Ok, this); - - msg.exec(); - - } } - + } -void MainWindow::ContactRequest() { - - - - ////////////////////////////Todo: Check if a Contact is selected////////// - - // Create a Tx from the values on the send tab. Note that this Tx object - // might not be valid yet. - // Memos can only be used with zAddrs. So check that first - // for(auto &c : AddressBook::getInstance()->getAllAddressLabels()) - - // if (ui->contactNameMemo->text().trimmed().isEmpty() || ui->memoTxtChat->toPlainText().trimmed().isEmpty()) { - - // auto addr = ""; - // if (! Settings::isZAddress(AddressBook::addressFromAddressLabel(addr->text()))) { - // QMessageBox msg(QMessageBox::Critical, tr("You have to select a contact and insert a Memo"), - // tr("You have selected no Contact from Contactlist,\n") + tr("\nor your Memo is empty"), - // QMessageBox::Ok, this); - - // msg.exec(); - // return; - // } - - -//}; +void MainWindow::ContactRequest() { Tx tx = createTxForSafeContactRequest(); - QString error = doSendChatTxValidations(tx); + QString error = doSendRequestTxValidations(tx); if (!error.isEmpty()) { // Something went wrong, so show an error and exit @@ -504,7 +527,7 @@ void MainWindow::ContactRequest() { } connD->status->setText(tr("Please wait...")); - connD->statusDetail->setText(tr("Your Message will be send")); + connD->statusDetail->setText(tr("Your Contact will be send")); d->show(); ui->memoTxtChat->clear(); diff --git a/src/chatmodel.h b/src/chatmodel.h index 490f336..cde16cb 100644 --- a/src/chatmodel.h +++ b/src/chatmodel.h @@ -310,6 +310,7 @@ class ChatModel void addCid(QString tx, QString cid); QString getCidByTx(QString tx); void killCidCache(); + }; #endif \ No newline at end of file diff --git a/src/contactmodel.cpp b/src/contactmodel.cpp index 0475e6e..d6a7e25 100644 --- a/src/contactmodel.cpp +++ b/src/contactmodel.cpp @@ -12,7 +12,6 @@ void ContactModel::renderContactList(QListView* view) auto theme = Settings::getInstance()->get_theme_name(); if ((theme == "dark" || theme == "midnight")) { - // QIcon avatar = c.getAvatar(); QString avatar = c.getAvatar(); QStandardItem* Items1 = new QStandardItem(QIcon(avatar) ,c.getName()); diff --git a/src/contactrequest.ui b/src/contactrequest.ui index 1bd758f..cee434f 100644 --- a/src/contactrequest.ui +++ b/src/contactrequest.ui @@ -13,130 +13,230 @@ Dialog - - - - 0 - 100 - 351 - 17 - - - - <html><head/><body><p>Please insert the Address of your contact :</p></body></html> - - - - - - 10 - 190 - 461 - 17 - - - - <html><head/><body><p>Insert a Message, and ask your friend for the contact request : </p><p><br/></p></body></html> - - - - - - 0 - 240 - 591 - 101 - - - - - - - 0 - 140 - 591 - 25 - - - - - - - 490 - 360 - 114 - 25 - - - - - 100 - 0 - - - - Send - - - false - - - - - - 320 - 360 - 114 - 25 - - - - - 100 - 0 - - - - Cancel - - - false - - - - - - 0 - 10 - 351 - 17 - - - - <html><head/><body><p>Please insert a Nickname for your contact :</p></body></html> - - - - - - 0 - 50 - 591 - 25 - - - + + + + + <html><head/><body><p align="right">Choose a avatar for your contact :</p></body></html> + + + + + + + <html><head/><body><p>Please insert a Nickname for your contact :</p></body></html> + + + + + + + + Stag + + + + :/icons/res/Hirsch.png + + + + + + Denio + + + + :/icons/res/Denio.png + + + + + + Duke + + + + :/icons/res/Duke.png + + + + + + Yoda + + + + :/icons/res/Yoda.png + + + + + + Berg + + + + :/icons/res/Berg.png + + + + + + Sharpee + + + + :/icons/res/Sharpee.png + + + + + + Garfield + + + + :/icons/res/Garfield.png + + + + + + Snoopy + + + + :/icons/res/Snoopy.png + + + + + + Popey + + + + :/icons/res/Popey.png + + + + + + Pinguin + + + + :/icons/res/Pinguin.png + + + + + + Mickey + + + + :/icons/res/Mickey.png + + + + + + SDLogo + + + + :/icons/res/sdlogo2.png + + + + + + + + + + + + <html><head/><body><p>Please insert the Address of your contact :</p></body></html> + + + + + + + + + + Your HushChat Address + + + + + + + + + + + + + + The Conversation ID + + + + + + + + + + + + + + + 100 + 0 + + + + Cancel + + + false + + + + + + + + 100 + 0 + + + + Add Contact + + + false + + + + - sendRequestButton + cancel clicked() Dialog - accept() + reject() - 536 + 396 262 @@ -146,13 +246,13 @@ - cancel + sendRequestButton clicked() Dialog - reject() + accept() - 396 + 536 262 diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 5e166e4..c2b1403 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -40,10 +40,9 @@ MainWindow::MainWindow(QWidget *parent) : ui->setupUi(this); - // ui->checkBox->setChecked(true); + ui->request->setChecked(true); logger = new Logger(this, QDir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)).filePath("silentdragonlite-wallet.log")); ui->memoTxtChat->setAutoFillBackground(false); - // ui->memoTxtChat->setStyleSheet(QString::fromUtf8("background-color: rgb(224, 224, 224);")); ui->memoTxtChat->setPlaceholderText("Send Message"); ui->memoTxtChat->setTextColor(Qt::white); @@ -436,11 +435,6 @@ void MainWindow::setupSettingsModal() { this->slot_change_currency(currency_name); - // Include Avatar - - - - // Setup theme combo int theme_index = settings.comboBoxTheme->findText(Settings::getInstance()->get_theme_name(), Qt::MatchExactly); settings.comboBoxTheme->setCurrentIndex(theme_index); @@ -1008,8 +1002,22 @@ void MainWindow::setupTransactionsTab() { void MainWindow::setupchatTab() { // Send button - QObject::connect(ui->sendChatButton, &QPushButton::clicked, this, &MainWindow::sendChatButton); - QObject::connect(ui->safeContactRequest, &QPushButton::clicked, this, &MainWindow::ContactRequest); + + // Is request Contact checked? + + if (ui->request->isChecked()) { + + + QObject::connect(ui->sendChatButton, &QPushButton::clicked, this, &MainWindow::ContactRequest); + + // qDebug() <request->isChecked()->text(); + }else{ + + QObject::connect(ui->sendChatButton, &QPushButton::clicked, this, &MainWindow::sendChatButton); + + } + + QObject::connect(ui->safeContactRequest, &QPushButton::clicked, this, &MainWindow::addContact); ///////// Set selected Zaddr for Chat with Doubleklick @@ -1470,26 +1478,6 @@ void MainWindow::slot_change_currency(const QString& currency_name) } } -void MainWindow::slot_change_avatar(const QString& avatar_name) - -{ - - AddressBook::getInstance()->set_avatar_name(avatar_name); - - // Include currency - - QString saved_avatar_name; - try - { - saved_avatar_name = AddressBook::getInstance()->get_avatar_name(); - - } - catch (...) - { - saved_avatar_name = "Yoda"; - - } -} void MainWindow::slot_change_theme(const QString& theme_name) diff --git a/src/mainwindow.h b/src/mainwindow.h index 0441de3..a98e622 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -83,7 +83,6 @@ public: public slots: void slot_change_theme(const QString& themeName); void slot_change_currency(const QString& currencyName); - void slot_change_avatar(const QString& avatarName); private: void closeEvent(QCloseEvent* event); @@ -116,6 +115,7 @@ private: void cancelButton(); void sendButton(); void sendChatButton(); + void addContact(); void ContactRequest(); void addAddressSection(); void maxAmountChecked(int checked); diff --git a/src/mainwindow.ui b/src/mainwindow.ui index e58e4ad..4c958a3 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -1334,7 +1334,7 @@ 0 40 341 - 551 + 601 @@ -1342,8 +1342,8 @@ 0 - 0 - 311 + 20 + 341 20 @@ -1355,9 +1355,9 @@ 340 - 460 + 560 921 - 131 + 81 @@ -1368,7 +1368,7 @@ 1190 - 610 + 650 47 17 @@ -1396,8 +1396,8 @@ - 710 - 610 + 720 + 640 114 25 @@ -1418,8 +1418,8 @@ - 50 - 600 + 30 + 640 211 25 @@ -1456,7 +1456,7 @@ 340 40 921 - 421 + 521 @@ -1484,6 +1484,19 @@ true + + + + 340 + 650 + 261 + 23 + + + + Is this message a contact request? + + @@ -1694,5 +1707,22 @@ - + + + request + stateChanged(int) + MainWindow + update() + + + 481 + 721 + + + 636 + 389 + + + +