Split confirm addresses for readability

This commit is contained in:
Aditya Kulkarni
2019-05-24 10:00:10 -07:00
parent 9d8b2364cc
commit 50b645bd19
2 changed files with 39 additions and 11 deletions

View File

@@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>429</width> <width>538</width>
<height>371</height> <height>458</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@@ -23,7 +23,7 @@
<item> <item>
<widget class="QLabel" name="sendFrom"> <widget class="QLabel" name="sendFrom">
<property name="text"> <property name="text">
<string/> <string notr="true"/>
</property> </property>
<property name="wordWrap"> <property name="wordWrap">
<bool>true</bool> <bool>true</bool>
@@ -67,6 +67,12 @@
</item> </item>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="Addr1"> <widget class="QLabel" name="Addr1">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text"> <property name="text">
<string notr="true">TextLabel</string> <string notr="true">TextLabel</string>
</property> </property>
@@ -93,6 +99,12 @@
</item> </item>
<item row="2" column="0"> <item row="2" column="0">
<widget class="QLabel" name="labelMinerFee"> <widget class="QLabel" name="labelMinerFee">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text"> <property name="text">
<string notr="true">Miner Textlabel</string> <string notr="true">Miner Textlabel</string>
</property> </property>
@@ -101,7 +113,7 @@
<item row="0" column="1"> <item row="0" column="1">
<widget class="QLabel" name="Amt1"> <widget class="QLabel" name="Amt1">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred"> <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
@@ -117,7 +129,7 @@
<item row="2" column="1"> <item row="2" column="1">
<widget class="QLabel" name="minerFee"> <widget class="QLabel" name="minerFee">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred"> <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
@@ -168,7 +180,7 @@
<string notr="true">color: red;</string> <string notr="true">color: red;</string>
</property> </property>
<property name="text"> <property name="text">
<string>zcashd doesn't seem to have any peers. You might not be connected to the internet, so this Transaction might not work.</string> <string>zcashd doesn't seem to have any peers. You might not be connected to the internet, so this transaction might not work.</string>
</property> </property>
<property name="wordWrap"> <property name="wordWrap">
<bool>true</bool> <bool>true</bool>

View File

@@ -552,12 +552,24 @@ Tx MainWindow::createTxFromSendPage() {
} }
bool MainWindow::confirmTx(Tx tx, RecurringPaymentInfo* rpi) { bool MainWindow::confirmTx(Tx tx, RecurringPaymentInfo* rpi) {
auto fnSplitAddressForWrap = [=] (const QString& a) -> QString {
if (! Settings::isZAddress(a)) return a;
auto half = a.length() / 2; // Function to split the address to make it easier to read.
auto splitted = a.left(half) + "\n" + a.right(a.length() - half); // Split it into chunks of 4 chars.
return splitted; auto fnSplitAddressForWrap = [=] (const QString& a) -> QString {
QStringList ans;
static int splitSize = 8;
for (int i=0; i < a.length(); i+= splitSize) {
ans << a.mid(i, splitSize);
}
return ans.join(" ");
// if (! Settings::isZAddress(a)) return a;
// auto half = a.length() / 2;
// auto splitted = a.left(half) + "\n" + a.right(a.length() - half);
// return splitted;
}; };
// Update the recurring info with the latest Tx // Update the recurring info with the latest Tx
@@ -570,6 +582,8 @@ bool MainWindow::confirmTx(Tx tx, RecurringPaymentInfo* rpi) {
Ui_confirm confirm; Ui_confirm confirm;
confirm.setupUi(&d); confirm.setupUi(&d);
const QFont fixedFont = QFontDatabase::systemFont(QFontDatabase::FixedFont);
// Remove all existing address/amt qlabels on the confirm dialog. // 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++) {
@@ -605,6 +619,7 @@ bool MainWindow::confirmTx(Tx tx, RecurringPaymentInfo* rpi) {
Addr->setObjectName(QString("Addr") % QString::number(i + 1)); Addr->setObjectName(QString("Addr") % QString::number(i + 1));
Addr->setWordWrap(true); Addr->setWordWrap(true);
Addr->setText(fnSplitAddressForWrap(toAddr.addr)); Addr->setText(fnSplitAddressForWrap(toAddr.addr));
Addr->setFont(fixedFont);
confirm.gridLayout->addWidget(Addr, row, 0, 1, 1); confirm.gridLayout->addWidget(Addr, row, 0, 1, 1);
// Amount (ZEC) // Amount (ZEC)
@@ -696,6 +711,7 @@ bool MainWindow::confirmTx(Tx tx, RecurringPaymentInfo* rpi) {
// And FromAddress in the confirm dialog // And FromAddress in the confirm dialog
confirm.sendFrom->setText(fnSplitAddressForWrap(tx.fromAddr)); confirm.sendFrom->setText(fnSplitAddressForWrap(tx.fromAddr));
confirm.sendFrom->setFont(fixedFont);
QString tooltip = tr("Current balance : ") + QString tooltip = tr("Current balance : ") +
Settings::getZECUSDDisplayFormat(rpc->getAllBalances()->value(tx.fromAddr)); Settings::getZECUSDDisplayFormat(rpc->getAllBalances()->value(tx.fromAddr));
tooltip += "\n" + tr("Balance after this Tx: ") + tooltip += "\n" + tr("Balance after this Tx: ") +