--- a/VCS/StatusMonitorLed.py Sun Mar 30 22:00:14 2014 +0200 +++ b/VCS/StatusMonitorLed.py Thu Apr 03 23:05:31 2014 +0200 @@ -13,12 +13,12 @@ from PyQt4.QtCore import Qt from PyQt4.QtGui import QColor, QInputDialog, QMenu -from E5Gui.E5Led import E5Led, E5LedRectangular +from E5Gui.E5Led import E5ClickableLed, E5LedRectangular import Preferences -class StatusMonitorLed(E5Led): +class StatusMonitorLed(E5ClickableLed): """ Class implementing a LED to indicate the status of the VCS status monitor thread. @@ -30,9 +30,12 @@ @param project reference to the project object (Project.Project) @param parent reference to the parent object (QWidget) """ - E5Led.__init__(self, parent, shape=E5LedRectangular, rectRatio=1.0) + super(StatusMonitorLed, self).__init__( + parent, shape=E5LedRectangular, rectRatio=1.0) + self.__vcsClean = True self.project = project + self.vcsMonitorLedColors = { "off": QColor(Qt.lightGray), "ok": QColor(Qt.green), @@ -44,7 +47,7 @@ } self.__on = False - self.setWhatsThis(self.trUtf8( + self.setWhatsThis(self.tr( """<p>This LED indicates the operating""" """ status of the VCS monitor thread (off = monitoring off,""" """ green = monitoring on and ok, red = monitoring on, but""" @@ -52,21 +55,21 @@ """ is given in the tooltip.</p>""" )) self.setToolTip( - self.trUtf8("Repository status checking is switched off") + self.tr("Repository status checking is switched off") ) self.setColor(self.vcsMonitorLedColors["off"]) # define a context menu self.__menu = QMenu(self) self.__checkAct = self.__menu.addAction( - self.trUtf8("Check status"), self.__checkStatus) + self.tr("Check status"), self.__checkStatus) self.__intervalAct = self.__menu.addAction( - self.trUtf8("Set interval..."), self.__setInterval) + self.tr("Set interval..."), self.__setInterval) self.__menu.addSeparator() self.__onAct = self.__menu.addAction( - self.trUtf8("Switch on"), self.__switchOn) + self.tr("Switch on"), self.__switchOn) self.__offAct = self.__menu.addAction( - self.trUtf8("Switch off"), self.__switchOff) + self.tr("Switch off"), self.__switchOff) self.__checkActions() # connect signals to our slots @@ -74,6 +77,8 @@ self.customContextMenuRequested.connect(self._showContextMenu) self.project.vcsStatusMonitorStatus.connect( self.__projectVcsMonitorStatus) + self.project.getModel().vcsStateChanged.connect(self.__vcsStateChanged) + self.clicked.connect(self.__ledClicked) def __checkActions(self): """ @@ -127,8 +132,8 @@ """ interval, ok = QInputDialog.getInt( None, - self.trUtf8("VCS Status Monitor"), - self.trUtf8("Enter monitor interval [s]"), + self.tr("VCS Status Monitor"), + self.tr("Enter monitor interval [s]"), self.project.getStatusMonitorInterval(), 0, 3600, 1) if ok: @@ -145,3 +150,27 @@ Private slot to switch the status monitor thread to Off. """ self.project.stopStatusMonitor() + + def __vcsStateChanged(self, state): + """ + Private slot to handle a change in the vcs state. + + @param state new vcs state (string) + """ + self.__vcsClean = state == " " + + def __ledClicked(self, pos): + """ + Private slot to react upon clicks on the LED. + + @param pos position of the click (QPoint) + """ + if self.__on: + vcs = self.project.getVcs() + if vcs: + if self.__vcsClean: + # call log browser dialog + vcs.vcsLogBrowser(self.project.getProjectPath()) + else: + # call status dialog + vcs.vcsStatus(self.project.getProjectPath())