allAddresses;
+
+ allAddresses = getRPC()->getModel()->getAllZAddresses();
+ QString depositzaddr = allAddresses[1];
+ deposithush.qrcodeDisplayDeposit->setQrcodeString(depositzaddr);
+ deposithush.zaddr->setText(depositzaddr);
+
+ QObject::connect(deposithush.CopyAddress, &QPushButton::clicked, [=](){
+
+ QGuiApplication::clipboard()->setText(depositzaddr);
+ ui->statusBar->showMessage(tr("Copied to clipboard"), 3 * 1000);
+
+ });
+
+
+
+ dialog.exec();
+
+
+
+
+ });
// Setup context menu on balances tab
@@ -878,6 +1221,7 @@ void MainWindow::setupBalancesTab() {
menu.exec(ui->balancesTable->viewport()->mapToGlobal(pos));
});
+
}
void MainWindow::setuphushdTab() {
@@ -899,8 +1243,22 @@ void MainWindow::setupTransactionsTab() {
});
// Set up context menu on transactions tab
+ auto theme = Settings::getInstance()->get_theme_name();
+ if (theme == "Dark" || theme == "Midnight") {
+ ui->listChat->setStyleSheet("background-image: url(:/icons/res/sdlogo.png) ;background-attachment: fixed ;background-position: center center ;background-repeat: no-repeat;background-size: cover");
+ }
+ if (theme == "Default") {ui->listChat->setStyleSheet("background-image: url(:/icons/res/sdlogo2.png) ;background-attachment: fixed ;background-position: center center ;background-repeat: no-repeat;background-size: cover");}
+
+ ui->listChat->setResizeMode(QListView::Adjust);
+ ui->listChat->setWordWrap(true);
+ ui->listChat->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
+ ui->listChat->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ ui->listChat->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ ui->listChat->setMinimumSize(200,350);
+ ui->listChat->setItemDelegate(new ListViewDelegate());
+ ui->listChat->show();
+
ui->transactionsTable->setContextMenuPolicy(Qt::CustomContextMenu);
-
// Table right click
QObject::connect(ui->transactionsTable, &QTableView::customContextMenuRequested, [=] (QPoint pos) {
QModelIndex index = ui->transactionsTable->indexAt(pos);
@@ -974,13 +1332,263 @@ void MainWindow::setupTransactionsTab() {
qApp->processEvents();
// Click the memo button
- this->memoButtonClicked(1, true);
+ this->memoButtonClicked(1, true);
});
}
}
menu.exec(ui->transactionsTable->viewport()->mapToGlobal(pos));
});
+
+}
+
+void MainWindow::setupchatTab() {
+
+ /////////////Setting Icons for Chattab and different themes
+
+ auto theme = Settings::getInstance()->get_theme_name();
+ if (theme == "Dark" || theme == "Midnight") {
+ QPixmap send(":/icons/res/send-white.png");
+ QIcon sendIcon(send);
+ ui->sendChatButton->setIcon(sendIcon);
+
+ QPixmap notification(":/icons/res/requestWhite.png");
+ QIcon notificationIcon(notification);
+ ui->pushContact->setIcon(notificationIcon);
+
+ QPixmap addContact(":/icons/res/addContactWhite.png");
+ QIcon addContactIcon(addContact);
+ ui->safeContactRequest->setIcon(addContactIcon);
+
+ QPixmap newAddr(":/icons/res/getAddrWhite.png");
+ QIcon addnewAddrIcon(newAddr);
+ ui->givemeZaddr->setIcon(addnewAddrIcon);
+
+ ui->memoTxtChat->setTextColor("White");
+
+ }else{
+
+ QPixmap send(":/icons/res/sendBlack.png");
+ QIcon sendIcon(send);
+ ui->sendChatButton->setIcon(sendIcon);
+
+ QPixmap notification(":/icons/res/requestBlack.png");
+ QIcon notificationIcon(notification);
+ ui->pushContact->setIcon(notificationIcon);
+
+ QPixmap addContact(":/icons/res/addContactBlack.png");
+ QIcon addContactIcon(addContact);
+ ui->safeContactRequest->setIcon(addContactIcon);
+
+ QPixmap newAddr(":/icons/res/getAddrBlack.png");
+ QIcon addnewAddrIcon(newAddr);
+ ui->givemeZaddr->setIcon(addnewAddrIcon);
+
+ ui->memoTxtChat->setTextColor("Black");
+ }
+
+ QObject::connect(ui->sendChatButton, &QPushButton::clicked, this, &MainWindow::sendChat);
+ QObject::connect(ui->safeContactRequest, &QPushButton::clicked, this, &MainWindow::addContact);
+ QObject::connect(ui->pushContact, &QPushButton::clicked, this , &MainWindow::renderContactRequest);
+
+ ui->contactNameMemo->setText("");
+
+ /////Copy Chatmessages
+
+ QMenu* contextMenuChat;
+ QAction* copymessage;
+ QAction* viewexplorer;
+ QAction* copytxid;
+ contextMenuChat = new QMenu(ui->listChat);
+ copymessage = new QAction("Copy message to clipboard",contextMenuChat);
+ viewexplorer = new QAction("View on block explorer",contextMenuChat);
+ copytxid = new QAction("Copy txid to clipboard ",contextMenuChat);
+
+ QObject::connect(ui->listContactWidget, &QTableView::clicked, [=] () {
+
+ ui->listChat->setContextMenuPolicy(Qt::ActionsContextMenu);
+ ui->listChat->addAction(copymessage);
+ ui->listChat->addAction(viewexplorer);
+ ui->listChat->addAction(copytxid);
+
+ QObject::connect(copymessage, &QAction::triggered, [=] {
+
+
+ QModelIndex index = ui->listChat->currentIndex();
+ QString memo_chat = index.data(Qt::DisplayRole).toString();
+ QClipboard *clipboard = QGuiApplication::clipboard();
+ int startPos = memo_chat.indexOf("") + 3;
+ int endPos = memo_chat.indexOf("
");
+ int length = endPos - startPos;
+ QString copymemo = memo_chat.mid(startPos, length);
+
+ clipboard->setText(copymemo);
+ ui->statusBar->showMessage(tr("Copied message to clipboard"), 3 * 1000);
+
+});
+ QObject::connect(copytxid, &QAction::triggered, [=] {
+
+ QModelIndex index = ui->listChat->currentIndex();
+ QString memo_chat = index.data(Qt::DisplayRole).toString();
+ QClipboard *clipboard = QGuiApplication::clipboard();
+
+ int startPos = memo_chat.indexOf("") + 3;
+ int endPos = memo_chat.indexOf("
");
+ int length = endPos - startPos;
+ QString copymemo = memo_chat.mid(startPos, length);
+ int startPosT = memo_chat.indexOf("") + 7;
+ int endPosT = memo_chat.indexOf("");
+ int lengthT = endPosT - startPosT;
+
+ QString time = memo_chat.mid(startPosT, lengthT);
+
+ for (auto &c : DataStore::getChatDataStore()->getAllRawChatItems()){
+
+ if (c.second.getMemo() == copymemo)
+ {
+ int timestamp = c.second.getTimestamp();
+ QDateTime myDateTime;
+ QString lock;
+ myDateTime.setTime_t(timestamp);
+ QString timestamphtml = myDateTime.toString("yyyy-MM-dd hh:mm");
+
+ if(timestamphtml == time)
+
+ {
+ clipboard->setText(c.second.getTxid());
+ ui->statusBar->showMessage(tr("Copied Txid to clipboard"), 3 * 1000);
+ }else{}
+
+ }
+
+}
+
+});
+
+ QObject::connect(viewexplorer, &QAction::triggered, [=] {
+
+ QModelIndex index = ui->listChat->currentIndex();
+ QString memo_chat = index.data(Qt::DisplayRole).toString();
+
+ int startPos = memo_chat.indexOf("") + 3;
+ int endPos = memo_chat.indexOf("
");
+ int length = endPos - startPos;
+ QString copymemo = memo_chat.mid(startPos, length);
+ int startPosT = memo_chat.indexOf("") + 7;
+ int endPosT = memo_chat.indexOf("");
+ int lengthT = endPosT - startPosT;
+
+ QString time = memo_chat.mid(startPosT, lengthT);
+
+ for (auto &c : DataStore::getChatDataStore()->getAllRawChatItems()){
+
+ if (c.second.getMemo() == copymemo)
+ {
+ int timestamp = c.second.getTimestamp();
+ QDateTime myDateTime;
+ QString lock;
+ myDateTime.setTime_t(timestamp);
+ QString timestamphtml = myDateTime.toString("yyyy-MM-dd hh:mm");
+
+ if(timestamphtml == time)
+
+ {
+
+ Settings::openTxInExplorer(c.second.getTxid());
+
+ }else{}
+
+ }
+
+}
+});
+
+});
+
+///////// Add contextmenu
+ QMenu* contextMenu;
+ QAction* requestAction;
+ QAction* editAction;
+ QAction* HushAction;
+ QAction* requestHushAction;
+ QAction* subatomicAction;
+ 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);
+ subatomicAction = new QAction("Make a subatomic swap with a friend- coming soon",contextMenu);
+
+
+///////// Set selected Zaddr for Chat with click
+
+ QObject::connect(ui->listContactWidget, &QTableView::clicked, [=] () {
+
+ ui->listContactWidget->setContextMenuPolicy(Qt::ActionsContextMenu);
+ ui->listContactWidget->addAction(requestAction);
+ ui->listContactWidget->addAction(editAction);
+ ui->listContactWidget->addAction(HushAction);
+ ui->listContactWidget->addAction(requestHushAction);
+ ui->listContactWidget->addAction(subatomicAction);
+
+ /*QObject::connect(requestHushAction, &QAction::triggered, [=]() {
+ 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);
+
+ }
+ MainWindow::showRequesthush();
+
+ }); */
+
+ QObject::connect(editAction, &QAction::triggered, [=]() {
+ QModelIndex index = ui->listContactWidget->currentIndex();
+ QString label_contact = index.data(Qt::DisplayRole).toString();
+
+ for(auto &p : AddressBook::getInstance()->getAllAddressLabels())
+ if (label_contact == p.getName()) {
+
+ QString label1 = p.getName();
+ QString addr = p.getPartnerAddress();
+ QString myzaddr = p.getMyAddress();
+ QString cid = p.getCid();
+ QString avatar = p.getAvatar();
+
+
+ AddressBook::getInstance()->removeAddressLabel(label1, addr, myzaddr, cid,avatar);
+ rpc->refreshContacts(
+ ui->listContactWidget);
+ rpc->refresh(true);
+ }
+ });
+
+ 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);
+}
+
+void MainWindow::updateChat()
+{
+ rpc->refreshChat(ui->listChat,ui->memoSizeChat);
+ rpc->refresh(true);
+}
+
+void MainWindow::updateContacts()
+{
+
}
void MainWindow::addNewZaddr(bool sapling) {
@@ -1214,6 +1822,7 @@ void MainWindow::setupReceiveTab() {
// Receive tab add/update label
QObject::connect(ui->rcvUpdateLabel, &QPushButton::clicked, [=]() {
QString addr = ui->listReceiveAddresses->currentText();
+
if (addr.isEmpty())
return;
@@ -1227,7 +1836,7 @@ void MainWindow::setupReceiveTab() {
if (!curLabel.isEmpty() && label.isEmpty()) {
info = "Removed Label '" % curLabel % "'";
- AddressBook::getInstance()->removeAddressLabel(curLabel, addr);
+ AddressBook::getInstance()->removeAddressLabel(curLabel, addr, "", "","" );
}
else if (!curLabel.isEmpty() && !label.isEmpty()) {
info = "Updated Label '" % curLabel % "' to '" % label % "'";
@@ -1235,7 +1844,7 @@ void MainWindow::setupReceiveTab() {
}
else if (curLabel.isEmpty() && !label.isEmpty()) {
info = "Added Label '" % label % "'";
- AddressBook::getInstance()->addAddressLabel(label, addr);
+ AddressBook::getInstance()->addAddressLabel(label, addr, "", "", "");
}
// Update labels everywhere on the UI
@@ -1285,7 +1894,7 @@ void MainWindow::updateTAddrCombo(bool checked) {
auto allTaddrs = this->rpc->getModel()->getAllTAddresses();
QSet labels;
for (auto p : AddressBook::getInstance()->getAllAddressLabels()) {
- labels.insert(p.second);
+ labels.insert(p.getPartnerAddress());
}
std::for_each(allTaddrs.begin(), allTaddrs.end(), [=, &addrs] (auto& taddr) {
// If the address is in the address book, add it.
@@ -1377,7 +1986,7 @@ void MainWindow::slot_change_theme(const QString& theme_name)
}
catch (...)
{
- saved_theme_name = "default";
+ saved_theme_name = "Dark";
}
QFile qFile(":/css/res/css/" + saved_theme_name +".css");
@@ -1406,3 +2015,17 @@ MainWindow::~MainWindow()
delete wsserver;
delete wormhole;
}
+void MainWindow::on_givemeZaddr_clicked()
+{
+
+ bool sapling = true;
+ rpc->createNewZaddr(sapling, [=] (json reply) {
+ QString hushchataddr = QString::fromStdString(reply.get()[0]);
+ QClipboard *zaddr_Clipboard = QApplication::clipboard();
+ zaddr_Clipboard ->setText(hushchataddr);
+ QMessageBox::information(this, "Your new HushChat address was copied to your clipboard!",hushchataddr);
+ ui->listReceiveAddresses->insertItem(0, hushchataddr);
+ ui->listReceiveAddresses->setCurrentIndex(0);
+
+ });
+}
diff --git a/src/mainwindow.h b/src/mainwindow.h
index 50f833a..62ff3f3 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -5,12 +5,14 @@
#include "logger.h"
#include "recurring.h"
+#include "firsttimewizard.h"
// Forward declare to break circular dependency.
class Controller;
class Settings;
class WSServer;
class WormholeClient;
+class ChatModel;
using json = nlohmann::json;
@@ -47,18 +49,32 @@ public:
QRegExpValidator* getAmountValidator() { return amtValidator; }
QString doSendTxValidations(Tx tx);
+ QString doSendChatTxValidations(Tx tx);
+ QString doSendRequestTxValidations(Tx tx);
+ QString getCid();
+ QString getPassword();
+ std::map pubkeyMap;
+ QString getPubkeyByAddress(QString requestZaddr);
+ void setPassword(QString Password);
+ void addPubkey(QString requestZaddr, QString pubkey);
+
+
+
void replaceWormholeClient(WormholeClient* newClient);
bool isWebsocketListening();
void createWebsocket(QString wormholecode);
void stopWebsocket();
-
+ void saveContact();
+ void saveandsendContact();
+ void showRequesthush();
+
void balancesReady();
void payhushURI(QString uri = "", QString myAddr = "");
void updateLabels();
void updateTAddrCombo(bool checked);
-
+
// Disable recurring on mainnet
void disableRecurring();
@@ -71,37 +87,68 @@ public:
QLabel* statusIcon;
QLabel* loadingLabel;
QWidget* hushdtab;
+ //ChatItem* currentChatItem;
+
Logger* logger;
void doClose();
+ void doClosePw();
+ QString createHeaderMemo(QString type, QString cid, QString zaddr,QString headerbytes,QString publickey, int version, int headerNumber);
public slots:
void slot_change_theme(const QString& themeName);
void slot_change_currency(const QString& currencyName);
+
-private:
+private slots:
+
+
+ void on_givemeZaddr_clicked();
+
+private:
+
+ bool fileExists(QString path);
void closeEvent(QCloseEvent* event);
+ void closeEventpw(QCloseEvent* event);
+ QString _password;
+
void setupSendTab();
void setupTransactionsTab();
void setupReceiveTab();
void setupBalancesTab();
void setuphushdTab();
+ void setupchatTab();
+ void renderContactRequest();
+
+ void updateContacts();
+ void updateChat();
void setupSettingsModal();
void setupStatusBar();
void clearSendForm();
+
Tx createTxFromSendPage();
bool confirmTx(Tx tx, RecurringPaymentInfo* rpi);
+ Tx createTxFromChatPage();
+ Tx createTxForSafeContactRequest();
+
+
void encryptWallet();
void removeWalletEncryption();
+ void removeWalletEncryptionStartUp();
void cancelButton();
void sendButton();
+ void sendChat();
+ void addContact();
+ void ContactRequest();
+
+
void addAddressSection();
void maxAmountChecked(int checked);
@@ -131,13 +178,18 @@ private:
void restoreSavedStates();
bool eventFilter(QObject *object, QEvent *event);
+
+
+
bool uiPaymentsReady = false;
QString pendingURIPayment;
WSServer* wsserver = nullptr;
WormholeClient* wormhole = nullptr;
+
Controller* rpc = nullptr;
+
QCompleter* labelCompleter = nullptr;
QRegExpValidator* amtValidator = nullptr;
QRegExpValidator* feesValidator = nullptr;
@@ -147,4 +199,21 @@ private:
QMovie* loadingMovie;
};
+class ChatMemoEdit : public QTextEdit
+{
+public:
+ ChatMemoEdit(QWidget* parent);
+
+ void setMaxLenChat(int len);
+ void setLenDisplayLabelChat(QLabel* label);
+ void SetSendChatButton(QPushButton* button);
+ void updateDisplayChat();
+
+private:
+ int maxlenchat = 235;
+ QLabel* lenDisplayLabelchat = nullptr;
+ QPushButton* sendChatButton = nullptr;
+};
+
+
#endif // MAINWINDOW_H
diff --git a/src/mainwindow.ui b/src/mainwindow.ui
index d7caf5d..8471227 100644
--- a/src/mainwindow.ui
+++ b/src/mainwindow.ui
@@ -10,6 +10,43 @@
779
+
+
+
+
+
+
+ 0
+ 0
+ 0
+
+
+
+
+
+
+
+
+ 0
+ 0
+ 0
+
+
+
+
+
+
+
+
+ 0
+ 0
+ 0
+
+
+
+
+
+
SilentDragonLite
@@ -18,11 +55,11 @@
:/icons/res/icon.ico:/icons/res/icon.ico
-
- -
+
+
-
- 0
+ 2
@@ -47,181 +84,184 @@
-
-
+
-
-
-
-
-
-
-
- 0
- 0
-
-
-
- Shielded
-
-
-
- -
-
-
-
-
-
- Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
-
-
-
-
+
+
+
+ 0
+ 0
+
+
+
+ Shielded
+
+
-
-
-
-
-
-
-
- 0
- 0
-
-
-
- Notarized
-
-
-
- -
-
-
-
-
-
- Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
-
-
-
-
+
+
+
+
+
+ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
+
+
+
+
+ -
+
-
-
-
-
-
-
-
- 0
- 0
-
-
-
- Transparent
-
-
-
- -
-
-
-
-
-
- Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
-
-
-
-
+
+
+
+ 0
+ 0
+
+
+
+ Notarized
+
+
-
-
-
- Qt::Horizontal
+
+
+
+
+
+ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
+
+
+ -
+
-
-
-
-
-
-
-
- 0
- 0
-
-
-
-
- 75
- true
-
-
-
- Total
-
-
-
- -
-
-
-
- 75
- true
-
-
-
-
-
-
- Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
-
-
-
-
+
+
+
+ 0
+ 0
+
+
+
+ Transparent
+
+
-
-
-
- color:red;
-
+
- Your node is still syncing, balances may not be updated.
+
-
- true
+
+ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ -
+
-
-
+
0
0
-
- color: red;
+
+
+ 75
+ true
+
- Some transactions are not yet confirmed. Balances may change.
-
-
- true
+ Total
-
-
-
- Qt::Vertical
+
+
+
+ 75
+ true
+
-
-
- 20
- 40
-
+
+
-
+
+ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
+
+
+ -
+
+
+ color:red;
+
+
+ Your node is still syncing, balances may not be updated.
+
+
+ true
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ color: red;
+
+
+ Some transactions are not yet confirmed. Balances may change.
+
+
+ true
+
+
+
+ -
+
+
+ Deposit Hush
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 383
+
+
+
+