Browse Source

USD Amount in send tab

import_zecw
Aditya Kulkarni 6 years ago
parent
commit
d2a1b2c673
  1. 4
      src/mainwindow.h
  2. 7
      src/mainwindow.ui
  3. 3
      src/rpc.cpp
  4. 51
      src/sendtab.cpp
  5. 7
      src/ui_mainwindow.h

4
src/mainwindow.h

@ -51,7 +51,11 @@ private:
void addAddressSection(); void addAddressSection();
void maxAmountChecked(int checked); void maxAmountChecked(int checked);
void addressChanged(int number, const QString& text);
void amountChanged (int numer, const QString& text);
void memoButtonClicked(int number); void memoButtonClicked(int number);
void setMemoEnabled(int number, bool enabled);
QString doSendTxValidations(QString fromAddr, QList<ToFields> toAddrs); QString doSendTxValidations(QString fromAddr, QList<ToFields> toAddrs);

7
src/mainwindow.ui

@ -352,6 +352,13 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QLabel" name="AmtUSD1">
<property name="text">
<string/>
</property>
</widget>
</item>
<item> <item>
<widget class="QCheckBox" name="Max1"> <widget class="QCheckBox" name="Max1">
<property name="text"> <property name="text">

3
src/rpc.cpp

@ -330,6 +330,9 @@ void RPC::getInfoThenRefresh() {
(progress < 0.99 ? ("/" % QString::number(progress*100, 'f', 0) % "%") : QString()) % (progress < 0.99 ? ("/" % QString::number(progress*100, 'f', 0) % "%") : QString()) %
")"; ")";
main->statusLabel->setText(statusText); main->statusLabel->setText(statusText);
auto zecPrice = Settings::getInstance()->getUSDFormat(1);
if (!zecPrice.isEmpty())
main->statusLabel->setToolTip("1 ZEC = " + zecPrice);
}); });
}); });

51
src/sendtab.cpp

