Browse Source

Remove "from" fields

pull/14/head
Aditya Kulkarni 5 years ago
parent
commit
fd9d668a44
  1. 4
      src/camount.h
  2. 34
      src/controller.cpp
  3. 6
      src/datamodel.h
  4. 51
      src/mainwindow.cpp
  5. 3
      src/mainwindow.h
  6. 142
      src/mainwindow.ui
  7. 34
      src/sendtab.cpp

4
src/camount.h

@ -43,6 +43,10 @@ public:
return this->amount < other.amount; return this->amount < other.amount;
} }
bool operator< (const qint64& other) const {
return this->amount < other;
}
bool operator> (const CAmount& other) const { bool operator> (const CAmount& other) const {
return this->amount > other.amount; return this->amount > other.amount;
} }

34
src/controller.cpp

@ -127,9 +127,6 @@ void Controller::noConnection() {
ui->balSheilded->setToolTip(""); ui->balSheilded->setToolTip("");
ui->balTransparent->setToolTip(""); ui->balTransparent->setToolTip("");
ui->balTotal->setToolTip(""); ui->balTotal->setToolTip("");
// Clear send tab from address
ui->inputsCombo->clear();
} }
/// This will refresh all the balance data from zcashd /// This will refresh all the balance data from zcashd
@ -243,9 +240,6 @@ void Controller::updateUI(bool anyUnconfirmed) {
// Update balances model data, which will update the table too // Update balances model data, which will update the table too
balancesTableModel->setNewData(model->getAllZAddresses(), model->getAllTAddresses(), model->getAllBalances(), model->getUTXOs()); balancesTableModel->setNewData(model->getAllZAddresses(), model->getAllTAddresses(), model->getAllBalances(), model->getUTXOs());
// Update from address
main->updateFromCombo();
}; };
// Function to process reply of the listunspent and z_listunspent API calls, used below. // Function to process reply of the listunspent and z_listunspent API calls, used below.
@ -280,19 +274,33 @@ void Controller::refreshBalances() {
// 1. Get the Balances // 1. Get the Balances
zrpc->fetchBalance([=] (json reply) { zrpc->fetchBalance([=] (json reply) {
CAmount balT = CAmount::fromqint64(reply["tbalance"].get<json::number_unsigned_t>()); CAmount balT = CAmount::fromqint64(reply["tbalance"].get<json::number_unsigned_t>());
CAmount balZ = CAmount::fromqint64(reply["zbalance"].get<json::number_unsigned_t>()); CAmount balZ = CAmount::fromqint64(reply["zbalance"].get<json::number_unsigned_t>());
CAmount balTotal = balT + balZ; CAmount balVerified = CAmount::fromqint64(reply["verified_zbalance"].get<json::number_unsigned_t>());
CAmount balTotal = balT + balZ;
CAmount balAvailable = balT + balVerified;
// This is for the websockets
AppDataModel::getInstance()->setBalances(balT, balZ); AppDataModel::getInstance()->setBalances(balT, balZ);
// This is for the datamodel
model->setAvailableBalance(balAvailable);
// Balances table
ui->balSheilded ->setText(balZ.toDecimalZECString()); ui->balSheilded ->setText(balZ.toDecimalZECString());
ui->balVerified ->setText(balVerified.toDecimalZECString());
ui->balTransparent->setText(balT.toDecimalZECString()); ui->balTransparent->setText(balT.toDecimalZECString());
ui->balTotal ->setText(balTotal.toDecimalZECString()); ui->balTotal ->setText(balTotal.toDecimalZECString());
ui->balSheilded ->setToolTip(balZ.toDecimalZECUSDString()); ui->balSheilded ->setToolTip(balZ.toDecimalUSDString());
ui->balTransparent->setToolTip(balT.toDecimalZECUSDString()); ui->balVerified ->setToolTip(balVerified.toDecimalUSDString());
ui->balTotal ->setToolTip(balTotal.toDecimalZECUSDString()); ui->balTransparent->setToolTip(balT.toDecimalUSDString());
ui->balTotal ->setToolTip(balTotal.toDecimalUSDString());
// Send tab
ui->txtAvailableZEC->setText(balAvailable.toDecimalZECString());
ui->txtAvailableUSD->setText(balAvailable.toDecimalUSDString());
}); });
// 2. Get the UTXOs // 2. Get the UTXOs

6
src/datamodel.h

@ -33,7 +33,9 @@ public:
const QList<UnspentOutput> getUTXOs() { QReadLocker locker(lock); return *utxos; } const QList<UnspentOutput> getUTXOs() { QReadLocker locker(lock); return *utxos; }
const QMap<QString, CAmount> getAllBalances() { QReadLocker locker(lock); return *balances; } const QMap<QString, CAmount> getAllBalances() { QReadLocker locker(lock); return *balances; }
const QMap<QString, bool> getUsedAddresses() { QReadLocker locker(lock); return *usedAddresses; } const QMap<QString, bool> getUsedAddresses() { QReadLocker locker(lock); return *usedAddresses; }
CAmount getAvailableBalance() { return availableBalance; }
void setAvailableBalance(CAmount a) { this->availableBalance = a; }
DataModel(); DataModel();
~DataModel(); ~DataModel();
@ -46,6 +48,8 @@ private:
QList<QString>* zaddresses = nullptr; QList<QString>* zaddresses = nullptr;
QList<QString>* taddresses = nullptr; QList<QString>* taddresses = nullptr;
CAmount availableBalance;
QReadWriteLock* lock; QReadWriteLock* lock;
}; };

