mirror of
https://github.com/feather-wallet/feather.git
synced 2024-12-22 11:39:25 +00:00
contacts: allow swapping name and address
This commit is contained in:
parent
7e74d0e1d1
commit
7e19d52788
2 changed files with 23 additions and 11 deletions
|
@ -126,11 +126,23 @@ void ContactsWidget::newContact(QString address, QString name)
|
|||
name = dialog.getName();
|
||||
|
||||
bool addressValid = WalletManager::addressValid(address, m_wallet->nettype());
|
||||
if (!addressValid) {
|
||||
bool nameIsAddress = WalletManager::addressValid(name, m_wallet->nettype());
|
||||
|
||||
if (addressValid && nameIsAddress) {
|
||||
Utils::showError(this, "Unable to add contact", "Name can not be an address", {}, "add_contact");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!addressValid && !nameIsAddress) {
|
||||
Utils::showError(this, "Unable to add contact", "Invalid address", {"Use 'Tools -> Address checker' to check if the address is valid."}, "add_contact");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!addressValid && nameIsAddress) {
|
||||
// User accidentally swapped name and address, allow it
|
||||
std::swap(address, name);
|
||||
}
|
||||
|
||||
int num_addresses = m_wallet->addressBook()->count();
|
||||
QString address_entry;
|
||||
QString name_entry;
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>136</height>
|
||||
<height>131</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
@ -17,13 +17,6 @@
|
|||
<item>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Address</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Name</string>
|
||||
|
@ -31,10 +24,17 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="lineEdit_address"/>
|
||||
<widget class="QLineEdit" name="lineEdit_name"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Address</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="lineEdit_name"/>
|
||||
<widget class="QLineEdit" name="lineEdit_address"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
|
|
Loading…
Reference in a new issue