From 87d1248b7134ea35e3c2340b9de534370be13fc7 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Sat, 16 Feb 2019 18:46:55 +0000 Subject: [PATCH] GUI: Add a new tab for pairing --- src/Makefile.qt.include | 3 +++ src/qt/bitcoingui.cpp | 17 ++++++++++++++++- src/qt/bitcoingui.h | 3 +++ src/qt/pairingpage.cpp | 10 ++++++++++ src/qt/pairingpage.h | 18 ++++++++++++++++++ src/qt/walletframe.cpp | 9 +++++++++ src/qt/walletframe.h | 5 +++++ 7 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 src/qt/pairingpage.cpp create mode 100644 src/qt/pairingpage.h diff --git a/src/Makefile.qt.include b/src/Makefile.qt.include index 5496314a35..324fb67f83 100644 --- a/src/Makefile.qt.include +++ b/src/Makefile.qt.include @@ -64,6 +64,7 @@ QT_MOC_CPP = \ qt/moc_optionsdialog.cpp \ qt/moc_optionsmodel.cpp \ qt/moc_overviewpage.cpp \ + qt/moc_pairingpage.cpp \ qt/moc_peertablemodel.cpp \ qt/moc_peertablesortproxy.cpp \ qt/moc_paymentserver.cpp \ @@ -140,6 +141,7 @@ BITCOIN_QT_H = \ qt/optionsdialog.h \ qt/optionsmodel.h \ qt/overviewpage.h \ + qt/pairingpage.h \ qt/paymentserver.h \ qt/peertablemodel.h \ qt/peertablesortproxy.h \ @@ -265,6 +267,7 @@ BITCOIN_QT_WALLET_CPP = \ qt/editaddressdialog.cpp \ qt/openuridialog.cpp \ qt/overviewpage.cpp \ + qt/pairingpage.cpp \ qt/paymentserver.cpp \ qt/psbtoperationsdialog.cpp \ qt/qrimagewidget.cpp \ diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index 13fac9b2f8..93bee98ae5 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -280,6 +280,13 @@ void BitcoinGUI::createActions() historyAction->setShortcut(QKeySequence(QStringLiteral("Alt+4"))); tabGroup->addAction(historyAction); + m_action_pairing = new QAction(platformStyle->SingleColorIcon(":/icons/connect_1"), tr("&Pairing"), this); + m_action_pairing->setStatusTip(tr("Pair other software or devices with your node")); + m_action_pairing->setToolTip(m_action_pairing->statusTip()); + m_action_pairing->setCheckable(true); + m_action_pairing->setShortcut(QKeySequence(QStringLiteral("Alt+5"))); + tabGroup->addAction(m_action_pairing); + #ifdef ENABLE_WALLET // These showNormalIfMinimized are needed because Send Coins and Receive Coins // can be triggered from the tray menu, and need to show the GUI to be useful. @@ -291,6 +298,8 @@ void BitcoinGUI::createActions() connect(receiveCoinsAction, &QAction::triggered, this, &BitcoinGUI::gotoReceiveCoinsPage); connect(historyAction, &QAction::triggered, [this]{ showNormalIfMinimized(); }); connect(historyAction, &QAction::triggered, this, &BitcoinGUI::gotoHistoryPage); + connect(m_action_pairing, &QAction::triggered, this, [this]{ showNormalIfMinimized(); }); + connect(m_action_pairing, &QAction::triggered, this, &BitcoinGUI::gotoPairingPage); #endif // ENABLE_WALLET quitAction = new QAction(tr("E&xit"), this); @@ -615,6 +624,7 @@ void BitcoinGUI::createToolBars() toolbar->addAction(sendCoinsAction); toolbar->addAction(receiveCoinsAction); toolbar->addAction(historyAction); + toolbar->addAction(m_action_pairing); overviewAction->setChecked(true); #ifdef ENABLE_WALLET @@ -839,7 +849,6 @@ void BitcoinGUI::removeAllWallets() void BitcoinGUI::setWalletActionsEnabled(bool enabled) { - overviewAction->setEnabled(enabled); sendCoinsAction->setEnabled(enabled); receiveCoinsAction->setEnabled(enabled); historyAction->setEnabled(enabled); @@ -1022,6 +1031,12 @@ void BitcoinGUI::gotoOverviewPage() if (walletFrame) walletFrame->gotoOverviewPage(); } +void BitcoinGUI::gotoPairingPage() +{ + m_action_pairing->setChecked(true); + if (walletFrame) walletFrame->gotoPairingPage(); +} + void BitcoinGUI::gotoHistoryPage() { historyAction->setChecked(true); diff --git a/src/qt/bitcoingui.h b/src/qt/bitcoingui.h index 351256b41d..86414fbeaa 100644 --- a/src/qt/bitcoingui.h +++ b/src/qt/bitcoingui.h @@ -135,6 +135,7 @@ private: QMenuBar* appMenuBar = nullptr; QToolBar* appToolBar = nullptr; QAction* overviewAction = nullptr; + QAction* m_action_pairing = nullptr; QAction* historyAction = nullptr; QAction* quitAction = nullptr; QAction* sendCoinsAction = nullptr; @@ -283,6 +284,8 @@ public Q_SLOTS: #ifdef ENABLE_WALLET /** Switch to overview (home) page */ void gotoOverviewPage(); + /** Switch to pairing page */ + void gotoPairingPage(); /** Switch to history (transactions) page */ void gotoHistoryPage(); /** Switch to receive coins page */ diff --git a/src/qt/pairingpage.cpp b/src/qt/pairingpage.cpp new file mode 100644 index 0000000000..bedc5d32e5 --- /dev/null +++ b/src/qt/pairingpage.cpp @@ -0,0 +1,10 @@ +// Copyright (c) 2018 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include + +PairingPage::PairingPage(QWidget *parent) : + QWidget(parent) +{ +} diff --git a/src/qt/pairingpage.h b/src/qt/pairingpage.h new file mode 100644 index 0000000000..befcf3f8d6 --- /dev/null +++ b/src/qt/pairingpage.h @@ -0,0 +1,18 @@ +// Copyright (c) 2018 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef BITCOIN_QT_PAIRINGPAGE_H +#define BITCOIN_QT_PAIRINGPAGE_H + +#include + +class PairingPage : public QWidget +{ + Q_OBJECT + +public: + explicit PairingPage(QWidget *parent = nullptr); +}; + +#endif // BITCOIN_QT_PAIRINGPAGE_H diff --git a/src/qt/walletframe.cpp b/src/qt/walletframe.cpp index 825f5756d8..4e217482c6 100644 --- a/src/qt/walletframe.cpp +++ b/src/qt/walletframe.cpp @@ -2,6 +2,7 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. +#include #include #include @@ -55,6 +56,9 @@ WalletFrame::WalletFrame(const PlatformStyle* _platformStyle, QWidget* parent) no_wallet_group->setLayout(no_wallet_layout); walletStack->addWidget(no_wallet_group); + + m_page_pairing = new PairingPage(this); + m_global_stack->addWidget(m_page_pairing); } WalletFrame::~WalletFrame() = default; @@ -158,6 +162,11 @@ void WalletFrame::gotoOverviewPage() m_global_stack->setCurrentWidget(walletStack); } +void WalletFrame::gotoPairingPage() +{ + m_global_stack->setCurrentWidget(m_page_pairing); +} + void WalletFrame::gotoHistoryPage() { QMap::const_iterator i; diff --git a/src/qt/walletframe.h b/src/qt/walletframe.h index d9c5b170c6..2760714cd4 100644 --- a/src/qt/walletframe.h +++ b/src/qt/walletframe.h @@ -9,6 +9,7 @@ #include class ClientModel; +class PairingPage; class PlatformStyle; class SendCoinsRecipient; class WalletModel; @@ -57,6 +58,8 @@ private: ClientModel *clientModel; QMap mapWalletViews; + PairingPage *m_page_pairing; + bool bOutOfSync; const PlatformStyle *platformStyle; @@ -70,6 +73,8 @@ public: public Q_SLOTS: /** Switch to overview (home) page */ void gotoOverviewPage(); + /** Switch to pairing page */ + void gotoPairingPage(); /** Switch to history (transactions) page */ void gotoHistoryPage(); /** Switch to receive coins page */