51
src/mainwindow.cpp

@ -430,10 +430,6 @@ void MainWindow::payZcashURI(QString uri, QString myAddr) {
// Now, set the fields on the send tab // Now, set the fields on the send tab
clearSendForm(); clearSendForm();
if (!myAddr.isEmpty()) {
ui->inputsCombo->setCurrentText(myAddr);
}
ui->Address1->setText(paymentInfo.addr); ui->Address1->setText(paymentInfo.addr);
ui->Address1->setCursorPosition(0); ui->Address1->setCursorPosition(0);
ui->Amount1->setText(paymentInfo.amt); ui->Amount1->setText(paymentInfo.amt);
@ -631,40 +627,6 @@ void MainWindow::setupBalancesTab() {
ui->lblSyncWarning->setVisible(false); ui->lblSyncWarning->setVisible(false);
ui->lblSyncWarningReceive->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 // Setup context menu on balances tab
ui->balancesTable->setContextMenuPolicy(Qt::CustomContextMenu); ui->balancesTable->setContextMenuPolicy(Qt::CustomContextMenu);
@ -688,18 +650,8 @@ void MainWindow::setupBalancesTab() {
this->exportKeys(addr); this->exportKeys(addr);
}); });
menu.addAction("Send from " % addr.left(40) % (addr.size() > 40 ? "..." : ""), [=]() {
fnDoSendFrom(addr);
});
if (Settings::isTAddress(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"), [=] () { menu.addAction(tr("View on block explorer"), [=] () {
Settings::openAddressInExplorer(addr); Settings::openAddressInExplorer(addr);
}); });
@ -1118,9 +1070,6 @@ void MainWindow::updateLabels() {
addZAddrsToComboList(ui->rdioZSAddr->isChecked())(true); addZAddrsToComboList(ui->rdioZSAddr->isChecked())(true);
} }
// Update the Send Tab
updateFromCombo();
// Update the autocomplete // Update the autocomplete
updateLabelsAutoComplete(); updateLabelsAutoComplete();
} }

3
src/mainwindow.h

@ -47,7 +47,6 @@ public:
QRegExpValidator* getAmountValidator() { return amtValidator; } QRegExpValidator* getAmountValidator() { return amtValidator; }
QString doSendTxValidations(Tx tx); QString doSendTxValidations(Tx tx);
void setDefaultPayFrom();
void replaceWormholeClient(WormholeClient* newClient); void replaceWormholeClient(WormholeClient* newClient);
bool isWebsocketListening(); bool isWebsocketListening();
@ -59,7 +58,6 @@ public:
void updateLabels(); void updateLabels();
void updateTAddrCombo(bool checked); void updateTAddrCombo(bool checked);
void updateFromCombo();
// Disable recurring on mainnet // Disable recurring on mainnet
void disableRecurring(); void disableRecurring();
@ -100,7 +98,6 @@ private:
void cancelButton(); void cancelButton();
void sendButton(); void sendButton();
void inputComboTextChanged(int index);
void addAddressSection(); void addAddressSection();
void maxAmountChecked(int checked); void maxAmountChecked(int checked);

