From e9ae0e78c5f21402b8f87ba4df6a0dde5cdfa731 Mon Sep 17 00:00:00 2001 From: DenioD <41270280+DenioD@users.noreply.github.com> Date: Wed, 29 Apr 2020 00:51:07 +0200 Subject: [PATCH] send Memo to selected Contact --- lib/Cargo.lock | 6 ++--- lib/Cargo.toml | 2 +- src/chatmodel.cpp | 17 ++++++++++---- src/contactmodel.cpp | 4 +++- src/mainwindow.cpp | 15 ++++++++++++ src/mainwindow.ui | 55 +++++++++++++++++++++++++++++++++++++------- 6 files changed, 82 insertions(+), 17 deletions(-) diff --git a/lib/Cargo.lock b/lib/Cargo.lock index 089d4ac..96d8bdf 100644 --- a/lib/Cargo.lock +++ b/lib/Cargo.lock @@ -1177,7 +1177,7 @@ version = "0.1.0" dependencies = [ "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", - "silentdragonlitelib 0.1.0 (git+https://github.com/MyHush/silentdragonlite-cli?rev=7efa024660cbe08e7eadf2524134e153c89c51ad)", + "silentdragonlitelib 0.1.0 (git+https://github.com/DenioD/silentdragonlite-cli?rev=d3a66550ed8c6216b13002ce6e5b425367f30770)", ] [[package]] @@ -1640,7 +1640,7 @@ dependencies = [ [[package]] name = "silentdragonlitelib" version = "0.1.0" -source = "git+https://github.com/MyHush/silentdragonlite-cli?rev=7efa024660cbe08e7eadf2524134e153c89c51ad#7efa024660cbe08e7eadf2524134e153c89c51ad" +source = "git+https://github.com/DenioD/silentdragonlite-cli?rev=d3a66550ed8c6216b13002ce6e5b425367f30770#d3a66550ed8c6216b13002ce6e5b425367f30770" dependencies = [ "base58 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "bellman 0.1.0 (git+https://github.com/MyHush/librustzcash.git?rev=1a0204113d487cdaaf183c2967010e5214ff9e37)", @@ -2630,7 +2630,7 @@ dependencies = [ "checksum serde_yaml 0.8.11 (registry+https://github.com/rust-lang/crates.io-index)" = "691b17f19fc1ec9d94ec0b5864859290dff279dbd7b03f017afda54eb36c3c35" "checksum sha2 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "27044adfd2e1f077f649f59deb9490d3941d674002f7d062870a60ebe9bd47a0" "checksum signal-hook-registry 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "94f478ede9f64724c5d173d7bb56099ec3e2d9fc2774aac65d34b8b890405f41" -"checksum silentdragonlitelib 0.1.0 (git+https://github.com/MyHush/silentdragonlite-cli?rev=7efa024660cbe08e7eadf2524134e153c89c51ad)" = "" +"checksum silentdragonlitelib 0.1.0 (git+https://github.com/DenioD/silentdragonlite-cli?rev=d3a66550ed8c6216b13002ce6e5b425367f30770)" = "" "checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" "checksum smallvec 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)" = "f7b0758c52e15a8b5e3691eae6cc559f08eee9406e548a4477ba4e67770a82b6" "checksum socket2 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)" = "e8b74de517221a2cb01a53349cf54182acdc31a074727d3079068448c0676d85" diff --git a/lib/Cargo.toml b/lib/Cargo.toml index 65c97ad..bd615ca 100644 --- a/lib/Cargo.toml +++ b/lib/Cargo.toml @@ -11,4 +11,4 @@ crate-type = ["staticlib"] [dependencies] libc = "0.2.58" lazy_static = "1.4.0" -silentdragonlitelib = { git = "https://github.com/MyHush/silentdragonlite-cli", rev = "7efa024660cbe08e7eadf2524134e153c89c51ad" } +silentdragonlitelib = { git = "https://github.com/DenioD/silentdragonlite-cli", rev = "d3a66550ed8c6216b13002ce6e5b425367f30770" } diff --git a/src/chatmodel.cpp b/src/chatmodel.cpp index 43e929e..64a781b 100644 --- a/src/chatmodel.cpp +++ b/src/chatmodel.cpp @@ -74,6 +74,7 @@ void ChatModel::renderChatBox(QListWidget &view) void ChatModel::renderChatBox(QListWidget *view) { + qDebug() << "called ChatModel::renderChatBox(QListWidget *view)"; QString line = ""; while(view->count() > 0) @@ -97,6 +98,7 @@ void ChatModel::renderChatBox(QListWidget *view) QString MainWindow::createHeaderMemo(QString cid, QString zaddr, int version=0, int headerNumber=1) { + QString header=""; QJsonDocument j; QJsonObject h; @@ -120,7 +122,14 @@ Tx MainWindow::createTxFromChatPage() { CAmount totalAmt; // For each addr/amt in the Chat tab { - QString addr = ""; // We need to set the reply Address for our Contact here + + + + // ui->ContactZaddr->setText("Zaddr"); + + + + QString addr = ui->ContactZaddr->text().trimmed(); // We need to set the reply Address for our Contact here // Remove label if it exists addr = AddressBook::addressFromAddressLabel(addr); @@ -134,15 +143,15 @@ Tx MainWindow::createTxFromChatPage() { totalAmt = totalAmt + amt; QString cid = QString::number( time(NULL) % std::rand() ); // low entropy for testing! // QString cid = QUuid::createUuid().toString(QUuid::WithoutBraces); // Needs to get a fix - QString hmemo= createHeaderMemo(cid,"ZADDR"); + QString hmemo= createHeaderMemo(cid,"Some ZADDR"); QString memo = ui->memoTxtChat->toPlainText().trimmed(); // ui->memoSizeChat->setLenDisplayLabel(); - tx.toAddrs.push_back(ToFields{addr, amt, hmemo.toUtf8().toHex()}) ; + tx.toAddrs.push_back(ToFields{addr, amt, hmemo}) ; qDebug()<getAllAddressLabels()) { - view->addItem(c.getName()); + view->addItem(c.getPartnerAddress()); + } } \ No newline at end of file diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index d1c331e..cf063b1 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -988,7 +988,22 @@ void MainWindow::setupchatTab() { // Send button QObject::connect(ui->sendChatButton, &QPushButton::clicked, this, &MainWindow::sendChatButton); + +///////// Set selected Zaddr for Chat with Doubleklick + + QObject::connect(ui->listContactWidget, &QTableView::doubleClicked, [=] () { + for (auto p : AddressBook::getInstance()->getAllAddressLabels()) { + QModelIndex index = ui->listContactWidget->currentIndex(); + QString itemText = index.data(Qt::DisplayRole).toString(); + ui->ContactZaddr->setText(itemText); + + } + + /// ui->listContactWidget->setCurrentRow(1) + + }); +} ChatMemoEdit::ChatMemoEdit(QWidget* parent) : QPlainTextEdit(parent) { QObject::connect(this, &QPlainTextEdit::textChanged, this, &ChatMemoEdit::updateDisplay); diff --git a/src/mainwindow.ui b/src/mainwindow.ui index 8dd559f..a2e83da 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -1354,9 +1354,9 @@ - 357 - 460 - 329 + 340 + 490 + 61 17 @@ -1367,8 +1367,8 @@ - 347 - 483 + 340 + 510 901 128 @@ -1377,8 +1377,8 @@ - 360 - 620 + 350 + 650 158 25 @@ -1445,7 +1445,7 @@ 1130 - 620 + 650 114 25 @@ -1463,6 +1463,45 @@ false + + + + 410 + 490 + 67 + 17 + + + + To: + + + + + + 520 + 490 + 67 + 17 + + + + + + + + + + 740 + 490 + 171 + 17 + + + + + +