aboutsummaryrefslogtreecommitdiff
path: root/src/qt
diff options
context:
space:
mode:
authorPhilip Kaufmann <phil.kaufmann@t-online.de>2013-01-25 18:46:53 +0100
committerPhilip Kaufmann <phil.kaufmann@t-online.de>2013-03-18 07:44:22 +0100
commit311993ab106c250a1779bfdb649cf4f8c2416fb5 (patch)
tree5a103deacc3066bf1733b843dbfe60186995e0cc /src/qt
parent74e4d80068f9c29d4891439332b4027328c8584b (diff)
Bitcoin-Qt: add "send coins" to context menu in addressbook
- allows to directly select an address from the addressbook, chose "send coins" from the context menu, which sends you to sendcoins tab and fills in the selected address
Diffstat (limited to 'src/qt')
-rw-r--r--src/qt/addressbookpage.cpp16
-rw-r--r--src/qt/addressbookpage.h3
-rw-r--r--src/qt/bitcoingui.cpp11
-rw-r--r--src/qt/bitcoingui.h2
-rw-r--r--src/qt/sendcoinsdialog.cpp20
-rw-r--r--src/qt/sendcoinsdialog.h1
-rw-r--r--src/qt/sendcoinsentry.cpp6
-rw-r--r--src/qt/sendcoinsentry.h1
8 files changed, 56 insertions, 4 deletions
diff --git a/src/qt/addressbookpage.cpp b/src/qt/addressbookpage.cpp
index b53a37fc22..9e35e51bbf 100644
--- a/src/qt/addressbookpage.cpp
+++ b/src/qt/addressbookpage.cpp
@@ -65,6 +65,7 @@ AddressBookPage::AddressBookPage(Mode mode, Tabs tab, QWidget *parent) :
QAction *copyAddressAction = new QAction(ui->copyToClipboard->text(), this);
QAction *copyLabelAction = new QAction(tr("Copy &Label"), this);
QAction *editAction = new QAction(tr("&Edit"), this);
+ QAction *sendCoinsAction = new QAction(tr("Send &Coins"), this);
QAction *showQRCodeAction = new QAction(ui->showQRCode->text(), this);
QAction *signMessageAction = new QAction(ui->signMessage->text(), this);
QAction *verifyMessageAction = new QAction(ui->verifyMessage->text(), this);
@@ -78,6 +79,8 @@ AddressBookPage::AddressBookPage(Mode mode, Tabs tab, QWidget *parent) :
if(tab == SendingTab)
contextMenu->addAction(deleteAction);
contextMenu->addSeparator();
+ if(tab == SendingTab)
+ contextMenu->addAction(sendCoinsAction);
#ifdef USE_QRCODE
contextMenu->addAction(showQRCodeAction);
#endif
@@ -91,6 +94,7 @@ AddressBookPage::AddressBookPage(Mode mode, Tabs tab, QWidget *parent) :
connect(copyLabelAction, SIGNAL(triggered()), this, SLOT(onCopyLabelAction()));
connect(editAction, SIGNAL(triggered()), this, SLOT(onEditAction()));
connect(deleteAction, SIGNAL(triggered()), this, SLOT(on_deleteButton_clicked()));
+ connect(sendCoinsAction, SIGNAL(triggered()), this, SLOT(onSendCoins_clicked()));
connect(showQRCodeAction, SIGNAL(triggered()), this, SLOT(on_showQRCode_clicked()));
connect(signMessageAction, SIGNAL(triggered()), this, SLOT(on_signMessage_clicked()));
connect(verifyMessageAction, SIGNAL(triggered()), this, SLOT(on_verifyMessage_clicked()));
@@ -206,6 +210,18 @@ void AddressBookPage::on_verifyMessage_clicked()
}
}
+void AddressBookPage::onSendCoins_clicked()
+{
+ QTableView *table = ui->tableView;
+ QModelIndexList indexes = table->selectionModel()->selectedRows(AddressTableModel::Address);
+
+ foreach (QModelIndex index, indexes)
+ {
+ QString address = index.data().toString();
+ emit sendCoins(address);
+ }
+}
+
void AddressBookPage::on_newAddressButton_clicked()
{
if(!model)
diff --git a/src/qt/addressbookpage.h b/src/qt/addressbookpage.h
index c676d1e941..c6653a5e8a 100644
--- a/src/qt/addressbookpage.h
+++ b/src/qt/addressbookpage.h
@@ -68,6 +68,8 @@ private slots:
void on_signMessage_clicked();
/** Open the verify message tab in the Sign/Verify Message dialog with currently selected address */
void on_verifyMessage_clicked();
+ /** Open send coins dialog for currently selected address (no button) */
+ void onSendCoins_clicked();
/** Generate a QR Code from the currently selected address */
void on_showQRCode_clicked();
/** Copy label of currently selected address entry to clipboard (no button) */
@@ -85,6 +87,7 @@ private slots:
signals:
void signMessage(QString addr);
void verifyMessage(QString addr);
+ void sendCoins(QString addr);
};
#endif // ADDRESSBOOKPAGE_H
diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp
index 4f97a4815f..0d951718bb 100644
--- a/src/qt/bitcoingui.cpp
+++ b/src/qt/bitcoingui.cpp
@@ -172,9 +172,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
+ // Clicking on "Send Coins" in the address book sends you to the send coins tab
+ connect(addressBookPage, SIGNAL(sendCoins(QString)), this, SLOT(gotoSendCoinsPage(QString)));
+ // Clicking on "Verify Message" in the address book opens the verify message tab in the Sign/Verify Message dialog
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
+ // Clicking on "Sign Message" in the receive coins page opens the sign message tab in the Sign/Verify Message dialog
connect(receiveCoinsPage, SIGNAL(signMessage(QString)), this, SLOT(gotoSignMessageTab(QString)));
// Install event filter to be able to catch status tip events (QEvent::StatusTip)
@@ -758,13 +760,16 @@ void BitcoinGUI::gotoReceiveCoinsPage()
connect(exportAction, SIGNAL(triggered()), receiveCoinsPage, SLOT(exportClicked()));
}
-void BitcoinGUI::gotoSendCoinsPage()
+void BitcoinGUI::gotoSendCoinsPage(QString addr)
{
sendCoinsAction->setChecked(true);
centralWidget->setCurrentWidget(sendCoinsPage);
exportAction->setEnabled(false);
disconnect(exportAction, SIGNAL(triggered()), 0, 0);
+
+ if(!addr.isEmpty())
+ sendCoinsPage->setAddress(addr);
}
void BitcoinGUI::gotoSignMessageTab(QString addr)
diff --git a/src/qt/bitcoingui.h b/src/qt/bitcoingui.h
index b992bfdc69..1b3e313fc2 100644
--- a/src/qt/bitcoingui.h
+++ b/src/qt/bitcoingui.h
@@ -149,7 +149,7 @@ private slots:
/** Switch to receive coins page */
void gotoReceiveCoinsPage();
/** Switch to send coins page */
- void gotoSendCoinsPage();
+ void gotoSendCoinsPage(QString addr = "");
/** Show Sign/Verify Message dialog and switch to sign message tab */
void gotoSignMessageTab(QString addr = "");
diff --git a/src/qt/sendcoinsdialog.cpp b/src/qt/sendcoinsdialog.cpp
index 56392f96dd..2133a5e729 100644
--- a/src/qt/sendcoinsdialog.cpp
+++ b/src/qt/sendcoinsdialog.cpp
@@ -245,6 +245,26 @@ QWidget *SendCoinsDialog::setupTabChain(QWidget *prev)
return ui->sendButton;
}
+void SendCoinsDialog::setAddress(const QString &address)
+{
+ SendCoinsEntry *entry = 0;
+ // Replace the first entry if it is still unused
+ if(ui->entries->count() == 1)
+ {
+ SendCoinsEntry *first = qobject_cast<SendCoinsEntry*>(ui->entries->itemAt(0)->widget());
+ if(first->isClear())
+ {
+ entry = first;
+ }
+ }
+ if(!entry)
+ {
+ entry = addEntry();
+ }
+
+ entry->setAddress(address);
+}
+
void SendCoinsDialog::pasteEntry(const SendCoinsRecipient &rv)
{
if(!fNewRecipientAllowed)
diff --git a/src/qt/sendcoinsdialog.h b/src/qt/sendcoinsdialog.h
index 8a6e050c11..043dfdcb40 100644
--- a/src/qt/sendcoinsdialog.h
+++ b/src/qt/sendcoinsdialog.h
@@ -29,6 +29,7 @@ public:
*/
QWidget *setupTabChain(QWidget *prev);
+ void setAddress(const QString &address);
void pasteEntry(const SendCoinsRecipient &rv);
bool handleURI(const QString &uri);
diff --git a/src/qt/sendcoinsentry.cpp b/src/qt/sendcoinsentry.cpp
index 7dbca24084..876b7f808b 100644
--- a/src/qt/sendcoinsentry.cpp
+++ b/src/qt/sendcoinsentry.cpp
@@ -153,6 +153,12 @@ void SendCoinsEntry::setValue(const SendCoinsRecipient &value)
ui->payAmount->setValue(value.amount);
}
+void SendCoinsEntry::setAddress(const QString &address)
+{
+ ui->payTo->setText(address);
+ ui->payAmount->setFocus();
+}
+
bool SendCoinsEntry::isClear()
{
return ui->payTo->text().isEmpty();
diff --git a/src/qt/sendcoinsentry.h b/src/qt/sendcoinsentry.h
index 0ac14c1472..ec5f3410c1 100644
--- a/src/qt/sendcoinsentry.h
+++ b/src/qt/sendcoinsentry.h
@@ -26,6 +26,7 @@ public:
bool isClear();
void setValue(const SendCoinsRecipient &value);
+ void setAddress(const QString &address);
/** Set up the tab chain manually, as Qt messes up the tab chain by default in some cases (issue https://bugreports.qt-project.org/browse/QTBUG-10907).
*/