mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-12-13 22:24:05 +01:00
Merge #12610: Multiwallet for the GUI
779c5f984Qt: hide RPCConsole wallet selector when no wallets are present (Jonas Schnelli)dc6f150f3Qt: show wallet name in request dlg in case of multiwallet (Jonas Schnelli)4826ca4b8Qt: show wallet name in send confirmation dlg in case of multiwallet (Jonas Schnelli)cfa4133ceGUI: RPCConsole: Log wallet changes (Luke Dashjr)b6d04fc7cQt: Get wallet name from WalletModel rather than passing it around (Luke Dashjr)12d8d2681Qt: When multiple wallets are used, include in notifications the name (Jonas Schnelli)d1ec34a76Qt: QComboBox::setVisible doesn't work in toolbars, so defer adding it at all until needed (Luke Dashjr)d49cc70e6Qt: Add wallet selector to debug console (Jonas Schnelli)d558f44c5Bugfix: RPC: Add missing UnregisterHTTPHandler for /wallet/ (Luke Dashjr)85d531971Qt: Ensure UI updates only come from the currently selected walletView (Luke Dashjr)e449f9a9eQt: Add a combobox to toolbar to select from multiple wallets (Luke Dashjr)3dba3c3acQt: Load all wallets into WalletModels (Luke Dashjr) Pull request description: This is an overhaul of #11383 (plus some additions). It avoids unnecessary coupling of httpserver/jsonrpc and the wallet as well as it avoids pointer pure passing (and pointer deletion) of `CWallet` (plus other minor design changes). Additionally it adds the wallet name to the sendconfirmation and request dialog (in case multiwallet is active) Tree-SHA512: 3d06e18badbc5d1821e488bf1dae463bb0be544cf11b2b618e025812bfdd13c5f39604bb93b4c705313930e7dc4e66f4848b9469ba14871bade58e7a027246a1
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
#ifdef ENABLE_WALLET
|
||||
#include <qt/walletframe.h>
|
||||
#include <qt/walletmodel.h>
|
||||
#include <qt/walletview.h>
|
||||
#endif // ENABLE_WALLET
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
@@ -36,6 +37,7 @@
|
||||
|
||||
#include <QAction>
|
||||
#include <QApplication>
|
||||
#include <QComboBox>
|
||||
#include <QDateTime>
|
||||
#include <QDesktopWidget>
|
||||
#include <QDragEnterEvent>
|
||||
@@ -70,10 +72,6 @@ const std::string BitcoinGUI::DEFAULT_UIPLATFORM =
|
||||
#endif
|
||||
;
|
||||
|
||||
/** Display name for default wallet name. Uses tilde to avoid name
|
||||
* collisions in the future with additional wallets */
|
||||
const QString BitcoinGUI::DEFAULT_WALLET = "~Default";
|
||||
|
||||
BitcoinGUI::BitcoinGUI(const PlatformStyle *_platformStyle, const NetworkStyle *networkStyle, QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
enableWallet(false),
|
||||
@@ -88,6 +86,7 @@ BitcoinGUI::BitcoinGUI(const PlatformStyle *_platformStyle, const NetworkStyle *
|
||||
progressBar(0),
|
||||
progressDialog(0),
|
||||
appMenuBar(0),
|
||||
appToolBar(0),
|
||||
overviewAction(0),
|
||||
historyAction(0),
|
||||
quitAction(0),
|
||||
@@ -455,6 +454,7 @@ void BitcoinGUI::createToolBars()
|
||||
if(walletFrame)
|
||||
{
|
||||
QToolBar *toolbar = addToolBar(tr("Tabs toolbar"));
|
||||
appToolBar = toolbar;
|
||||
toolbar->setContextMenuPolicy(Qt::PreventContextMenu);
|
||||
toolbar->setMovable(false);
|
||||
toolbar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
|
||||
@@ -463,6 +463,15 @@ void BitcoinGUI::createToolBars()
|
||||
toolbar->addAction(receiveCoinsAction);
|
||||
toolbar->addAction(historyAction);
|
||||
overviewAction->setChecked(true);
|
||||
|
||||
#ifdef ENABLE_WALLET
|
||||
QWidget *spacer = new QWidget();
|
||||
spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
toolbar->addWidget(spacer);
|
||||
|
||||
m_wallet_selector = new QComboBox();
|
||||
connect(m_wallet_selector, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(setCurrentWallet(const QString&)));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -529,12 +538,22 @@ void BitcoinGUI::setClientModel(ClientModel *_clientModel)
|
||||
}
|
||||
|
||||
#ifdef ENABLE_WALLET
|
||||
bool BitcoinGUI::addWallet(const QString& name, WalletModel *walletModel)
|
||||
bool BitcoinGUI::addWallet(WalletModel *walletModel)
|
||||
{
|
||||
if(!walletFrame)
|
||||
return false;
|
||||
const QString name = walletModel->getWalletName();
|
||||
setWalletActionsEnabled(true);
|
||||
return walletFrame->addWallet(name, walletModel);
|
||||
m_wallet_selector->addItem(name);
|
||||
if (m_wallet_selector->count() == 2) {
|
||||
m_wallet_selector_label = new QLabel();
|
||||
m_wallet_selector_label->setText(tr("Wallet:") + " ");
|
||||
m_wallet_selector_label->setBuddy(m_wallet_selector);
|
||||
appToolBar->addWidget(m_wallet_selector_label);
|
||||
appToolBar->addWidget(m_wallet_selector);
|
||||
}
|
||||
rpcConsole->addWallet(walletModel);
|
||||
return walletFrame->addWallet(walletModel);
|
||||
}
|
||||
|
||||
bool BitcoinGUI::setCurrentWallet(const QString& name)
|
||||
@@ -983,12 +1002,15 @@ void BitcoinGUI::showEvent(QShowEvent *event)
|
||||
}
|
||||
|
||||
#ifdef ENABLE_WALLET
|
||||
void BitcoinGUI::incomingTransaction(const QString& date, int unit, const CAmount& amount, const QString& type, const QString& address, const QString& label)
|
||||
void BitcoinGUI::incomingTransaction(const QString& date, int unit, const CAmount& amount, const QString& type, const QString& address, const QString& label, const QString& walletName)
|
||||
{
|
||||
// On new transaction, make an info balloon
|
||||
QString msg = tr("Date: %1\n").arg(date) +
|
||||
tr("Amount: %1\n").arg(BitcoinUnits::formatWithUnit(unit, amount, true)) +
|
||||
tr("Type: %1\n").arg(type);
|
||||
tr("Amount: %1\n").arg(BitcoinUnits::formatWithUnit(unit, amount, true));
|
||||
if (WalletModel::isMultiwallet() && !walletName.isEmpty()) {
|
||||
msg += tr("Wallet: %1\n").arg(walletName);
|
||||
}
|
||||
msg += tr("Type: %1\n").arg(type);
|
||||
if (!label.isEmpty())
|
||||
msg += tr("Label: %1\n").arg(label);
|
||||
else if (!address.isEmpty())
|
||||
@@ -1079,6 +1101,20 @@ void BitcoinGUI::setEncryptionStatus(int status)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void BitcoinGUI::updateWalletStatus()
|
||||
{
|
||||
if (!walletFrame) {
|
||||
return;
|
||||
}
|
||||
WalletView * const walletView = walletFrame->currentWalletView();
|
||||
if (!walletView) {
|
||||
return;
|
||||
}
|
||||
WalletModel * const walletModel = walletView->getWalletModel();
|
||||
setEncryptionStatus(walletModel->getEncryptionStatus());
|
||||
setHDStatus(walletModel->hdEnabled());
|
||||
}
|
||||
#endif // ENABLE_WALLET
|
||||
|
||||
void BitcoinGUI::showNormalIfMinimized(bool fToggleHidden)
|
||||
|
||||
Reference in New Issue
Block a user