diff --git a/lib/Cargo.lock b/lib/Cargo.lock index 1b4b61b..f01b494 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)", - "silentdragonlitelib 0.1.0 (git+https://github.com/DenioD/silentdragonlite-cli?rev=127b8533cd3b20f454853f9da372215a72d469e7)", + "silentdragonlitelib 0.1.0 (git+https://github.com/DenioD/silentdragonlite-cli?rev=0b09f20990195a2a44bce871cd0bb293eaf38b33)", ] [[package]] @@ -1467,7 +1467,7 @@ dependencies = [ [[package]] name = "silentdragonlitelib" version = "0.1.0" -source = "git+https://github.com/DenioD/silentdragonlite-cli?rev=127b8533cd3b20f454853f9da372215a72d469e7#127b8533cd3b20f454853f9da372215a72d469e7" +source = "git+https://github.com/DenioD/silentdragonlite-cli?rev=0b09f20990195a2a44bce871cd0bb293eaf38b33#0b09f20990195a2a44bce871cd0bb293eaf38b33" dependencies = [ "base58 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "bellman 0.1.0 (git+https://github.com/DenioD/librustzcash.git?rev=caaee693c47c2ee9ecd1e1546b8fe3c714f342bc)", @@ -2481,7 +2481,7 @@ dependencies = [ "checksum serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)" = "2f72eb2a68a7dc3f9a691bfda9305a1c017a6215e5a4545c258500d2099a37c2" "checksum serde_yaml 0.8.11 (registry+https://github.com/rust-lang/crates.io-index)" = "691b17f19fc1ec9d94ec0b5864859290dff279dbd7b03f017afda54eb36c3c35" "checksum sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b4d8bfd0e469f417657573d8451fb33d16cfe0989359b93baf3a1ffc639543d" -"checksum silentdragonlitelib 0.1.0 (git+https://github.com/DenioD/silentdragonlite-cli?rev=127b8533cd3b20f454853f9da372215a72d469e7)" = "" +"checksum silentdragonlitelib 0.1.0 (git+https://github.com/DenioD/silentdragonlite-cli?rev=0b09f20990195a2a44bce871cd0bb293eaf38b33)" = "" "checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" "checksum smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "ab606a9c5e214920bb66c458cd7be8ef094f813f20fe77a54cc7dbfff220d4b7" "checksum sodiumoxide 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "585232e78a4fc18133eef9946d3080befdf68b906c51b621531c37e91787fa2b" diff --git a/lib/Cargo.toml b/lib/Cargo.toml index 4b79775..ecfda16 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" -silentdragonlitelib = { git = "https://github.com/DenioD/silentdragonlite-cli", rev = "127b8533cd3b20f454853f9da372215a72d469e7" } +silentdragonlitelib = { git = "https://github.com/DenioD/silentdragonlite-cli", rev = "0b09f20990195a2a44bce871cd0bb293eaf38b33" } diff --git a/src/controller.cpp b/src/controller.cpp index 1c94ead..df4ca23 100644 --- a/src/controller.cpp +++ b/src/controller.cpp @@ -144,8 +144,6 @@ void Controller::getInfoThenRefresh(bool force) { static bool prevCallSucceeded = false; zrpc->fetchInfo([=] (const json& reply) { - qDebug() << "Info updated"; - prevCallSucceeded = true; // Testnet? @@ -159,11 +157,13 @@ void Controller::getInfoThenRefresh(bool force) { if (!Settings::getInstance()->isTestnet()) main->disableRecurring(); - static int lastBlock = 0; int curBlock = reply["latest_block_height"].get(); + bool doUpdate = force || (model->getLatestBlock() != curBlock); model->setLatestBlock(curBlock); ui->blockHeight->setText(QString::number(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"); @@ -185,10 +185,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(); @@ -347,6 +345,16 @@ void Controller::refreshTransactions() { CAmount total_amount; QList items; + 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(); + // First, check if there's outgoing metadata if (!it["outgoing_metadata"].is_null()) { @@ -375,12 +383,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 @@ -400,12 +403,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); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index c037218..32a1033 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -179,13 +179,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() { @@ -196,8 +202,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 618e8fe..d346b3c 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 diff --git a/src/sendtab.cpp b/src/sendtab.cpp index 9db07e5..7da1f79 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 (hush) @@ -646,11 +643,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 @@ -661,6 +683,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;