142
src/mainwindow.ui

@ -22,7 +22,7 @@
<item row="0" column="0"> <item row="0" column="0">
<widget class="QTabWidget" name="tabWidget"> <widget class="QTabWidget" name="tabWidget">
<property name="currentIndex"> <property name="currentIndex">
<number>0</number> <number>1</number>
</property> </property>
<widget class="QWidget" name="tab"> <widget class="QWidget" name="tab">
<attribute name="title"> <attribute name="title">
@ -75,6 +75,37 @@
</item> </item>
</layout> </layout>
</item> </item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_17">
<item>
<widget class="QLabel" name="label_15">
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string>Verified</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="balVerified">
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_2"> <layout class="QHBoxLayout" name="horizontalLayout_2">
<item> <item>
@ -270,60 +301,59 @@
<property name="flat"> <property name="flat">
<bool>false</bool> <bool>false</bool>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_6"> <layout class="QHBoxLayout" name="horizontalLayout_8">
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_8"> <spacer name="horizontalSpacer_6">
<item> <property name="orientation">
<widget class="AddressCombo" name="inputsCombo"/> <enum>Qt::Horizontal</enum>
</item> </property>
</layout> <property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item> </item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_15"> <widget class="QLabel" name="label_5">
<item> <property name="font">
<widget class="QLabel" name="label_5"> <font>
<property name="text"> <weight>75</weight>
<string>Address Balance</string> <bold>true</bold>
</property> </font>
</widget> </property>
</item> <property name="text">
<item> <string>Total verified funds available:</string>
<widget class="QLineEdit" name="sendAddressBalance"> </property>
<property name="sizePolicy"> </widget>
<sizepolicy hsizetype="Preferred" vsizetype="Fixed"> </item>
<horstretch>0</horstretch> <item>
<verstretch>0</verstretch> <widget class="QLabel" name="txtAvailableZEC">
</sizepolicy> <property name="text">
</property> <string/>
<property name="alignment"> </property>
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> </widget>
</property> </item>
<property name="readOnly"> <item>
<bool>true</bool> <widget class="QLabel" name="txtAvailableUSD">
</property> <property name="text">
</widget> <string/>
</item> </property>
<item> </widget>
<widget class="QLabel" name="sendAddressBalanceUSD"> </item>
<property name="text"> <item>
<string/> <spacer name="horizontalSpacer_8">
</property> <property name="orientation">
</widget> <enum>Qt::Horizontal</enum>
</item> </property>
<item> <property name="sizeHint" stdset="0">
<spacer name="horizontalSpacer_6"> <size>
<property name="orientation"> <width>40</width>
<enum>Qt::Horizontal</enum> <height>20</height>
</property> </size>
<property name="sizeHint" stdset="0"> </property>
<size> </spacer>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item> </item>
</layout> </layout>
</widget> </widget>
@ -362,8 +392,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>1162</width> <width>1226</width>
<height>344</height> <height>504</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="sendToLayout"> <layout class="QVBoxLayout" name="sendToLayout">
@ -1055,7 +1085,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>1274</width> <width>1274</width>
<height>39</height> <height>22</height>
</rect> </rect>
</property> </property>
<widget class="QMenu" name="menuFile"> <widget class="QMenu" name="menuFile">
@ -1201,7 +1231,6 @@
</customwidgets> </customwidgets>
<tabstops> <tabstops>
<tabstop>tabWidget</tabstop> <tabstop>tabWidget</tabstop>
<tabstop>inputsCombo</tabstop>
<tabstop>Address1</tabstop> <tabstop>Address1</tabstop>
<tabstop>Amount1</tabstop> <tabstop>Amount1</tabstop>
<tabstop>Max1</tabstop> <tabstop>Max1</tabstop>
@ -1220,7 +1249,6 @@
<tabstop>transactionsTable</tabstop> <tabstop>transactionsTable</tabstop>
<tabstop>balancesTable</tabstop> <tabstop>balancesTable</tabstop>
<tabstop>minerFeeAmt</tabstop> <tabstop>minerFeeAmt</tabstop>
<tabstop>sendAddressBalance</tabstop>
<tabstop>sendToScrollArea</tabstop> <tabstop>sendToScrollArea</tabstop>
</tabstops> </tabstops>
<resources> <resources>

