Merge pull request #553 from samrg472/master
Added ability to minimize to tray
This commit is contained in:
commit
0bc42a1f1f
|
@ -98,37 +98,22 @@ class StatusBarButton(QPushButton):
|
||||||
default_column_widths = { "history":[40,140,350,140], "contacts":[350,330], "receive": [370,200,130] }
|
default_column_widths = { "history":[40,140,350,140], "contacts":[350,330], "receive": [370,200,130] }
|
||||||
|
|
||||||
class ElectrumWindow(QMainWindow):
|
class ElectrumWindow(QMainWindow):
|
||||||
def changeEvent(self, event):
|
def build_menu(self):
|
||||||
flags = self.windowFlags();
|
|
||||||
if event and event.type() == QtCore.QEvent.WindowStateChange:
|
|
||||||
if self.windowState() & QtCore.Qt.WindowMinimized:
|
|
||||||
self.build_menu(True)
|
|
||||||
# The only way to toggle the icon in the window managers taskbar is to use the Qt.Tooltip flag
|
|
||||||
# The problem is that it somehow creates an (in)visible window that will stay active and prevent
|
|
||||||
# Electrum from closing.
|
|
||||||
# As for now I have no clue how to implement a proper 'hide to tray' functionality.
|
|
||||||
# self.setWindowFlags(flags & ~Qt.ToolTip)
|
|
||||||
elif event.oldState() & QtCore.Qt.WindowMinimized:
|
|
||||||
self.build_menu(False)
|
|
||||||
#self.setWindowFlags(flags | Qt.ToolTip)
|
|
||||||
|
|
||||||
def build_menu(self, is_hidden = False):
|
|
||||||
m = QMenu()
|
m = QMenu()
|
||||||
if self.isMinimized():
|
m.addAction(_("Show/Hide"), self.show_or_hide)
|
||||||
m.addAction(_("Show"), self.showNormal)
|
|
||||||
else:
|
|
||||||
m.addAction(_("Hide"), self.showMinimized)
|
|
||||||
|
|
||||||
m.addSeparator()
|
m.addSeparator()
|
||||||
m.addAction(_("Exit Electrum"), self.close)
|
m.addAction(_("Exit Electrum"), self.close)
|
||||||
self.tray.setContextMenu(m)
|
self.tray.setContextMenu(m)
|
||||||
|
|
||||||
|
def show_or_hide(self):
|
||||||
|
self.tray_activated(QSystemTrayIcon.DoubleClick)
|
||||||
|
|
||||||
def tray_activated(self, reason):
|
def tray_activated(self, reason):
|
||||||
if reason == QSystemTrayIcon.DoubleClick:
|
if reason == QSystemTrayIcon.DoubleClick:
|
||||||
self.showNormal()
|
if self.isMinimized() or self.isHidden():
|
||||||
|
self.show()
|
||||||
def showNormal(self):
|
else:
|
||||||
self.setWindowState(self.windowState() & ~QtCore.Qt.WindowMinimized | QtCore.Qt.WindowActive)
|
self.hide()
|
||||||
|
|
||||||
def __init__(self, config, network):
|
def __init__(self, config, network):
|
||||||
QMainWindow.__init__(self)
|
QMainWindow.__init__(self)
|
||||||
|
|
Loading…
Reference in New Issue