VCS/StatusMonitorLed.py

changeset 3013
fe886b7f8f40
parent 2302
f29e9405c851
child 3057
10516539f238
child 3160
209a07d7e401
equal deleted inserted replaced
3012:d177226027e2 3013:fe886b7f8f40
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 PyQt4.QtCore import Qt 11 from PyQt4.QtCore import Qt
11 from PyQt4.QtGui import QColor, QInputDialog, QMenu 12 from PyQt4.QtGui import QColor, QInputDialog, QMenu
12 13
15 import Preferences 16 import Preferences
16 17
17 18
18 class StatusMonitorLed(E5Led): 19 class StatusMonitorLed(E5Led):
19 """ 20 """
20 Class implementing a LED to indicate the status of the VCS status monitor thread. 21 Class implementing a LED to indicate the status of the VCS status monitor
22 thread.
21 """ 23 """
22 def __init__(self, project, parent): 24 def __init__(self, project, parent):
23 """ 25 """
24 Constructor 26 Constructor
25 27
41 self.__on = False 43 self.__on = False
42 44
43 self.setWhatsThis(self.trUtf8( 45 self.setWhatsThis(self.trUtf8(
44 """<p>This LED indicates the operating""" 46 """<p>This LED indicates the operating"""
45 """ status of the VCS monitor thread (off = monitoring off,""" 47 """ status of the VCS monitor thread (off = monitoring off,"""
46 """ green = monitoring on and ok, red = monitoring on, but not ok,""" 48 """ green = monitoring on and ok, red = monitoring on, but"""
47 """ yellow = checking VCS status). A status description is given""" 49 """ not ok, yellow = checking VCS status). A status description"""
48 """ in the tooltip.</p>""" 50 """ is given in the tooltip.</p>"""
49 )) 51 ))
50 self.setToolTip( 52 self.setToolTip(
51 self.trUtf8("Repository status checking is switched off") 53 self.trUtf8("Repository status checking is switched off")
52 ) 54 )
53 self.setColor(self.vcsMonitorLedColors["off"]) 55 self.setColor(self.vcsMonitorLedColors["off"])
54 56
55 # define a context menu 57 # define a context menu
56 self.__menu = QMenu(self) 58 self.__menu = QMenu(self)
57 self.__checkAct = \ 59 self.__checkAct = self.__menu.addAction(
58 self.__menu.addAction(self.trUtf8("Check status"), self.__checkStatus) 60 self.trUtf8("Check status"), self.__checkStatus)
59 self.__intervalAct = \ 61 self.__intervalAct = self.__menu.addAction(
60 self.__menu.addAction(self.trUtf8("Set interval..."), self.__setInterval) 62 self.trUtf8("Set interval..."), self.__setInterval)
61 self.__menu.addSeparator() 63 self.__menu.addSeparator()
62 self.__onAct = \ 64 self.__onAct = self.__menu.addAction(
63 self.__menu.addAction(self.trUtf8("Switch on"), self.__switchOn) 65 self.trUtf8("Switch on"), self.__switchOn)
64 self.__offAct = \ 66 self.__offAct = self.__menu.addAction(
65 self.__menu.addAction(self.trUtf8("Switch off"), self.__switchOff) 67 self.trUtf8("Switch off"), self.__switchOff)
66 self.__checkActions() 68 self.__checkActions()
67 69
68 # connect signals to our slots 70 # connect signals to our slots
69 self.setContextMenuPolicy(Qt.CustomContextMenu) 71 self.setContextMenuPolicy(Qt.CustomContextMenu)
70 self.customContextMenuRequested.connect(self._showContextMenu) 72 self.customContextMenuRequested.connect(self._showContextMenu)
71 self.project.vcsStatusMonitorStatus.connect(self.__projectVcsMonitorStatus) 73 self.project.vcsStatusMonitorStatus.connect(
74 self.__projectVcsMonitorStatus)
72 75
73 def __checkActions(self): 76 def __checkActions(self):
74 """ 77 """
75 Private method to set the enabled status of the context menu actions. 78 Private method to set the enabled status of the context menu actions.
76 """ 79 """
77 if self.project.pudata["VCSSTATUSMONITORINTERVAL"]: 80 if self.project.pudata["VCSSTATUSMONITORINTERVAL"]:
78 vcsStatusMonitorInterval = self.project.pudata["VCSSTATUSMONITORINTERVAL"][0] 81 vcsStatusMonitorInterval = \
82 self.project.pudata["VCSSTATUSMONITORINTERVAL"][0]
79 else: 83 else:
80 vcsStatusMonitorInterval = Preferences.getVCS("StatusMonitorInterval") 84 vcsStatusMonitorInterval = \
85 Preferences.getVCS("StatusMonitorInterval")
81 self.__checkAct.setEnabled(self.__on) 86 self.__checkAct.setEnabled(self.__on)
82 self.__intervalAct.setEnabled(self.__on) 87 self.__intervalAct.setEnabled(self.__on)
83 self.__onAct.setEnabled((not self.__on) and vcsStatusMonitorInterval > 0) 88 self.__onAct.setEnabled(
89 (not self.__on) and vcsStatusMonitorInterval > 0)
84 self.__offAct.setEnabled(self.__on) 90 self.__offAct.setEnabled(self.__on)
85 91
86 def __projectVcsMonitorStatus(self, status, statusMsg): 92 def __projectVcsMonitorStatus(self, status, statusMsg):
87 """ 93 """
88 Private method to receive the status monitor status. 94 Private method to receive the status monitor status.

eric ide

mercurial