VCS/StatusMonitorLed.py

branch
Py2 comp.
changeset 3057
10516539f238
parent 2525
8b507a9a2d40
parent 3013
fe886b7f8f40
child 3145
a9de05d4a22f
equal deleted inserted replaced
3056:9986ec0e559a 3057:10516539f238
2 2
3 # Copyright (c) 2007 - 2013 Detlev Offenbach <detlev@die-offenbachs.de> 3 # Copyright (c) 2007 - 2013 Detlev Offenbach <detlev@die-offenbachs.de>
4 # 4 #
5 5
6 """ 6 """
7 Module implementing a LED to indicate the status of the VCS status monitor thread. 7 Module implementing a LED to indicate the status of the VCS status monitor
8 thread.
8 """ 9 """
9 10
10 from __future__ import unicode_literals # __IGNORE_WARNING__ 11 from __future__ import unicode_literals # __IGNORE_WARNING__
11 12
12 from PyQt4.QtCore import Qt 13 from PyQt4.QtCore import Qt
17 import Preferences 18 import Preferences
18 19
19 20
20 class StatusMonitorLed(E5Led): 21 class StatusMonitorLed(E5Led):
21 """ 22 """
22 Class implementing a LED to indicate the status of the VCS status monitor thread. 23 Class implementing a LED to indicate the status of the VCS status monitor
24 thread.
23 """ 25 """
24 def __init__(self, project, parent): 26 def __init__(self, project, parent):
25 """ 27 """
26 Constructor 28 Constructor
27 29
43 self.__on = False 45 self.__on = False
44 46
45 self.setWhatsThis(self.trUtf8( 47 self.setWhatsThis(self.trUtf8(
46 """<p>This LED indicates the operating""" 48 """<p>This LED indicates the operating"""
47 """ status of the VCS monitor thread (off = monitoring off,""" 49 """ status of the VCS monitor thread (off = monitoring off,"""
48 """ green = monitoring on and ok, red = monitoring on, but not ok,""" 50 """ green = monitoring on and ok, red = monitoring on, but"""
49 """ yellow = checking VCS status). A status description is given""" 51 """ not ok, yellow = checking VCS status). A status description"""
50 """ in the tooltip.</p>""" 52 """ is given in the tooltip.</p>"""
51 )) 53 ))
52 self.setToolTip( 54 self.setToolTip(
53 self.trUtf8("Repository status checking is switched off") 55 self.trUtf8("Repository status checking is switched off")
54 ) 56 )
55 self.setColor(self.vcsMonitorLedColors["off"]) 57 self.setColor(self.vcsMonitorLedColors["off"])
56 58
57 # define a context menu 59 # define a context menu
58 self.__menu = QMenu(self) 60 self.__menu = QMenu(self)
59 self.__checkAct = \ 61 self.__checkAct = self.__menu.addAction(
60 self.__menu.addAction(self.trUtf8("Check status"), self.__checkStatus) 62 self.trUtf8("Check status"), self.__checkStatus)
61 self.__intervalAct = \ 63 self.__intervalAct = self.__menu.addAction(
62 self.__menu.addAction(self.trUtf8("Set interval..."), self.__setInterval) 64 self.trUtf8("Set interval..."), self.__setInterval)
63 self.__menu.addSeparator() 65 self.__menu.addSeparator()
64 self.__onAct = \ 66 self.__onAct = self.__menu.addAction(
65 self.__menu.addAction(self.trUtf8("Switch on"), self.__switchOn) 67 self.trUtf8("Switch on"), self.__switchOn)
66 self.__offAct = \ 68 self.__offAct = self.__menu.addAction(
67 self.__menu.addAction(self.trUtf8("Switch off"), self.__switchOff) 69 self.trUtf8("Switch off"), self.__switchOff)
68 self.__checkActions() 70 self.__checkActions()
69 71
70 # connect signals to our slots 72 # connect signals to our slots
71 self.setContextMenuPolicy(Qt.CustomContextMenu) 73 self.setContextMenuPolicy(Qt.CustomContextMenu)
72 self.customContextMenuRequested.connect(self._showContextMenu) 74 self.customContextMenuRequested.connect(self._showContextMenu)
73 self.project.vcsStatusMonitorStatus.connect(self.__projectVcsMonitorStatus) 75 self.project.vcsStatusMonitorStatus.connect(
76 self.__projectVcsMonitorStatus)
74 77
75 def __checkActions(self): 78 def __checkActions(self):
76 """ 79 """
77 Private method to set the enabled status of the context menu actions. 80 Private method to set the enabled status of the context menu actions.
78 """ 81 """
79 if self.project.pudata["VCSSTATUSMONITORINTERVAL"]: 82 if self.project.pudata["VCSSTATUSMONITORINTERVAL"]:
80 vcsStatusMonitorInterval = self.project.pudata["VCSSTATUSMONITORINTERVAL"][0] 83 vcsStatusMonitorInterval = \
84 self.project.pudata["VCSSTATUSMONITORINTERVAL"][0]
81 else: 85 else:
82 vcsStatusMonitorInterval = Preferences.getVCS("StatusMonitorInterval") 86 vcsStatusMonitorInterval = \
87 Preferences.getVCS("StatusMonitorInterval")
83 self.__checkAct.setEnabled(self.__on) 88 self.__checkAct.setEnabled(self.__on)
84 self.__intervalAct.setEnabled(self.__on) 89 self.__intervalAct.setEnabled(self.__on)
85 self.__onAct.setEnabled((not self.__on) and vcsStatusMonitorInterval > 0) 90 self.__onAct.setEnabled(
91 (not self.__on) and vcsStatusMonitorInterval > 0)
86 self.__offAct.setEnabled(self.__on) 92 self.__offAct.setEnabled(self.__on)
87 93
88 def __projectVcsMonitorStatus(self, status, statusMsg): 94 def __projectVcsMonitorStatus(self, status, statusMsg):
89 """ 95 """
90 Private method to receive the status monitor status. 96 Private method to receive the status monitor status.

eric ide

mercurial