Skip to content

Commit

Permalink
replace some ugly code in addressbookpage.cpp
Browse files Browse the repository at this point in the history
- add signals signMessage() and verifyMessage() in addressbookpage.cpp
- connect to them in bitcoingui.cpp to switch to the corresponding tab in the Sign/Verify Message dialog
- make gotoSignMessageTab() and gotoVerifyMessageTab() private slots
  • Loading branch information
Philip Kaufmann committed Jul 8, 2012
1 parent ea53f18 commit ddadf79
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
10 changes: 2 additions & 8 deletions src/qt/addressbookpage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,7 @@ void AddressBookPage::on_signMessage_clicked()
addr = address.toString();
}

QObject *qoGUI = parent()->parent();
BitcoinGUI *gui = qobject_cast<BitcoinGUI *>(qoGUI);
if (gui)
gui->gotoSignMessageTab(addr);
emit signMessage(addr);
}

void AddressBookPage::on_verifyMessage_clicked()
Expand All @@ -208,10 +205,7 @@ void AddressBookPage::on_verifyMessage_clicked()
addr = address.toString();
}

QObject *qoGUI = parent()->parent();
BitcoinGUI *gui = qobject_cast<BitcoinGUI *>(qoGUI);
if (gui)
gui->gotoVerifyMessageTab(addr);
emit verifyMessage(addr);
}

void AddressBookPage::on_newAddressButton_clicked()
Expand Down
4 changes: 4 additions & 0 deletions src/qt/addressbookpage.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ private slots:

/** New entry/entries were added to address table */
void selectNewAddress(const QModelIndex &parent, int begin, int end);

signals:
void signMessage(QString addr);
void verifyMessage(QString addr);
};

#endif // ADDRESSBOOKDIALOG_H
5 changes: 5 additions & 0 deletions src/qt/bitcoingui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,11 @@ BitcoinGUI::BitcoinGUI(QWidget *parent):
rpcConsole = new RPCConsole(this);
connect(openRPCConsoleAction, SIGNAL(triggered()), rpcConsole, SLOT(show()));

// Clicking on "Verify Message" in the address book sends you to the verify message tab
connect(addressBookPage, SIGNAL(verifyMessage(QString)), this, SLOT(gotoVerifyMessageTab(QString)));
// Clicking on "Sign Message" in the receive coins page sends you to the sign message tab
connect(receiveCoinsPage, SIGNAL(signMessage(QString)), this, SLOT(gotoSignMessageTab(QString)));

gotoOverviewPage();
}

Expand Down
8 changes: 5 additions & 3 deletions src/qt/bitcoingui.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,6 @@ public slots:
void askFee(qint64 nFeeRequired, bool *payFee);
void handleURI(QString strURI);

void gotoSignMessageTab(QString addr = "");
void gotoVerifyMessageTab(QString addr = "");

private slots:
/** Switch to overview (home) page */
void gotoOverviewPage();
Expand All @@ -147,6 +144,11 @@ private slots:
/** Switch to send coins page */
void gotoSendCoinsPage();

/** Show Sign/Verify Message dialog and switch to sign message tab */
void gotoSignMessageTab(QString addr = "");
/** Show Sign/Verify Message dialog and switch to verify message tab */
void gotoVerifyMessageTab(QString addr = "");

/** Show configuration dialog */
void optionsClicked();
/** Show about dialog */
Expand Down

0 comments on commit ddadf79

Please sign in to comment.