GUI: Add a new tab for pairing

This commit is contained in:
Luke Dashjr 2019-02-16 18:46:55 +00:00
parent 2649e679a7
commit 87d1248b71
7 changed files with 64 additions and 1 deletions

View File

@ -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 \

View File

@ -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);

View File

@ -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 */

10
src/qt/pairingpage.cpp Normal file
View File

@ -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 <qt/pairingpage.h>
PairingPage::PairingPage(QWidget *parent) :
QWidget(parent)
{
}

18
src/qt/pairingpage.h Normal file
View File

@ -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 <QWidget>
class PairingPage : public QWidget
{
Q_OBJECT
public:
explicit PairingPage(QWidget *parent = nullptr);
};
#endif // BITCOIN_QT_PAIRINGPAGE_H

View File

@ -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 <qt/pairingpage.h>
#include <qt/walletframe.h>
#include <node/interface_ui.h>
@ -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<WalletModel*, WalletView*>::const_iterator i;

View File

@ -9,6 +9,7 @@
#include <QMap>
class ClientModel;
class PairingPage;
class PlatformStyle;
class SendCoinsRecipient;
class WalletModel;
@ -57,6 +58,8 @@ private:
ClientModel *clientModel;
QMap<WalletModel*, WalletView*> 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 */