class StartQT4 QMainWindow def __init__ self paused True parent None i

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
class StartQT4(QMainWindow):
def __init__(self, paused=True, parent=None):
...
if QSystemTrayIcon.isSystemTrayAvailable():
self.tray_icon = QSystemTrayIcon(QIcon("icons/main_clock.png"))
self.connect(self.tray_icon, SIGNAL('activated(QSystemTrayIcon::ActivationReason)'), self.toggleMainWindowVisibility)
self.tray_icon.show()
self.tray_icon.setToolTip(u'Choose your task')
def changeEvent(self, event):
""
if event.type() == QEvent.WindowStateChange:
if self.isMinimized(): self.hide(event.oldState())
#else: self.show(event.oldState())
def hide(self, state = None):
if state != None: self.__windowState = state
else: self.__windowState = self.windowState()
self.setWindowFlags(self.windowFlags()^Qt.WindowSystemMenuHint)
self.__windowState=self.saveState()
QMainWindow.hide(self)
def toggleMainWindowVisibility(self):
""
if self.isVisible():
self.showMinimized()
self.hide()
else:
self.show()
self.showNormal()
self.restoreState(self.__windowState)