9 """ |
9 """ |
10 |
10 |
11 from PyQt4.QtCore import Qt |
11 from PyQt4.QtCore import Qt |
12 from PyQt4.QtGui import QColor, QInputDialog, QMenu |
12 from PyQt4.QtGui import QColor, QInputDialog, QMenu |
13 |
13 |
14 from E5Gui.E5Led import E5Led, E5LedRectangular |
14 from E5Gui.E5Led import E5ClickableLed, E5LedRectangular |
15 |
15 |
16 import Preferences |
16 import Preferences |
17 |
17 |
18 |
18 |
19 class StatusMonitorLed(E5Led): |
19 class StatusMonitorLed(E5ClickableLed): |
20 """ |
20 """ |
21 Class implementing a LED to indicate the status of the VCS status monitor |
21 Class implementing a LED to indicate the status of the VCS status monitor |
22 thread. |
22 thread. |
23 """ |
23 """ |
24 def __init__(self, project, parent): |
24 def __init__(self, project, parent): |
26 Constructor |
26 Constructor |
27 |
27 |
28 @param project reference to the project object (Project.Project) |
28 @param project reference to the project object (Project.Project) |
29 @param parent reference to the parent object (QWidget) |
29 @param parent reference to the parent object (QWidget) |
30 """ |
30 """ |
31 E5Led.__init__(self, parent, shape=E5LedRectangular, rectRatio=1.0) |
31 super().__init__(parent, shape=E5LedRectangular, rectRatio=1.0) |
32 |
32 |
|
33 self.__vcsClean = True |
33 self.project = project |
34 self.project = project |
|
35 |
34 self.vcsMonitorLedColors = { |
36 self.vcsMonitorLedColors = { |
35 "off": QColor(Qt.lightGray), |
37 "off": QColor(Qt.lightGray), |
36 "ok": QColor(Qt.green), |
38 "ok": QColor(Qt.green), |
37 "nok": QColor(Qt.red), |
39 "nok": QColor(Qt.red), |
38 "op": QColor(Qt.yellow), |
40 "op": QColor(Qt.yellow), |
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( |
75 self.project.vcsStatusMonitorStatus.connect( |
74 self.__projectVcsMonitorStatus) |
76 self.__projectVcsMonitorStatus) |
|
77 self.project.getModel().vcsStateChanged.connect(self.__vcsStateChanged) |
|
78 self.clicked.connect(self.__ledClicked) |
75 |
79 |
76 def __checkActions(self): |
80 def __checkActions(self): |
77 """ |
81 """ |
78 Private method to set the enabled status of the context menu actions. |
82 Private method to set the enabled status of the context menu actions. |
79 """ |
83 """ |
141 def __switchOff(self): |
145 def __switchOff(self): |
142 """ |
146 """ |
143 Private slot to switch the status monitor thread to Off. |
147 Private slot to switch the status monitor thread to Off. |
144 """ |
148 """ |
145 self.project.stopStatusMonitor() |
149 self.project.stopStatusMonitor() |
|
150 |
|
151 def __vcsStateChanged(self, state): |
|
152 """ |
|
153 Private slot to handle a change in the vcs state. |
|
154 |
|
155 @param state new vcs state (string) |
|
156 """ |
|
157 self.__vcsClean = state == " " |
|
158 |
|
159 def __ledClicked(self, pos): |
|
160 """ |
|
161 Private slot to react upon clicks on the LED. |
|
162 |
|
163 @param pos position of the click (QPoint) |
|
164 """ |
|
165 if self.__on: |
|
166 print(self.__vcsClean) |
|
167 vcs = self.project.getVcs() |
|
168 if vcs: |
|
169 if self.__vcsClean: |
|
170 # call log browser dialog |
|
171 vcs.vcsLogBrowser(self.project.getProjectPath()) |
|
172 else: |
|
173 # call status dialog |
|
174 vcs.vcsStatus(self.project.getProjectPath()) |