Changeset View
Changeset View
Standalone View
Standalone View
src/qt/bitcoingui.cpp
Show All 19 Lines | |||||
#include "optionsmodel.h" | #include "optionsmodel.h" | ||||
#include "platformstyle.h" | #include "platformstyle.h" | ||||
#include "rpcconsole.h" | #include "rpcconsole.h" | ||||
#include "utilitydialog.h" | #include "utilitydialog.h" | ||||
#ifdef ENABLE_WALLET | #ifdef ENABLE_WALLET | ||||
#include "walletframe.h" | #include "walletframe.h" | ||||
#include "walletmodel.h" | #include "walletmodel.h" | ||||
#include "walletview.h" | |||||
#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 "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 <QDateTime> | #include <QDateTime> | ||||
#include <QDesktopWidget> | #include <QDesktopWidget> | ||||
#include <QDragEnterEvent> | #include <QDragEnterEvent> | ||||
#include <QListWidget> | #include <QListWidget> | ||||
#include <QMenuBar> | #include <QMenuBar> | ||||
#include <QMessageBox> | #include <QMessageBox> | ||||
#include <QMimeData> | #include <QMimeData> | ||||
#include <QProgressDialog> | #include <QProgressDialog> | ||||
Show All 12 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 | ||||
; | ; | ||||
/** | |||||
* 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 Config *configIn, | BitcoinGUI::BitcoinGUI(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), platformStyle(_platformStyle), | ||||
config(configIn) { | 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 | ||||
▲ Show 20 Lines • Show All 399 Lines • ▼ Show 20 Lines | #endif | ||||
help->addSeparator(); | help->addSeparator(); | ||||
help->addAction(aboutAction); | help->addAction(aboutAction); | ||||
help->addAction(aboutQtAction); | help->addAction(aboutQtAction); | ||||
} | } | ||||
void BitcoinGUI::createToolBars() { | void BitcoinGUI::createToolBars() { | ||||
if (walletFrame) { | if (walletFrame) { | ||||
QToolBar *toolbar = addToolBar(tr("Tabs toolbar")); | QToolBar *toolbar = addToolBar(tr("Tabs toolbar")); | ||||
appToolBar = toolbar; | |||||
toolbar->setContextMenuPolicy(Qt::PreventContextMenu); | toolbar->setContextMenuPolicy(Qt::PreventContextMenu); | ||||
toolbar->setMovable(false); | toolbar->setMovable(false); | ||||
toolbar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); | toolbar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); | ||||
toolbar->addAction(overviewAction); | toolbar->addAction(overviewAction); | ||||
toolbar->addAction(sendCoinsAction); | toolbar->addAction(sendCoinsAction); | ||||
toolbar->addAction(receiveCoinsAction); | toolbar->addAction(receiveCoinsAction); | ||||
toolbar->addAction(historyAction); | toolbar->addAction(historyAction); | ||||
overviewAction->setChecked(true); | 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 | |||||
} | } | ||||
} | } | ||||
void BitcoinGUI::setClientModel(ClientModel *_clientModel) { | void BitcoinGUI::setClientModel(ClientModel *_clientModel) { | ||||
this->clientModel = _clientModel; | this->clientModel = _clientModel; | ||||
if (_clientModel) { | if (_clientModel) { | ||||
// Create system tray menu (or setup the dock menu) that late to prevent | // Create system tray menu (or setup the dock menu) that late to prevent | ||||
// users from calling actions, while the client has not yet fully loaded | // users from calling actions, while the client has not yet fully loaded | ||||
▲ Show 20 Lines • Show All 58 Lines • ▼ Show 20 Lines | #ifdef ENABLE_WALLET | ||||
walletFrame->setClientModel(nullptr); | walletFrame->setClientModel(nullptr); | ||||
} | } | ||||
#endif // ENABLE_WALLET | #endif // ENABLE_WALLET | ||||
unitDisplayControl->setOptionsModel(nullptr); | unitDisplayControl->setOptionsModel(nullptr); | ||||
} | } | ||||
} | } | ||||
#ifdef ENABLE_WALLET | #ifdef ENABLE_WALLET | ||||
bool BitcoinGUI::addWallet(const QString &name, WalletModel *walletModel) { | bool BitcoinGUI::addWallet(WalletModel *walletModel) { | ||||
if (!walletFrame) return false; | if (!walletFrame) return false; | ||||
const QString name = walletModel->getWalletName(); | |||||
setWalletActionsEnabled(true); | 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) { | bool BitcoinGUI::setCurrentWallet(const QString &name) { | ||||
if (!walletFrame) return false; | if (!walletFrame) return false; | ||||
return walletFrame->setCurrentWallet(name); | return walletFrame->setCurrentWallet(name); | ||||
} | } | ||||
void BitcoinGUI::removeAllWallets() { | void BitcoinGUI::removeAllWallets() { | ||||
▲ Show 20 Lines • Show All 428 Lines • ▼ Show 20 Lines | void BitcoinGUI::showEvent(QShowEvent *event) { | ||||
aboutAction->setEnabled(true); | aboutAction->setEnabled(true); | ||||
optionsAction->setEnabled(true); | optionsAction->setEnabled(true); | ||||
} | } | ||||
#ifdef ENABLE_WALLET | #ifdef ENABLE_WALLET | ||||
void BitcoinGUI::incomingTransaction(const QString &date, int unit, | 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) { | |||||
// 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)); | ||||
tr("Type: %1\n").arg(type); | if (WalletModel::isMultiwallet() && !walletName.isEmpty()) { | ||||
msg += tr("Wallet: %1\n").arg(walletName); | |||||
} | |||||
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); | ||||
} | } | ||||
message(amount < Amount::zero() ? tr("Sent transaction") | message(amount < Amount::zero() ? tr("Sent transaction") | ||||
: tr("Incoming transaction"), | : tr("Incoming transaction"), | ||||
msg, CClientUIInterface::MSG_INFORMATION); | msg, CClientUIInterface::MSG_INFORMATION); | ||||
▲ Show 20 Lines • Show All 82 Lines • ▼ Show 20 Lines | switch (status) { | ||||
tr("Wallet is <b>encrypted</b> and currently <b>locked</b>")); | tr("Wallet is <b>encrypted</b> and currently <b>locked</b>")); | ||||
encryptWalletAction->setChecked(true); | encryptWalletAction->setChecked(true); | ||||
changePassphraseAction->setEnabled(true); | changePassphraseAction->setEnabled(true); | ||||
encryptWalletAction->setEnabled( | encryptWalletAction->setEnabled( | ||||
false); // TODO: decrypt currently not supported | false); // TODO: decrypt currently not supported | ||||
break; | 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 | #endif // ENABLE_WALLET | ||||
void BitcoinGUI::showNormalIfMinimized(bool fToggleHidden) { | void BitcoinGUI::showNormalIfMinimized(bool fToggleHidden) { | ||||
if (!clientModel) { | if (!clientModel) { | ||||
return; | return; | ||||
} | } | ||||
// activateWindow() (sometimes) helps with keyboard focus on Windows | // activateWindow() (sometimes) helps with keyboard focus on Windows | ||||
▲ Show 20 Lines • Show All 168 Lines • Show Last 20 Lines |