Wladimir J. van der Laan
11 years ago
19 changed files with 533 additions and 235 deletions
@ -0,0 +1,164 @@
@@ -0,0 +1,164 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<ui version="4.0"> |
||||
<class>ReceiveCoinsDialog</class> |
||||
<widget class="QWidget" name="ReceiveCoinsDialog"> |
||||
<property name="geometry"> |
||||
<rect> |
||||
<x>0</x> |
||||
<y>0</y> |
||||
<width>776</width> |
||||
<height>343</height> |
||||
</rect> |
||||
</property> |
||||
<property name="windowTitle"> |
||||
<string>Form</string> |
||||
</property> |
||||
<layout class="QVBoxLayout" name="verticalLayout"> |
||||
<item> |
||||
<layout class="QFormLayout" name="formLayout"> |
||||
<property name="fieldGrowthPolicy"> |
||||
<enum>QFormLayout::AllNonFixedFieldsGrow</enum> |
||||
</property> |
||||
<item row="3" column="0"> |
||||
<widget class="QLabel" name="label"> |
||||
<property name="text"> |
||||
<string>&Amount:</string> |
||||
</property> |
||||
<property name="buddy"> |
||||
<cstring>reqAmount</cstring> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="3" column="1"> |
||||
<widget class="BitcoinAmountField" name="reqAmount" native="true"> |
||||
<property name="minimumSize"> |
||||
<size> |
||||
<width>80</width> |
||||
<height>0</height> |
||||
</size> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="4" column="0"> |
||||
<widget class="QLabel" name="label_2"> |
||||
<property name="text"> |
||||
<string>&Label:</string> |
||||
</property> |
||||
<property name="buddy"> |
||||
<cstring>reqLabel</cstring> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="4" column="1"> |
||||
<widget class="QLineEdit" name="reqLabel"/> |
||||
</item> |
||||
<item row="5" column="0"> |
||||
<widget class="QLabel" name="label_3"> |
||||
<property name="text"> |
||||
<string>&Message:</string> |
||||
</property> |
||||
<property name="buddy"> |
||||
<cstring>reqMessage</cstring> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="5" column="1"> |
||||
<widget class="QLineEdit" name="reqMessage"/> |
||||
</item> |
||||
<item row="6" column="0"> |
||||
<widget class="QLabel" name="label_4"> |
||||
<property name="text"> |
||||
<string/> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="6" column="1"> |
||||
<widget class="QCheckBox" name="reuseAddress"> |
||||
<property name="text"> |
||||
<string>R&euse an existing receiving address</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="2" column="1"> |
||||
<widget class="QLabel" name="label_5"> |
||||
<property name="text"> |
||||
<string>Use this form to request payments. All fields are optional.</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
</layout> |
||||
</item> |
||||
<item> |
||||
<layout class="QHBoxLayout" name="horizontalLayout"> |
||||
<item> |
||||
<widget class="QPushButton" name="clearButton"> |
||||
<property name="sizePolicy"> |
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed"> |
||||
<horstretch>0</horstretch> |
||||
<verstretch>0</verstretch> |
||||
</sizepolicy> |
||||
</property> |
||||
<property name="toolTip"> |
||||
<string>Remove all transaction fields</string> |
||||
</property> |
||||
<property name="text"> |
||||
<string>Clear</string> |
||||
</property> |
||||
<property name="icon"> |
||||
<iconset resource="../bitcoin.qrc"> |
||||
<normaloff>:/icons/remove</normaloff>:/icons/remove</iconset> |
||||
</property> |
||||
<property name="autoRepeatDelay"> |
||||
<number>300</number> |
||||
</property> |
||||
<property name="autoDefault"> |
||||
<bool>false</bool> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<spacer name="horizontalSpacer"> |
||||
<property name="orientation"> |
||||
<enum>Qt::Horizontal</enum> |
||||
</property> |
||||
<property name="sizeHint" stdset="0"> |
||||
<size> |
||||
<width>40</width> |
||||
<height>20</height> |
||||
</size> |
||||
</property> |
||||
</spacer> |
||||
</item> |
||||
<item> |
||||
<widget class="QPushButton" name="receiveButton"> |
||||
<property name="minimumSize"> |
||||
<size> |
||||
<width>150</width> |
||||
<height>0</height> |
||||
</size> |
||||
</property> |
||||
<property name="text"> |
||||
<string>&Request payment</string> |
||||
</property> |
||||
<property name="icon"> |
||||
<iconset resource="../bitcoin.qrc"> |
||||
<normaloff>:/icons/receiving_addresses</normaloff>:/icons/receiving_addresses</iconset> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
</layout> |
||||
</item> |
||||
</layout> |
||||
</widget> |
||||
<customwidgets> |
||||
<customwidget> |
||||
<class>BitcoinAmountField</class> |
||||
<extends>QLineEdit</extends> |
||||
<header>bitcoinamountfield.h</header> |
||||
</customwidget> |
||||
</customwidgets> |
||||
<resources> |
||||
<include location="../bitcoin.qrc"/> |
||||
</resources> |
||||
<connections/> |
||||
</ui> |
@ -0,0 +1,105 @@
@@ -0,0 +1,105 @@
|
||||
#include "receivecoinsdialog.h" |
||||
#include "ui_receivecoinsdialog.h" |
||||
|
||||
#include "walletmodel.h" |
||||
#include "bitcoinunits.h" |
||||
#include "addressbookpage.h" |
||||
#include "optionsmodel.h" |
||||
#include "guiutil.h" |
||||
#include "receiverequestdialog.h" |
||||
#include "addresstablemodel.h" |
||||
|
||||
#include <QMessageBox> |
||||
#include <QTextDocument> |
||||
#include <QScrollBar> |
||||
|
||||
ReceiveCoinsDialog::ReceiveCoinsDialog(QWidget *parent) : |
||||
QDialog(parent), |
||||
ui(new Ui::ReceiveCoinsDialog), |
||||
model(0) |
||||
{ |
||||
ui->setupUi(this); |
||||
|
||||
#ifdef Q_OS_MAC // Icons on push buttons are very uncommon on Mac
|
||||
ui->clearButton->setIcon(QIcon()); |
||||
ui->receiveButton->setIcon(QIcon()); |
||||
#endif |
||||
connect(ui->clearButton, SIGNAL(clicked()), this, SLOT(clear())); |
||||
} |
||||
|
||||
void ReceiveCoinsDialog::setModel(WalletModel *model) |
||||
{ |
||||
this->model = model; |
||||
|
||||
if(model && model->getOptionsModel()) |
||||
{ |
||||
connect(model->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, SLOT(updateDisplayUnit())); |
||||
updateDisplayUnit(); |
||||
} |
||||
} |
||||
|
||||
ReceiveCoinsDialog::~ReceiveCoinsDialog() |
||||
{ |
||||
delete ui; |
||||
} |
||||
|
||||
void ReceiveCoinsDialog::clear() |
||||
{ |
||||
ui->reqAmount->clear(); |
||||
ui->reqLabel->setText(""); |
||||
ui->reqMessage->setText(""); |
||||
ui->reuseAddress->setChecked(false); |
||||
updateDisplayUnit(); |
||||
} |
||||
|
||||
void ReceiveCoinsDialog::reject() |
||||
{ |
||||
clear(); |
||||
} |
||||
|
||||
void ReceiveCoinsDialog::accept() |
||||
{ |
||||
clear(); |
||||
} |
||||
|
||||
void ReceiveCoinsDialog::updateDisplayUnit() |
||||
{ |
||||
if(model && model->getOptionsModel()) |
||||
{ |
||||
ui->reqAmount->setDisplayUnit(model->getOptionsModel()->getDisplayUnit()); |
||||
} |
||||
} |
||||
|
||||
void ReceiveCoinsDialog::on_receiveButton_clicked() |
||||
{ |
||||
if(!model || !model->getOptionsModel() || !model->getAddressTableModel()) |
||||
return; |
||||
|
||||
QString address; |
||||
QString label = ui->reqLabel->text(); |
||||
if(ui->reuseAddress->isChecked()) |
||||
{ |
||||
/* Choose existing receiving address */ |
||||
AddressBookPage dlg(AddressBookPage::ForSelection, AddressBookPage::ReceivingTab, this); |
||||
dlg.setModel(model->getAddressTableModel()); |
||||
if(dlg.exec()) |
||||
{ |
||||
address = dlg.getReturnValue(); |
||||
if(label.isEmpty()) /* If no label provided, use the previously used label */ |
||||
{ |
||||
label = model->getAddressTableModel()->labelForAddress(address); |
||||
} |
||||
} else { |
||||
return; |
||||
} |
||||
} else { |
||||
/* Generate new receiving address */ |
||||
address = model->getAddressTableModel()->addRow(AddressTableModel::Receive, label, ""); |
||||
} |
||||
ReceiveRequestDialog *dialog = new ReceiveRequestDialog(address, label, |
||||
ui->reqAmount->value(), ui->reqMessage->text(), this); |
||||
dialog->setModel(model->getOptionsModel()); |
||||
dialog->setAttribute(Qt::WA_DeleteOnClose); |
||||
dialog->show(); |
||||
clear(); |
||||
} |
@ -0,0 +1,38 @@
@@ -0,0 +1,38 @@
|
||||
#ifndef RECEIVECOINSDIALOG_H |
||||
#define RECEIVECOINSDIALOG_H |
||||
|
||||
#include <QDialog> |
||||
#include <QVariant> |
||||
|
||||
namespace Ui { |
||||
class ReceiveCoinsDialog; |
||||
} |
||||
class WalletModel; |
||||
class OptionsModel; |
||||
|
||||
/** Dialog for requesting payment of bitcoins */ |
||||
class ReceiveCoinsDialog : public QDialog |
||||
{ |
||||
Q_OBJECT |
||||
|
||||
public: |
||||
explicit ReceiveCoinsDialog(QWidget *parent = 0); |
||||
~ReceiveCoinsDialog(); |
||||
|
||||
void setModel(WalletModel *model); |
||||
|
||||
public slots: |
||||
void clear(); |
||||
void reject(); |
||||
void accept(); |
||||
|
||||
private: |
||||
Ui::ReceiveCoinsDialog *ui; |
||||
WalletModel *model; |
||||
|
||||
private slots: |
||||
void on_receiveButton_clicked(); |
||||
void updateDisplayUnit(); |
||||
}; |
||||
|
||||
#endif // RECEIVECOINSDIALOG_H
|
Loading…
Reference in new issue