From 89579022ef98f162c48abda1fa60777f4215d6bf Mon Sep 17 00:00:00 2001 From: DenioD <41270280+DenioD@users.noreply.github.com> Date: Thu, 10 Sep 2020 19:17:17 +0200 Subject: [PATCH 1/5] show timestamp of incoming contact request #194 --- src/chatmodel.cpp | 73 ++- src/requestContactDialog.ui | 952 ++++++++++++++++++++---------------- 2 files changed, 574 insertions(+), 451 deletions(-) diff --git a/src/chatmodel.cpp b/src/chatmodel.cpp index eb113cf..33cf8dc 100644 --- a/src/chatmodel.cpp +++ b/src/chatmodel.cpp @@ -91,7 +91,7 @@ QString ChatModel::Addressbylabel(QString address) return QString("0xdeadbeef"); } - + void MainWindow::renderContactRequest(){ Ui_requestDialog requestContact; @@ -109,58 +109,63 @@ void MainWindow::renderContactRequest(){ QPixmap unknownWhite(icon); QIcon addnewAddrIcon(unknownWhite); - - - - - QStandardItemModel* contactRequest = new QStandardItemModel(); + + + ///////// Tableview for incoming contact request + int requestsize = DataStore::getChatDataStore()->getAllNewContactRequests().size(); + requestContact.requestContact->setRowCount(requestsize); + requestContact.requestContact->setColumnCount(2); + QStringList request_TableHeader; + request_TableHeader<<"Address"<<"Date"; + requestContact.requestContact->setHorizontalHeaderLabels(request_TableHeader); + requestContact.requestContact->setShowGrid(false); + requestContact.requestContact->setEditTriggers(QAbstractItemView::NoEditTriggers); + requestContact.requestContact->setSelectionBehavior(QAbstractItemView::SelectRows); + requestContact.requestContact->setSelectionMode(QAbstractItemView::SingleSelection); + requestContact.requestContact->setColumnWidth(0,205); - for (auto &c : DataStore::getChatDataStore()->getAllNewContactRequests()) + int i=0; + + for (auto &c : DataStore::getChatDataStore()->getAllNewContactRequests()) + + { - { + int timestamp = c.second.getTimestamp(); + QDateTime myDateTime; + myDateTime.setTime_t(timestamp); + QString timestamphtml = myDateTime.toString("yyyy-MM-dd"); - QStandardItem* Items = new QStandardItem(QString(c.second.getRequestZaddr())); - contactRequest->appendRow(Items); - requestContact.requestContact->setModel(contactRequest); - Items->setData(QIcon(addnewAddrIcon),Qt::DecorationRole); - requestContact.requestContact->setIconSize(QSize(40,50)); - requestContact.requestContact->setUniformItemSizes(true); - requestContact.requestContact->show(); - requestContact.zaddrnew->setVisible(false); - requestContact.zaddrnew->setText(c.second.getRequestZaddr()); + requestContact.requestContact->setItem(i, 0, new QTableWidgetItem(c.second.getRequestZaddr())); + requestContact.requestContact->setItem(i, 1, new QTableWidgetItem(timestamphtml)); + requestContact.zaddrnew->setVisible(false); + requestContact.zaddrnew->setText(c.second.getRequestZaddr()); + requestContact.requestContact->sortByColumn(1, Qt::DescendingOrder); - - - } + i++; + + } - QStandardItemModel* contactRequestOld = new QStandardItemModel(); + QStandardItemModel* contactRequestOld = new QStandardItemModel(); - for (auto &c : DataStore::getChatDataStore()->getAllOldContactRequests()) + for (auto &c : DataStore::getChatDataStore()->getAllOldContactRequests()) { QStandardItem* Items = new QStandardItem(c.second.getContact()); contactRequestOld->appendRow(Items); requestContact.requestContactOld->setModel(contactRequestOld); requestContact.zaddrold->setVisible(false); requestContact.zaddrold->setText(c.second.getRequestZaddr()); - - + } - - QObject::connect(requestContact.requestContact, &QTableView::clicked, [&] () { for (auto &c : DataStore::getChatDataStore()->getAllRawChatItems()){ QModelIndex index = requestContact.requestContact->currentIndex(); QString label_contact = index.data(Qt::DisplayRole).toString(); QStandardItemModel* contactMemo = new QStandardItemModel(); - - - - if ((c.second.isOutgoing() == false) && (label_contact == c.second.getRequestZaddr() && (c.second.getMemo().startsWith("{") == false))) @@ -184,8 +189,6 @@ void MainWindow::renderContactRequest(){ }); - - QObject::connect(requestContact.requestContactOld, &QTableView::clicked, [&] () { for (auto &c : DataStore::getChatDataStore()->getAllRawChatItems()){ @@ -210,9 +213,7 @@ void MainWindow::renderContactRequest(){ }else{ } - } - - + } }); @@ -247,8 +248,6 @@ void MainWindow::renderContactRequest(){ ); return; } - - AddressBook::getInstance()->addAddressLabel(newLabel, addr, myAddr, cid, avatar); rpc->refreshContacts( ui->listContactWidget); diff --git a/src/requestContactDialog.ui b/src/requestContactDialog.ui index 76e904a..b41713c 100644 --- a/src/requestContactDialog.ui +++ b/src/requestContactDialog.ui @@ -6,7 +6,7 @@ 0 0 - 850 + 764 495 @@ -18,438 +18,562 @@ - 850 + 600 + 495 + + + + + 764 495 Incoming Contact Request - - - - - <html><head/><body><p><span style=" font-weight:600; text-decoration: underline;">Memo of the request</span></p></body></html> - - - - - - - - 500 - 231 - - - - Qt::ScrollBarAlwaysOff - - - Qt::ScrollBarAlwaysOff - - - QAbstractScrollArea::AdjustToContents - - - QAbstractItemView::NoEditTriggers - - - QListView::Adjust - - - 0 - - - false - - - true - - - - - - - <html><head/><body><p><span style=" font-weight:600; text-decoration: underline;">Open requests</span></p></body></html> - - - - - - - - 0 - 0 - - - - - 225 - 190 - - - - true - - - QAbstractItemView::EditKeyPressed|QAbstractItemView::SelectedClicked - - - false - - - QAbstractItemView::SingleSelection - - - - - - - - 351 - 25 - - - - - 351 - 25 - - - - - - - - - 0 - 0 - - - - Request from: - - - - - - - - 0 - 0 - - - - - 0 - 25 - - - - 25 - - - - - - - - - + + + + 360 + 10 + 151 + 17 + + + + <html><head/><body><p><span style=" font-weight:600; text-decoration: underline;">Memo of the request</span></p></body></html> + + + + + + 355 + 32 + 400 + 231 + + + + + 400 + 231 + + + + Qt::ScrollBarAlwaysOff + + + Qt::ScrollBarAlwaysOff + + + QAbstractScrollArea::AdjustToContents + + + QAbstractItemView::NoEditTriggers + + + QListView::Adjust + + + 0 + + + false + + + true + + + + + + 9 + 9 + 161 + 17 + + + + <html><head/><body><p><span style=" font-weight:600; text-decoration: underline;">Open requests from:</span></p></body></html> + + + + + + 9 + 294 + 162 + 192 + + + + + 0 + 0 + + + + + 150 + 190 + + + + true + + + QAbstractItemView::EditKeyPressed|QAbstractItemView::SelectedClicked + + + false + + + QAbstractItemView::SingleSelection + + + + + + 299 + 328 + 450 + 25 + + + + + 450 + 25 + + + + + 351 + 25 + + + + + + + 177 + 343 + 97 + 17 + + + + + 0 + 0 + + + + Request from: + + + + + + 299 + 399 + 142 + 25 + + + + + 0 + 0 + + + + + 0 + 25 + + + + 25 + + + + + + 480 + 461 + 16 + 17 + + + + + + + + + + 628 + 461 + 127 + 25 + + + + Add New Contact + + + false + + + + + + 417 + 461 + 16 + 17 + + + + + + + + + + 177 + 430 + 233 + 17 + + + + + 0 + 0 + + + + <html><head/><body><p>Choose an avatar for your contact:</p></body></html> + + + + + + 177 + 368 + 68 + 17 + + + + + 0 + 0 + + + + My Zaddr: + + + + + + 340 + 461 + 16 + 17 + + + + + + + + + + 542 + 461 + 80 + 25 + + + + + 0 + 0 + + + + + 100 + 0 + + + + Cancel + + + false + + + false + + + + + + 417 + 430 + 106 + 25 + + + + + 106 + 25 + + + + + 106 + 25 + + + + + SDLogo + + + + :/icons/res/SDLogo.png + + - - - - Add New Contact - - - false - - + + + Duke + + + + :/icons/res/Duke.png + + - - - - - - + + + Denio + + + + :/icons/res/Denio.png + + - - - - - 0 - 0 - - - - <html><head/><body><p>Choose an avatar for your contact:</p></body></html> - - + + + Berg + + + + :/icons/res/Berg.png + + - - - - - 0 - 0 - - - - My Zaddr: - - + + + Sharpee + + + + :/icons/res/Sharpee.png + + - - - - - - + + + Elsa + + + + :/icons/res/Elsa.png + + - - - - - 0 - 0 - - - - - 100 - 0 - - - - Cancel - - - false - - - false - - + + + Yoda + + + + :/icons/res/Yoda.png + + - - - - - 106 - 25 - - - - - 106 - 25 - - - - - SDLogo - - - - :/icons/res/SDLogo.png - - - - - - Duke - - - - :/icons/res/Duke.png - - - - - - Denio - - - - :/icons/res/Denio.png - - - - - - Berg - - - - :/icons/res/Berg.png - - - - - - Sharpee - - - - :/icons/res/Sharpee.png - - - - - - Elsa - - - - :/icons/res/Elsa.png - - - - - - Yoda - - - - :/icons/res/Yoda.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 - - - - - - Stag - - - - :/icons/res/Stag.png - - - - + + + Garfield + + + + :/icons/res/Garfield.png + + - - - - - 225 - 231 - - - - true - - - QAbstractItemView::EditKeyPressed|QAbstractItemView::SelectedClicked - - - false - - - QAbstractItemView::SingleSelection - - + + + Snoopy + + + + :/icons/res/Snoopy.png + + - - - - <html><head/><body><p><span style=" font-weight:600; text-decoration: underline;">Recently closed requests</span></p></body></html> - - + + + Popey + + + + :/icons/res/Popey.png + + - - - - - 0 - 0 - - - - <html><head/><body><p><span style=" font-weight:600; text-decoration: underline;">Details of the request</span></p></body></html> - - + + + Pinguin + + + + :/icons/res/Pinguin.png + + - - - - - 0 - 0 - - - - Give a Nickname: - - + + + Mickey + + + + :/icons/res/Mickey.png + + - - - - - 351 - 25 - - - - - 351 - 25 - - - + + + Stag + + + + :/icons/res/Stag.png + + - + + + + + 9 + 271 + 179 + 17 + + + + <html><head/><body><p><span style=" font-weight:600; text-decoration: underline;">Recently closed requests</span></p></body></html> + + + + + + 177 + 294 + 157 + 17 + + + + + 0 + 0 + + + + <html><head/><body><p><span style=" font-weight:600; text-decoration: underline;">Details of the request</span></p></body></html> + + + + + + 177 + 399 + 116 + 17 + + + + + 0 + 0 + + + + Give a Nickname: + + + + + + 299 + 368 + 450 + 25 + + + + + 450 + 25 + + + + + 351 + 25 + + + + + + + 9 + 32 + 321 + 231 + + + + + 150 + 231 + + + + true + + + QAbstractItemView::EditKeyPressed|QAbstractItemView::SelectedClicked + + + false + + + QAbstractItemView::SingleSelection + + From f0e5d2334ea97673fa685eef509fadfb397a7652 Mon Sep 17 00:00:00 2001 From: DenioD <41270280+DenioD@users.noreply.github.com> Date: Thu, 10 Sep 2020 21:29:32 +0200 Subject: [PATCH 2/5] simplified dust memo creation #192 --- src/controller.cpp | 53 ++++++++++------------------------------------ src/controller.h | 3 +-- 2 files changed, 12 insertions(+), 44 deletions(-) diff --git a/src/controller.cpp b/src/controller.cpp index 5e9f9c3..9500e81 100644 --- a/src/controller.cpp +++ b/src/controller.cpp @@ -108,22 +108,6 @@ void Controller::setConnection(Connection* c) ui->listChat->verticalScrollBar()->maximum()); } -std::string Controller::encryptDecrypt(std::string toEncrypt) -{ - - int radomInteger = rand() % 1000000000 +100000; - - - char key = radomInteger; - std::string output = toEncrypt; - - for (int i = 0; i < toEncrypt.size(); i++) - output[i] = toEncrypt[i] ^ key; - - return output; - -} - // Build the RPC JSON Parameters for this tx void Controller::fillTxJsonParams(json& allRecepients, Tx tx) { @@ -153,43 +137,28 @@ void Controller::fillTxJsonParams(json& allRecepients, Tx tx) } DataStore::getSietchDataStore()->clear(); // clears the datastore + + const QString possibleCharacters("0123456789abcdef"); + int sizerandomString = 512; + const int randomStringLength = sizerandomString; + + for(uint8_t i = 0; i < 8; i++) + { - const QString possibleCharacters("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"); + QString randomString; - int sizerandomString = rand() % 120 +10; - const int randomStringLength = sizerandomString; + QRandomGenerator *gen = QRandomGenerator::system(); - QString randomString; - QRandomGenerator *gen = QRandomGenerator::system(); for(int i=0; ibounded(0, possibleCharacters.length() - 1); QChar nextChar = possibleCharacters.at(index); randomString.append(nextChar); } - - for(uint8_t i = 0; i < 8; i++) - { - int length = randomString.length(); - int randomSize = rand() % 120 +10; - char *randomHash = NULL; - randomHash = new char[length+1]; - strncpy(randomHash, randomString.toLocal8Bit(), length +1); - #define MESSAGE ((const unsigned char *) randomHash) - #define MESSAGE_LEN length - #define MESSAGE_LEN1 length + randomSize - - unsigned char hash[crypto_secretstream_xchacha20poly1305_ABYTES]; - crypto_generichash(hash, sizeof hash, - MESSAGE, MESSAGE_LEN1, - NULL, 0); + dust.at(i)["memo"] = randomString.toStdString(); - std::string decryptedMemo(reinterpret_cast(hash),MESSAGE_LEN1); - std::string encrypt = this->encryptDecrypt(decryptedMemo); - QString randomHashafter1 = QByteArray(reinterpret_cast(encrypt.c_str()),encrypt.size()).toHex(); - dust.at(i)["memo"] = randomHashafter1.toStdString(); } for(auto &it: dust) diff --git a/src/controller.h b/src/controller.h index bbf3cc7..a3333c2 100644 --- a/src/controller.h +++ b/src/controller.h @@ -45,8 +45,7 @@ public: int getLag(); void setLag(int lag); int _lag; - std::string encryptDecrypt(std::string); - + void checkForUpdate(bool silent = true); void refreshZECPrice(); void refreshEURPrice(); From 06b2e469bd5b195a085fcd314bfabc6c5a90d7f1 Mon Sep 17 00:00:00 2001 From: DenioD <41270280+DenioD@users.noreply.github.com> Date: Sun, 13 Sep 2020 09:48:10 +0200 Subject: [PATCH 3/5] fix background Actionmenu --- src/mainwindow.cpp | 22 +++++++++------------- src/mainwindow.h | 1 + 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 79da896..d9f2402 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1334,12 +1334,13 @@ void MainWindow::setupTransactionsTab() { }); // Set up context menu on transactions tab + ui->listChat->setContextMenuPolicy(Qt::ActionsContextMenu); + contextMenuChat->setObjectName("contextMenuChat"); + QString style = "QMenu{background-color: rgb(0, 0, 255);}"; 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"); - } - if (theme == "Default") {ui->listChat->setStyleSheet("background-image: url(:/icons/res/sdlogo2.png) ;background-attachment: fixed ;background-position: center center ;background-repeat: no-repeat");} - + ui->listChat->setStyleSheet("QListView{background-image: url(:/icons/res/SDLogo.png) ;background-position: center center ;background-repeat: no-repeat;} QMenu::item:selected { border-color: darkblue; background: rgba(100, 100, 100, 150);}");} + if (theme == "Default") {ui->listChat->setStyleSheet("QListView{background-image: url(:/icons/res/sdlogo2.png) ;background-attachment: fixed ;background-position: center center ;background-repeat: no-repeat;} QMenu::item:selected { border-color: darkblue; background: rgba(100, 100, 100, 150);}");} ui->listChat->setResizeMode(QListView::Adjust); ui->listChat->setWordWrap(true); ui->listChat->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); @@ -1495,17 +1496,14 @@ void MainWindow::setupchatTab() { ui->contactNameMemo->setText(""); - /////Copy Chatmessages + /////Setup Actions - QMenu* contextMenuChat; - QAction* copymessage; - + QAction* copymessage; QAction* viewexplorer; QAction* copytxid; QAction* copylink; QAction* openlink; - contextMenuChat = new QMenu(ui->listChat); - ui->listChat->setContextMenuPolicy(Qt::ActionsContextMenu); + copymessage = new QAction("Copy message to clipboard",contextMenuChat); viewexplorer = new QAction("View on block explorer",contextMenuChat); copytxid = new QAction("Copy txid to clipboard ",contextMenuChat); @@ -1514,14 +1512,12 @@ void MainWindow::setupchatTab() { QObject::connect(ui->listContactWidget, &QTableView::clicked, [=] () { - - - //contextMenuChat->autoFillBackground(false); ui->listChat->addAction(copymessage); ui->listChat->addAction(viewexplorer); ui->listChat->addAction(copytxid); ui->listChat->addAction(copylink); ui->listChat->addAction(openlink); + }); diff --git a/src/mainwindow.h b/src/mainwindow.h index 09edc6e..e592c18 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -139,6 +139,7 @@ private: void setupStatusBar(); void clearSendForm(); + QMenu* contextMenuChat = new QMenu(); Tx createTxFromSendPage(); From 1b26930e75dac6126a78deb1977fae26711cb6a6 Mon Sep 17 00:00:00 2001 From: DenioD <41270280+DenioD@users.noreply.github.com> Date: Sun, 13 Sep 2020 10:05:30 +0200 Subject: [PATCH 4/5] update lib, new checkpoints --- lib/Cargo.lock | 6 +++--- lib/Cargo.toml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/Cargo.lock b/lib/Cargo.lock index 1ecce55..7a5dc66 100644 --- a/lib/Cargo.lock +++ b/lib/Cargo.lock @@ -1192,7 +1192,7 @@ dependencies = [ "blake3 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "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=7c65e566c44268954654d9ff3e1c26b1e1d16167)", + "silentdragonlitelib 0.1.0 (git+https://github.com/MyHush/silentdragonlite-cli?rev=1d678e4280975a532cdff58f55b2b129c033c9f8)", ] [[package]] @@ -1655,7 +1655,7 @@ dependencies = [ [[package]] name = "silentdragonlitelib" version = "0.1.0" -source = "git+https://github.com/MyHush/silentdragonlite-cli?rev=7c65e566c44268954654d9ff3e1c26b1e1d16167#7c65e566c44268954654d9ff3e1c26b1e1d16167" +source = "git+https://github.com/MyHush/silentdragonlite-cli?rev=1d678e4280975a532cdff58f55b2b129c033c9f8#1d678e4280975a532cdff58f55b2b129c033c9f8" 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)", @@ -2671,7 +2671,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=7c65e566c44268954654d9ff3e1c26b1e1d16167)" = "" +"checksum silentdragonlitelib 0.1.0 (git+https://github.com/MyHush/silentdragonlite-cli?rev=1d678e4280975a532cdff58f55b2b129c033c9f8)" = "" "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 cd7e67b..2bd1c32 100644 --- a/lib/Cargo.toml +++ b/lib/Cargo.toml @@ -12,4 +12,4 @@ crate-type = ["staticlib"] libc = "0.2.58" lazy_static = "1.4.0" blake3 = "0.3.4" -silentdragonlitelib = { git = "https://github.com/MyHush/silentdragonlite-cli", rev = "7c65e566c44268954654d9ff3e1c26b1e1d16167" } +silentdragonlitelib = { git = "https://github.com/MyHush/silentdragonlite-cli", rev = "1d678e4280975a532cdff58f55b2b129c033c9f8" } From 45765bb0ab1eec443d434f07536002aeac25e875 Mon Sep 17 00:00:00 2001 From: DenioD <41270280+DenioD@users.noreply.github.com> Date: Sun, 13 Sep 2020 10:06:05 +0200 Subject: [PATCH 5/5] push version to 1.4.0 --- src/version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/version.h b/src/version.h index c8d8c95..d9bca91 100644 --- a/src/version.h +++ b/src/version.h @@ -1 +1 @@ -#define APP_VERSION "1.3.9" +#define APP_VERSION "1.4.0"