aboutsummaryrefslogtreecommitdiff
path: root/src/qt/messagepage.cpp
diff options
context:
space:
mode:
authorPhilip Kaufmann <phil.kaufmann@t-online.de>2012-06-15 09:48:26 +0200
committerPhilip Kaufmann <phil.kaufmann@t-online.de>2012-07-06 11:31:27 +0200
commit47894585aeaa4f5475c50bc4415ed6ced868fbf7 (patch)
treebcde56cf582a8c1b705b7101df076eb8fb34f147 /src/qt/messagepage.cpp
parent6e3a1a374293a8a5adeb2ad464f7205e819585ee (diff)
downloadbitcoin-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/messagepage.cpp')
-rw-r--r--src/qt/messagepage.cpp143
1 files changed, 0 insertions, 143 deletions
diff --git a/src/qt/messagepage.cpp b/src/qt/messagepage.cpp
deleted file mode 100644
index ab3ea5a0c5..0000000000
--- a/src/qt/messagepage.cpp
+++ /dev/null
@@ -1,143 +0,0 @@
-#include <string>
-#include <vector>
-
-#include <QClipboard>
-#include <QInputDialog>
-#include <QList>
-#include <QListWidgetItem>
-#include <QMessageBox>
-
-#include "main.h"
-#include "wallet.h"
-#include "init.h"
-#include "base58.h"
-
-#include "messagepage.h"
-#include "ui_messagepage.h"
-
-#include "addressbookpage.h"
-#include "guiutil.h"
-#include "walletmodel.h"
-
-MessagePage::MessagePage(QWidget *parent) :
- QDialog(parent),
- ui(new Ui::MessagePage)
-{
- ui->setupUi(this);
-
-#if (QT_VERSION >= 0x040700)
- /* Do not move this to the XML file, Qt before 4.7 will choke on it */
- ui->signFrom->setPlaceholderText(tr("Enter a Bitcoin address (e.g. 1NS17iag9jJgTHD1VXjvLCEnZuQ3rJDE9L)"));
- ui->signature->setPlaceholderText(tr("Click \"Sign Message\" to get signature"));
-#endif
-
- GUIUtil::setupAddressWidget(ui->signFrom, this);
- ui->signature->installEventFilter(this);
-
- ui->signFrom->setFocus();
-}
-
-MessagePage::~MessagePage()
-{
- delete ui;
-}
-
-void MessagePage::setModel(WalletModel *model)
-{
- this->model = model;
-}
-
-void MessagePage::setAddress(QString addr)
-{
- ui->signFrom->setText(addr);
- ui->message->setFocus();
-}
-
-void MessagePage::on_pasteButton_clicked()
-{
- setAddress(QApplication::clipboard()->text());
-}
-
-void MessagePage::on_addressBookButton_clicked()
-{
- AddressBookPage dlg(AddressBookPage::ForSending, AddressBookPage::ReceivingTab, this);
- dlg.setModel(model->getAddressTableModel());
- if(dlg.exec())
- {
- setAddress(dlg.getReturnValue());
- }
-}
-
-void MessagePage::on_copyToClipboard_clicked()
-{
- QApplication::clipboard()->setText(ui->signature->text());
-}
-
-void MessagePage::on_signMessage_clicked()
-{
- QString address = ui->signFrom->text();
-
- CBitcoinAddress addr(address.toStdString());
- if (!addr.IsValid())
- {
- QMessageBox::critical(this, tr("Error signing"), tr("%1 is not a valid address.").arg(address),
- QMessageBox::Abort, QMessageBox::Abort);
- return;
- }
- CKeyID keyID;
- if (!addr.GetKeyID(keyID))
- {
- QMessageBox::critical(this, tr("Error signing"), tr("%1 does not refer to a key.").arg(address),
- QMessageBox::Abort, QMessageBox::Abort);
- return;
- }
-
- WalletModel::UnlockContext ctx(model->requestUnlock());
- if(!ctx.isValid())
- {
- // Unlock wallet was cancelled
- return;
- }
-
- CKey key;
- if (!pwalletMain->GetKey(keyID, key))
- {
- QMessageBox::critical(this, tr("Error signing"), tr("Private key for %1 is not available.").arg(address),
- QMessageBox::Abort, QMessageBox::Abort);
- return;
- }
-
- CDataStream ss(SER_GETHASH, 0);
- ss << strMessageMagic;
- ss << ui->message->document()->toPlainText().toStdString();
-
- std::vector<unsigned char> vchSig;
- if (!key.SignCompact(Hash(ss.begin(), ss.end()), vchSig))
- {
- QMessageBox::critical(this, tr("Error signing"), tr("Sign failed"),
- QMessageBox::Abort, QMessageBox::Abort);
- }
-
- ui->signature->setText(QString::fromStdString(EncodeBase64(&vchSig[0], vchSig.size())));
- ui->signature->setFont(GUIUtil::bitcoinAddressFont());
-}
-
-void MessagePage::on_clearButton_clicked()
-{
- ui->signFrom->clear();
- ui->message->clear();
- ui->signature->clear();
-
- ui->signFrom->setFocus();
-}
-
-bool MessagePage::eventFilter(QObject *object, QEvent *event)
-{
- if(object == ui->signature && (event->type() == QEvent::MouseButtonPress ||
- event->type() == QEvent::FocusIn))
- {
- ui->signature->selectAll();
- return true;
- }
- return QDialog::eventFilter(object, event);
-}