Skip to content

Commit e820e44

Browse files
committed
gui: make error message layout in editaddressdialog consistent
1 parent fa3b835 commit e820e44

3 files changed

Lines changed: 64 additions & 43 deletions

File tree

src/qt/editaddressdialog.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44

55
#include <qt/editaddressdialog.h>
6-
#include <qt/forms/ui_editaddressdialog.h>
76

7+
#include <key_io.h>
88
#include <qt/addresstablemodel.h>
9+
#include <qt/forms/ui_editaddressdialog.h>
910
#include <qt/guiutil.h>
1011

1112
#include <QDataWidgetMapper>
@@ -44,6 +45,8 @@ EditAddressDialog::EditAddressDialog(Mode _mode, QWidget *parent) :
4445
connect(delegate, &GUIUtil::ItemDelegate::keyEscapePressed, this, &EditAddressDialog::reject);
4546
mapper->setItemDelegate(delegate);
4647

48+
connect(ui->addressEdit, &QValidatedLineEdit::textEdited, this, &EditAddressDialog::addressEdited);
49+
4750
GUIUtil::handleCloseWindowShortcut(this);
4851
}
4952

@@ -164,3 +167,15 @@ void EditAddressDialog::setAddress(const QString &_address)
164167
this->address = _address;
165168
ui->addressEdit->setText(_address);
166169
}
170+
171+
// Address changed
172+
void EditAddressDialog::addressEdited(const QString& address)
173+
{
174+
ui->addressErrorLabel->setStyleSheet("QLabel{color:red;}");
175+
176+
if (!address.isEmpty() && !IsValidDestination(DecodeDestination(address.toStdString()))) {
177+
ui->addressErrorLabel->setText(tr("Warning: Invalid Bitcoin address"));
178+
} else {
179+
ui->addressErrorLabel->setText("");
180+
}
181+
}

src/qt/editaddressdialog.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ class EditAddressDialog : public QDialog
4242
public Q_SLOTS:
4343
void accept() override;
4444

45+
private Q_SLOTS:
46+
void addressEdited(const QString& address);
47+
4548
private:
4649
bool saveCurrentRow();
4750

src/qt/forms/editaddressdialog.ui

Lines changed: 45 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -6,56 +6,59 @@
66
<rect>
77
<x>0</x>
88
<y>0</y>
9-
<width>457</width>
9+
<width>537</width>
1010
<height>126</height>
1111
</rect>
1212
</property>
1313
<property name="windowTitle">
1414
<string>Edit Address</string>
1515
</property>
16-
<layout class="QVBoxLayout" name="verticalLayout">
17-
<item>
18-
<layout class="QFormLayout" name="formLayout">
19-
<property name="fieldGrowthPolicy">
20-
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
16+
<layout class="QGridLayout" name="gridLayout">
17+
<item row="1" column="1">
18+
<widget class="QValidatedLineEdit" name="addressEdit">
19+
<property name="toolTip">
20+
<string>The address associated with this address list entry. This can only be modified for sending addresses.</string>
2121
</property>
22-
<item row="0" column="0">
23-
<widget class="QLabel" name="label">
24-
<property name="text">
25-
<string>&amp;Label</string>
26-
</property>
27-
<property name="buddy">
28-
<cstring>labelEdit</cstring>
29-
</property>
30-
</widget>
31-
</item>
32-
<item row="0" column="1">
33-
<widget class="QLineEdit" name="labelEdit">
34-
<property name="toolTip">
35-
<string>The label associated with this address list entry</string>
36-
</property>
37-
</widget>
38-
</item>
39-
<item row="1" column="0">
40-
<widget class="QLabel" name="label_2">
41-
<property name="text">
42-
<string>&amp;Address</string>
43-
</property>
44-
<property name="buddy">
45-
<cstring>addressEdit</cstring>
46-
</property>
47-
</widget>
48-
</item>
49-
<item row="1" column="1">
50-
<widget class="QValidatedLineEdit" name="addressEdit">
51-
<property name="toolTip">
52-
<string>The address associated with this address list entry. This can only be modified for sending addresses.</string>
53-
</property>
54-
</widget>
55-
</item>
56-
</layout>
22+
</widget>
23+
</item>
24+
<item row="1" column="0">
25+
<widget class="QLabel" name="label_2">
26+
<property name="text">
27+
<string>&amp;Address</string>
28+
</property>
29+
<property name="buddy">
30+
<cstring>addressEdit</cstring>
31+
</property>
32+
</widget>
33+
</item>
34+
<item row="0" column="0">
35+
<widget class="QLabel" name="label">
36+
<property name="text">
37+
<string>&amp;Label</string>
38+
</property>
39+
<property name="buddy">
40+
<cstring>labelEdit</cstring>
41+
</property>
42+
</widget>
43+
</item>
44+
<item row="1" column="2">
45+
<widget class="QLabel" name="addressErrorLabel">
46+
<property name="text">
47+
<string/>
48+
</property>
49+
</widget>
50+
</item>
51+
<item row="0" column="1" colspan="2">
52+
<widget class="QLineEdit" name="labelEdit">
53+
<property name="toolTip">
54+
<string>The label associated with this address list entry</string>
55+
</property>
56+
<property name="frame">
57+
<bool>true</bool>
58+
</property>
59+
</widget>
5760
</item>
58-
<item>
61+
<item row="2" column="0" colspan="3">
5962
<widget class="QDialogButtonBox" name="buttonBox">
6063
<property name="orientation">
6164
<enum>Qt::Horizontal</enum>

0 commit comments

Comments
 (0)