Changeset View
Changeset View
Standalone View
Standalone View
src/qt/bitcoingui.cpp
Show First 20 Lines • Show All 65 Lines • ▼ Show 20 Lines | |||||
#else | #else | ||||
"other" | "other" | ||||
#endif | #endif | ||||
; | ; | ||||
BitcoinGUI::BitcoinGUI(interfaces::Node &node, const Config *configIn, | BitcoinGUI::BitcoinGUI(interfaces::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), m_node(node), | : QMainWindow(parent), m_node(node), config(configIn), | ||||
platformStyle(_platformStyle), config(configIn) { | platformStyle(_platformStyle), m_network_style(networkStyle) { | ||||
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) + " - "; | |||||
#ifdef ENABLE_WALLET | #ifdef ENABLE_WALLET | ||||
enableWallet = WalletModel::isWalletEnabled(); | enableWallet = WalletModel::isWalletEnabled(); | ||||
#endif // ENABLE_WALLET | #endif // ENABLE_WALLET | ||||
if (enableWallet) { | QApplication::setWindowIcon(m_network_style->getTrayAndWindowIcon()); | ||||
windowTitle += tr("Wallet"); | setWindowIcon(m_network_style->getTrayAndWindowIcon()); | ||||
} else { | updateWindowTitle(); | ||||
windowTitle += tr("Node"); | |||||
} | |||||
windowTitle += " " + networkStyle->getTitleAddText(); | |||||
QApplication::setWindowIcon(networkStyle->getTrayAndWindowIcon()); | |||||
setWindowIcon(networkStyle->getTrayAndWindowIcon()); | |||||
setWindowTitle(windowTitle); | |||||
rpcConsole = new RPCConsole(node, _platformStyle, 0); | rpcConsole = new RPCConsole(node, _platformStyle, 0); | ||||
helpMessageDialog = new HelpMessageDialog(node, 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, this); | walletFrame = new WalletFrame(_platformStyle, this); | ||||
setCentralWidget(walletFrame); | setCentralWidget(walletFrame); | ||||
Show All 18 Lines | #endif // ENABLE_WALLET | ||||
// Create application menu bar | // Create application menu bar | ||||
createMenuBar(); | createMenuBar(); | ||||
// Create the toolbars | // Create the toolbars | ||||
createToolBars(); | createToolBars(); | ||||
// Create system tray icon and notification | // Create system tray icon and notification | ||||
if (QSystemTrayIcon::isSystemTrayAvailable()) { | if (QSystemTrayIcon::isSystemTrayAvailable()) { | ||||
createTrayIcon(networkStyle); | createTrayIcon(); | ||||
} | } | ||||
notificator = | notificator = | ||||
new Notificator(QApplication::applicationName(), trayIcon, this); | new Notificator(QApplication::applicationName(), trayIcon, this); | ||||
// Create status bar | // Create status bar | ||||
statusBar(); | statusBar(); | ||||
// Disable size grip because it looks ugly and nobody needs it | // Disable size grip because it looks ugly and nobody needs it | ||||
▲ Show 20 Lines • Show All 467 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(WalletModel *walletModel) { | void BitcoinGUI::addWallet(WalletModel *walletModel) { | ||||
if (!walletFrame) { | if (!walletFrame) { | ||||
return false; | return; | ||||
} | } | ||||
const QString display_name = walletModel->getDisplayName(); | const QString display_name = walletModel->getDisplayName(); | ||||
setWalletActionsEnabled(true); | setWalletActionsEnabled(true); | ||||
m_wallet_selector->addItem(display_name, QVariant::fromValue(walletModel)); | m_wallet_selector->addItem(display_name, QVariant::fromValue(walletModel)); | ||||
if (m_wallet_selector->count() == 2) { | if (m_wallet_selector->count() == 2) { | ||||
m_wallet_selector_label_action->setVisible(true); | m_wallet_selector_label_action->setVisible(true); | ||||
m_wallet_selector_action->setVisible(true); | m_wallet_selector_action->setVisible(true); | ||||
} | } | ||||
rpcConsole->addWallet(walletModel); | rpcConsole->addWallet(walletModel); | ||||
return walletFrame->addWallet(walletModel); | walletFrame->addWallet(walletModel); | ||||
} | } | ||||
bool BitcoinGUI::removeWallet(WalletModel *walletModel) { | void BitcoinGUI::removeWallet(WalletModel *walletModel) { | ||||
if (!walletFrame) { | if (!walletFrame) { | ||||
return false; | return; | ||||
} | } | ||||
int index = m_wallet_selector->findData(QVariant::fromValue(walletModel)); | int index = m_wallet_selector->findData(QVariant::fromValue(walletModel)); | ||||
m_wallet_selector->removeItem(index); | m_wallet_selector->removeItem(index); | ||||
if (m_wallet_selector->count() == 0) { | if (m_wallet_selector->count() == 0) { | ||||
setWalletActionsEnabled(false); | setWalletActionsEnabled(false); | ||||
} else if (m_wallet_selector->count() == 1) { | } else if (m_wallet_selector->count() == 1) { | ||||
m_wallet_selector_label_action->setVisible(false); | m_wallet_selector_label_action->setVisible(false); | ||||
m_wallet_selector_action->setVisible(false); | m_wallet_selector_action->setVisible(false); | ||||
} | } | ||||
rpcConsole->removeWallet(walletModel); | rpcConsole->removeWallet(walletModel); | ||||
return walletFrame->removeWallet(walletModel); | walletFrame->removeWallet(walletModel); | ||||
updateWindowTitle(); | |||||
} | } | ||||
bool BitcoinGUI::setCurrentWallet(WalletModel *wallet_model) { | void BitcoinGUI::setCurrentWallet(WalletModel *wallet_model) { | ||||
if (!walletFrame) { | if (!walletFrame) { | ||||
return false; | return; | ||||
} | } | ||||
return walletFrame->setCurrentWallet(wallet_model); | walletFrame->setCurrentWallet(wallet_model); | ||||
updateWindowTitle(); | |||||
} | } | ||||
bool BitcoinGUI::setCurrentWalletBySelectorIndex(int index) { | void BitcoinGUI::setCurrentWalletBySelectorIndex(int index) { | ||||
WalletModel *wallet_model = | WalletModel *wallet_model = | ||||
m_wallet_selector->itemData(index).value<WalletModel *>(); | m_wallet_selector->itemData(index).value<WalletModel *>(); | ||||
return setCurrentWallet(wallet_model); | setCurrentWallet(wallet_model); | ||||
} | } | ||||
void BitcoinGUI::removeAllWallets() { | void BitcoinGUI::removeAllWallets() { | ||||
if (!walletFrame) return; | if (!walletFrame) return; | ||||
setWalletActionsEnabled(false); | setWalletActionsEnabled(false); | ||||
walletFrame->removeAllWallets(); | walletFrame->removeAllWallets(); | ||||
} | } | ||||
#endif // ENABLE_WALLET | #endif // ENABLE_WALLET | ||||
Show All 10 Lines | void BitcoinGUI::setWalletActionsEnabled(bool enabled) { | ||||
changePassphraseAction->setEnabled(enabled); | changePassphraseAction->setEnabled(enabled); | ||||
signMessageAction->setEnabled(enabled); | signMessageAction->setEnabled(enabled); | ||||
verifyMessageAction->setEnabled(enabled); | verifyMessageAction->setEnabled(enabled); | ||||
usedSendingAddressesAction->setEnabled(enabled); | usedSendingAddressesAction->setEnabled(enabled); | ||||
usedReceivingAddressesAction->setEnabled(enabled); | usedReceivingAddressesAction->setEnabled(enabled); | ||||
openAction->setEnabled(enabled); | openAction->setEnabled(enabled); | ||||
} | } | ||||
void BitcoinGUI::createTrayIcon(const NetworkStyle *networkStyle) { | void BitcoinGUI::createTrayIcon() { | ||||
assert(QSystemTrayIcon::isSystemTrayAvailable()); | assert(QSystemTrayIcon::isSystemTrayAvailable()); | ||||
#ifndef Q_OS_MAC | #ifndef Q_OS_MAC | ||||
if (QSystemTrayIcon::isSystemTrayAvailable()) { | if (QSystemTrayIcon::isSystemTrayAvailable()) { | ||||
trayIcon = | trayIcon = | ||||
new QSystemTrayIcon(networkStyle->getTrayAndWindowIcon(), this); | new QSystemTrayIcon(m_network_style->getTrayAndWindowIcon(), this); | ||||
QString toolTip = tr("%1 client").arg(tr(PACKAGE_NAME)) + " " + | QString toolTip = tr("%1 client").arg(tr(PACKAGE_NAME)) + " " + | ||||
networkStyle->getTitleAddText(); | m_network_style->getTitleAddText(); | ||||
trayIcon->setToolTip(toolTip); | trayIcon->setToolTip(toolTip); | ||||
} | } | ||||
#endif | #endif | ||||
} | } | ||||
void BitcoinGUI::createTrayIconMenu() { | void BitcoinGUI::createTrayIconMenu() { | ||||
#ifndef Q_OS_MAC | #ifndef Q_OS_MAC | ||||
// Return if trayIcon is unset (only on non-macOSes) | // Return if trayIcon is unset (only on non-macOSes) | ||||
▲ Show 20 Lines • Show All 556 Lines • ▼ Show 20 Lines | if (proxy_enabled) { | ||||
} else { | } else { | ||||
labelProxyIcon->show(); | labelProxyIcon->show(); | ||||
} | } | ||||
} else { | } else { | ||||
labelProxyIcon->hide(); | labelProxyIcon->hide(); | ||||
} | } | ||||
} | } | ||||
void BitcoinGUI::updateWindowTitle() { | |||||
QString window_title = tr(PACKAGE_NAME) + " - "; | |||||
#ifdef ENABLE_WALLET | |||||
if (walletFrame) { | |||||
WalletModel *const wallet_model = walletFrame->currentWalletModel(); | |||||
if (wallet_model && !wallet_model->getWalletName().isEmpty()) { | |||||
window_title += wallet_model->getDisplayName() + " - "; | |||||
} | |||||
} | |||||
#endif | |||||
window_title += m_network_style->getTitleAddText(); | |||||
setWindowTitle(window_title); | |||||
} | |||||
void BitcoinGUI::showNormalIfMinimized(bool fToggleHidden) { | void BitcoinGUI::showNormalIfMinimized(bool fToggleHidden) { | ||||
if (!clientModel) { | if (!clientModel) { | ||||
return; | return; | ||||
} | } | ||||
if (!isHidden() && !isMinimized() && !GUIUtil::isObscured(this) && | if (!isHidden() && !isMinimized() && !GUIUtil::isObscured(this) && | ||||
fToggleHidden) { | fToggleHidden) { | ||||
hide(); | hide(); | ||||
▲ Show 20 Lines • Show All 153 Lines • Show Last 20 Lines |