From 34aa3112c8d3366303873fbd217e23d9cba798e4 Mon Sep 17 00:00:00 2001 From: Philip Kaufmann Date: Mon, 14 May 2012 23:22:45 +0200 Subject: [PATCH] adapt user-experience from messagepage / move placeholderTexts from XML to source to avoid a problem with Qt < 4.7 / add eventFilter for address field to select text when clicking in / add Clear All button / rework strings --- src/qt/forms/verifymessagedialog.ui | 84 +++++++++++------------------ src/qt/verifymessagedialog.cpp | 35 ++++++++++-- src/qt/verifymessagedialog.h | 19 +++---- 3 files changed, 72 insertions(+), 66 deletions(-) diff --git a/src/qt/forms/verifymessagedialog.ui b/src/qt/forms/verifymessagedialog.ui index 6b7f94258b..a7c99716e4 100644 --- a/src/qt/forms/verifymessagedialog.ui +++ b/src/qt/forms/verifymessagedialog.ui @@ -17,7 +17,7 @@ - Enter the message and signature below (be careful to correctly copy newlines, spaces, tabs, and other invisible characters), and press apply to obtain the bitcoin address used to sign the message. + Enter the message and signature below (be careful to correctly copy newlines, spaces, tabs and other invisible characters) to obtain the Bitcoin address used to sign the message. Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop @@ -35,9 +35,6 @@ - - Signature - @@ -48,9 +45,6 @@ true - - Address - @@ -62,6 +56,20 @@ + + + + Verify a message and obtain the Bitcoin address used to sign the message + + + &Verify Message + + + + :/icons/transaction_0:/icons/transaction_0 + + + @@ -79,6 +87,20 @@ + + + + Reset all verify message fields + + + Clear &All + + + + :/icons/remove:/icons/remove + + + @@ -92,19 +114,6 @@ - - - - Qt::Horizontal - - - QDialogButtonBox::Apply|QDialogButtonBox::Close - - - false - - - @@ -112,38 +121,5 @@ - - - buttonBox - accepted() - VerifyMessageDialog - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - VerifyMessageDialog - reject() - - - 316 - 260 - - - 286 - 274 - - - - + diff --git a/src/qt/verifymessagedialog.cpp b/src/qt/verifymessagedialog.cpp index 8842908718..1f82e2ac31 100644 --- a/src/qt/verifymessagedialog.cpp +++ b/src/qt/verifymessagedialog.cpp @@ -22,7 +22,16 @@ VerifyMessageDialog::VerifyMessageDialog(AddressTableModel *addressModel, QWidge { ui->setupUi(this); +#if (QT_VERSION >= 0x040700) + /* Do not move this to the XML file, Qt before 4.7 will choke on it */ + ui->lnSig->setPlaceholderText(tr("Enter Bitcoin signature")); + ui->lnAddress->setPlaceholderText(tr("Click \"Apply\" to obtain address")); +#endif + GUIUtil::setupAddressWidget(ui->lnAddress, this); + ui->lnAddress->installEventFilter(this); + + ui->edMessage->setFocus(); } VerifyMessageDialog::~VerifyMessageDialog() @@ -63,13 +72,33 @@ bool VerifyMessageDialog::checkAddress() return true; } -void VerifyMessageDialog::on_buttonBox_clicked(QAbstractButton *button) +void VerifyMessageDialog::on_verifyMessage_clicked() { - if(ui->buttonBox->buttonRole(button) == QDialogButtonBox::ApplyRole) - checkAddress(); + checkAddress(); } void VerifyMessageDialog::on_copyToClipboard_clicked() { QApplication::clipboard()->setText(ui->lnAddress->text()); } + +void VerifyMessageDialog::on_clearButton_clicked() +{ + ui->edMessage->clear(); + ui->lnSig->clear(); + ui->lnAddress->clear(); + ui->lblStatus->clear(); + + ui->edMessage->setFocus(); +} + +bool VerifyMessageDialog::eventFilter(QObject *object, QEvent *event) +{ + if(object == ui->lnAddress && (event->type() == QEvent::MouseButtonPress || + event->type() == QEvent::FocusIn)) + { + ui->lnAddress->selectAll(); + return true; + } + return QDialog::eventFilter(object, event); +} diff --git a/src/qt/verifymessagedialog.h b/src/qt/verifymessagedialog.h index 6a641f7731..9a3fb43415 100644 --- a/src/qt/verifymessagedialog.h +++ b/src/qt/verifymessagedialog.h @@ -3,16 +3,14 @@ #include +namespace Ui { + class VerifyMessageDialog; +} class AddressTableModel; QT_BEGIN_NAMESPACE -class QAbstractButton; QT_END_NAMESPACE -namespace Ui { - class VerifyMessageDialog; -} - class VerifyMessageDialog : public QDialog { Q_OBJECT @@ -21,16 +19,19 @@ public: explicit VerifyMessageDialog(AddressTableModel *addressModel, QWidget *parent = 0); ~VerifyMessageDialog(); -private slots: - void on_buttonBox_clicked(QAbstractButton *button); - - void on_copyToClipboard_clicked(); +protected: + bool eventFilter(QObject *object, QEvent *event); private: bool checkAddress(); Ui::VerifyMessageDialog *ui; AddressTableModel *model; + +private slots: + void on_verifyMessage_clicked(); + void on_copyToClipboard_clicked(); + void on_clearButton_clicked(); }; #endif // VERIFYMESSAGEDIALOG_H