electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 0bc42a1f1fe52142f548e392bd40f2f5f25231c0
parent 8c9a26cbf7b26bceaaa2beb481847ab9bda054c1
Author: ThomasV <thomasv1@gmx.de>
Date:   Wed, 22 Jan 2014 06:42:20 -0800

Merge pull request #553 from samrg472/master

Added ability to minimize to tray
Diffstat:
Mgui/qt/main_window.py | 33+++++++++------------------------
1 file changed, 9 insertions(+), 24 deletions(-)

diff --git a/gui/qt/main_window.py b/gui/qt/main_window.py @@ -98,37 +98,22 @@ class StatusBarButton(QPushButton): default_column_widths = { "history":[40,140,350,140], "contacts":[350,330], "receive": [370,200,130] } class ElectrumWindow(QMainWindow): - def changeEvent(self, event): - 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): + def build_menu(self): m = QMenu() - if self.isMinimized(): - m.addAction(_("Show"), self.showNormal) - else: - m.addAction(_("Hide"), self.showMinimized) - + m.addAction(_("Show/Hide"), self.show_or_hide) m.addSeparator() m.addAction(_("Exit Electrum"), self.close) self.tray.setContextMenu(m) + def show_or_hide(self): + self.tray_activated(QSystemTrayIcon.DoubleClick) + def tray_activated(self, reason): if reason == QSystemTrayIcon.DoubleClick: - self.showNormal() - - def showNormal(self): - self.setWindowState(self.windowState() & ~QtCore.Qt.WindowMinimized | QtCore.Qt.WindowActive) + if self.isMinimized() or self.isHidden(): + self.show() + else: + self.hide() def __init__(self, config, network): QMainWindow.__init__(self)