Cleanup labels code
This commit is contained in:
parent
be87587ff5
commit
5eb2a14aec
|
@ -111,7 +111,7 @@ void AddressBook::open(MainWindow* parent, QLineEdit* target) {
|
|||
}
|
||||
|
||||
// Connect the dialog's closing to updating the label address completor
|
||||
QObject::connect(&d, &QDialog::finished, [=] (auto) { parent->updateLabelsAutoComplete(); });
|
||||
QObject::connect(&d, &QDialog::finished, [=] (auto) { parent->updateLabels(); });
|
||||
|
||||
// If there is a target then make it the addr for the "Add to" button
|
||||
if (target != nullptr && Settings::isValidAddress(target->text())) {
|
||||
|
|
|
@ -1223,27 +1223,12 @@ void MainWindow::setupRecieveTab() {
|
|||
});
|
||||
};
|
||||
|
||||
auto fnUpdateTAddrCombo = [=] (bool checked) {
|
||||
if (checked) {
|
||||
auto utxos = this->rpc->getUTXOs();
|
||||
ui->listRecieveAddresses->clear();
|
||||
|
||||
std::for_each(utxos->begin(), utxos->end(), [=](auto& utxo) {
|
||||
auto addr = utxo.address;
|
||||
if (addr.startsWith("t") && ui->listRecieveAddresses->findText(addr) < 0) {
|
||||
auto bal = rpc->getAllBalances()->value(addr);
|
||||
ui->listRecieveAddresses->addItem(addr, bal);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// Connect t-addr radio button
|
||||
QObject::connect(ui->rdioTAddr, &QRadioButton::toggled, [=] (bool checked) {
|
||||
// Whenever the t-address is selected, we generate a new address, because we don't
|
||||
// want to reuse t-addrs
|
||||
if (checked && this->rpc->getUTXOs() != nullptr) {
|
||||
fnUpdateTAddrCombo(checked);
|
||||
updateTAddrCombo(checked);
|
||||
addNewTAddr();
|
||||
}
|
||||
});
|
||||
|
@ -1368,16 +1353,8 @@ void MainWindow::setupRecieveTab() {
|
|||
AddressBook::getInstance()->addAddressLabel(label, addr);
|
||||
}
|
||||
|
||||
// Update the UI
|
||||
if (ui->rdioTAddr->isChecked()) {
|
||||
fnUpdateTAddrCombo(true);
|
||||
}
|
||||
else {
|
||||
addZAddrsToComboList(ui->rdioZSAddr->isChecked())(true);
|
||||
}
|
||||
|
||||
// Update the autocomplete
|
||||
updateLabelsAutoComplete();
|
||||
// Update labels everywhere on the UI
|
||||
updateLabels();
|
||||
|
||||
// Show the user feedback
|
||||
if (!info.isEmpty()) {
|
||||
|
@ -1395,6 +1372,35 @@ void MainWindow::setupRecieveTab() {
|
|||
});
|
||||
}
|
||||
|
||||
void MainWindow::updateTAddrCombo(bool checked) {
|
||||
if (checked) {
|
||||
auto utxos = this->rpc->getUTXOs();
|
||||
ui->listRecieveAddresses->clear();
|
||||
|
||||
std::for_each(utxos->begin(), utxos->end(), [=](auto& utxo) {
|
||||
auto addr = utxo.address;
|
||||
if (addr.startsWith("t") && ui->listRecieveAddresses->findText(addr) < 0) {
|
||||
auto bal = rpc->getAllBalances()->value(addr);
|
||||
ui->listRecieveAddresses->addItem(addr, bal);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// Updates the labels everywhere on the UI. Call this after the labels have been updated
|
||||
void MainWindow::updateLabels() {
|
||||
// Update the Receive tab
|
||||
if (ui->rdioTAddr->isChecked()) {
|
||||
updateTAddrCombo(true);
|
||||
}
|
||||
else {
|
||||
addZAddrsToComboList(ui->rdioZSAddr->isChecked())(true);
|
||||
}
|
||||
|
||||
// Update the autocomplete
|
||||
updateLabelsAutoComplete();
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
delete ui;
|
||||
|
|
|
@ -50,6 +50,10 @@ public:
|
|||
void createWebsocket(QString wormholecode);
|
||||
void stopWebsocket();
|
||||
|
||||
void updateLabels();
|
||||
void updateTAddrCombo(bool checked);
|
||||
|
||||
|
||||
Ui::MainWindow* ui;
|
||||
|
||||
QLabel* statusLabel;
|
||||
|
|
Loading…
Reference in New Issue