Changeset View
Changeset View
Standalone View
Standalone View
src/qt/bitcoingui.cpp
Show All 28 Lines | |||||
#endif // ENABLE_WALLET | #endif // ENABLE_WALLET | ||||
#ifdef Q_OS_MAC | #ifdef Q_OS_MAC | ||||
#include "macdockiconhandler.h" | #include "macdockiconhandler.h" | ||||
#endif | #endif | ||||
#include "chainparams.h" | #include "chainparams.h" | ||||
#include "init.h" | #include "init.h" | ||||
#include "interface/handler.h" | |||||
#include "interface/node.h" | |||||
#include "ui_interface.h" | #include "ui_interface.h" | ||||
#include "util.h" | #include "util.h" | ||||
#include <iostream> | #include <iostream> | ||||
#include <QAction> | #include <QAction> | ||||
#include <QApplication> | #include <QApplication> | ||||
#include <QComboBox> | #include <QComboBox> | ||||
Show All 20 Lines | #if defined(Q_OS_MAC) | ||||
"macosx" | "macosx" | ||||
#elif defined(Q_OS_WIN) | #elif defined(Q_OS_WIN) | ||||
"windows" | "windows" | ||||
#else | #else | ||||
"other" | "other" | ||||
#endif | #endif | ||||
; | ; | ||||
BitcoinGUI::BitcoinGUI(const Config *configIn, | BitcoinGUI::BitcoinGUI(interface::Node &node, const Config *configIn, | ||||
const PlatformStyle *_platformStyle, | const PlatformStyle *_platformStyle, | ||||
const NetworkStyle *networkStyle, QWidget *parent) | const NetworkStyle *networkStyle, QWidget *parent) | ||||
: QMainWindow(parent), enableWallet(false), platformStyle(_platformStyle), | : QMainWindow(parent), enableWallet(false), m_node(node), | ||||
config(configIn) { | platformStyle(_platformStyle), config(configIn) { | ||||
QSettings settings; | QSettings settings; | ||||
if (!restoreGeometry(settings.value("MainWindowGeometry").toByteArray())) { | if (!restoreGeometry(settings.value("MainWindowGeometry").toByteArray())) { | ||||
// Restore failed (perhaps missing setting), center the window | // Restore failed (perhaps missing setting), center the window | ||||
move(QApplication::desktop()->availableGeometry().center() - | move(QApplication::desktop()->availableGeometry().center() - | ||||
frameGeometry().center()); | frameGeometry().center()); | ||||
} | } | ||||
QString windowTitle = tr(PACKAGE_NAME) + " - "; | QString windowTitle = tr(PACKAGE_NAME) + " - "; | ||||
Show All 9 Lines | |||||
#ifndef Q_OS_MAC | #ifndef Q_OS_MAC | ||||
QApplication::setWindowIcon(networkStyle->getTrayAndWindowIcon()); | QApplication::setWindowIcon(networkStyle->getTrayAndWindowIcon()); | ||||
setWindowIcon(networkStyle->getTrayAndWindowIcon()); | setWindowIcon(networkStyle->getTrayAndWindowIcon()); | ||||
#else | #else | ||||
MacDockIconHandler::instance()->setIcon(networkStyle->getAppIcon()); | MacDockIconHandler::instance()->setIcon(networkStyle->getAppIcon()); | ||||
#endif | #endif | ||||
setWindowTitle(windowTitle); | setWindowTitle(windowTitle); | ||||
rpcConsole = new RPCConsole(_platformStyle, 0); | rpcConsole = new RPCConsole(node, _platformStyle, 0); | ||||
helpMessageDialog = new HelpMessageDialog(this, false); | helpMessageDialog = new HelpMessageDialog(node, this, false); | ||||
#ifdef ENABLE_WALLET | #ifdef ENABLE_WALLET | ||||
if (enableWallet) { | if (enableWallet) { | ||||
/** Create wallet frame and make it the central widget */ | /** Create wallet frame and make it the central widget */ | ||||
walletFrame = new WalletFrame(_platformStyle, config, this); | walletFrame = new WalletFrame(_platformStyle, config, this); | ||||
setCentralWidget(walletFrame); | setCentralWidget(walletFrame); | ||||
} else | } else | ||||
#endif // ENABLE_WALLET | #endif // ENABLE_WALLET | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 406 Lines • ▼ Show 20 Lines | if (_clientModel) { | ||||
connect(_clientModel, SIGNAL(numConnectionsChanged(int)), this, | connect(_clientModel, SIGNAL(numConnectionsChanged(int)), this, | ||||
SLOT(setNumConnections(int))); | SLOT(setNumConnections(int))); | ||||
connect(_clientModel, SIGNAL(networkActiveChanged(bool)), this, | connect(_clientModel, SIGNAL(networkActiveChanged(bool)), this, | ||||
SLOT(setNetworkActive(bool))); | SLOT(setNetworkActive(bool))); | ||||
modalOverlay->setKnownBestHeight( | modalOverlay->setKnownBestHeight( | ||||
_clientModel->getHeaderTipHeight(), | _clientModel->getHeaderTipHeight(), | ||||
QDateTime::fromTime_t(_clientModel->getHeaderTipTime())); | QDateTime::fromTime_t(_clientModel->getHeaderTipTime())); | ||||
setNumBlocks(_clientModel->getNumBlocks(), | setNumBlocks(m_node.getNumBlocks(), | ||||
_clientModel->getLastBlockDate(), | QDateTime::fromTime_t(m_node.getLastBlockTime()), | ||||
_clientModel->getVerificationProgress(nullptr), false); | m_node.getVerificationProgress(), false); | ||||
connect(_clientModel, | connect(_clientModel, | ||||
SIGNAL(numBlocksChanged(int, QDateTime, double, bool)), this, | SIGNAL(numBlocksChanged(int, QDateTime, double, bool)), this, | ||||
SLOT(setNumBlocks(int, QDateTime, double, bool))); | SLOT(setNumBlocks(int, QDateTime, double, bool))); | ||||
// Receive and report messages from client model | // Receive and report messages from client model | ||||
connect(_clientModel, SIGNAL(message(QString, QString, unsigned int)), | connect(_clientModel, SIGNAL(message(QString, QString, unsigned int)), | ||||
this, SLOT(message(QString, QString, unsigned int))); | this, SLOT(message(QString, QString, unsigned int))); | ||||
▲ Show 20 Lines • Show All 147 Lines • ▼ Show 20 Lines | void BitcoinGUI::optionsClicked() { | ||||
OptionsDialog dlg(this, enableWallet); | OptionsDialog dlg(this, enableWallet); | ||||
dlg.setModel(clientModel->getOptionsModel()); | dlg.setModel(clientModel->getOptionsModel()); | ||||
dlg.exec(); | dlg.exec(); | ||||
} | } | ||||
void BitcoinGUI::aboutClicked() { | void BitcoinGUI::aboutClicked() { | ||||
if (!clientModel) return; | if (!clientModel) return; | ||||
HelpMessageDialog dlg(this, true); | HelpMessageDialog dlg(m_node, this, true); | ||||
dlg.exec(); | dlg.exec(); | ||||
} | } | ||||
void BitcoinGUI::showDebugWindow() { | void BitcoinGUI::showDebugWindow() { | ||||
rpcConsole->showNormal(); | rpcConsole->showNormal(); | ||||
rpcConsole->show(); | rpcConsole->show(); | ||||
rpcConsole->raise(); | rpcConsole->raise(); | ||||
rpcConsole->activateWindow(); | rpcConsole->activateWindow(); | ||||
▲ Show 20 Lines • Show All 69 Lines • ▼ Show 20 Lines | switch (count) { | ||||
break; | break; | ||||
default: | default: | ||||
icon = ":/icons/connect_4"; | icon = ":/icons/connect_4"; | ||||
break; | break; | ||||
} | } | ||||
QString tooltip; | QString tooltip; | ||||
if (clientModel->getNetworkActive()) { | if (m_node.getNetworkActive()) { | ||||
tooltip = tr("%n active connection(s) to Bitcoin network", "", count) + | tooltip = tr("%n active connection(s) to Bitcoin network", "", count) + | ||||
QString(".<br>") + tr("Click to disable network activity."); | QString(".<br>") + tr("Click to disable network activity."); | ||||
} else { | } else { | ||||
tooltip = tr("Network activity disabled.") + QString("<br>") + | tooltip = tr("Network activity disabled.") + QString("<br>") + | ||||
tr("Click to enable network activity again."); | tr("Click to enable network activity again."); | ||||
icon = ":/icons/network_disabled"; | icon = ":/icons/network_disabled"; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 249 Lines • ▼ Show 20 Lines | void BitcoinGUI::incomingTransaction(const QString &date, int unit, | ||||
const Amount amount, const QString &type, | const Amount amount, const QString &type, | ||||
const QString &address, | const QString &address, | ||||
const QString &label, | const QString &label, | ||||
const QString &walletName) { | const QString &walletName) { | ||||
// On new transaction, make an info balloon | // On new transaction, make an info balloon | ||||
QString msg = tr("Date: %1\n").arg(date) + | QString msg = tr("Date: %1\n").arg(date) + | ||||
tr("Amount: %1\n") | tr("Amount: %1\n") | ||||
.arg(BitcoinUnits::formatWithUnit(unit, amount, true)); | .arg(BitcoinUnits::formatWithUnit(unit, amount, true)); | ||||
if (WalletModel::isMultiwallet() && !walletName.isEmpty()) { | if (m_node.getWallets().size() > 1 && !walletName.isEmpty()) { | ||||
msg += tr("Wallet: %1\n").arg(walletName); | msg += tr("Wallet: %1\n").arg(walletName); | ||||
} | } | ||||
msg += tr("Type: %1\n").arg(type); | msg += tr("Type: %1\n").arg(type); | ||||
if (!label.isEmpty()) { | if (!label.isEmpty()) { | ||||
msg += tr("Label: %1\n").arg(label); | msg += tr("Label: %1\n").arg(label); | ||||
} else if (!address.isEmpty()) { | } else if (!address.isEmpty()) { | ||||
msg += tr("Address: %1\n").arg(address); | msg += tr("Address: %1\n").arg(address); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 96 Lines • ▼ Show 20 Lines | if (!walletFrame) { | ||||
return; | return; | ||||
} | } | ||||
WalletView *const walletView = walletFrame->currentWalletView(); | WalletView *const walletView = walletFrame->currentWalletView(); | ||||
if (!walletView) { | if (!walletView) { | ||||
return; | return; | ||||
} | } | ||||
WalletModel *const walletModel = walletView->getWalletModel(); | WalletModel *const walletModel = walletView->getWalletModel(); | ||||
setEncryptionStatus(walletModel->getEncryptionStatus()); | setEncryptionStatus(walletModel->getEncryptionStatus()); | ||||
setHDStatus(walletModel->hdEnabled()); | setHDStatus(walletModel->wallet().hdEnabled()); | ||||
} | } | ||||
#endif // ENABLE_WALLET | #endif // ENABLE_WALLET | ||||
void BitcoinGUI::showNormalIfMinimized(bool fToggleHidden) { | void BitcoinGUI::showNormalIfMinimized(bool fToggleHidden) { | ||||
if (!clientModel) { | if (!clientModel) { | ||||
return; | return; | ||||
} | } | ||||
Show All 12 Lines | void BitcoinGUI::showNormalIfMinimized(bool fToggleHidden) { | ||||
} | } | ||||
} | } | ||||
void BitcoinGUI::toggleHidden() { | void BitcoinGUI::toggleHidden() { | ||||
showNormalIfMinimized(true); | showNormalIfMinimized(true); | ||||
} | } | ||||
void BitcoinGUI::detectShutdown() { | void BitcoinGUI::detectShutdown() { | ||||
if (ShutdownRequested()) { | if (m_node.shutdownRequested()) { | ||||
if (rpcConsole) { | if (rpcConsole) { | ||||
rpcConsole->hide(); | rpcConsole->hide(); | ||||
} | } | ||||
qApp->quit(); | qApp->quit(); | ||||
} | } | ||||
} | } | ||||
void BitcoinGUI::showProgress(const QString &title, int nProgress) { | void BitcoinGUI::showProgress(const QString &title, int nProgress) { | ||||
▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | QMetaObject::invokeMethod(gui, "message", | ||||
Q_ARG(QString, QString::fromStdString(caption)), | Q_ARG(QString, QString::fromStdString(caption)), | ||||
Q_ARG(QString, QString::fromStdString(message)), | Q_ARG(QString, QString::fromStdString(message)), | ||||
Q_ARG(unsigned int, style), Q_ARG(bool *, &ret)); | Q_ARG(unsigned int, style), Q_ARG(bool *, &ret)); | ||||
return ret; | return ret; | ||||
} | } | ||||
void BitcoinGUI::subscribeToCoreSignals() { | void BitcoinGUI::subscribeToCoreSignals() { | ||||
// Connect signals to client | // Connect signals to client | ||||
uiInterface.ThreadSafeMessageBox.connect( | m_handler_message_box = m_node.handleMessageBox( | ||||
boost::bind(ThreadSafeMessageBox, this, _1, _2, _3)); | boost::bind(ThreadSafeMessageBox, this, _1, _2, _3)); | ||||
uiInterface.ThreadSafeQuestion.connect( | m_handler_question = m_node.handleQuestion( | ||||
boost::bind(ThreadSafeMessageBox, this, _1, _3, _4)); | boost::bind(ThreadSafeMessageBox, this, _1, _3, _4)); | ||||
} | } | ||||
void BitcoinGUI::unsubscribeFromCoreSignals() { | void BitcoinGUI::unsubscribeFromCoreSignals() { | ||||
// Disconnect signals from client | // Disconnect signals from client | ||||
uiInterface.ThreadSafeMessageBox.disconnect( | m_handler_message_box->disconnect(); | ||||
boost::bind(ThreadSafeMessageBox, this, _1, _2, _3)); | m_handler_question->disconnect(); | ||||
uiInterface.ThreadSafeQuestion.disconnect( | |||||
boost::bind(ThreadSafeMessageBox, this, _1, _3, _4)); | |||||
} | } | ||||
void BitcoinGUI::toggleNetworkActive() { | void BitcoinGUI::toggleNetworkActive() { | ||||
if (clientModel) { | m_node.setNetworkActive(!m_node.getNetworkActive()); | ||||
clientModel->setNetworkActive(!clientModel->getNetworkActive()); | |||||
} | |||||
} | } | ||||
UnitDisplayStatusBarControl::UnitDisplayStatusBarControl( | UnitDisplayStatusBarControl::UnitDisplayStatusBarControl( | ||||
const PlatformStyle *platformStyle) | const PlatformStyle *platformStyle) | ||||
: optionsModel(0), menu(0) { | : optionsModel(0), menu(0) { | ||||
createContextMenu(); | createContextMenu(); | ||||
setToolTip(tr("Unit to show amounts in. Click to select another unit.")); | setToolTip(tr("Unit to show amounts in. Click to select another unit.")); | ||||
QList<BitcoinUnits::Unit> units = BitcoinUnits::availableUnits(); | QList<BitcoinUnits::Unit> units = BitcoinUnits::availableUnits(); | ||||
▲ Show 20 Lines • Show All 63 Lines • Show Last 20 Lines |