Browse Source

send Memo to selected Contact

pull/130/head
DenioD 4 years ago
parent
commit
e9ae0e78c5
  1. 6
      lib/Cargo.lock
  2. 2
      lib/Cargo.toml
  3. 17
      src/chatmodel.cpp
  4. 4
      src/contactmodel.cpp
  5. 15
      src/mainwindow.cpp
  6. 55
      src/mainwindow.ui

6
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)" = "<none>"
"checksum silentdragonlitelib 0.1.0 (git+https://github.com/DenioD/silentdragonlite-cli?rev=d3a66550ed8c6216b13002ce6e5b425367f30770)" = "<none>"
"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"

2
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" }

17
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()<<hmemo;
tx.toAddrs.push_back( ToFields{addr, amt, memo.toUtf8().toHex()});
tx.toAddrs.push_back( ToFields{addr, amt, memo});
qDebug() << "pushback chattx";
}

4
src/contactmodel.cpp

@ -1,5 +1,6 @@
#include "contactmodel.h"
#include "addressbook.h"
#include "mainwindow.h"
void ContactModel::renderContactList(QListWidget* view)
{
@ -9,7 +10,8 @@ void ContactModel::renderContactList(QListWidget* view)
}
for(auto &c : AddressBook::getInstance()->getAllAddressLabels())
{
view->addItem(c.getName());
view->addItem(c.getPartnerAddress());
}
}

15
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);

55
src/mainwindow.ui

@ -1354,9 +1354,9 @@
<widget class="QLabel" name="label_40">
<property name="geometry">
<rect>
<x>357</x>
<y>460</y>
<width>329</width>
<x>340</x>
<y>490</y>
<width>61</width>
<height>17</height>
</rect>
</property>
@ -1367,8 +1367,8 @@
<widget class="MemoEdit" name="memoTxtChat">
<property name="geometry">
<rect>
<x>347</x>
<y>483</y>
<x>340</x>
<y>510</y>
<width>901</width>
<height>128</height>
</rect>
@ -1377,8 +1377,8 @@
<widget class="QPushButton" name="btnInsertFrom">
<property name="geometry">
<rect>
<x>360</x>
<y>620</y>
<x>350</x>
<y>650</y>
<width>158</width>
<height>25</height>
</rect>
@ -1445,7 +1445,7 @@
<property name="geometry">
<rect>
<x>1130</x>
<y>620</y>
<y>650</y>
<width>114</width>
<height>25</height>
</rect>
@ -1463,6 +1463,45 @@
<bool>false</bool>
</property>
</widget>
<widget class="QLabel" name="label_42">
<property name="geometry">
<rect>
<x>410</x>
<y>490</y>
<width>67</width>
<height>17</height>
</rect>
</property>
<property name="text">
<string>To:</string>
</property>
</widget>
<widget class="QLabel" name="ContactName">
<property name="geometry">
<rect>
<x>520</x>
<y>490</y>
<width>67</width>
<height>17</height>
</rect>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="ContactZaddr">
<property name="geometry">
<rect>
<x>740</x>
<y>490</y>
<width>171</width>
<height>17</height>
</rect>
</property>
<property name="text">
<string/>
</property>
</widget>
</widget>
</widget>
</item>

Loading…
Cancel
Save