merge and updates
This commit is contained in:
@@ -259,11 +259,6 @@ void MainWindow::setupSettingsModal() {
|
||||
settings.setupUi(&settingsDialog);
|
||||
Settings::saveRestore(&settingsDialog);
|
||||
|
||||
// Setup save sent check box
|
||||
QObject::connect(settings.chkSaveTxs, &QCheckBox::stateChanged, [=](auto checked) {
|
||||
Settings::getInstance()->setSaveZtxs(checked);
|
||||
});
|
||||
|
||||
// Setup theme combo
|
||||
int theme_index = settings.comboBoxTheme->findText(Settings::getInstance()->get_theme_name(), Qt::MatchExactly);
|
||||
settings.comboBoxTheme->setCurrentIndex(theme_index);
|
||||
@@ -274,55 +269,15 @@ void MainWindow::setupSettingsModal() {
|
||||
QMessageBox::information(this, tr("Restart"), tr("Please restart Silentdragonlite to have the theme apply"), QMessageBox::Ok);
|
||||
});
|
||||
|
||||
// Save sent transactions
|
||||
settings.chkSaveTxs->setChecked(Settings::getInstance()->getSaveZtxs());
|
||||
|
||||
// Custom fees
|
||||
settings.chkCustomFees->setChecked(Settings::getInstance()->getAllowCustomFees());
|
||||
|
||||
// Auto shielding
|
||||
settings.chkAutoShield->setChecked(Settings::getInstance()->getAutoShield());
|
||||
|
||||
// Check for updates
|
||||
settings.chkCheckUpdates->setChecked(Settings::getInstance()->getCheckForUpdates());
|
||||
|
||||
// Fetch prices
|
||||
settings.chkFetchPrices->setChecked(Settings::getInstance()->getAllowFetchPrices());
|
||||
|
||||
// Use Tor
|
||||
bool isUsingTor = false;
|
||||
if (rpc->getConnection() != nullptr) {
|
||||
isUsingTor = !rpc->getConnection()->config->proxy.isEmpty();
|
||||
}
|
||||
settings.chkTor->setChecked(isUsingTor);
|
||||
|
||||
// Connection Settings
|
||||
QIntValidator validator(0, 65535);
|
||||
settings.port->setValidator(&validator);
|
||||
|
||||
// If values are coming from hush.conf, then disable all the fields
|
||||
auto hushConfLocation = Settings::getInstance()->gethushdConfLocation();
|
||||
if (!hushConfLocation.isEmpty()) {
|
||||
settings.confMsg->setText("Settings are being read from \n" + hushConfLocation);
|
||||
settings.hostname->setEnabled(false);
|
||||
settings.port->setEnabled(false);
|
||||
settings.rpcuser->setEnabled(false);
|
||||
settings.rpcpassword->setEnabled(false);
|
||||
}
|
||||
else {
|
||||
settings.confMsg->setText("No local HUSH3.conf found. Please configure connection manually.");
|
||||
settings.hostname->setEnabled(true);
|
||||
settings.port->setEnabled(true);
|
||||
settings.rpcuser->setEnabled(true);
|
||||
settings.rpcpassword->setEnabled(true);
|
||||
}
|
||||
|
||||
// Load current values into the dialog
|
||||
auto conf = Settings::getInstance()->getSettings();
|
||||
settings.hostname->setText(conf.host);
|
||||
settings.port->setText(conf.port);
|
||||
settings.rpcuser->setText(conf.rpcuser);
|
||||
settings.rpcpassword->setText(conf.rpcpassword);
|
||||
settings.txtServer->setText(conf.server);
|
||||
|
||||
// Connection tab by default
|
||||
settings.tabWidget->setCurrentIndex(0);
|
||||
@@ -330,79 +285,26 @@ void MainWindow::setupSettingsModal() {
|
||||
// Enable the troubleshooting options only if using embedded hushd
|
||||
if (!rpc->isEmbedded()) {
|
||||
settings.chkRescan->setEnabled(false);
|
||||
settings.chkRescan->setToolTip(tr("You're using an external hushd. Please restart hushd with -rescan"));
|
||||
|
||||
settings.chkReindex->setEnabled(false);
|
||||
settings.chkReindex->setToolTip(tr("You're using an external hushd. Please restart hushd with -reindex"));
|
||||
settings.chkRescan->setToolTip(tr("You're using an external hushd. Please restart zcashd with -rescan"));
|
||||
}
|
||||
|
||||
if (settingsDialog.exec() == QDialog::Accepted) {
|
||||
// Custom fees
|
||||
bool customFees = settings.chkCustomFees->isChecked();
|
||||
Settings::getInstance()->setAllowCustomFees(customFees);
|
||||
ui->minerFeeAmt->setReadOnly(!customFees);
|
||||
if (!customFees)
|
||||
ui->minerFeeAmt->setText(Settings::getDecimalString(Settings::getMinerFee()));
|
||||
|
||||
// Auto shield
|
||||
Settings::getInstance()->setAutoShield(settings.chkAutoShield->isChecked());
|
||||
|
||||
// Check for updates
|
||||
Settings::getInstance()->setCheckForUpdates(settings.chkCheckUpdates->isChecked());
|
||||
|
||||
// Allow fetching prices
|
||||
Settings::getInstance()->setAllowFetchPrices(settings.chkFetchPrices->isChecked());
|
||||
|
||||
if (!isUsingTor && settings.chkTor->isChecked()) {
|
||||
// If "use tor" was previously unchecked and now checked
|
||||
Settings::addTohushConf(hushConfLocation, "proxy=127.0.0.1:9050");
|
||||
rpc->getConnection()->config->proxy = "proxy=127.0.0.1:9050";
|
||||
// Save the server
|
||||
Settings::getInstance()->saveSettings(settings.txtServer->text().trimmed());
|
||||
|
||||
QMessageBox::information(this, tr("Enable Tor"),
|
||||
tr("Connection over Tor has been enabled. To use this feature, you need to restart Silentdragonlite."),
|
||||
QMessageBox::Ok);
|
||||
}
|
||||
|
||||
if (isUsingTor && !settings.chkTor->isChecked()) {
|
||||
// If "use tor" was previously checked and now is unchecked
|
||||
Settings::removeFromhushConf(hushConfLocation, "proxy");
|
||||
rpc->getConnection()->config->proxy.clear();
|
||||
|
||||
QMessageBox::information(this, tr("Disable Tor"),
|
||||
tr("Connection over Tor has been disabled. To fully disconnect from Tor, you need to restart silentdragon."),
|
||||
QMessageBox::Ok);
|
||||
}
|
||||
|
||||
if (hushConfLocation.isEmpty()) {
|
||||
if (false /* connection needs reloading?*/) {
|
||||
// Save settings
|
||||
Settings::getInstance()->saveSettings(
|
||||
settings.hostname->text(),
|
||||
settings.port->text(),
|
||||
settings.rpcuser->text(),
|
||||
settings.rpcpassword->text());
|
||||
Settings::getInstance()->saveSettings(settings.txtServer->text());
|
||||
|
||||
auto cl = new ConnectionLoader(this, rpc);
|
||||
cl->loadConnection();
|
||||
}
|
||||
|
||||
// Check to see if rescan or reindex have been enabled
|
||||
bool showRestartInfo = false;
|
||||
if (settings.chkRescan->isChecked()) {
|
||||
Settings::addTohushConf(hushConfLocation, "rescan=1");
|
||||
showRestartInfo = true;
|
||||
}
|
||||
|
||||
if (settings.chkReindex->isChecked()) {
|
||||
Settings::addTohushConf(hushConfLocation, "reindex=1");
|
||||
showRestartInfo = true;
|
||||
}
|
||||
|
||||
if (showRestartInfo) {
|
||||
auto desc = tr("silentdragon needs to restart to rescan/reindex. silentdragon will now close, please restart silentdragon to continue");
|
||||
|
||||
QMessageBox::information(this, tr("Restart silentdragon"), desc, QMessageBox::Ok);
|
||||
QTimer::singleShot(1, [=]() { this->close(); });
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -541,13 +443,9 @@ void MainWindow::payhushURI(QString uri, QString myAddr) {
|
||||
// Now, set the fields on the send tab
|
||||
clearSendForm();
|
||||
|
||||
if (!myAddr.isEmpty()) {
|
||||
ui->inputsCombo->setCurrentText(myAddr);
|
||||
}
|
||||
|
||||
ui->Address1->setText(paymentInfo.addr);
|
||||
ui->Address1->setCursorPosition(0);
|
||||
ui->Amount1->setText(Settings::getDecimalString(paymentInfo.amt.toDouble()));
|
||||
ui->Amount1->setText(paymentInfo.amt);
|
||||
ui->MemoTxt1->setText(paymentInfo.memo);
|
||||
|
||||
// And switch to the send tab.
|
||||
@@ -743,40 +641,6 @@ void MainWindow::setupBalancesTab() {
|
||||
ui->lblSyncWarning->setVisible(false);
|
||||
ui->lblSyncWarningReceive->setVisible(false);
|
||||
|
||||
// Double click on balances table
|
||||
auto fnDoSendFrom = [=](const QString& addr, const QString& to = QString(), bool sendMax = false) {
|
||||
// Find the inputs combo
|
||||
for (int i = 0; i < ui->inputsCombo->count(); i++) {
|
||||
auto inputComboAddress = ui->inputsCombo->itemText(i);
|
||||
if (inputComboAddress.startsWith(addr)) {
|
||||
ui->inputsCombo->setCurrentIndex(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// If there's a to address, add that as well
|
||||
if (!to.isEmpty()) {
|
||||
// Remember to clear any existing address fields, because we are creating a new transaction.
|
||||
this->clearSendForm();
|
||||
ui->Address1->setText(to);
|
||||
}
|
||||
|
||||
// See if max button has to be checked
|
||||
if (sendMax) {
|
||||
ui->Max1->setChecked(true);
|
||||
}
|
||||
|
||||
// And switch to the send tab.
|
||||
ui->tabWidget->setCurrentIndex(1);
|
||||
};
|
||||
|
||||
// Double click opens up memo if one exists
|
||||
QObject::connect(ui->balancesTable, &QTableView::doubleClicked, [=](auto index) {
|
||||
index = index.sibling(index.row(), 0);
|
||||
auto addr = AddressBook::addressFromAddressLabel(ui->balancesTable->model()->data(index).toString());
|
||||
|
||||
fnDoSendFrom(addr);
|
||||
});
|
||||
|
||||
// Setup context menu on balances tab
|
||||
ui->balancesTable->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
@@ -800,18 +664,8 @@ void MainWindow::setupBalancesTab() {
|
||||
this->exportKeys(addr);
|
||||
});
|
||||
|
||||
menu.addAction("Send from " % addr.left(40) % (addr.size() > 40 ? "..." : ""), [=]() {
|
||||
fnDoSendFrom(addr);
|
||||
});
|
||||
|
||||
if (Settings::isTAddress(addr)) {
|
||||
auto defaultSapling = rpc->getDefaultSaplingAddress();
|
||||
if (!defaultSapling.isEmpty()) {
|
||||
menu.addAction(tr("Shield balance to Sapling"), [=] () {
|
||||
fnDoSendFrom(addr, defaultSapling, true);
|
||||
});
|
||||
}
|
||||
|
||||
menu.addAction(tr("View on block explorer"), [=] () {
|
||||
Settings::openAddressInExplorer(addr);
|
||||
});
|
||||
@@ -1092,7 +946,7 @@ void MainWindow::setupReceiveTab() {
|
||||
}
|
||||
|
||||
ui->rcvLabel->setText(label);
|
||||
ui->rcvBal->setText(Settings::gethushUSDDisplayFormat(rpc->getModel()->getAllBalances().value(addr)));
|
||||
ui->rcvBal->setText(rpc->getModel()->getAllBalances().value(addr).toDecimalhushUSDString());
|
||||
ui->txtReceive->setPlainText(addr);
|
||||
ui->qrcodeDisplay->setQrcodeString(addr);
|
||||
if (rpc->getModel()->getUsedAddresses().value(addr, false)) {
|
||||
@@ -1183,7 +1037,7 @@ void MainWindow::updateTAddrCombo(bool checked) {
|
||||
// If the address is in the address book, add it.
|
||||
if (labels.contains(taddr) && !addrs.contains(taddr)) {
|
||||
addrs.insert(taddr);
|
||||
ui->listReceiveAddresses->addItem(taddr, 0);
|
||||
ui->listReceiveAddresses->addItem(taddr, CAmount::fromqint64(0));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1194,7 +1048,7 @@ void MainWindow::updateTAddrCombo(bool checked) {
|
||||
if (!addrs.contains(addr)) {
|
||||
addrs.insert(addr);
|
||||
// Balance is zero since it has not been previously added
|
||||
ui->listReceiveAddresses->addItem(addr, 0);
|
||||
ui->listReceiveAddresses->addItem(addr, CAmount::fromqint64(0));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1211,7 +1065,7 @@ void MainWindow::updateTAddrCombo(bool checked) {
|
||||
// 5. Add a last, disabled item if there are remaining items
|
||||
if (allTaddrs.size() > addrs.size()) {
|
||||
auto num = QString::number(allTaddrs.size() - addrs.size());
|
||||
ui->listReceiveAddresses->addItem("-- " + num + " more --", 0);
|
||||
ui->listReceiveAddresses->addItem("-- " + num + " more --", CAmount::fromqint64(0));
|
||||
|
||||
QStandardItemModel* model = qobject_cast<QStandardItemModel*>(ui->listReceiveAddresses->model());
|
||||
QStandardItem* item = model->findItems("--", Qt::MatchStartsWith)[0];
|
||||
@@ -1230,9 +1084,6 @@ void MainWindow::updateLabels() {
|
||||
addZAddrsToComboList(ui->rdioZSAddr->isChecked())(true);
|
||||
}
|
||||
|
||||
// Update the Send Tab
|
||||
updateFromCombo();
|
||||
|
||||
// Update the autocomplete
|
||||
updateLabelsAutoComplete();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user