Fix minimized window bug on Linux

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.
This commit is contained in:
Hennadii Stepanov 2018-10-28 15:48:05 +02:00
parent c651265c93
commit a88640e123
No known key found for this signature in database
GPG key ID: 410108112E7EA81F
2 changed files with 7 additions and 7 deletions

View file

@ -36,6 +36,7 @@
#include <util/system.h> #include <util/system.h>
#include <iostream> #include <iostream>
#include <memory>
#include <QAction> #include <QAction>
#include <QApplication> #include <QApplication>
@ -44,6 +45,7 @@
#include <QDesktopWidget> #include <QDesktopWidget>
#include <QDragEnterEvent> #include <QDragEnterEvent>
#include <QListWidget> #include <QListWidget>
#include <QMenu>
#include <QMenuBar> #include <QMenuBar>
#include <QMessageBox> #include <QMessageBox>
#include <QMimeData> #include <QMimeData>
@ -53,6 +55,7 @@
#include <QStackedWidget> #include <QStackedWidget>
#include <QStatusBar> #include <QStatusBar>
#include <QStyle> #include <QStyle>
#include <QSystemTrayIcon>
#include <QTimer> #include <QTimer>
#include <QToolBar> #include <QToolBar>
#include <QUrlQuery> #include <QUrlQuery>
@ -73,6 +76,7 @@ const std::string BitcoinGUI::DEFAULT_UIPLATFORM =
BitcoinGUI::BitcoinGUI(interfaces::Node& node, const PlatformStyle *_platformStyle, const NetworkStyle *networkStyle, QWidget *parent) : BitcoinGUI::BitcoinGUI(interfaces::Node& node, const PlatformStyle *_platformStyle, const NetworkStyle *networkStyle, QWidget *parent) :
QMainWindow(parent), QMainWindow(parent),
m_node(node), m_node(node),
trayIconMenu{new QMenu()},
platformStyle(_platformStyle) platformStyle(_platformStyle)
{ {
QSettings settings; QSettings settings;
@ -610,16 +614,12 @@ void BitcoinGUI::createTrayIconMenu()
if (!trayIcon) if (!trayIcon)
return; return;
trayIconMenu = new QMenu(this); trayIcon->setContextMenu(trayIconMenu.get());
trayIcon->setContextMenu(trayIconMenu);
connect(trayIcon, &QSystemTrayIcon::activated, this, &BitcoinGUI::trayIconActivated); connect(trayIcon, &QSystemTrayIcon::activated, this, &BitcoinGUI::trayIconActivated);
#else #else
// Note: On macOS, the Dock icon is used to provide the tray's functionality. // Note: On macOS, the Dock icon is used to provide the tray's functionality.
MacDockIconHandler *dockIconHandler = MacDockIconHandler::instance(); MacDockIconHandler *dockIconHandler = MacDockIconHandler::instance();
connect(dockIconHandler, &MacDockIconHandler::dockIconClicked, this, &BitcoinGUI::macosDockIconActivated); connect(dockIconHandler, &MacDockIconHandler::dockIconClicked, this, &BitcoinGUI::macosDockIconActivated);
trayIconMenu = new QMenu(this);
trayIconMenu->setAsDockMenu(); trayIconMenu->setAsDockMenu();
#endif #endif

View file

@ -16,7 +16,6 @@
#include <QLabel> #include <QLabel>
#include <QMainWindow> #include <QMainWindow>
#include <QMap> #include <QMap>
#include <QMenu>
#include <QPoint> #include <QPoint>
#include <QSystemTrayIcon> #include <QSystemTrayIcon>
@ -47,6 +46,7 @@ class Node;
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QAction; class QAction;
class QComboBox; class QComboBox;
class QMenu;
class QProgressBar; class QProgressBar;
class QProgressDialog; class QProgressDialog;
QT_END_NAMESPACE QT_END_NAMESPACE
@ -141,7 +141,7 @@ private:
QComboBox* m_wallet_selector = nullptr; QComboBox* m_wallet_selector = nullptr;
QSystemTrayIcon* trayIcon = nullptr; QSystemTrayIcon* trayIcon = nullptr;
QMenu* trayIconMenu = nullptr; const std::unique_ptr<QMenu> trayIconMenu;
Notificator* notificator = nullptr; Notificator* notificator = nullptr;
RPCConsole* rpcConsole = nullptr; RPCConsole* rpcConsole = nullptr;
HelpMessageDialog* helpMessageDialog = nullptr; HelpMessageDialog* helpMessageDialog = nullptr;