34
src/sendtab.cpp

@ -22,10 +22,6 @@ void MainWindow::setupSendTab() {
// Cancel Button // Cancel Button
QObject::connect(ui->cancelSendButton, &QPushButton::clicked, this, &MainWindow::cancelButton); QObject::connect(ui->cancelSendButton, &QPushButton::clicked, this, &MainWindow::cancelButton);
// Input Combobox current text changed
QObject::connect(ui->inputsCombo, QOverload<int>::of(&QComboBox::currentIndexChanged),
this, &MainWindow::inputComboTextChanged);
// Hook up add address button click // Hook up add address button click
QObject::connect(ui->addAddressButton, &QPushButton::clicked, this, &MainWindow::addAddressSection); QObject::connect(ui->addAddressButton, &QPushButton::clicked, this, &MainWindow::addAddressSection);
@ -168,18 +164,6 @@ void MainWindow::updateLabelsAutoComplete() {
} }
} }
void MainWindow::setDefaultPayFrom() {
};
void MainWindow::updateFromCombo() {
// delete
}
void MainWindow::inputComboTextChanged(int) {
// delete
}
void MainWindow::addAddressSection() { void MainWindow::addAddressSection() {
int itemNumber = ui->sendToWidgets->children().size() - 1; int itemNumber = ui->sendToWidgets->children().size() - 1;
@ -336,12 +320,9 @@ void MainWindow::memoButtonClicked(int number, bool includeReplyTo) {
memoDialog.memoTxt->setAcceptButton(memoDialog.buttonBox->button(QDialogButtonBox::Ok)); memoDialog.memoTxt->setAcceptButton(memoDialog.buttonBox->button(QDialogButtonBox::Ok));
auto fnAddReplyTo = [=, &dialog]() { auto fnAddReplyTo = [=, &dialog]() {
QString replyTo = ui->inputsCombo->currentText(); auto replyTo = rpc->getDefaultSaplingAddress();
if (!Settings::isZAddress(replyTo)) { if (replyTo.isEmpty())
replyTo = rpc->getDefaultSaplingAddress(); return;
if (replyTo.isEmpty())
return;
}
memoDialog.memoTxt->includeReplyTo(replyTo); memoDialog.memoTxt->includeReplyTo(replyTo);
@ -424,10 +405,8 @@ void MainWindow::maxAmountChecked(int checked) {
sumAllAmounts = sumAllAmounts + Settings::getMinerFee(); sumAllAmounts = sumAllAmounts + Settings::getMinerFee();
auto addr = ui->inputsCombo->currentText(); auto maxamount = rpc->getModel()->getAvailableBalance() - sumAllAmounts;
maxamount = (maxamount < 0) ? CAmount::fromqint64(0): maxamount;
auto maxamount = rpc->getModel()->getAllBalances().value(addr) - sumAllAmounts;
maxamount = (maxamount.toqint64() < 0) ? CAmount::fromqint64(0) : maxamount;
ui->Amount1->setText(maxamount.toDecimalString()); ui->Amount1->setText(maxamount.toDecimalString());
} else if (checked == Qt::Unchecked) { } else if (checked == Qt::Unchecked) {
@ -440,9 +419,6 @@ void MainWindow::maxAmountChecked(int checked) {
Tx MainWindow::createTxFromSendPage() { Tx MainWindow::createTxFromSendPage() {
Tx tx; Tx tx;
// Gather the from / to addresses
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
CAmount totalAmt; CAmount totalAmt;

Loading…
Cancel
Save