Labels (#59)
* hacked up labels * Custom widget for addresses with labels * turnstile to use labels
This commit is contained in:
@@ -251,10 +251,11 @@ void AddressBook::addAddressLabel(QString label, QString address) {
|
|||||||
void AddressBook::removeAddressLabel(QString label, QString address) {
|
void AddressBook::removeAddressLabel(QString label, QString address) {
|
||||||
// Iterate over the list and remove the label/address
|
// Iterate over the list and remove the label/address
|
||||||
for (int i=0; i < allLabels.size(); i++) {
|
for (int i=0; i < allLabels.size(); i++) {
|
||||||
if (allLabels[i].first == label && allLabels[i].second == address)
|
if (allLabels[i].first == label && allLabels[i].second == address) {
|
||||||
allLabels.removeAt(i);
|
allLabels.removeAt(i);
|
||||||
writeToStorage();
|
writeToStorage();
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -273,4 +274,16 @@ QString AddressBook::getLabelForAddress(QString addr) {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString AddressBook::addLabelToAddress(QString addr) {
|
||||||
|
QString label = AddressBook::getInstance()->getLabelForAddress(addr);
|
||||||
|
if (!label.isEmpty())
|
||||||
|
return label + "/" + addr;
|
||||||
|
else
|
||||||
|
return addr;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString AddressBook::addressFromAddressLabel(const QString& lblAddr) {
|
||||||
|
return lblAddr.trimmed().split("/").last();
|
||||||
|
}
|
||||||
|
|
||||||
AddressBook* AddressBook::instance = nullptr;
|
AddressBook* AddressBook::instance = nullptr;
|
||||||
@@ -35,6 +35,8 @@ public:
|
|||||||
static void open(MainWindow* parent, QLineEdit* target = nullptr);
|
static void open(MainWindow* parent, QLineEdit* target = nullptr);
|
||||||
|
|
||||||
static AddressBook* getInstance();
|
static AddressBook* getInstance();
|
||||||
|
static QString addLabelToAddress(QString addr);
|
||||||
|
static QString addressFromAddressLabel(const QString& lblAddr);
|
||||||
|
|
||||||
// Add a new address/label to the database
|
// Add a new address/label to the database
|
||||||
void addAddressLabel(QString label, QString address);
|
void addAddressLabel(QString label, QString address);
|
||||||
|
|||||||
41
src/addresscombo.cpp
Normal file
41
src/addresscombo.cpp
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
#include "addresscombo.h"
|
||||||
|
|
||||||
|
#include "addressbook.h"
|
||||||
|
#include "settings.h"
|
||||||
|
|
||||||
|
AddressCombo::AddressCombo(QWidget* parent) :
|
||||||
|
QComboBox(parent) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
QString AddressCombo::itemText(int i) {
|
||||||
|
QString txt = QComboBox::itemText(i);
|
||||||
|
return AddressBook::addressFromAddressLabel(txt.split("(")[0].trimmed());
|
||||||
|
}
|
||||||
|
|
||||||
|
QString AddressCombo::currentText() {
|
||||||
|
QString txt = QComboBox::currentText();
|
||||||
|
return AddressBook::addressFromAddressLabel(txt.split("(")[0].trimmed());
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddressCombo::setCurrentText(const QString& text) {
|
||||||
|
for (int i=0; i < count(); i++) {
|
||||||
|
if (itemText(i) == text) {
|
||||||
|
QComboBox::setCurrentIndex(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddressCombo::addItem(const QString& text, double bal) {
|
||||||
|
QString txt = AddressBook::addLabelToAddress(text);
|
||||||
|
if (bal > 0)
|
||||||
|
txt = txt % "(" % Settings::getZECDisplayFormat(bal) % ")";
|
||||||
|
|
||||||
|
QComboBox::addItem(txt);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddressCombo::insertItem(int index, const QString& text, double bal) {
|
||||||
|
QString txt = AddressBook::addLabelToAddress(text) %
|
||||||
|
"(" % Settings::getZECDisplayFormat(bal) % ")";
|
||||||
|
QComboBox::insertItem(index, txt);
|
||||||
|
}
|
||||||
24
src/addresscombo.h
Normal file
24
src/addresscombo.h
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
#ifndef ADDRESSCOMBO_H
|
||||||
|
#define ADDRESSCOMBO_H
|
||||||
|
|
||||||
|
#include "precompiled.h"
|
||||||
|
|
||||||
|
class AddressCombo : public QComboBox
|
||||||
|
{
|
||||||
|
Q_OBJECT;
|
||||||
|
public:
|
||||||
|
explicit AddressCombo(QWidget* parent = nullptr);
|
||||||
|
|
||||||
|
QString itemText(int i);
|
||||||
|
QString currentText();
|
||||||
|
|
||||||
|
void addItem(const QString& itemText, double bal);
|
||||||
|
void insertItem(int index, const QString& text, double bal = 0.0);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void setCurrentText(const QString& itemText);
|
||||||
|
|
||||||
|
private:
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // ADDRESSCOMBO_H
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
#include "balancestablemodel.h"
|
#include "balancestablemodel.h"
|
||||||
|
#include "addressbook.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -84,17 +85,15 @@ QVariant BalancesTableModel::data(const QModelIndex &index, int role) const
|
|||||||
|
|
||||||
if (role == Qt::DisplayRole) {
|
if (role == Qt::DisplayRole) {
|
||||||
switch (index.column()) {
|
switch (index.column()) {
|
||||||
case 0: return std::get<0>(modeldata->at(index.row()));
|
case 0: return AddressBook::addLabelToAddress(std::get<0>(modeldata->at(index.row())));
|
||||||
case 1: return Settings::getZECDisplayFormat(std::get<1>(modeldata->at(index.row())));
|
case 1: return Settings::getZECDisplayFormat(std::get<1>(modeldata->at(index.row())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(role == Qt::ToolTipRole) {
|
if(role == Qt::ToolTipRole) {
|
||||||
switch (index.column()) {
|
switch (index.column()) {
|
||||||
case 0: return std::get<0>(modeldata->at(index.row()));
|
case 0: return AddressBook::addLabelToAddress(std::get<0>(modeldata->at(index.row())));
|
||||||
case 1: {
|
case 1: return Settings::getUSDFormat(std::get<1>(modeldata->at(index.row())));
|
||||||
return Settings::getUSDFormat(std::get<1>(modeldata->at(index.row())));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -219,13 +219,13 @@ void MainWindow::turnstileDoMigration(QString fromAddr) {
|
|||||||
return bal;
|
return bal;
|
||||||
};
|
};
|
||||||
|
|
||||||
//turnstile.migrateZaddList->addItem("All Sprout z-Addrs");
|
|
||||||
turnstile.fromBalance->setText(Settings::getZECUSDDisplayFormat(fnGetAllSproutBalance()));
|
turnstile.fromBalance->setText(Settings::getZECUSDDisplayFormat(fnGetAllSproutBalance()));
|
||||||
for (auto addr : *rpc->getAllZAddresses()) {
|
for (auto addr : *rpc->getAllZAddresses()) {
|
||||||
|
auto bal = rpc->getAllBalances()->value(addr);
|
||||||
if (Settings::getInstance()->isSaplingAddress(addr)) {
|
if (Settings::getInstance()->isSaplingAddress(addr)) {
|
||||||
turnstile.migrateTo->addItem(addr);
|
turnstile.migrateTo->addItem(addr, bal);
|
||||||
} else {
|
} else {
|
||||||
turnstile.migrateZaddList->addItem(addr);
|
turnstile.migrateZaddList->addItem(addr, bal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -458,7 +458,7 @@ void MainWindow::addressBook() {
|
|||||||
void MainWindow::donate() {
|
void MainWindow::donate() {
|
||||||
// Set up a donation to me :)
|
// Set up a donation to me :)
|
||||||
ui->Address1->setText(Settings::getDonationAddr(
|
ui->Address1->setText(Settings::getDonationAddr(
|
||||||
Settings::getInstance()->isSaplingAddress(ui->inputsCombo->currentText())));
|
Settings::getInstance()->isSaplingAddress(ui->inputsCombo->currentText())));
|
||||||
ui->Address1->setCursorPosition(0);
|
ui->Address1->setCursorPosition(0);
|
||||||
ui->Amount1->setText("0.01");
|
ui->Amount1->setText("0.01");
|
||||||
ui->MemoTxt1->setText("Thanks for supporting zec-qt-wallet!");
|
ui->MemoTxt1->setText("Thanks for supporting zec-qt-wallet!");
|
||||||
@@ -735,7 +735,8 @@ void MainWindow::setupBalancesTab() {
|
|||||||
auto fnDoSendFrom = [=](const QString& addr, const QString& to = QString(), bool sendMax = false) {
|
auto fnDoSendFrom = [=](const QString& addr, const QString& to = QString(), bool sendMax = false) {
|
||||||
// Find the inputs combo
|
// Find the inputs combo
|
||||||
for (int i = 0; i < ui->inputsCombo->count(); i++) {
|
for (int i = 0; i < ui->inputsCombo->count(); i++) {
|
||||||
if (ui->inputsCombo->itemText(i).startsWith(addr)) {
|
auto inputComboAddress = ui->inputsCombo->itemText(i);
|
||||||
|
if (inputComboAddress.startsWith(addr)) {
|
||||||
ui->inputsCombo->setCurrentIndex(i);
|
ui->inputsCombo->setCurrentIndex(i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -772,7 +773,8 @@ void MainWindow::setupBalancesTab() {
|
|||||||
if (index.row() < 0) return;
|
if (index.row() < 0) return;
|
||||||
|
|
||||||
index = index.sibling(index.row(), 0);
|
index = index.sibling(index.row(), 0);
|
||||||
auto addr = ui->balancesTable->model()->data(index).toString();
|
auto addr = AddressBook::addressFromAddressLabel(
|
||||||
|
ui->balancesTable->model()->data(index).toString());
|
||||||
|
|
||||||
QMenu menu(this);
|
QMenu menu(this);
|
||||||
|
|
||||||
@@ -931,8 +933,10 @@ std::function<void(bool)> MainWindow::addZAddrsToComboList(bool sapling) {
|
|||||||
|
|
||||||
std::for_each(addrs->begin(), addrs->end(), [=] (auto addr) {
|
std::for_each(addrs->begin(), addrs->end(), [=] (auto addr) {
|
||||||
if ( (sapling && Settings::getInstance()->isSaplingAddress(addr)) ||
|
if ( (sapling && Settings::getInstance()->isSaplingAddress(addr)) ||
|
||||||
(!sapling && !Settings::getInstance()->isSaplingAddress(addr)))
|
(!sapling && !Settings::getInstance()->isSaplingAddress(addr))) {
|
||||||
ui->listRecieveAddresses->addItem(addr);
|
auto bal = rpc->getAllBalances()->value(addr);
|
||||||
|
ui->listRecieveAddresses->addItem(addr, bal);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// If z-addrs are empty, then create a new one.
|
// If z-addrs are empty, then create a new one.
|
||||||
@@ -969,7 +973,8 @@ void MainWindow::setupRecieveTab() {
|
|||||||
std::for_each(utxos->begin(), utxos->end(), [=] (auto& utxo) {
|
std::for_each(utxos->begin(), utxos->end(), [=] (auto& utxo) {
|
||||||
auto addr = utxo.address;
|
auto addr = utxo.address;
|
||||||
if (addr.startsWith("t") && ui->listRecieveAddresses->findText(addr) < 0) {
|
if (addr.startsWith("t") && ui->listRecieveAddresses->findText(addr) < 0) {
|
||||||
ui->listRecieveAddresses->addItem(addr);
|
auto bal = rpc->getAllBalances()->value(addr);
|
||||||
|
ui->listRecieveAddresses->addItem(addr, bal);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1026,7 +1031,8 @@ void MainWindow::setupRecieveTab() {
|
|||||||
|
|
||||||
// Select item in address list
|
// Select item in address list
|
||||||
QObject::connect(ui->listRecieveAddresses,
|
QObject::connect(ui->listRecieveAddresses,
|
||||||
QOverload<const QString &>::of(&QComboBox::currentIndexChanged), [=] (const QString& addr) {
|
QOverload<int>::of(&QComboBox::currentIndexChanged), [=] (int index) {
|
||||||
|
QString addr = ui->listRecieveAddresses->itemText(index);
|
||||||
if (addr.isEmpty()) {
|
if (addr.isEmpty()) {
|
||||||
// Draw empty stuff
|
// Draw empty stuff
|
||||||
|
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ private:
|
|||||||
|
|
||||||
void cancelButton();
|
void cancelButton();
|
||||||
void sendButton();
|
void sendButton();
|
||||||
void inputComboTextChanged(const QString& text);
|
void inputComboTextChanged(int index);
|
||||||
void addAddressSection();
|
void addAddressSection();
|
||||||
void maxAmountChecked(int checked);
|
void maxAmountChecked(int checked);
|
||||||
|
|
||||||
|
|||||||
@@ -228,7 +228,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_8">
|
<layout class="QHBoxLayout" name="horizontalLayout_8">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QComboBox" name="inputsCombo"/>
|
<widget class="AddressCombo" name="inputsCombo"/>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
@@ -316,8 +316,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>928</width>
|
<width>920</width>
|
||||||
<height>380</height>
|
<height>334</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="sendToLayout">
|
<layout class="QVBoxLayout" name="sendToLayout">
|
||||||
@@ -628,7 +628,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_10">
|
<layout class="QHBoxLayout" name="horizontalLayout_10">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QComboBox" name="listRecieveAddresses">
|
<widget class="AddressCombo" name="listRecieveAddresses">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
@@ -849,7 +849,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>968</width>
|
<width>968</width>
|
||||||
<height>19</height>
|
<height>22</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QMenu" name="menuFile">
|
<widget class="QMenu" name="menuFile">
|
||||||
@@ -970,6 +970,11 @@
|
|||||||
<extends>QLabel</extends>
|
<extends>QLabel</extends>
|
||||||
<header>fillediconlabel.h</header>
|
<header>fillediconlabel.h</header>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
|
<customwidget>
|
||||||
|
<class>AddressCombo</class>
|
||||||
|
<extends>QComboBox</extends>
|
||||||
|
<header>addresscombo.h</header>
|
||||||
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<tabstops>
|
<tabstops>
|
||||||
<tabstop>tabWidget</tabstop>
|
<tabstop>tabWidget</tabstop>
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
#include <QHeaderView>
|
#include <QHeaderView>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
|
#include <QComboBox>
|
||||||
#include <QScrollBar>
|
#include <QScrollBar>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QMovie>
|
#include <QMovie>
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ class QRCodeLabel : public QLabel
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit QRCodeLabel(QWidget *parent = 0);
|
explicit QRCodeLabel(QWidget *parent = nullptr);
|
||||||
virtual QSize sizeHint() const;
|
virtual QSize sizeHint() const;
|
||||||
|
|
||||||
void setAddress(QString address);
|
void setAddress(QString address);
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#include "rpc.h"
|
#include "rpc.h"
|
||||||
|
|
||||||
|
#include "addressbook.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include "senttxstore.h"
|
#include "senttxstore.h"
|
||||||
#include "turnstile.h"
|
#include "turnstile.h"
|
||||||
@@ -635,14 +636,13 @@ void RPC::updateUI(bool anyUnconfirmed) {
|
|||||||
balancesTableModel->setNewData(allBalances, utxos);
|
balancesTableModel->setNewData(allBalances, utxos);
|
||||||
|
|
||||||
// Add all the addresses into the inputs combo box
|
// Add all the addresses into the inputs combo box
|
||||||
auto lastFromAddr = ui->inputsCombo->currentText().split("(")[0].trimmed();
|
auto lastFromAddr = ui->inputsCombo->currentText();
|
||||||
|
|
||||||
ui->inputsCombo->clear();
|
ui->inputsCombo->clear();
|
||||||
auto i = allBalances->constBegin();
|
auto i = allBalances->constBegin();
|
||||||
while (i != allBalances->constEnd()) {
|
while (i != allBalances->constEnd()) {
|
||||||
QString item = i.key() % "(" % Settings::getZECDisplayFormat(i.value()) % ")";
|
ui->inputsCombo->addItem(i.key(), i.value());
|
||||||
ui->inputsCombo->addItem(item);
|
if (i.key() == lastFromAddr) ui->inputsCombo->setCurrentText(i.key());
|
||||||
if (item.startsWith(lastFromAddr)) ui->inputsCombo->setCurrentText(item);
|
|
||||||
|
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ void MainWindow::setupSendTab() {
|
|||||||
QObject::connect(ui->cancelSendButton, &QPushButton::clicked, this, &MainWindow::cancelButton);
|
QObject::connect(ui->cancelSendButton, &QPushButton::clicked, this, &MainWindow::cancelButton);
|
||||||
|
|
||||||
// Input Combobox current text changed
|
// Input Combobox current text changed
|
||||||
QObject::connect(ui->inputsCombo, QOverload<const QString &>::of(&QComboBox::currentIndexChanged),
|
QObject::connect(ui->inputsCombo, QOverload<int>::of(&QComboBox::currentIndexChanged),
|
||||||
this, &MainWindow::inputComboTextChanged);
|
this, &MainWindow::inputComboTextChanged);
|
||||||
|
|
||||||
// Hook up add address button click
|
// Hook up add address button click
|
||||||
@@ -52,7 +52,7 @@ void MainWindow::setupSendTab() {
|
|||||||
// This is the damnest thing ever. If we do AddressBook::readFromStorage() directly, the whole file
|
// This is the damnest thing ever. If we do AddressBook::readFromStorage() directly, the whole file
|
||||||
// doesn't get read. It needs to run in a timer after everything has finished to be able to read
|
// doesn't get read. It needs to run in a timer after everything has finished to be able to read
|
||||||
// the file properly.
|
// the file properly.
|
||||||
QTimer::singleShot(100, [=]() { updateLabelsAutoComplete(); });
|
QTimer::singleShot(2000, [=]() { updateLabelsAutoComplete(); });
|
||||||
|
|
||||||
// The first address book button
|
// The first address book button
|
||||||
QObject::connect(ui->AddressBook1, &QPushButton::clicked, [=] () {
|
QObject::connect(ui->AddressBook1, &QPushButton::clicked, [=] () {
|
||||||
@@ -117,7 +117,7 @@ void MainWindow::setDefaultPayFrom() {
|
|||||||
for (int i=0; i < ui->inputsCombo->count(); i++) {
|
for (int i=0; i < ui->inputsCombo->count(); i++) {
|
||||||
auto addr = ui->inputsCombo->itemText(i);
|
auto addr = ui->inputsCombo->itemText(i);
|
||||||
if (addr.startsWith(startsWith)) {
|
if (addr.startsWith(startsWith)) {
|
||||||
auto amt = rpc->getAllBalances()->value(addr.split("(")[0]);
|
auto amt = rpc->getAllBalances()->value(addr);
|
||||||
if (max_amt < amt) {
|
if (max_amt < amt) {
|
||||||
max_amt = amt;
|
max_amt = amt;
|
||||||
idx = i;
|
idx = i;
|
||||||
@@ -139,8 +139,9 @@ void MainWindow::setDefaultPayFrom() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
void MainWindow::inputComboTextChanged(const QString& text) {
|
void MainWindow::inputComboTextChanged(int index) {
|
||||||
auto bal = rpc->getAllBalances()->value(text.split("(")[0].trimmed());
|
auto addr = ui->inputsCombo->itemText(index);
|
||||||
|
auto bal = rpc->getAllBalances()->value(addr);
|
||||||
auto balFmt = Settings::getZECDisplayFormat(bal);
|
auto balFmt = Settings::getZECDisplayFormat(bal);
|
||||||
|
|
||||||
ui->sendAddressBalance->setText(balFmt);
|
ui->sendAddressBalance->setText(balFmt);
|
||||||
@@ -244,7 +245,7 @@ void MainWindow::addAddressSection() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::addressChanged(int itemNumber, const QString& text) {
|
void MainWindow::addressChanged(int itemNumber, const QString& text) {
|
||||||
auto addr = Settings::addressFromAddressLabel(text);
|
auto addr = AddressBook::addressFromAddressLabel(text);
|
||||||
setMemoEnabled(itemNumber, addr.startsWith("z"));
|
setMemoEnabled(itemNumber, addr.startsWith("z"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -267,7 +268,7 @@ void MainWindow::setMemoEnabled(int number, bool enabled) {
|
|||||||
void MainWindow::memoButtonClicked(int number) {
|
void MainWindow::memoButtonClicked(int number) {
|
||||||
// Memos can only be used with zAddrs. So check that first
|
// Memos can only be used with zAddrs. So check that first
|
||||||
auto addr = ui->sendToWidgets->findChild<QLineEdit*>(QString("Address") + QString::number(number));
|
auto addr = ui->sendToWidgets->findChild<QLineEdit*>(QString("Address") + QString::number(number));
|
||||||
if (!Settings::addressFromAddressLabel(addr->text()).startsWith("z")) {
|
if (!AddressBook::addressFromAddressLabel(addr->text()).startsWith("z")) {
|
||||||
QMessageBox msg(QMessageBox::Critical, "Memos can only be used with z-addresses",
|
QMessageBox msg(QMessageBox::Critical, "Memos can only be used with z-addresses",
|
||||||
"The memo field can only be used with a z-address.\n" + addr->text() + "\ndoesn't look like a z-address",
|
"The memo field can only be used with a z-address.\n" + addr->text() + "\ndoesn't look like a z-address",
|
||||||
QMessageBox::Ok, this);
|
QMessageBox::Ok, this);
|
||||||
@@ -357,7 +358,7 @@ void MainWindow::maxAmountChecked(int checked) {
|
|||||||
}
|
}
|
||||||
sumAllAmounts += Settings::getTotalFee();
|
sumAllAmounts += Settings::getTotalFee();
|
||||||
|
|
||||||
auto addr = Settings::addressFromAddressLabel(ui->inputsCombo->currentText().split("(")[0]);
|
auto addr = ui->inputsCombo->currentText();
|
||||||
|
|
||||||
auto maxamount = rpc->getAllBalances()->value(addr) - sumAllAmounts;
|
auto maxamount = rpc->getAllBalances()->value(addr) - sumAllAmounts;
|
||||||
maxamount = (maxamount < 0) ? 0 : maxamount;
|
maxamount = (maxamount < 0) ? 0 : maxamount;
|
||||||
@@ -373,14 +374,14 @@ void MainWindow::maxAmountChecked(int checked) {
|
|||||||
Tx MainWindow::createTxFromSendPage() {
|
Tx MainWindow::createTxFromSendPage() {
|
||||||
Tx tx;
|
Tx tx;
|
||||||
// Gather the from / to addresses
|
// Gather the from / to addresses
|
||||||
tx.fromAddr = ui->inputsCombo->currentText().split("(")[0].trimmed();
|
tx.fromAddr = ui->inputsCombo->currentText();
|
||||||
|
|
||||||
// For each addr/amt in the sendTo tab
|
// For each addr/amt in the sendTo tab
|
||||||
int totalItems = ui->sendToWidgets->children().size() - 2; // The last one is a spacer, so ignore that
|
int totalItems = ui->sendToWidgets->children().size() - 2; // The last one is a spacer, so ignore that
|
||||||
for (int i=0; i < totalItems; i++) {
|
for (int i=0; i < totalItems; i++) {
|
||||||
QString addr = ui->sendToWidgets->findChild<QLineEdit*>(QString("Address") % QString::number(i+1))->text().trimmed();
|
QString addr = ui->sendToWidgets->findChild<QLineEdit*>(QString("Address") % QString::number(i+1))->text().trimmed();
|
||||||
// Remove label if it exists
|
// Remove label if it exists
|
||||||
addr = Settings::addressFromAddressLabel(addr);
|
addr = AddressBook::addressFromAddressLabel(addr);
|
||||||
|
|
||||||
double amt = ui->sendToWidgets->findChild<QLineEdit*>(QString("Amount") % QString::number(i+1))->text().trimmed().toDouble();
|
double amt = ui->sendToWidgets->findChild<QLineEdit*>(QString("Amount") % QString::number(i+1))->text().trimmed().toDouble();
|
||||||
QString memo = ui->sendToWidgets->findChild<QLabel*>(QString("MemoTxt") % QString::number(i+1))->text().trimmed();
|
QString memo = ui->sendToWidgets->findChild<QLabel*>(QString("MemoTxt") % QString::number(i+1))->text().trimmed();
|
||||||
|
|||||||
@@ -206,6 +206,3 @@ bool Settings::isValidAddress(QString addr) {
|
|||||||
ztsexp.exactMatch(addr) || zsexp.exactMatch(addr);
|
ztsexp.exactMatch(addr) || zsexp.exactMatch(addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Settings::addressFromAddressLabel(const QString& lblAddr) {
|
|
||||||
return lblAddr.trimmed().split("/").last();
|
|
||||||
}
|
|
||||||
@@ -72,8 +72,6 @@ public:
|
|||||||
static double getTotalFee();
|
static double getTotalFee();
|
||||||
|
|
||||||
static bool isValidAddress(QString addr);
|
static bool isValidAddress(QString addr);
|
||||||
static QString addressFromAddressLabel(const QString& lblAddr);
|
|
||||||
static QString addressLabelFromAddress(const QString& addr);
|
|
||||||
|
|
||||||
static const int updateSpeed = 20 * 1000; // 20 sec
|
static const int updateSpeed = 20 * 1000; // 20 sec
|
||||||
static const int quickUpdateSpeed = 5 * 1000; // 5 sec
|
static const int quickUpdateSpeed = 5 * 1000; // 5 sec
|
||||||
|
|||||||
@@ -59,7 +59,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="1" colspan="2">
|
<item row="2" column="1" colspan="2">
|
||||||
<widget class="QComboBox" name="migrateZaddList">
|
<widget class="AddressCombo" name="migrateZaddList">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
@@ -108,7 +108,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="1" colspan="2">
|
<item row="4" column="1" colspan="2">
|
||||||
<widget class="QComboBox" name="migrateTo"/>
|
<widget class="AddressCombo" name="migrateTo"/>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0" colspan="3">
|
<item row="1" column="0" colspan="3">
|
||||||
<widget class="Line" name="line">
|
<widget class="Line" name="line">
|
||||||
@@ -190,6 +190,13 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>AddressCombo</class>
|
||||||
|
<extends>QComboBox</extends>
|
||||||
|
<header>addresscombo.h</header>
|
||||||
|
</customwidget>
|
||||||
|
</customwidgets>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections>
|
<connections>
|
||||||
<connection>
|
<connection>
|
||||||
|
|||||||
@@ -50,7 +50,8 @@ SOURCES += \
|
|||||||
src/connection.cpp \
|
src/connection.cpp \
|
||||||
src/fillediconlabel.cpp \
|
src/fillediconlabel.cpp \
|
||||||
src/addressbook.cpp \
|
src/addressbook.cpp \
|
||||||
src/logger.cpp
|
src/logger.cpp \
|
||||||
|
src/addresscombo.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
src/mainwindow.h \
|
src/mainwindow.h \
|
||||||
@@ -69,7 +70,8 @@ HEADERS += \
|
|||||||
src/connection.h \
|
src/connection.h \
|
||||||
src/fillediconlabel.h \
|
src/fillediconlabel.h \
|
||||||
src/addressbook.h \
|
src/addressbook.h \
|
||||||
src/logger.h
|
src/logger.h \
|
||||||
|
src/addresscombo.h
|
||||||
|
|
||||||
FORMS += \
|
FORMS += \
|
||||||
src/mainwindow.ui \
|
src/mainwindow.ui \
|
||||||
|
|||||||
Reference in New Issue
Block a user