From 791a54157fc73ab9c1938454ec713f43c0036525 Mon Sep 17 00:00:00 2001 From: DenioD <41270280+DenioD@users.noreply.github.com> Date: Sat, 20 Jun 2020 22:38:28 +0200 Subject: [PATCH] add send Hush to a friend --- silentdragon-lite.pro | 1 + src/mainwindow.cpp | 58 +++++--- src/sendHushTransactionChat.ui | 243 ++++++++++++++++++++++++++------- 3 files changed, 237 insertions(+), 65 deletions(-) diff --git a/silentdragon-lite.pro b/silentdragon-lite.pro index 4338b4b..60d9b13 100644 --- a/silentdragon-lite.pro +++ b/silentdragon-lite.pro @@ -129,6 +129,7 @@ FORMS += \ src/newwallet.ui \ src/recurringpayments.ui \ src/restoreseed.ui \ + src/sendHushTransactionChat.ui \ src/settings.ui \ src/about.ui \ src/confirm.ui \ diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 6910eff..6ed707a 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -17,6 +17,7 @@ #include "settings.h" #include "version.h" #include "connection.h" +#include "ui_sendHushTransactionChat.h" #include "ui_contactrequest.h" #include "ui_deposithush.h" #include "ui_requestContactDialog.h" @@ -1465,8 +1466,7 @@ void MainWindow::setupchatTab() { contextMenu = new QMenu(ui->listContactWidget); requestAction = new QAction("Send a contact request - coming soon",contextMenu); editAction = new QAction("Delete this contact",contextMenu); - HushAction = new QAction("Send a friend some Hush - coming soon",contextMenu); - requestHushAction = new QAction("Request some Hush - coming soon",contextMenu); + HushAction = new QAction("Send or Request some Hush - coming soon",contextMenu); subatomicAction = new QAction("Make a subatomic swap with a friend- coming soon",contextMenu); @@ -1478,23 +1478,54 @@ void MainWindow::setupchatTab() { ui->listContactWidget->addAction(requestAction); ui->listContactWidget->addAction(editAction); ui->listContactWidget->addAction(HushAction); - ui->listContactWidget->addAction(requestHushAction); ui->listContactWidget->addAction(subatomicAction); ui->memoTxtChat->setEnabled(true); - /*QObject::connect(requestHushAction, &QAction::triggered, [=]() { QModelIndex index = ui->listContactWidget->currentIndex(); - QString label_contact = index.data(Qt::DisplayRole).toString(); + QString label_contact = index.data(Qt::DisplayRole).toString(); for(auto &p : AddressBook::getInstance()->getAllAddressLabels()) if (label_contact == p.getName()) { ui->contactNameMemo->setText(p.getName()); rpc->refresh(true); + + } + }); + + QObject::connect(HushAction, &QAction::triggered, [=]() { + + QModelIndex index = ui->listContactWidget->currentIndex(); + QString label_contact = index.data(Qt::DisplayRole).toString(); + + QDialog transactionDialog(this); + Ui_transactionHush transaction; + transaction.setupUi(&transactionDialog); + + + + for(auto &p : AddressBook::getInstance()->getAllAddressLabels()) + if (label_contact == p.getName()) { + // Settings::saveRestore(&transactionDialog); + QStandardItemModel* contact = new QStandardItemModel(); + QString avatar = p.getAvatar(); + QStandardItem* Items1 = new QStandardItem(p.getName()); + Items1->setData(QIcon(avatar),Qt::DecorationRole); + contact->appendRow(Items1); + transaction.contactName->setModel(contact); + transaction.contactName->setIconSize(QSize(60,70)); + transaction.contactName->setUniformItemSizes(true); + transaction.contactName->setDragDropMode(QAbstractItemView::DropOnly); + transaction.contactName->show(); + + + QString amt = transaction.amountChat->text(); + qDebug()<<"AMT : " << amt; } - MainWindow::showRequesthush(); - - }); */ + + transactionDialog.exec(); + + }); QObject::connect(editAction, &QAction::triggered, [=]() { QModelIndex index = ui->listContactWidget->currentIndex(); @@ -1517,16 +1548,7 @@ void MainWindow::setupchatTab() { } }); - QModelIndex index = ui->listContactWidget->currentIndex(); - QString label_contact = index.data(Qt::DisplayRole).toString(); - - for(auto &p : AddressBook::getInstance()->getAllAddressLabels()) - if (label_contact == p.getName()) { - ui->contactNameMemo->setText(p.getName()); - rpc->refresh(true); - - } - }); + ui->memoTxtChat->setLenDisplayLabelChat(ui->memoSizeChat); diff --git a/src/sendHushTransactionChat.ui b/src/sendHushTransactionChat.ui index fb923db..936e38f 100644 --- a/src/sendHushTransactionChat.ui +++ b/src/sendHushTransactionChat.ui @@ -1,67 +1,217 @@ - - - - - Dialog - - + + + transactionHush + + 0 0 - 400 - 300 + 530 + 377 - + Dialog - - - - 30 - 240 - 341 - 32 - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - + + + + + + 16777215 + 20 + + + + <html><head/><body><p align="center"><span style=" font-weight:600;">Send or Request some Hush</span></p></body></html> + + + + + + + To : + + + + + + + Qt::Vertical + + + + 20 + 65 + + + + + + + + QLayout::SetFixedSize + + + 6 + + + 6 + + + 6 + + + 6 + + + + + + 16777215 + 70 + + + + Qt::ScrollBarAlwaysOff + + + Qt::ScrollBarAlwaysOff + + + QAbstractItemView::NoEditTriggers + + + false + + + + + + + + + Qt::Vertical + + + + 20 + 79 + + + + + + + + + + Amount: + + + + + + + + 200 + 0 + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + Amount + + + + + + + + + Qt::Vertical + + + + 20 + 64 + + + + + + + + QLayout::SetFixedSize + + + 6 + + + 6 + + + 6 + + + 6 + + + + + Request Hush + + + + + + + + 16777215 + 25 + + + + Send Hush + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel + + + + + + + Hush + + + + - - - buttonBox - accepted() - Dialog - accept() - - - 248 - 254 - - - 157 - 274 - - - buttonBox rejected() - Dialog + transactionHush reject() - + 316 260 - + 286 274 @@ -69,4 +219,3 @@ -