Qt: Add option to hide the system tray icon
My changes leave all tray icon and menu creation/initialization logic untouched. It only shows or hides the icon according to the setting. A new checkbox was added to the OptionsDialog under the Window tab. A bool option named "hideTrayIcon" was added to OptionsModel. This checkbox was mapped like other all options to the OptionsModel. A signal was added to the OptionsModel for broadcasting changes the the hideTrayIcon option. This signal was connected to a new slot added to BitcoinGUI named setTrayIconVisible(bool). The slot simply hides or shows the trayIcon in BitcoinGUI according to the parameter recieved.
This commit is contained in:
@@ -500,6 +500,16 @@ void BitcoinGUI::setClientModel(ClientModel *clientModel)
|
||||
}
|
||||
#endif // ENABLE_WALLET
|
||||
unitDisplayControl->setOptionsModel(clientModel->getOptionsModel());
|
||||
|
||||
OptionsModel* optionsModel = clientModel->getOptionsModel();
|
||||
if(optionsModel)
|
||||
{
|
||||
// be aware of the tray icon disable state change reported by the OptionsModel object.
|
||||
connect(optionsModel,SIGNAL(hideTrayIconChanged(bool)),this,SLOT(setTrayIconVisible(bool)));
|
||||
|
||||
// initialize the disable state of the tray icon with the current value in the model.
|
||||
setTrayIconVisible(optionsModel->getHideTrayIcon());
|
||||
}
|
||||
} else {
|
||||
// Disable possibility to show main window via action
|
||||
toggleHideAction->setEnabled(false);
|
||||
@@ -562,7 +572,7 @@ void BitcoinGUI::createTrayIcon(const NetworkStyle *networkStyle)
|
||||
QString toolTip = tr("Bitcoin Core client") + " " + networkStyle->getTitleAddText();
|
||||
trayIcon->setToolTip(toolTip);
|
||||
trayIcon->setIcon(networkStyle->getTrayAndWindowIcon());
|
||||
trayIcon->show();
|
||||
trayIcon->hide();
|
||||
#endif
|
||||
|
||||
notificator = new Notificator(QApplication::applicationName(), trayIcon, this);
|
||||
@@ -1134,6 +1144,14 @@ void BitcoinGUI::showProgress(const QString &title, int nProgress)
|
||||
progressDialog->setValue(nProgress);
|
||||
}
|
||||
|
||||
void BitcoinGUI::setTrayIconVisible(bool fHideTrayIcon)
|
||||
{
|
||||
if (trayIcon)
|
||||
{
|
||||
trayIcon->setVisible(!fHideTrayIcon);
|
||||
}
|
||||
}
|
||||
|
||||
static bool ThreadSafeMessageBox(BitcoinGUI *gui, const std::string& message, const std::string& caption, unsigned int style)
|
||||
{
|
||||
bool modal = (style & CClientUIInterface::MODAL);
|
||||
|
||||
Reference in New Issue
Block a user