mirror of
https://github.com/feather-wallet/feather.git
synced 2024-12-22 19:49:28 +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();
|
name = dialog.getName();
|
||||||
|
|
||||||
bool addressValid = WalletManager::addressValid(address, m_wallet->nettype());
|
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");
|
Utils::showError(this, "Unable to add contact", "Invalid address", {"Use 'Tools -> Address checker' to check if the address is valid."}, "add_contact");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!addressValid && nameIsAddress) {
|
||||||
|
// User accidentally swapped name and address, allow it
|
||||||
|
std::swap(address, name);
|
||||||
|
}
|
||||||
|
|
||||||
int num_addresses = m_wallet->addressBook()->count();
|
int num_addresses = m_wallet->addressBook()->count();
|
||||||
QString address_entry;
|
QString address_entry;
|
||||||
QString name_entry;
|
QString name_entry;
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>400</width>
|
<width>400</width>
|
||||||
<height>136</height>
|
<height>131</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
|
@ -17,13 +17,6 @@
|
||||||
<item>
|
<item>
|
||||||
<layout class="QFormLayout" name="formLayout">
|
<layout class="QFormLayout" name="formLayout">
|
||||||
<item row="0" column="0">
|
<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">
|
<widget class="QLabel" name="label_3">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Name</string>
|
<string>Name</string>
|
||||||
|
@ -31,10 +24,17 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1">
|
<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>
|
||||||
<item row="1" column="1">
|
<item row="1" column="1">
|
||||||
<widget class="QLineEdit" name="lineEdit_name"/>
|
<widget class="QLineEdit" name="lineEdit_address"/>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
|
Loading…
Reference in a new issue