Add migration option on balances table context menu

This commit is contained in:
Aditya Kulkarni
2018-10-29 14:16:07 -07:00
parent a599dec6d8
commit 2fe2b44696
2 changed files with 13 additions and 4 deletions

View File

@@ -137,7 +137,7 @@ void MainWindow::turnstileProgress() {
} }
} }
void MainWindow::turnstileDoMigration() { void MainWindow::turnstileDoMigration(QString fromAddr) {
// Return if there is no connection // Return if there is no connection
if (rpc->getAllZAddresses() == nullptr) if (rpc->getAllZAddresses() == nullptr)
return; return;
@@ -166,8 +166,7 @@ void MainWindow::turnstileDoMigration() {
if (Settings::getInstance()->isSaplingAddress(addr)) { if (Settings::getInstance()->isSaplingAddress(addr)) {
turnstile.migrateTo->addItem(addr); turnstile.migrateTo->addItem(addr);
} else { } else {
if (rpc->getAllBalances()->value(addr) > 0) turnstile.migrateZaddList->addItem(addr);
turnstile.migrateZaddList->addItem(addr);
} }
} }
@@ -194,8 +193,12 @@ void MainWindow::turnstileDoMigration() {
} }
}; };
if (!fromAddr.isEmpty())
turnstile.migrateZaddList->setCurrentText(fromAddr);
fnUpdateSproutBalance(turnstile.migrateZaddList->currentText()); fnUpdateSproutBalance(turnstile.migrateZaddList->currentText());
// Combo box selection event // Combo box selection event
QObject::connect(turnstile.migrateZaddList, &QComboBox::currentTextChanged, fnUpdateSproutBalance); QObject::connect(turnstile.migrateZaddList, &QComboBox::currentTextChanged, fnUpdateSproutBalance);
@@ -447,6 +450,12 @@ void MainWindow::setupBalancesTab() {
}); });
} }
if (Settings::getInstance()->isSproutAddress(addr)) {
menu.addAction("Migrate to Sapling", [=] () {
this->turnstileDoMigration(addr);
});
}
menu.exec(ui->balancesTable->viewport()->mapToGlobal(pos)); menu.exec(ui->balancesTable->viewport()->mapToGlobal(pos));
}); });
} }

View File

@@ -58,7 +58,7 @@ private:
Tx createTxFromSendPage(); Tx createTxFromSendPage();
bool confirmTx(Tx tx, ToFields devFee); bool confirmTx(Tx tx, ToFields devFee);
void turnstileDoMigration(); void turnstileDoMigration(QString fromAddr = "");
void turnstileProgress(); void turnstileProgress();
void cancelButton(); void cancelButton();