@ -37,6 +37,17 @@ void MainWindow::setupSendTab() {
QObject::connect(ui->MemoBtn1, &QPushButton::clicked, [=] () { QObject::connect(ui->MemoBtn1, &QPushButton::clicked, [=] () {
memoButtonClicked(1); memoButtonClicked(1);
}); });
setMemoEnabled(1, false);
// The first Address button
QObject::connect(ui->Address1, &QLineEdit::textChanged, [=] (auto text) {
addressChanged(1, text);
});
// The first Amount button
QObject::connect(ui->Amount1, &QLineEdit::textChanged, [=] (auto text) {
amountChanged(1, text);
});
// Set up focus enter to set fees // Set up focus enter to set fees
QObject::connect(ui->tabWidget, &QTabWidget::currentChanged, [=] (int pos) { QObject::connect(ui->tabWidget, &QTabWidget::currentChanged, [=] (int pos) {
@ -110,6 +121,9 @@ void MainWindow::addAddressSection() {
auto Address1 = new QLineEdit(verticalGroupBox); auto Address1 = new QLineEdit(verticalGroupBox);
Address1->setObjectName(QString("Address") % QString::number(itemNumber)); Address1->setObjectName(QString("Address") % QString::number(itemNumber));
Address1->setPlaceholderText("Address"); Address1->setPlaceholderText("Address");
QObject::connect(Address1, &QLineEdit::textChanged, [=] (auto text) {
addressChanged(itemNumber, text);
});
horizontalLayout_12->addWidget(Address1); horizontalLayout_12->addWidget(Address1);
sendAddressLayout->addLayout(horizontalLayout_12); sendAddressLayout->addLayout(horizontalLayout_12);
@ -128,12 +142,19 @@ void MainWindow::addAddressSection() {
// Create the validator for send to/amount fields // Create the validator for send to/amount fields
auto amtValidator = new QDoubleValidator(0, 21000000, 8, Amount1); auto amtValidator = new QDoubleValidator(0, 21000000, 8, Amount1);
Amount1->setValidator(amtValidator); Amount1->setValidator(amtValidator);
QObject::connect(Amount1, &QLineEdit::textChanged, [=] (auto text) {
amountChanged(itemNumber, text);
});
horizontalLayout_13->addWidget(Amount1); horizontalLayout_13->addWidget(Amount1);
auto AmtUSD1 = new QLabel(verticalGroupBox);
AmtUSD1->setObjectName(QString("AmtUSD") % QString::number(itemNumber));
horizontalLayout_13->addWidget(AmtUSD1);
auto horizontalSpacer_4 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); auto horizontalSpacer_4 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
horizontalLayout_13->addItem(horizontalSpacer_4); horizontalLayout_13->addItem(horizontalSpacer_4);
auto MemoBtn1 = new QPushButton(verticalGroupBox); auto MemoBtn1 = new QPushButton(verticalGroupBox);
MemoBtn1->setObjectName(QString("MemoBtn") % QString::number(itemNumber)); MemoBtn1->setObjectName(QString("MemoBtn") % QString::number(itemNumber));
MemoBtn1->setText("Memo"); MemoBtn1->setText("Memo");
@ -142,6 +163,7 @@ void MainWindow::addAddressSection() {
memoButtonClicked(itemNumber); memoButtonClicked(itemNumber);
}); });
horizontalLayout_13->addWidget(MemoBtn1); horizontalLayout_13->addWidget(MemoBtn1);
setMemoEnabled(itemNumber, false);
sendAddressLayout->addLayout(horizontalLayout_13); sendAddressLayout->addLayout(horizontalLayout_13);
@ -161,6 +183,26 @@ void MainWindow::addAddressSection() {
QTimer::singleShot(10, [=] () {ui->sendToScrollArea->ensureWidgetVisible(ui->addAddressButton);}); QTimer::singleShot(10, [=] () {ui->sendToScrollArea->ensureWidgetVisible(ui->addAddressButton);});
} }
void MainWindow::addressChanged(int itemNumber, const QString& text) {
setMemoEnabled(itemNumber, text.startsWith("z"));
}
void MainWindow::amountChanged(int item, const QString& text) {
auto usd = ui->sendToWidgets->findChild<QLabel*>(QString("AmtUSD") % QString::number(item));
usd->setText(Settings::getInstance()->getUSDFormat(text.toDouble()));
}
void MainWindow::setMemoEnabled(int number, bool enabled) {
auto memoBtn = ui->sendToWidgets->findChild<QPushButton*>(QString("MemoBtn") % QString::number(number));
if (enabled) {
memoBtn->setEnabled(true);
memoBtn->setToolTip("");
} else {
memoBtn->setEnabled(false);
memoBtn->setToolTip("Only Z addresses can have memos");
}
}
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));
@ -196,11 +238,16 @@ void MainWindow::removeExtraAddresses() {
addr->clear(); addr->clear();
auto amt = ui->sendToWidgets->findChild<QLineEdit*>(QString("Amount1")); auto amt = ui->sendToWidgets->findChild<QLineEdit*>(QString("Amount1"));
amt->clear(); amt->clear();
auto amtUSD = ui->sendToWidgets->findChild<QLabel*>(QString("AmtUSD1"));
amtUSD->clear();
auto max = ui->sendToWidgets->findChild<QCheckBox*>(QString("Max1")); auto max = ui->sendToWidgets->findChild<QCheckBox*>(QString("Max1"));
max->setChecked(false); max->setChecked(false);
auto memo = ui->sendToWidgets->findChild<QLabel*>(QString("MemoTxt1")); auto memo = ui->sendToWidgets->findChild<QLabel*>(QString("MemoTxt1"));
memo->clear(); memo->clear();
// Disable first memo btn
setMemoEnabled(1, false);
// Start the deletion after the first item, since we want to keep 1 send field there all there // Start the deletion after the first item, since we want to keep 1 send field there all there
for (int i=1; i < totalItems; i++) { for (int i=1; i < totalItems; i++) {
auto addressGroupBox = ui->sendToWidgets->findChild<QGroupBox*>(QString("AddressGroupBox") % QString::number(i+1)); auto addressGroupBox = ui->sendToWidgets->findChild<QGroupBox*>(QString("AddressGroupBox") % QString::number(i+1));
@ -289,7 +336,7 @@ void MainWindow::sendButton() {
Ui_confirm confirm; Ui_confirm confirm;
confirm.setupUi(&d); confirm.setupUi(&d);
// Remove all existing address/amt qlabels // Remove all existing address/amt qlabels on the confirm dialog.
int totalConfirmAddrItems = confirm.sendToAddrs->children().size(); int totalConfirmAddrItems = confirm.sendToAddrs->children().size();
for (int i = 0; i < totalConfirmAddrItems / 3; i++) { for (int i = 0; i < totalConfirmAddrItems / 3; i++) {
auto addr = confirm.sendToAddrs->findChild<QLabel*>(QString("Addr") % QString::number(i+1)); auto addr = confirm.sendToAddrs->findChild<QLabel*>(QString("Addr") % QString::number(i+1));

7
src/ui_mainwindow.h

@ -95,6 +95,7 @@ public:
QHBoxLayout *horizontalLayout_13; QHBoxLayout *horizontalLayout_13;
QLabel *label_6; QLabel *label_6;
QLineEdit *Amount1; QLineEdit *Amount1;
QLabel *AmtUSD1;
QCheckBox *Max1; QCheckBox *Max1;
QSpacerItem *horizontalSpacer_4; QSpacerItem *horizontalSpacer_4;
QPushButton *MemoBtn1; QPushButton *MemoBtn1;
@ -402,6 +403,11 @@ public:
horizontalLayout_13->addWidget(Amount1); horizontalLayout_13->addWidget(Amount1);
AmtUSD1 = new QLabel(verticalGroupBox);
AmtUSD1->setObjectName(QStringLiteral("AmtUSD1"));
horizontalLayout_13->addWidget(AmtUSD1);
Max1 = new QCheckBox(verticalGroupBox); Max1 = new QCheckBox(verticalGroupBox);
Max1->setObjectName(QStringLiteral("Max1")); Max1->setObjectName(QStringLiteral("Max1"));
@ -693,6 +699,7 @@ public:
Address1->setPlaceholderText(QApplication::translate("MainWindow", "Address", nullptr)); Address1->setPlaceholderText(QApplication::translate("MainWindow", "Address", nullptr));
label_6->setText(QApplication::translate("MainWindow", "Amount", nullptr)); label_6->setText(QApplication::translate("MainWindow", "Amount", nullptr));
Amount1->setPlaceholderText(QApplication::translate("MainWindow", "Amount", nullptr)); Amount1->setPlaceholderText(QApplication::translate("MainWindow", "Amount", nullptr));
AmtUSD1->setText(QString());
Max1->setText(QApplication::translate("MainWindow", "Max Available", nullptr)); Max1->setText(QApplication::translate("MainWindow", "Max Available", nullptr));
#ifndef QT_NO_TOOLTIP #ifndef QT_NO_TOOLTIP
MemoBtn1->setToolTip(QString()); MemoBtn1->setToolTip(QString());

Loading…
Cancel
Save