Skip to content

Commit

Permalink
Don't use systray icon on inappropriate systems
Browse files Browse the repository at this point in the history
Prevent a user from losing access to the main window by minimizing it to
the tray on some systems (e.g. GNOME 3.26+).
  • Loading branch information
hebasto committed Sep 27, 2018
1 parent d799efe commit ec1201a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/qt/bitcoingui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@ BitcoinGUI::BitcoinGUI(interfaces::Node& node, const PlatformStyle *_platformSty
createToolBars();

// Create system tray icon and notification
createTrayIcon(networkStyle);
if (QSystemTrayIcon::isSystemTrayAvailable()) {
createTrayIcon(networkStyle);
}

// Create status bar
statusBar();
Expand Down Expand Up @@ -585,6 +587,8 @@ void BitcoinGUI::setWalletActionsEnabled(bool enabled)

void BitcoinGUI::createTrayIcon(const NetworkStyle *networkStyle)
{
assert(QSystemTrayIcon::isSystemTrayAvailable());

#ifndef Q_OS_MAC
trayIcon = new QSystemTrayIcon(this);
QString toolTip = tr("%1 client").arg(tr(PACKAGE_NAME)) + " " + networkStyle->getTitleAddText();
Expand Down
14 changes: 12 additions & 2 deletions src/qt/optionsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <QIntValidator>
#include <QLocale>
#include <QMessageBox>
#include <QSystemTrayIcon>
#include <QTimer>

OptionsDialog::OptionsDialog(QWidget *parent, bool enableWallet) :
Expand Down Expand Up @@ -126,6 +127,13 @@ OptionsDialog::OptionsDialog(QWidget *parent, bool enableWallet) :
connect(ui->proxyIpTor, &QValidatedLineEdit::validationDidChange, this, &OptionsDialog::updateProxyValidationState);
connect(ui->proxyPort, &QLineEdit::textChanged, this, &OptionsDialog::updateProxyValidationState);
connect(ui->proxyPortTor, &QLineEdit::textChanged, this, &OptionsDialog::updateProxyValidationState);

if (!QSystemTrayIcon::isSystemTrayAvailable()) {
ui->hideTrayIcon->setChecked(true);
ui->hideTrayIcon->setEnabled(false);
ui->minimizeToTray->setChecked(false);
ui->minimizeToTray->setEnabled(false);
}
}

OptionsDialog::~OptionsDialog()
Expand Down Expand Up @@ -211,8 +219,10 @@ void OptionsDialog::setMapper()

/* Window */
#ifndef Q_OS_MAC
mapper->addMapping(ui->hideTrayIcon, OptionsModel::HideTrayIcon);
mapper->addMapping(ui->minimizeToTray, OptionsModel::MinimizeToTray);
if (QSystemTrayIcon::isSystemTrayAvailable()) {
mapper->addMapping(ui->hideTrayIcon, OptionsModel::HideTrayIcon);
mapper->addMapping(ui->minimizeToTray, OptionsModel::MinimizeToTray);
}
mapper->addMapping(ui->minimizeOnClose, OptionsModel::MinimizeOnClose);
#endif

Expand Down

0 comments on commit ec1201a

Please sign in to comment.