From 5915f254c487d16deb22bc99968be39859268f7e Mon Sep 17 00:00:00 2001 From: Aditya Kulkarni Date: Sun, 27 Oct 2019 12:29:24 -0700 Subject: [PATCH 1/4] Refresh logic --- src/controller.cpp | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/src/controller.cpp b/src/controller.cpp index f43fe4d..7eb4282 100644 --- a/src/controller.cpp +++ b/src/controller.cpp @@ -137,15 +137,13 @@ void Controller::refresh(bool force) { getInfoThenRefresh(force); } -void Controller::getInfoThenRefresh(bool force) { +void Controller::getInfoThenRefresh(bool doUpdate) { if (!zrpc->haveConnection()) return noConnection(); static bool prevCallSucceeded = false; zrpc->fetchInfo([=] (const json& reply) { - qDebug() << "Info updated"; - prevCallSucceeded = true; // Testnet? @@ -159,10 +157,12 @@ void Controller::getInfoThenRefresh(bool force) { if (!Settings::getInstance()->isTestnet()) main->disableRecurring(); - static int lastBlock = 0; int curBlock = reply["latest_block_height"].get(); + bool doUpdate = doUpdate || (model->getLatestBlock() != curBlock); model->setLatestBlock(curBlock); + qDebug() << "Refreshing. Full update: " << doUpdate; + // Connected, so display checkmark. auto tooltip = Settings::getInstance()->getSettings().server + "\n" + QString::fromStdString(reply.dump()); QIcon i(":/icons/res/connected.gif"); @@ -178,10 +178,8 @@ void Controller::getInfoThenRefresh(bool force) { // See if recurring payments needs anything Recurring::getInstance()->processPending(main); - if ( force || (curBlock != lastBlock) ) { + if ( doUpdate ) { // Something changed, so refresh everything. - lastBlock = curBlock; - refreshBalances(); refreshAddresses(); // This calls refreshZSentTransactions() and refreshReceivedZTrans() refreshTransactions(); @@ -340,6 +338,10 @@ void Controller::refreshTransactions() { CAmount total_amount; QList items; + auto confirmations = model->getLatestBlock() - it["block_height"].get() + 1; + auto txid = QString::fromStdString(it["txid"]); + auto datetime = it["datetime"].get(); + // First, check if there's outgoing metadata if (!it["outgoing_metadata"].is_null()) { @@ -365,12 +367,7 @@ void Controller::refreshTransactions() { } txdata.push_back(TransactionItem{ - "Sent", - it["datetime"].get(), - address, - QString::fromStdString(it["txid"]), - model->getLatestBlock() - it["block_height"].get(), - items + "Sent", datetime, address, txid,confirmations, items }); } else { // Incoming Transaction @@ -389,12 +386,7 @@ void Controller::refreshTransactions() { }); TransactionItem tx{ - "Receive", - it["datetime"].get(), - address, - QString::fromStdString(it["txid"]), - model->getLatestBlock() - it["block_height"].get() + 1, - items + "Receive", datetime, address, txid,confirmations, items }; txdata.push_back(tx); From 73c6773e4990ad54de2d5b2308d6d723a865fad1 Mon Sep 17 00:00:00 2001 From: Aditya Kulkarni Date: Sun, 27 Oct 2019 12:33:12 -0700 Subject: [PATCH 2/4] Fix update force logic --- src/controller.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/controller.cpp b/src/controller.cpp index 7eb4282..aab6eec 100644 --- a/src/controller.cpp +++ b/src/controller.cpp @@ -137,7 +137,7 @@ void Controller::refresh(bool force) { getInfoThenRefresh(force); } -void Controller::getInfoThenRefresh(bool doUpdate) { +void Controller::getInfoThenRefresh(bool force) { if (!zrpc->haveConnection()) return noConnection(); @@ -158,7 +158,7 @@ void Controller::getInfoThenRefresh(bool doUpdate) { main->disableRecurring(); int curBlock = reply["latest_block_height"].get(); - bool doUpdate = doUpdate || (model->getLatestBlock() != curBlock); + bool doUpdate = force || (model->getLatestBlock() != curBlock); model->setLatestBlock(curBlock); qDebug() << "Refreshing. Full update: " << doUpdate; From 13953f2dd5961d0f008611ad7c15d18a4ffcec2d Mon Sep 17 00:00:00 2001 From: Aditya Kulkarni Date: Sun, 27 Oct 2019 21:17:34 -0700 Subject: [PATCH 3/4] Add post-confirmation screen --- lib/Cargo.lock | 6 +++--- lib/Cargo.toml | 2 +- src/controller.cpp | 8 +++++++- src/sendtab.cpp | 33 ++++++++++++++++++++++++++++++--- 4 files changed, 41 insertions(+), 8 deletions(-) diff --git a/lib/Cargo.lock b/lib/Cargo.lock index 2082d37..f885015 100644 --- a/lib/Cargo.lock +++ b/lib/Cargo.lock @@ -1051,7 +1051,7 @@ version = "0.1.0" dependencies = [ "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", - "zecwalletlitelib 0.1.0 (git+https://github.com/adityapk00/zecwallet-light-cli?rev=865a72442db4ee1862fa776514da4a4a1c935b94)", + "zecwalletlitelib 0.1.0 (git+https://github.com/adityapk00/zecwallet-light-cli?rev=01cd0269d558f8755ddc720dc26b81767a773cde)", ] [[package]] @@ -2266,7 +2266,7 @@ dependencies = [ [[package]] name = "zecwalletlitelib" version = "0.1.0" -source = "git+https://github.com/adityapk00/zecwallet-light-cli?rev=865a72442db4ee1862fa776514da4a4a1c935b94#865a72442db4ee1862fa776514da4a4a1c935b94" +source = "git+https://github.com/adityapk00/zecwallet-light-cli?rev=01cd0269d558f8755ddc720dc26b81767a773cde#01cd0269d558f8755ddc720dc26b81767a773cde" dependencies = [ "base58 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "bellman 0.1.0 (git+https://github.com/adityapk00/librustzcash.git?rev=188537ea025fcb7fbdfc11266f307a084a5451e4)", @@ -2562,4 +2562,4 @@ dependencies = [ "checksum zcash_client_backend 0.0.0 (git+https://github.com/adityapk00/librustzcash.git?rev=188537ea025fcb7fbdfc11266f307a084a5451e4)" = "" "checksum zcash_primitives 0.0.0 (git+https://github.com/adityapk00/librustzcash.git?rev=188537ea025fcb7fbdfc11266f307a084a5451e4)" = "" "checksum zcash_proofs 0.0.0 (git+https://github.com/adityapk00/librustzcash.git?rev=188537ea025fcb7fbdfc11266f307a084a5451e4)" = "" -"checksum zecwalletlitelib 0.1.0 (git+https://github.com/adityapk00/zecwallet-light-cli?rev=865a72442db4ee1862fa776514da4a4a1c935b94)" = "" +"checksum zecwalletlitelib 0.1.0 (git+https://github.com/adityapk00/zecwallet-light-cli?rev=01cd0269d558f8755ddc720dc26b81767a773cde)" = "" diff --git a/lib/Cargo.toml b/lib/Cargo.toml index 6ebdb8e..b205001 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" -zecwalletlitelib = { git = "https://github.com/adityapk00/zecwallet-light-cli", rev = "865a72442db4ee1862fa776514da4a4a1c935b94" } +zecwalletlitelib = { git = "https://github.com/adityapk00/zecwallet-light-cli", rev = "01cd0269d558f8755ddc720dc26b81767a773cde" } diff --git a/src/controller.cpp b/src/controller.cpp index aab6eec..a763e50 100644 --- a/src/controller.cpp +++ b/src/controller.cpp @@ -338,7 +338,13 @@ void Controller::refreshTransactions() { CAmount total_amount; QList items; - auto confirmations = model->getLatestBlock() - it["block_height"].get() + 1; + long confirmations; + if (it.find("unconfirmed") != it.end() && it["unconfirmed"].get()) { + confirmations = 0; + } else { + confirmations = model->getLatestBlock() - it["block_height"].get() + 1; + } + auto txid = QString::fromStdString(it["txid"]); auto datetime = it["datetime"].get(); diff --git a/src/sendtab.cpp b/src/sendtab.cpp index 9c6171a..a3196c4 100644 --- a/src/sendtab.cpp +++ b/src/sendtab.cpp @@ -489,8 +489,6 @@ bool MainWindow::confirmTx(Tx tx, RecurringPaymentInfo* rpi) { confirm.setupUi(&d); Settings::saveRestore(&d); - const QFont fixedFont = QFontDatabase::systemFont(QFontDatabase::FixedFont); - // Remove all existing address/amt qlabels on the confirm dialog. int totalConfirmAddrItems = confirm.sendToAddrs->children().size(); for (int i = 0; i < totalConfirmAddrItems / 3; i++) { @@ -526,7 +524,6 @@ bool MainWindow::confirmTx(Tx tx, RecurringPaymentInfo* rpi) { Addr->setObjectName(QString("Addr") % QString::number(i + 1)); Addr->setWordWrap(true); Addr->setText(fnSplitAddressForWrap(toAddr.addr)); - Addr->setFont(fixedFont); confirm.gridLayout->addWidget(Addr, row, 0, 1, 1); // Amount (ZEC) @@ -644,11 +641,36 @@ void MainWindow::sendButton() { // Then delete the additional fields from the sendTo tab clearSendForm(); + // Create a new Dialog to show that we are computing/sending the Tx + auto d = new QDialog(this); + auto connD = new Ui_ConnectionDialog(); + connD->setupUi(d); + QPixmap logo(":/img/res/logobig.gif"); + connD->topIcon->setBasePixmap(logo.scaled(256, 256, Qt::KeepAspectRatio, Qt::SmoothTransformation)); + + connD->status->setText(tr("Please wait...")); + connD->statusDetail->setText(tr("Computing your transaction")); + + d->show(); + // And send the Tx rpc->executeTransaction(tx, [=] (QString txid) { ui->statusBar->showMessage(Settings::txidStatusMessage + " " + txid); + connD->status->setText(tr("Done!")); + connD->statusDetail->setText(txid); + + QTimer::singleShot(1000, [=]() { + d->accept(); + d->close(); + delete connD; + delete d; + }); + + // Force a UI update so we get the unconfirmed Tx + rpc->refresh(true); + // If this was a recurring payment, update the payment with the info if (!recurringPaymentHash.isEmpty()) { // Since this is the send button payment, this is the first payment @@ -659,6 +681,11 @@ void MainWindow::sendButton() { // Errored out [=] (QString opid, QString errStr) { ui->statusBar->showMessage(QObject::tr(" Tx ") % opid % QObject::tr(" failed"), 15 * 1000); + + d->accept(); + d->close(); + delete connD; + delete d; if (!opid.isEmpty()) errStr = QObject::tr("The transaction with id ") % opid % QObject::tr(" failed. The error was") + ":\n\n" + errStr; From eb2309b30fd50f79bec8d7be19644ce83292d302 Mon Sep 17 00:00:00 2001 From: Aditya Kulkarni Date: Sun, 27 Oct 2019 21:33:38 -0700 Subject: [PATCH 4/4] Default table widths --- src/mainwindow.cpp | 22 ++++++++++++++-------- src/mainwindow.ui | 11 +++++++---- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index fa7e50c..7bb370b 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -175,13 +175,19 @@ void MainWindow::restoreSavedStates() { QSettings s; restoreGeometry(s.value("geometry").toByteArray()); - ui->balancesTable->horizontalHeader()->restoreState(s.value("baltablegeometry").toByteArray()); - ui->transactionsTable->horizontalHeader()->restoreState(s.value("tratablegeometry").toByteArray()); + auto balance_geom = s.value("baltablegeom"); + if (balance_geom == QVariant()) { + ui->balancesTable->setColumnWidth(0, 500); + } else { + ui->balancesTable->horizontalHeader()->restoreState(balance_geom.toByteArray()); + } - // Explicitly set the tx table resize headers, since some previous values may have made them - // non-expandable. - ui->transactionsTable->horizontalHeader()->setSectionResizeMode(3, QHeaderView::Interactive); - ui->transactionsTable->horizontalHeader()->setSectionResizeMode(4, QHeaderView::Interactive); + auto tx_geom = s.value("tratablegeom"); + if (tx_geom == QVariant()) { + ui->transactionsTable->setColumnWidth(1, 500); + } else { + ui->transactionsTable->horizontalHeader()->restoreState(tx_geom.toByteArray()); + } } void MainWindow::doClose() { @@ -192,8 +198,8 @@ void MainWindow::closeEvent(QCloseEvent* event) { QSettings s; s.setValue("geometry", saveGeometry()); - s.setValue("baltablegeometry", ui->balancesTable->horizontalHeader()->saveState()); - s.setValue("tratablegeometry", ui->transactionsTable->horizontalHeader()->saveState()); + s.setValue("baltablegeom", ui->balancesTable->horizontalHeader()->saveState()); + s.setValue("tratablegeom", ui->transactionsTable->horizontalHeader()->saveState()); s.sync(); diff --git a/src/mainwindow.ui b/src/mainwindow.ui index b44dce6..5a9ac48 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -22,7 +22,7 @@ - 1 + 3 @@ -392,8 +392,8 @@ 0 0 - 1226 - 504 + 1162 + 344 @@ -932,6 +932,9 @@ QAbstractItemView::SelectRows + + true + @@ -1085,7 +1088,7 @@ 0 0 1274 - 22 + 39