diff options
author | Philip Kaufmann <phil.kaufmann@t-online.de> | 2012-06-15 09:48:26 +0200 |
---|---|---|
committer | Philip Kaufmann <phil.kaufmann@t-online.de> | 2012-07-06 11:31:27 +0200 |
commit | 47894585aeaa4f5475c50bc4415ed6ced868fbf7 (patch) | |
tree | bcde56cf582a8c1b705b7101df076eb8fb34f147 /src/qt/verifymessagedialog.cpp | |
parent | 6e3a1a374293a8a5adeb2ad464f7205e819585ee (diff) | |
download | bitcoin-47894585aeaa4f5475c50bc4415ed6ced868fbf7.tar.xz |
GUI: merge sign/verify message into a single window with tabbed UI
- add UI-feedback via QValidatedLineEdit
- copy button for generated signature was moved to the signature output field
- add an addressbook button to verify message tab
- input fields are now evenly ordered for sign and verify tabs
- update FIRST_CLASS_MESSAGING support to ensure a good UX
- add a button and context menu entry in addressbook for verify message (to be consistent with sign message)
- focus is now only set/changed, when clearing input fields or adding an address via addressbook
- re-work / update some strings
- ensure model gets initialized in the SignVerifyMessageDialog constructor
- add checks for a valid model to both addressbook buttons
- remove unneeded includes for Qt GUI elements that are listed in ui_signverifymessagedialog.h anyway
Diffstat (limited to 'src/qt/verifymessagedialog.cpp')
-rw-r--r-- | src/qt/verifymessagedialog.cpp | 119 |
1 files changed, 0 insertions, 119 deletions
diff --git a/src/qt/verifymessagedialog.cpp b/src/qt/verifymessagedialog.cpp deleted file mode 100644 index 92f58328a4..0000000000 --- a/src/qt/verifymessagedialog.cpp +++ /dev/null @@ -1,119 +0,0 @@ -#include "verifymessagedialog.h" -#include "ui_verifymessagedialog.h" - -#include <string> -#include <vector> - -#include <QDialog> -#include <QLabel> -#include <QLineEdit> -#include <QPlainTextEdit> -#include <QPushButton> - -#include "main.h" -#include "wallet.h" -#include "walletmodel.h" -#include "guiutil.h" -#include "base58.h" - -VerifyMessageDialog::VerifyMessageDialog(QWidget *parent) : - QDialog(parent), - ui(new Ui::VerifyMessageDialog) -{ - ui->setupUi(this); - -#if (QT_VERSION >= 0x040700) - /* Do not move this to the XML file, Qt before 4.7 will choke on it */ - ui->lnAddress->setPlaceholderText(tr("Enter a Bitcoin address (e.g. 1NS17iag9jJgTHD1VXjvLCEnZuQ3rJDE9L)")); - ui->lnSig->setPlaceholderText(tr("Enter Bitcoin signature")); -#endif - - GUIUtil::setupAddressWidget(ui->lnAddress, this); - ui->lnAddress->installEventFilter(this); - - ui->lnSig->setFont(GUIUtil::bitcoinAddressFont()); - - ui->lnAddress->setFocus(); -} - -VerifyMessageDialog::~VerifyMessageDialog() -{ - delete ui; -} - -void VerifyMessageDialog::on_verifyMessage_clicked() -{ - CBitcoinAddress addr(ui->lnAddress->text().toStdString()); - if (!addr.IsValid()) - { - ui->lnAddress->setValid(false); - ui->lblStatus->setStyleSheet("QLabel { color: red; }"); - ui->lblStatus->setText(tr("\"%1\" is not a valid address.").arg(ui->lnAddress->text()) + QString(" ") + tr("Please check the address and try again.")); - return; - } - CKeyID keyID; - if (!addr.GetKeyID(keyID)) - { - ui->lnAddress->setValid(false); - ui->lblStatus->setStyleSheet("QLabel { color: red; }"); - ui->lblStatus->setText(tr("\"%1\" does not refer to a key.").arg(ui->lnAddress->text()) + QString(" ") + tr("Please check the address and try again.")); - return; - } - - bool fInvalid = false; - std::vector<unsigned char> vchSig = DecodeBase64(ui->lnSig->text().toStdString().c_str(), &fInvalid); - - if (fInvalid) - { - ui->lnSig->setValid(false); - ui->lblStatus->setStyleSheet("QLabel { color: red; }"); - ui->lblStatus->setText(tr("The signature could not be decoded.") + QString(" ") + tr("Please check the signature and try again.")); - return; - } - - CDataStream ss(SER_GETHASH, 0); - ss << strMessageMagic; - ss << ui->edMessage->document()->toPlainText().toStdString(); - - CKey key; - if (!key.SetCompactSignature(Hash(ss.begin(), ss.end()), vchSig)) - { - ui->lnSig->setValid(false); - ui->lblStatus->setStyleSheet("QLabel { color: red; }"); - ui->lblStatus->setText(tr("The signature did not match the message digest.")+ QString(" ") + tr("Please check the signature and try again.")); - return; - } - - if (!(CBitcoinAddress(key.GetPubKey().GetID()) == addr)) - { - ui->lblStatus->setStyleSheet("QLabel { color: red; }"); - ui->lblStatus->setText(QString("<nobr>") + tr("Message verification failed.") + QString("</nobr>")); - return; - } - - ui->lblStatus->setStyleSheet("QLabel { color: green; }"); - ui->lblStatus->setText(QString("<nobr>") + tr("Message verified.") + QString("</nobr>")); -} - -void VerifyMessageDialog::on_clearButton_clicked() -{ - ui->lnAddress->clear(); - ui->lnSig->clear(); - ui->edMessage->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)) - { - // set lnAddress to valid, as QEvent::FocusIn would not reach QValidatedLineEdit::focusInEvent - ui->lnAddress->setValid(true); - ui->lnAddress->selectAll(); - return true; - } - return QDialog::eventFilter(object, event); -} |