mirror of
https://github.com/kvazar-network/kevacoin.git
synced 2025-01-11 23:58:18 +00:00
allow adding address to address book in send dialog
This commit is contained in:
parent
c88e14fe26
commit
38deedc1b5
@ -60,7 +60,7 @@ void ClientModel::update()
|
||||
addressTableModel->update();
|
||||
}
|
||||
|
||||
ClientModel::StatusCode ClientModel::sendCoins(const QString &payTo, qint64 payAmount)
|
||||
ClientModel::StatusCode ClientModel::sendCoins(const QString &payTo, qint64 payAmount, const QString &addToAddressBookAs)
|
||||
{
|
||||
uint160 hash160 = 0;
|
||||
bool valid = false;
|
||||
@ -95,7 +95,7 @@ ClientModel::StatusCode ClientModel::sendCoins(const QString &payTo, qint64 payA
|
||||
std::string strError = SendMoney(scriptPubKey, payAmount, wtx, true);
|
||||
if (strError == "")
|
||||
{
|
||||
return OK;
|
||||
// OK
|
||||
}
|
||||
else if (strError == "ABORTED")
|
||||
{
|
||||
@ -107,11 +107,12 @@ ClientModel::StatusCode ClientModel::sendCoins(const QString &payTo, qint64 payA
|
||||
return MiscError;
|
||||
}
|
||||
}
|
||||
|
||||
// Add addresses that we've sent to to the address book
|
||||
std::string strAddress = payTo.toStdString();
|
||||
CRITICAL_BLOCK(cs_mapAddressBook)
|
||||
if (!mapAddressBook.count(strAddress))
|
||||
SetAddressBookName(strAddress, "");
|
||||
SetAddressBookName(strAddress, addToAddressBookAs.toStdString());
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ public:
|
||||
int getTotalBlocksEstimate() const;
|
||||
|
||||
/* Send coins */
|
||||
StatusCode sendCoins(const QString &payTo, qint64 payAmount);
|
||||
StatusCode sendCoins(const QString &payTo, qint64 payAmount, const QString &addToAddressBookAs=QString());
|
||||
private:
|
||||
OptionsModel *optionsModel;
|
||||
AddressTableModel *addressTableModel;
|
||||
|
@ -16,7 +16,7 @@
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="4" column="0">
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>&Amount:</string>
|
||||
@ -90,9 +90,33 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<item row="5" column="1">
|
||||
<widget class="BitcoinAmountField" name="payAmount" native="true"/>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="addToAddressBook">
|
||||
<property name="toolTip">
|
||||
<string>Add specified destination address to address book</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Add to address book as</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="addAsLabel">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Label to add address as</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
@ -170,6 +194,8 @@
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>payTo</tabstop>
|
||||
<tabstop>addToAddressBook</tabstop>
|
||||
<tabstop>addAsLabel</tabstop>
|
||||
<tabstop>payAmount</tabstop>
|
||||
<tabstop>pasteButton</tabstop>
|
||||
<tabstop>addressBookButton</tabstop>
|
||||
|
@ -46,6 +46,7 @@ void SendCoinsDialog::on_sendButton_clicked()
|
||||
{
|
||||
bool valid;
|
||||
QString payAmount = ui->payAmount->text();
|
||||
QString label;
|
||||
qint64 payAmountParsed;
|
||||
|
||||
valid = ParseMoney(payAmount.toStdString(), payAmountParsed);
|
||||
@ -58,7 +59,13 @@ void SendCoinsDialog::on_sendButton_clicked()
|
||||
return;
|
||||
}
|
||||
|
||||
switch(model->sendCoins(ui->payTo->text(), payAmountParsed))
|
||||
if(ui->addToAddressBook->isChecked())
|
||||
{
|
||||
// Add address to address book under label, if specified
|
||||
label = ui->addAsLabel->text();
|
||||
}
|
||||
|
||||
switch(model->sendCoins(ui->payTo->text(), payAmountParsed, label))
|
||||
{
|
||||
case ClientModel::InvalidAddress:
|
||||
QMessageBox::warning(this, tr("Send Coins"),
|
||||
@ -110,3 +117,8 @@ void SendCoinsDialog::on_buttonBox_rejected()
|
||||
{
|
||||
reject();
|
||||
}
|
||||
|
||||
void SendCoinsDialog::on_addToAddressBook_toggled(bool checked)
|
||||
{
|
||||
ui->addAsLabel->setEnabled(checked);
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ private:
|
||||
ClientModel *model;
|
||||
|
||||
private slots:
|
||||
void on_addToAddressBook_toggled(bool checked);
|
||||
void on_buttonBox_rejected();
|
||||
void on_addressBookButton_clicked();
|
||||
void on_pasteButton_clicked();
|
||||
|
Loading…
Reference in New Issue
Block a user