mirror of
https://github.com/twisterarmy/twister-core.git
synced 2025-01-11 07:17:53 +00:00
make send coins dialog more user friendly (better checking)
This commit is contained in:
parent
85663f2c18
commit
992ff49b43
4
TODO
4
TODO
@ -92,3 +92,7 @@ Todo:
|
|||||||
|
|
||||||
- Check windows support / cross platform
|
- Check windows support / cross platform
|
||||||
|
|
||||||
|
Check send dialog:
|
||||||
|
1MCwBbhNGp5hRm5rC1Aims2YFRe2SXPYKt
|
||||||
|
|
||||||
|
|
||||||
|
@ -64,6 +64,9 @@
|
|||||||
<property name="text">
|
<property name="text">
|
||||||
<string>&Paste</string>
|
<string>&Paste</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="autoDefault">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="3">
|
<item row="3" column="3">
|
||||||
@ -71,6 +74,9 @@
|
|||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Address &Book...</string>
|
<string>Address &Book...</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="autoDefault">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="1">
|
<item row="2" column="1">
|
||||||
@ -124,6 +130,9 @@
|
|||||||
<iconset resource="../bitcoin.qrc">
|
<iconset resource="../bitcoin.qrc">
|
||||||
<normaloff>:/icons/send</normaloff>:/icons/send</iconset>
|
<normaloff>:/icons/send</normaloff>:/icons/send</iconset>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="default">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
@ -146,22 +155,5 @@
|
|||||||
<resources>
|
<resources>
|
||||||
<include location="../bitcoin.qrc"/>
|
<include location="../bitcoin.qrc"/>
|
||||||
</resources>
|
</resources>
|
||||||
<connections>
|
<connections/>
|
||||||
<connection>
|
|
||||||
<sender>payAmount</sender>
|
|
||||||
<signal>returnPressed()</signal>
|
|
||||||
<receiver>sendButton</receiver>
|
|
||||||
<slot>click()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>191</x>
|
|
||||||
<y>65</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>570</x>
|
|
||||||
<y>121</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
</connections>
|
|
||||||
</ui>
|
</ui>
|
||||||
|
@ -12,7 +12,7 @@ class SendCoinsDialog : public QDialog
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit SendCoinsDialog(QWidget *parent = 0);
|
explicit SendCoinsDialog(QWidget *parent = 0, const QString &address = "");
|
||||||
~SendCoinsDialog();
|
~SendCoinsDialog();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -127,6 +127,12 @@ void AddressBookDialog::on_buttonBox_accepted()
|
|||||||
QVariant address = table->model()->data(index);
|
QVariant address = table->model()->data(index);
|
||||||
returnValue = address.toString();
|
returnValue = address.toString();
|
||||||
}
|
}
|
||||||
|
if(!returnValue.isEmpty())
|
||||||
accept();
|
{
|
||||||
|
accept();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
reject();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -211,7 +211,12 @@ void BitcoinGUI::addressbookClicked()
|
|||||||
qDebug() << "Address book clicked";
|
qDebug() << "Address book clicked";
|
||||||
AddressBookDialog dlg;
|
AddressBookDialog dlg;
|
||||||
dlg.setTab(AddressBookDialog::SendingTab);
|
dlg.setTab(AddressBookDialog::SendingTab);
|
||||||
dlg.exec();
|
/* if an address accepted, do a 'send' to specified address */
|
||||||
|
if(dlg.exec())
|
||||||
|
{
|
||||||
|
SendCoinsDialog send(0, dlg.getReturnValue());
|
||||||
|
send.exec();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BitcoinGUI::receivingAddressesClicked()
|
void BitcoinGUI::receivingAddressesClicked()
|
||||||
|
@ -6,17 +6,31 @@
|
|||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QClipboard>
|
#include <QClipboard>
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QLocale>
|
||||||
|
|
||||||
#include "base58.h"
|
#include "base58.h"
|
||||||
|
|
||||||
SendCoinsDialog::SendCoinsDialog(QWidget *parent) :
|
SendCoinsDialog::SendCoinsDialog(QWidget *parent, const QString &address) :
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
ui(new Ui::SendCoinsDialog)
|
ui(new Ui::SendCoinsDialog)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
/* Set up validators */
|
||||||
ui->payTo->setMaxLength(BitcoinAddressValidator::MaxAddressLength);
|
ui->payTo->setMaxLength(BitcoinAddressValidator::MaxAddressLength);
|
||||||
ui->payTo->setValidator(new BitcoinAddressValidator(this));
|
ui->payTo->setValidator(new BitcoinAddressValidator(this));
|
||||||
ui->payAmount->setValidator(new QDoubleValidator(this));
|
QDoubleValidator *amountValidator = new QDoubleValidator(this);
|
||||||
|
amountValidator->setDecimals(8);
|
||||||
|
amountValidator->setBottom(0.0);
|
||||||
|
ui->payAmount->setValidator(amountValidator);
|
||||||
|
|
||||||
|
/* Set initial address if provided */
|
||||||
|
if(!address.isEmpty())
|
||||||
|
{
|
||||||
|
ui->payTo->setText(address);
|
||||||
|
ui->payAmount->setFocus();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SendCoinsDialog::~SendCoinsDialog()
|
SendCoinsDialog::~SendCoinsDialog()
|
||||||
@ -28,14 +42,31 @@ void SendCoinsDialog::on_sendButton_clicked()
|
|||||||
{
|
{
|
||||||
QByteArray payTo = ui->payTo->text().toUtf8();
|
QByteArray payTo = ui->payTo->text().toUtf8();
|
||||||
uint160 payToHash = 0;
|
uint160 payToHash = 0;
|
||||||
if(AddressToHash160(payTo.constData(), payToHash))
|
double payAmount = 0.0;
|
||||||
{
|
bool valid = false;
|
||||||
accept();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
|
|
||||||
|
if(!AddressToHash160(payTo.constData(), payToHash))
|
||||||
|
{
|
||||||
|
QMessageBox::warning(this, tr("Warning"),
|
||||||
|
tr("The recepient address is not valid, please recheck."),
|
||||||
|
QMessageBox::Ok,
|
||||||
|
QMessageBox::Ok);
|
||||||
|
ui->payTo->setFocus();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
payAmount = QLocale::system().toDouble(ui->payAmount->text(), &valid);
|
||||||
|
if(!valid || payAmount <= 0.0)
|
||||||
|
{
|
||||||
|
QMessageBox::warning(this, tr("Warning"),
|
||||||
|
tr("The amount to pay must be a valid number larger than 0."),
|
||||||
|
QMessageBox::Ok,
|
||||||
|
QMessageBox::Ok);
|
||||||
|
ui->payAmount->setFocus();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* TODO: send command to core, once this succeeds do accept() */
|
||||||
|
accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SendCoinsDialog::on_pasteButton_clicked()
|
void SendCoinsDialog::on_pasteButton_clicked()
|
||||||
|
Loading…
Reference in New Issue
Block a user