Skip to content

Commit

Permalink
Fix minimized window bug on Linux
Browse files Browse the repository at this point in the history
On some Linux systems the minimized to the taskbar (iconified) main
window cannot be restored properly using actions from the systray icon
menu when QSystemTrayIcon::contextMenu() is a child of the main window.
  • Loading branch information
hebasto committed Jan 4, 2019
1 parent c651265 commit a88640e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/qt/bitcoingui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include <util/system.h>

#include <iostream>
#include <memory>

#include <QAction>
#include <QApplication>
Expand All @@ -44,6 +45,7 @@
#include <QDesktopWidget>
#include <QDragEnterEvent>
#include <QListWidget>
#include <QMenu>
#include <QMenuBar>
#include <QMessageBox>
#include <QMimeData>
Expand All @@ -53,6 +55,7 @@
#include <QStackedWidget>
#include <QStatusBar>
#include <QStyle>
#include <QSystemTrayIcon>
#include <QTimer>
#include <QToolBar>
#include <QUrlQuery>
Expand All @@ -73,6 +76,7 @@ const std::string BitcoinGUI::DEFAULT_UIPLATFORM =
BitcoinGUI::BitcoinGUI(interfaces::Node& node, const PlatformStyle *_platformStyle, const NetworkStyle *networkStyle, QWidget *parent) :
QMainWindow(parent),
m_node(node),
trayIconMenu{new QMenu()},
platformStyle(_platformStyle)
{
QSettings settings;
Expand Down Expand Up @@ -610,16 +614,12 @@ void BitcoinGUI::createTrayIconMenu()
if (!trayIcon)
return;

trayIconMenu = new QMenu(this);
trayIcon->setContextMenu(trayIconMenu);

trayIcon->setContextMenu(trayIconMenu.get());
connect(trayIcon, &QSystemTrayIcon::activated, this, &BitcoinGUI::trayIconActivated);
#else
// Note: On macOS, the Dock icon is used to provide the tray's functionality.
MacDockIconHandler *dockIconHandler = MacDockIconHandler::instance();
connect(dockIconHandler, &MacDockIconHandler::dockIconClicked, this, &BitcoinGUI::macosDockIconActivated);

trayIconMenu = new QMenu(this);
trayIconMenu->setAsDockMenu();
#endif

Expand Down
4 changes: 2 additions & 2 deletions src/qt/bitcoingui.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#include <QLabel>
#include <QMainWindow>
#include <QMap>
#include <QMenu>
#include <QPoint>
#include <QSystemTrayIcon>

Expand Down Expand Up @@ -47,6 +46,7 @@ class Node;
QT_BEGIN_NAMESPACE
class QAction;
class QComboBox;
class QMenu;
class QProgressBar;
class QProgressDialog;
QT_END_NAMESPACE
Expand Down Expand Up @@ -141,7 +141,7 @@ class BitcoinGUI : public QMainWindow
QComboBox* m_wallet_selector = nullptr;

QSystemTrayIcon* trayIcon = nullptr;
QMenu* trayIconMenu = nullptr;
const std::unique_ptr<QMenu> trayIconMenu;
Notificator* notificator = nullptr;
RPCConsole* rpcConsole = nullptr;
HelpMessageDialog* helpMessageDialog = nullptr;
Expand Down

0 comments on commit a88640e

Please sign in to comment.