Browse Source

[Qt] allow deletion of payment-requests in sendcoins

- this adds a delete button for insecure and secure payment requests in
  the sendcoins dialog
- it also enables the delete button even for single and empty entries, as
  this is much easier to handle and doesn't need to special case single
  entries
- big parts of the ui file were changed, because I copied the delete
  button and had to delete the layout too and created it from scratch
  (which seems to cleanup the rows and colums in the layout also, which is
  nice IMHO)
0.10
Philip Kaufmann 11 years ago
parent
commit
84b695cc9d
  1. 238
      src/qt/forms/sendcoinsentry.ui
  2. 29
      src/qt/sendcoinsdialog.cpp
  3. 2
      src/qt/sendcoinsdialog.h
  4. 10
      src/qt/sendcoinsentry.cpp
  5. 3
      src/qt/sendcoinsentry.h

238
src/qt/forms/sendcoinsentry.ui

@ -16,9 +16,6 @@
<property name="autoFillBackground"> <property name="autoFillBackground">
<bool>false</bool> <bool>false</bool>
</property> </property>
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QFrame" name="SendCoins"> <widget class="QFrame" name="SendCoins">
<property name="toolTip"> <property name="toolTip">
<string>This is a normal payment.</string> <string>This is a normal payment.</string>
@ -33,20 +30,7 @@
<property name="spacing"> <property name="spacing">
<number>12</number> <number>12</number>
</property> </property>
<item row="5" column="0"> <item row="0" column="0">
<widget class="QLabel" name="amountLabel">
<property name="text">
<string>A&amp;mount:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>payAmount</cstring>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="payToLabel"> <widget class="QLabel" name="payToLabel">
<property name="text"> <property name="text">
<string>Pay &amp;To:</string> <string>Pay &amp;To:</string>
@ -59,23 +43,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="5" column="1"> <item row="0" column="1">
<widget class="BitcoinAmountField" name="payAmount"/>
</item>
<item row="4" column="0">
<widget class="QLabel" name="labellLabel">
<property name="text">
<string>&amp;Label:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>addAsLabel</cstring>
</property>
</widget>
</item>
<item row="3" column="1">
<layout class="QHBoxLayout" name="payToLayout"> <layout class="QHBoxLayout" name="payToLayout">
<property name="spacing"> <property name="spacing">
<number>0</number> <number>0</number>
@ -85,9 +53,6 @@
<property name="toolTip"> <property name="toolTip">
<string>The address to send the payment to (e.g. 1NS17iag9jJgTHD1VXjvLCEnZuQ3rJDE9L)</string> <string>The address to send the payment to (e.g. 1NS17iag9jJgTHD1VXjvLCEnZuQ3rJDE9L)</string>
</property> </property>
<property name="maxLength">
<number>34</number>
</property>
</widget> </widget>
</item> </item>
<item> <item>
@ -127,7 +92,7 @@
<item> <item>
<widget class="QToolButton" name="deleteButton"> <widget class="QToolButton" name="deleteButton">
<property name="toolTip"> <property name="toolTip">
<string>Remove this recipient</string> <string>Remove this entry</string>
</property> </property>
<property name="text"> <property name="text">
<string/> <string/>
@ -140,13 +105,42 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="4" column="1"> <item row="1" column="0">
<widget class="QLabel" name="labellLabel">
<property name="text">
<string>&amp;Label:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>addAsLabel</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="addAsLabel"> <widget class="QLineEdit" name="addAsLabel">
<property name="toolTip"> <property name="toolTip">
<string>Enter a label for this address to add it to the list of used addresses</string> <string>Enter a label for this address to add it to the list of used addresses</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="0">
<widget class="QLabel" name="amountLabel">
<property name="text">
<string>A&amp;mount:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>payAmount</cstring>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="BitcoinAmountField" name="payAmount"/>
</item>
</layout> </layout>
</widget> </widget>
<widget class="QFrame" name="SendCoins_InsecurePaymentRequest"> <widget class="QFrame" name="SendCoins_InsecurePaymentRequest">
@ -581,57 +575,74 @@
<property name="spacing"> <property name="spacing">
<number>12</number> <number>12</number>
</property> </property>
<item row="4" column="0"> <item row="0" column="0">
<widget class="QLabel" name="memoLabel_is"> <widget class="QLabel" name="payToLabel_is">
<property name="text"> <property name="text">
<string>Memo:</string> <string>Pay To:</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property> </property>
</widget> </widget>
</item> </item>
<item row="5" column="0"> <item row="0" column="1">
<widget class="QLabel" name="amountLabel_is"> <layout class="QHBoxLayout" name="payToLayout_is">
<property name="spacing">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="payTo_is"/>
</item>
<item>
<widget class="QToolButton" name="deleteButton_is">
<property name="toolTip">
<string>Remove this entry</string>
</property>
<property name="text"> <property name="text">
<string>Amount:</string> <string/>
</property> </property>
<property name="alignment"> <property name="icon">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> <iconset resource="../bitcoin.qrc">
<normaloff>:/icons/remove</normaloff>:/icons/remove</iconset>
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="0"> </layout>
<widget class="QLabel" name="payToLabel_is"> </item>
<item row="1" column="0">
<widget class="QLabel" name="memoLabel_is">
<property name="text"> <property name="text">
<string>Pay To:</string> <string>Memo:</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property> </property>
</widget> </widget>
</item> </item>
<item row="5" column="2"> <item row="1" column="1">
<widget class="BitcoinAmountField" name="payAmount_is"> <widget class="QLabel" name="memoTextLabel_is">
<property name="acceptDrops"> <property name="textFormat">
<bool>false</bool> <enum>Qt::PlainText</enum>
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="2"> <item row="2" column="0">
<layout class="QHBoxLayout" name="payToLayout_is"> <widget class="QLabel" name="amountLabel_is">
<property name="spacing"> <property name="text">
<number>0</number> <string>A&amp;mount:</string>
</property> </property>
<item> <property name="alignment">
<widget class="QLabel" name="payTo_is"/> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</item> </property>
</layout> <property name="buddy">
<cstring>payAmount_is</cstring>
</property>
</widget>
</item> </item>
<item row="4" column="2"> <item row="2" column="1">
<widget class="QLabel" name="memoTextLabel_is"> <widget class="BitcoinAmountField" name="payAmount_is">
<property name="textFormat"> <property name="acceptDrops">
<enum>Qt::PlainText</enum> <bool>false</bool>
</property> </property>
</widget> </widget>
</item> </item>
@ -1096,61 +1107,78 @@
<property name="spacing"> <property name="spacing">
<number>12</number> <number>12</number>
</property> </property>
<item row="4" column="0"> <item row="0" column="0">
<widget class="QLabel" name="memoLabel_s"> <widget class="QLabel" name="payToLabel_s">
<property name="text"> <property name="text">
<string>Memo:</string> <string>Pay To:</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property> </property>
</widget> </widget>
</item> </item>
<item row="5" column="0"> <item row="0" column="1">
<widget class="QLabel" name="amountLabel_s"> <layout class="QHBoxLayout" name="payToLayout_s">
<property name="spacing">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="payTo_s">
<property name="textFormat">
<enum>Qt::PlainText</enum>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="deleteButton_s">
<property name="toolTip">
<string>Remove this entry</string>
</property>
<property name="text"> <property name="text">
<string>Amount:</string> <string/>
</property> </property>
<property name="alignment"> <property name="icon">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> <iconset resource="../bitcoin.qrc">
<normaloff>:/icons/remove</normaloff>:/icons/remove</iconset>
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="0"> </layout>
<widget class="QLabel" name="payToLabel_s"> </item>
<item row="1" column="0">
<widget class="QLabel" name="memoLabel_s">
<property name="text"> <property name="text">
<string>Pay To:</string> <string>Memo:</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property> </property>
</widget> </widget>
</item> </item>
<item row="5" column="2"> <item row="1" column="1">
<widget class="BitcoinAmountField" name="payAmount_s"> <widget class="QLabel" name="memoTextLabel_s">
<property name="acceptDrops"> <property name="textFormat">
<bool>false</bool> <enum>Qt::PlainText</enum>
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="2"> <item row="2" column="0">
<layout class="QHBoxLayout" name="payToLayout_s"> <widget class="QLabel" name="amountLabel_s">
<property name="spacing"> <property name="text">
<number>0</number> <string>A&amp;mount:</string>
</property> </property>
<item> <property name="alignment">
<widget class="QLabel" name="payTo_s"> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
<property name="textFormat"> </property>
<enum>Qt::PlainText</enum> <property name="buddy">
<cstring>payAmount_s</cstring>
</property> </property>
</widget> </widget>
</item> </item>
</layout> <item row="2" column="1">
</item> <widget class="BitcoinAmountField" name="payAmount_s">
<item row="4" column="2"> <property name="acceptDrops">
<widget class="QLabel" name="memoTextLabel_s"> <bool>false</bool>
<property name="textFormat">
<enum>Qt::PlainText</enum>
</property> </property>
</widget> </widget>
</item> </item>
@ -1159,16 +1187,28 @@
</widget> </widget>
<customwidgets> <customwidgets>
<customwidget> <customwidget>
<class>BitcoinAmountField</class> <class>QValidatedLineEdit</class>
<extends>QLineEdit</extends> <extends>QLineEdit</extends>
<header>bitcoinamountfield.h</header> <header>qvalidatedlineedit.h</header>
</customwidget> </customwidget>
<customwidget> <customwidget>
<class>QValidatedLineEdit</class> <class>BitcoinAmountField</class>
<extends>QLineEdit</extends> <extends>QLineEdit</extends>
<header>qvalidatedlineedit.h</header> <header>bitcoinamountfield.h</header>
</customwidget> </customwidget>
</customwidgets> </customwidgets>
<tabstops>
<tabstop>payTo</tabstop>
<tabstop>addressBookButton</tabstop>
<tabstop>pasteButton</tabstop>
<tabstop>deleteButton</tabstop>
<tabstop>addAsLabel</tabstop>
<tabstop>payAmount</tabstop>
<tabstop>payAmount_is</tabstop>
<tabstop>deleteButton_is</tabstop>
<tabstop>payAmount_s</tabstop>
<tabstop>deleteButton_s</tabstop>
</tabstops>
<resources> <resources>
<include location="../bitcoin.qrc"/> <include location="../bitcoin.qrc"/>
</resources> </resources>

