Changeset View
Changeset View
Standalone View
Standalone View
src/qt/bitcoingui.cpp
Show First 20 Lines • Show All 202 Lines • ▼ Show 20 Lines | #endif // ENABLE_WALLET | ||||
connect(connectionsControl, &GUIUtil::ClickableLabel::clicked, | connect(connectionsControl, &GUIUtil::ClickableLabel::clicked, | ||||
[this] { m_node.setNetworkActive(!m_node.getNetworkActive()); }); | [this] { m_node.setNetworkActive(!m_node.getNetworkActive()); }); | ||||
connect(labelProxyIcon, &GUIUtil::ClickableLabel::clicked, | connect(labelProxyIcon, &GUIUtil::ClickableLabel::clicked, | ||||
[this] { openOptionsDialogWithTab(OptionsDialog::TAB_NETWORK); }); | [this] { openOptionsDialogWithTab(OptionsDialog::TAB_NETWORK); }); | ||||
modalOverlay = new ModalOverlay(this->centralWidget()); | modalOverlay = new ModalOverlay(this->centralWidget()); | ||||
#ifdef ENABLE_WALLET | #ifdef ENABLE_WALLET | ||||
if (enableWallet) { | if (enableWallet) { | ||||
connect(walletFrame, SIGNAL(requestedSyncWarningInfo()), this, | connect(walletFrame, &WalletFrame::requestedSyncWarningInfo, this, | ||||
SLOT(showModalOverlay())); | &BitcoinGUI::showModalOverlay); | ||||
connect(labelBlocksIcon, SIGNAL(clicked(QPoint)), this, | connect(labelBlocksIcon, &GUIUtil::ClickableLabel::clicked, this, | ||||
SLOT(showModalOverlay())); | &BitcoinGUI::showModalOverlay); | ||||
connect(progressBar, SIGNAL(clicked(QPoint)), this, | connect(progressBar, &GUIUtil::ClickableProgressBar::clicked, this, | ||||
SLOT(showModalOverlay())); | &BitcoinGUI::showModalOverlay); | ||||
} | } | ||||
#endif | #endif | ||||
} | } | ||||
BitcoinGUI::~BitcoinGUI() { | BitcoinGUI::~BitcoinGUI() { | ||||
// Unsubscribe from notifications from core | // Unsubscribe from notifications from core | ||||
unsubscribeFromCoreSignals(); | unsubscribeFromCoreSignals(); | ||||
▲ Show 20 Lines • Show All 63 Lines • ▼ Show 20 Lines | void BitcoinGUI::createActions() { | ||||
historyAction->setCheckable(true); | historyAction->setCheckable(true); | ||||
historyAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_4)); | historyAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_4)); | ||||
tabGroup->addAction(historyAction); | tabGroup->addAction(historyAction); | ||||
#ifdef ENABLE_WALLET | #ifdef ENABLE_WALLET | ||||
// These showNormalIfMinimized are needed because Send Coins and Receive | // 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 | // Coins can be triggered from the tray menu, and need to show the GUI to be | ||||
// useful. | // useful. | ||||
connect(overviewAction, SIGNAL(triggered()), this, | connect(overviewAction, &QAction::triggered, this, | ||||
SLOT(showNormalIfMinimized())); | static_cast<void (BitcoinGUI::*)()>( | ||||
connect(overviewAction, SIGNAL(triggered()), this, | &BitcoinGUI::showNormalIfMinimized)); | ||||
SLOT(gotoOverviewPage())); | connect(overviewAction, &QAction::triggered, this, | ||||
connect(sendCoinsAction, SIGNAL(triggered()), this, | &BitcoinGUI::gotoOverviewPage); | ||||
SLOT(showNormalIfMinimized())); | connect(sendCoinsAction, &QAction::triggered, this, | ||||
connect(sendCoinsAction, SIGNAL(triggered()), this, | static_cast<void (BitcoinGUI::*)()>( | ||||
SLOT(gotoSendCoinsPage())); | &BitcoinGUI::showNormalIfMinimized)); | ||||
connect(sendCoinsMenuAction, SIGNAL(triggered()), this, | connect(sendCoinsAction, &QAction::triggered, | ||||
SLOT(showNormalIfMinimized())); | [this] { gotoSendCoinsPage(); }); | ||||
connect(sendCoinsMenuAction, SIGNAL(triggered()), this, | connect(sendCoinsMenuAction, &QAction::triggered, this, | ||||
SLOT(gotoSendCoinsPage())); | static_cast<void (BitcoinGUI::*)()>( | ||||
connect(receiveCoinsAction, SIGNAL(triggered()), this, | &BitcoinGUI::showNormalIfMinimized)); | ||||
SLOT(showNormalIfMinimized())); | connect(sendCoinsMenuAction, &QAction::triggered, | ||||
connect(receiveCoinsAction, SIGNAL(triggered()), this, | [this] { gotoSendCoinsPage(); }); | ||||
SLOT(gotoReceiveCoinsPage())); | connect(receiveCoinsAction, &QAction::triggered, this, | ||||
connect(receiveCoinsMenuAction, SIGNAL(triggered()), this, | static_cast<void (BitcoinGUI::*)()>( | ||||
SLOT(showNormalIfMinimized())); | &BitcoinGUI::showNormalIfMinimized)); | ||||
connect(receiveCoinsMenuAction, SIGNAL(triggered()), this, | connect(receiveCoinsAction, &QAction::triggered, this, | ||||
SLOT(gotoReceiveCoinsPage())); | &BitcoinGUI::gotoReceiveCoinsPage); | ||||
connect(historyAction, SIGNAL(triggered()), this, | connect(receiveCoinsMenuAction, &QAction::triggered, this, | ||||
SLOT(showNormalIfMinimized())); | static_cast<void (BitcoinGUI::*)()>( | ||||
connect(historyAction, SIGNAL(triggered()), this, SLOT(gotoHistoryPage())); | &BitcoinGUI::showNormalIfMinimized)); | ||||
connect(receiveCoinsMenuAction, &QAction::triggered, this, | |||||
&BitcoinGUI::gotoReceiveCoinsPage); | |||||
connect(historyAction, &QAction::triggered, this, | |||||
static_cast<void (BitcoinGUI::*)()>( | |||||
&BitcoinGUI::showNormalIfMinimized)); | |||||
connect(historyAction, &QAction::triggered, this, | |||||
&BitcoinGUI::gotoHistoryPage); | |||||
#endif // ENABLE_WALLET | #endif // ENABLE_WALLET | ||||
quitAction = new QAction(platformStyle->TextColorIcon(":/icons/quit"), | quitAction = new QAction(platformStyle->TextColorIcon(":/icons/quit"), | ||||
tr("E&xit"), this); | tr("E&xit"), this); | ||||
quitAction->setStatusTip(tr("Quit application")); | quitAction->setStatusTip(tr("Quit application")); | ||||
quitAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q)); | quitAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q)); | ||||
quitAction->setMenuRole(QAction::QuitRole); | quitAction->setMenuRole(QAction::QuitRole); | ||||
aboutAction = new QAction(platformStyle->TextColorIcon(":/icons/about"), | aboutAction = new QAction(platformStyle->TextColorIcon(":/icons/about"), | ||||
▲ Show 20 Lines • Show All 75 Lines • ▼ Show 20 Lines | showHelpMessageAction = | ||||
new QAction(platformStyle->TextColorIcon(":/icons/info"), | new QAction(platformStyle->TextColorIcon(":/icons/info"), | ||||
tr("&Command-line options"), this); | tr("&Command-line options"), this); | ||||
showHelpMessageAction->setMenuRole(QAction::NoRole); | showHelpMessageAction->setMenuRole(QAction::NoRole); | ||||
showHelpMessageAction->setStatusTip( | showHelpMessageAction->setStatusTip( | ||||
tr("Show the %1 help message to get a list with possible Bitcoin " | tr("Show the %1 help message to get a list with possible Bitcoin " | ||||
"command-line options") | "command-line options") | ||||
.arg(tr(PACKAGE_NAME))); | .arg(tr(PACKAGE_NAME))); | ||||
connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit())); | connect(quitAction, &QAction::triggered, qApp, QApplication::quit); | ||||
connect(aboutAction, SIGNAL(triggered()), this, SLOT(aboutClicked())); | connect(aboutAction, &QAction::triggered, this, &BitcoinGUI::aboutClicked); | ||||
connect(aboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt())); | connect(aboutQtAction, &QAction::triggered, qApp, QApplication::aboutQt); | ||||
connect(optionsAction, SIGNAL(triggered()), this, SLOT(optionsClicked())); | connect(optionsAction, &QAction::triggered, this, | ||||
connect(toggleHideAction, SIGNAL(triggered()), this, SLOT(toggleHidden())); | &BitcoinGUI::optionsClicked); | ||||
connect(showHelpMessageAction, SIGNAL(triggered()), this, | connect(toggleHideAction, &QAction::triggered, this, | ||||
SLOT(showHelpMessageClicked())); | &BitcoinGUI::toggleHidden); | ||||
connect(openRPCConsoleAction, SIGNAL(triggered()), this, | connect(showHelpMessageAction, &QAction::triggered, this, | ||||
SLOT(showDebugWindow())); | &BitcoinGUI::showHelpMessageClicked); | ||||
connect(openRPCConsoleAction, &QAction::triggered, this, | |||||
&BitcoinGUI::showDebugWindow); | |||||
// prevents an open debug window from becoming stuck/unusable on client | // prevents an open debug window from becoming stuck/unusable on client | ||||
// shutdown | // shutdown | ||||
connect(quitAction, SIGNAL(triggered()), rpcConsole, SLOT(hide())); | connect(quitAction, &QAction::triggered, rpcConsole, &QWidget::hide); | ||||
#ifdef ENABLE_WALLET | #ifdef ENABLE_WALLET | ||||
if (walletFrame) { | if (walletFrame) { | ||||
connect(encryptWalletAction, SIGNAL(triggered(bool)), walletFrame, | connect(encryptWalletAction, &QAction::triggered, walletFrame, | ||||
SLOT(encryptWallet(bool))); | &WalletFrame::encryptWallet); | ||||
connect(backupWalletAction, SIGNAL(triggered()), walletFrame, | connect(backupWalletAction, &QAction::triggered, walletFrame, | ||||
SLOT(backupWallet())); | &WalletFrame::backupWallet); | ||||
connect(changePassphraseAction, SIGNAL(triggered()), walletFrame, | connect(changePassphraseAction, &QAction::triggered, walletFrame, | ||||
SLOT(changePassphrase())); | &WalletFrame::changePassphrase); | ||||
connect(signMessageAction, SIGNAL(triggered()), this, | connect(signMessageAction, &QAction::triggered, | ||||
SLOT(gotoSignMessageTab())); | [this] { gotoSignMessageTab(); }); | ||||
connect(verifyMessageAction, SIGNAL(triggered()), this, | connect(verifyMessageAction, &QAction::triggered, | ||||
SLOT(gotoVerifyMessageTab())); | [this] { gotoVerifyMessageTab(); }); | ||||
connect(usedSendingAddressesAction, SIGNAL(triggered()), walletFrame, | connect(usedSendingAddressesAction, &QAction::triggered, walletFrame, | ||||
SLOT(usedSendingAddresses())); | &WalletFrame::usedSendingAddresses); | ||||
connect(usedReceivingAddressesAction, SIGNAL(triggered()), walletFrame, | connect(usedReceivingAddressesAction, &QAction::triggered, walletFrame, | ||||
SLOT(usedReceivingAddresses())); | &WalletFrame::usedReceivingAddresses); | ||||
connect(openAction, SIGNAL(triggered()), this, SLOT(openClicked())); | connect(openAction, &QAction::triggered, this, | ||||
&BitcoinGUI::openClicked); | |||||
} | } | ||||
#endif // ENABLE_WALLET | #endif // ENABLE_WALLET | ||||
new QShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_C), this, | connect(new QShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_C), this), | ||||
SLOT(showDebugWindowActivateConsole())); | &QShortcut::activated, this, | ||||
new QShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_D), this, | &BitcoinGUI::showDebugWindowActivateConsole); | ||||
SLOT(showDebugWindow())); | connect(new QShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_D), this), | ||||
&QShortcut::activated, this, &BitcoinGUI::showDebugWindow); | |||||
} | } | ||||
void BitcoinGUI::createMenuBar() { | void BitcoinGUI::createMenuBar() { | ||||
#ifdef Q_OS_MAC | #ifdef Q_OS_MAC | ||||
// Create a decoupled menu bar on Mac which stays even if the window is | // Create a decoupled menu bar on Mac which stays even if the window is | ||||
// closed | // closed | ||||
appMenuBar = new QMenuBar(); | appMenuBar = new QMenuBar(); | ||||
#else | #else | ||||
▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | if (walletFrame) { | ||||
overviewAction->setChecked(true); | overviewAction->setChecked(true); | ||||
#ifdef ENABLE_WALLET | #ifdef ENABLE_WALLET | ||||
QWidget *spacer = new QWidget(); | QWidget *spacer = new QWidget(); | ||||
spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); | spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); | ||||
toolbar->addWidget(spacer); | toolbar->addWidget(spacer); | ||||
m_wallet_selector = new QComboBox(); | m_wallet_selector = new QComboBox(); | ||||
connect(m_wallet_selector, SIGNAL(currentIndexChanged(int)), this, | connect(m_wallet_selector, | ||||
SLOT(setCurrentWalletBySelectorIndex(int))); | static_cast<void (QComboBox::*)(int)>( | ||||
&QComboBox::currentIndexChanged), | |||||
this, &BitcoinGUI::setCurrentWalletBySelectorIndex); | |||||
m_wallet_selector_label = new QLabel(); | m_wallet_selector_label = new QLabel(); | ||||
m_wallet_selector_label->setText(tr("Wallet:") + " "); | m_wallet_selector_label->setText(tr("Wallet:") + " "); | ||||
m_wallet_selector_label->setBuddy(m_wallet_selector); | m_wallet_selector_label->setBuddy(m_wallet_selector); | ||||
m_wallet_selector_label_action = | m_wallet_selector_label_action = | ||||
appToolBar->addWidget(m_wallet_selector_label); | appToolBar->addWidget(m_wallet_selector_label); | ||||
m_wallet_selector_action = appToolBar->addWidget(m_wallet_selector); | m_wallet_selector_action = appToolBar->addWidget(m_wallet_selector); | ||||
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); | ||||
#endif | #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 | ||||
createTrayIconMenu(); | createTrayIconMenu(); | ||||
// Keep up to date with client | // Keep up to date with client | ||||
updateNetworkState(); | updateNetworkState(); | ||||
connect(_clientModel, SIGNAL(numConnectionsChanged(int)), this, | connect(_clientModel, &ClientModel::numConnectionsChanged, this, | ||||
SLOT(setNumConnections(int))); | &BitcoinGUI::setNumConnections); | ||||
connect(_clientModel, SIGNAL(networkActiveChanged(bool)), this, | connect(_clientModel, &ClientModel::networkActiveChanged, this, | ||||
SLOT(setNetworkActive(bool))); | &BitcoinGUI::setNetworkActive); | ||||
modalOverlay->setKnownBestHeight( | modalOverlay->setKnownBestHeight( | ||||
_clientModel->getHeaderTipHeight(), | _clientModel->getHeaderTipHeight(), | ||||
QDateTime::fromTime_t(_clientModel->getHeaderTipTime())); | QDateTime::fromTime_t(_clientModel->getHeaderTipTime())); | ||||
setNumBlocks(m_node.getNumBlocks(), | setNumBlocks(m_node.getNumBlocks(), | ||||
QDateTime::fromTime_t(m_node.getLastBlockTime()), | QDateTime::fromTime_t(m_node.getLastBlockTime()), | ||||
m_node.getVerificationProgress(), false); | m_node.getVerificationProgress(), false); | ||||
connect(_clientModel, | connect(_clientModel, &ClientModel::numBlocksChanged, this, | ||||
SIGNAL(numBlocksChanged(int, QDateTime, double, bool)), this, | &BitcoinGUI::setNumBlocks); | ||||
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, &ClientModel::message, | ||||
this, SLOT(message(QString, QString, unsigned int))); | [this](const QString &title, const QString &message, | ||||
unsigned int style) { | |||||
this->message(title, message, style); | |||||
}); | |||||
// Show progress dialog | // Show progress dialog | ||||
connect(_clientModel, SIGNAL(showProgress(QString, int)), this, | connect(_clientModel, &ClientModel::showProgress, this, | ||||
SLOT(showProgress(QString, int))); | &BitcoinGUI::showProgress); | ||||
rpcConsole->setClientModel(_clientModel); | rpcConsole->setClientModel(_clientModel); | ||||
updateProxyIcon(); | updateProxyIcon(); | ||||
#ifdef ENABLE_WALLET | #ifdef ENABLE_WALLET | ||||
if (walletFrame) { | if (walletFrame) { | ||||
walletFrame->setClientModel(_clientModel); | walletFrame->setClientModel(_clientModel); | ||||
} | } | ||||
#endif // ENABLE_WALLET | #endif // ENABLE_WALLET | ||||
unitDisplayControl->setOptionsModel(_clientModel->getOptionsModel()); | unitDisplayControl->setOptionsModel(_clientModel->getOptionsModel()); | ||||
OptionsModel *optionsModel = _clientModel->getOptionsModel(); | OptionsModel *optionsModel = _clientModel->getOptionsModel(); | ||||
if (optionsModel) { | if (optionsModel) { | ||||
// be aware of the tray icon disable state change reported by the | // be aware of the tray icon disable state change reported by the | ||||
// OptionsModel object. | // OptionsModel object. | ||||
connect(optionsModel, SIGNAL(hideTrayIconChanged(bool)), this, | connect(optionsModel, &OptionsModel::hideTrayIconChanged, this, | ||||
SLOT(setTrayIconVisible(bool))); | &BitcoinGUI::setTrayIconVisible); | ||||
// initialize the disable state of the tray icon with the current | // initialize the disable state of the tray icon with the current | ||||
// value in the model. | // value in the model. | ||||
setTrayIconVisible(optionsModel->getHideTrayIcon()); | setTrayIconVisible(optionsModel->getHideTrayIcon()); | ||||
} | } | ||||
} else { | } else { | ||||
// Disable possibility to show main window via action | // Disable possibility to show main window via action | ||||
toggleHideAction->setEnabled(false); | toggleHideAction->setEnabled(false); | ||||
▲ Show 20 Lines • Show All 96 Lines • ▼ Show 20 Lines | |||||
void BitcoinGUI::createTrayIconMenu() { | void BitcoinGUI::createTrayIconMenu() { | ||||
#ifndef Q_OS_MAC | #ifndef Q_OS_MAC | ||||
// return if trayIcon is unset (only on non-Mac OSes) | // return if trayIcon is unset (only on non-Mac OSes) | ||||
if (!trayIcon) return; | if (!trayIcon) return; | ||||
trayIconMenu = new QMenu(this); | trayIconMenu = new QMenu(this); | ||||
trayIcon->setContextMenu(trayIconMenu); | trayIcon->setContextMenu(trayIconMenu); | ||||
connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), | connect(trayIcon, &QSystemTrayIcon::activated, this, | ||||
this, SLOT(trayIconActivated(QSystemTrayIcon::ActivationReason))); | &BitcoinGUI::trayIconActivated); | ||||
#else | #else | ||||
// Note: On Mac, the dock icon is used to provide the tray's functionality. | // Note: On Mac, the dock icon is used to provide the tray's functionality. | ||||
MacDockIconHandler *dockIconHandler = MacDockIconHandler::instance(); | MacDockIconHandler *dockIconHandler = MacDockIconHandler::instance(); | ||||
dockIconHandler->setMainWindow(static_cast<QMainWindow *>(this)); | dockIconHandler->setMainWindow(static_cast<QMainWindow *>(this)); | ||||
trayIconMenu = dockIconHandler->dockMenu(); | trayIconMenu = dockIconHandler->dockMenu(); | ||||
#endif | #endif | ||||
// Configuration of the tray icon (or dock icon) icon menu | // Configuration of the tray icon (or dock icon) icon menu | ||||
▲ Show 20 Lines • Show All 344 Lines • ▼ Show 20 Lines | void BitcoinGUI::changeEvent(QEvent *e) { | ||||
QMainWindow::changeEvent(e); | QMainWindow::changeEvent(e); | ||||
#ifndef Q_OS_MAC // Ignored on Mac | #ifndef Q_OS_MAC // Ignored on Mac | ||||
if (e->type() == QEvent::WindowStateChange) { | if (e->type() == QEvent::WindowStateChange) { | ||||
if (clientModel && clientModel->getOptionsModel() && | if (clientModel && clientModel->getOptionsModel() && | ||||
clientModel->getOptionsModel()->getMinimizeToTray()) { | clientModel->getOptionsModel()->getMinimizeToTray()) { | ||||
QWindowStateChangeEvent *wsevt = | QWindowStateChangeEvent *wsevt = | ||||
static_cast<QWindowStateChangeEvent *>(e); | static_cast<QWindowStateChangeEvent *>(e); | ||||
if (!(wsevt->oldState() & Qt::WindowMinimized) && isMinimized()) { | if (!(wsevt->oldState() & Qt::WindowMinimized) && isMinimized()) { | ||||
QTimer::singleShot(0, this, SLOT(hide())); | QTimer::singleShot(0, this, &BitcoinGUI::hide); | ||||
e->ignore(); | e->ignore(); | ||||
} else if ((wsevt->oldState() & Qt::WindowMinimized) && | } else if ((wsevt->oldState() & Qt::WindowMinimized) && | ||||
!isMinimized()) { | !isMinimized()) { | ||||
QTimer::singleShot(0, this, SLOT(show())); | QTimer::singleShot(0, this, &BitcoinGUI::show); | ||||
e->ignore(); | e->ignore(); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
#endif | #endif | ||||
} | } | ||||
void BitcoinGUI::closeEvent(QCloseEvent *event) { | void BitcoinGUI::closeEvent(QCloseEvent *event) { | ||||
▲ Show 20 Lines • Show All 294 Lines • ▼ Show 20 Lines | |||||
* mouse events. */ | * mouse events. */ | ||||
void UnitDisplayStatusBarControl::createContextMenu() { | void UnitDisplayStatusBarControl::createContextMenu() { | ||||
menu = new QMenu(this); | menu = new QMenu(this); | ||||
for (const BitcoinUnits::Unit u : BitcoinUnits::availableUnits()) { | for (const BitcoinUnits::Unit u : BitcoinUnits::availableUnits()) { | ||||
QAction *menuAction = new QAction(QString(BitcoinUnits::name(u)), this); | QAction *menuAction = new QAction(QString(BitcoinUnits::name(u)), this); | ||||
menuAction->setData(QVariant(u)); | menuAction->setData(QVariant(u)); | ||||
menu->addAction(menuAction); | menu->addAction(menuAction); | ||||
} | } | ||||
connect(menu, SIGNAL(triggered(QAction *)), this, | connect(menu, &QMenu::triggered, this, | ||||
SLOT(onMenuSelection(QAction *))); | &UnitDisplayStatusBarControl::onMenuSelection); | ||||
} | } | ||||
/** Lets the control know about the Options Model (and its signals) */ | /** Lets the control know about the Options Model (and its signals) */ | ||||
void UnitDisplayStatusBarControl::setOptionsModel(OptionsModel *_optionsModel) { | void UnitDisplayStatusBarControl::setOptionsModel(OptionsModel *_optionsModel) { | ||||
if (_optionsModel) { | if (_optionsModel) { | ||||
this->optionsModel = _optionsModel; | this->optionsModel = _optionsModel; | ||||
// be aware of a display unit change reported by the OptionsModel | // be aware of a display unit change reported by the OptionsModel | ||||
// object. | // object. | ||||
connect(_optionsModel, SIGNAL(displayUnitChanged(int)), this, | connect(_optionsModel, &OptionsModel::displayUnitChanged, this, | ||||
SLOT(updateDisplayUnit(int))); | &UnitDisplayStatusBarControl::updateDisplayUnit); | ||||
// initialize the display units label with the current value in the | // initialize the display units label with the current value in the | ||||
// model. | // model. | ||||
updateDisplayUnit(_optionsModel->getDisplayUnit()); | updateDisplayUnit(_optionsModel->getDisplayUnit()); | ||||
} | } | ||||
} | } | ||||
/** When Display Units are changed on OptionsModel it will refresh the display | /** When Display Units are changed on OptionsModel it will refresh the display | ||||
Show All 17 Lines |