Skip to content

Commit 5cdfd72

Browse files
committed
Merge #14228: Qt: Enable system tray icon by default if available
ec1201a Don't use systray icon on inappropriate systems (Hennadii Stepanov) Pull request description: Prevent a user from losing access to the main window by minimizing it to the tray on the systems which have not “system tray” or “notification area” available (e.g. GNOME 3.26+). Tested on Fedora 28 + GNOME 3.28. Tree-SHA512: c2dc26ff31c38a882dbd7d1ff71af99f1ba38a04a1c8b7fe7b99b93e4c0719f2916c7db0e620806a36582402d18939c635e1913c276b452ecbf939936067407b
2 parents af3c8a7 + ec1201a commit 5cdfd72

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

src/qt/bitcoingui.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,9 @@ BitcoinGUI::BitcoinGUI(interfaces::Node& node, const PlatformStyle *_platformSty
127127
createToolBars();
128128

129129
// Create system tray icon and notification
130-
createTrayIcon(networkStyle);
130+
if (QSystemTrayIcon::isSystemTrayAvailable()) {
131+
createTrayIcon(networkStyle);
132+
}
131133

132134
// Create status bar
133135
statusBar();
@@ -588,6 +590,8 @@ void BitcoinGUI::setWalletActionsEnabled(bool enabled)
588590

589591
void BitcoinGUI::createTrayIcon(const NetworkStyle *networkStyle)
590592
{
593+
assert(QSystemTrayIcon::isSystemTrayAvailable());
594+
591595
#ifndef Q_OS_MAC
592596
trayIcon = new QSystemTrayIcon(this);
593597
QString toolTip = tr("%1 client").arg(tr(PACKAGE_NAME)) + " " + networkStyle->getTitleAddText();

src/qt/optionsdialog.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <QIntValidator>
2424
#include <QLocale>
2525
#include <QMessageBox>
26+
#include <QSystemTrayIcon>
2627
#include <QTimer>
2728

2829
OptionsDialog::OptionsDialog(QWidget *parent, bool enableWallet) :
@@ -126,6 +127,13 @@ OptionsDialog::OptionsDialog(QWidget *parent, bool enableWallet) :
126127
connect(ui->proxyIpTor, &QValidatedLineEdit::validationDidChange, this, &OptionsDialog::updateProxyValidationState);
127128
connect(ui->proxyPort, &QLineEdit::textChanged, this, &OptionsDialog::updateProxyValidationState);
128129
connect(ui->proxyPortTor, &QLineEdit::textChanged, this, &OptionsDialog::updateProxyValidationState);
130+
131+
if (!QSystemTrayIcon::isSystemTrayAvailable()) {
132+
ui->hideTrayIcon->setChecked(true);
133+
ui->hideTrayIcon->setEnabled(false);
134+
ui->minimizeToTray->setChecked(false);
135+
ui->minimizeToTray->setEnabled(false);
136+
}
129137
}
130138

131139
OptionsDialog::~OptionsDialog()
@@ -211,8 +219,10 @@ void OptionsDialog::setMapper()
211219

212220
/* Window */
213221
#ifndef Q_OS_MAC
214-
mapper->addMapping(ui->hideTrayIcon, OptionsModel::HideTrayIcon);
215-
mapper->addMapping(ui->minimizeToTray, OptionsModel::MinimizeToTray);
222+
if (QSystemTrayIcon::isSystemTrayAvailable()) {
223+
mapper->addMapping(ui->hideTrayIcon, OptionsModel::HideTrayIcon);
224+
mapper->addMapping(ui->minimizeToTray, OptionsModel::MinimizeToTray);
225+
}
216226
mapper->addMapping(ui->minimizeOnClose, OptionsModel::MinimizeOnClose);
217227
#endif
218228

0 commit comments

Comments
 (0)