29
src/qt/sendcoinsdialog.cpp

@ -264,9 +264,7 @@ void SendCoinsDialog::clear()
} }
addEntry(); addEntry();
updateRemoveEnabled(); updateTabsAndLabels();
ui->sendButton->setDefault(true);
} }
void SendCoinsDialog::reject() void SendCoinsDialog::reject()
@ -287,7 +285,7 @@ SendCoinsEntry *SendCoinsDialog::addEntry()
connect(entry, SIGNAL(removeEntry(SendCoinsEntry*)), this, SLOT(removeEntry(SendCoinsEntry*))); connect(entry, SIGNAL(removeEntry(SendCoinsEntry*)), this, SLOT(removeEntry(SendCoinsEntry*)));
connect(entry, SIGNAL(payAmountChanged()), this, SLOT(coinControlUpdateLabels())); connect(entry, SIGNAL(payAmountChanged()), this, SLOT(coinControlUpdateLabels()));
updateRemoveEnabled(); updateTabsAndLabels();
// Focus the field, so that entry can start immediately // Focus the field, so that entry can start immediately
entry->clear(); entry->clear();
@ -300,27 +298,21 @@ SendCoinsEntry *SendCoinsDialog::addEntry()
return entry; return entry;
} }
void SendCoinsDialog::updateRemoveEnabled() void SendCoinsDialog::updateTabsAndLabels()
{
// Remove buttons are enabled as soon as there is more than one send-entry
bool enabled = (ui->entries->count() > 1);
for(int i = 0; i < ui->entries->count(); ++i)
{ {
SendCoinsEntry *entry = qobject_cast<SendCoinsEntry*>(ui->entries->itemAt(i)->widget());
if(entry)
{
entry->setRemoveEnabled(enabled);
}
}
setupTabChain(0); setupTabChain(0);
coinControlUpdateLabels(); coinControlUpdateLabels();
} }
void SendCoinsDialog::removeEntry(SendCoinsEntry* entry) void SendCoinsDialog::removeEntry(SendCoinsEntry* entry)
{ {
delete entry; delete entry;
updateRemoveEnabled();
// If the last entry was removed add an empty one
if (!ui->entries->count())
addEntry();
updateTabsAndLabels();
} }
QWidget *SendCoinsDialog::setupTabChain(QWidget *prev) QWidget *SendCoinsDialog::setupTabChain(QWidget *prev)
@ -379,7 +371,7 @@ void SendCoinsDialog::pasteEntry(const SendCoinsRecipient &rv)
} }
entry->setValue(rv); entry->setValue(rv);
coinControlUpdateLabels(); updateTabsAndLabels();
} }
bool SendCoinsDialog::handlePaymentRequest(const SendCoinsRecipient &rv) bool SendCoinsDialog::handlePaymentRequest(const SendCoinsRecipient &rv)
@ -619,4 +611,3 @@ void SendCoinsDialog::coinControlUpdateLabels()
ui->labelCoinControlInsuffFunds->hide(); ui->labelCoinControlInsuffFunds->hide();
} }
} }

2
src/qt/sendcoinsdialog.h

@ -46,7 +46,7 @@ public slots:
void reject(); void reject();
void accept(); void accept();
SendCoinsEntry *addEntry(); SendCoinsEntry *addEntry();
void updateRemoveEnabled(); void updateTabsAndLabels();
void setBalance(qint64 balance, qint64 unconfirmedBalance, qint64 immatureBalance); void setBalance(qint64 balance, qint64 unconfirmedBalance, qint64 immatureBalance);
private: private:

10
src/qt/sendcoinsentry.cpp

@ -75,15 +75,13 @@ void SendCoinsEntry::setModel(WalletModel *model)
connect(model->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, SLOT(updateDisplayUnit())); connect(model->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, SLOT(updateDisplayUnit()));
connect(ui->payAmount, SIGNAL(textChanged()), this, SIGNAL(payAmountChanged())); connect(ui->payAmount, SIGNAL(textChanged()), this, SIGNAL(payAmountChanged()));
connect(ui->deleteButton, SIGNAL(clicked()), this, SLOT(deleteClicked()));
connect(ui->deleteButton_is, SIGNAL(clicked()), this, SLOT(deleteClicked()));
connect(ui->deleteButton_s, SIGNAL(clicked()), this, SLOT(deleteClicked()));
clear(); clear();
} }
void SendCoinsEntry::setRemoveEnabled(bool enabled)
{
ui->deleteButton->setEnabled(enabled);
}
void SendCoinsEntry::clear() void SendCoinsEntry::clear()
{ {
// clear UI elements for normal payment // clear UI elements for normal payment
@ -105,7 +103,7 @@ void SendCoinsEntry::clear()
updateDisplayUnit(); updateDisplayUnit();
} }
void SendCoinsEntry::on_deleteButton_clicked() void SendCoinsEntry::deleteClicked()
{ {
emit removeEntry(this); emit removeEntry(this);
} }

3
src/qt/sendcoinsentry.h

@ -46,7 +46,6 @@ public:
void setFocus(); void setFocus();
public slots: public slots:
void setRemoveEnabled(bool enabled);
void clear(); void clear();
signals: signals:
@ -54,7 +53,7 @@ signals:
void payAmountChanged(); void payAmountChanged();
private slots: private slots:
void on_deleteButton_clicked(); void deleteClicked();
void on_payTo_textChanged(const QString &address); void on_payTo_textChanged(const QString &address);
void on_addressBookButton_clicked(); void on_addressBookButton_clicked();
void on_pasteButton_clicked(); void on_pasteButton_clicked();

Loading…
Cancel
Save