def generateIcon(self): import svnmanip if self.readonly is True: pixmap = qt.QtGui.QPixmap(":/images/icons/lock.png") elif self._edited: pixmap = qt.QtGui.QPixmap(":/images/icons/codefile-red.png") else: pixmap = qt.QtGui.QPixmap(":/images/icons/codefile.png") if not self.readonly and not self.fname is None and svnmanip.hasSvnSupport(): if svnmanip.isSvnFile(self.fname): status = svnmanip.svnFileTextStatus(self.fname) self.svnstatus = status if status == svnmanip.modified: pixmap2 = qt.QtGui.QPixmap(":/images/icons/svn-modified.png") elif status == svnmanip.normal: pixmap2 = qt.QtGui.QPixmap(":/images/icons/svn-normal.png") elif status == svnmanip.conflicted: pixmap2 = qt.QtGui.QPixmap(":/images/icons/svn-conflict.png") elif status == svnmanip.added: pixmap2 = qt.QtGui.QPixmap(":/images/icons/svn-add.png") else: pixmap2 = None if not pixmap2 is None: painter = qt.QtGui.QPainter(pixmap) painter.drawPixmap(pixmap.width() - pixmap2.width(), pixmap.height() - pixmap2.height(), pixmap2) painter.end() icon = qt.QtGui.QIcon() icon.addPixmap(pixmap.scaledToHeight(32), qt.QtGui.QIcon.Normal, qt.QtGui.QIcon.Off) return icon
def check_lpy_update(self, silent = False): import svnmanip, os, time if svnmanip.hasSvnSupport(): import openalea.lpy.__version__ as lv testfile = os.path.dirname(lv.__file__)+'/__version__.py' if svnmanip.isSvnFile(testfile): # we are dealing with a develop version of lpy current_rev = svnmanip.svnFileInfo(testfile).revision.number if not silent or ((current_rev > self.svnLastRevisionChecked) and ((self.svnLastDateChecked + 24*60*60) < time.time())): self.svnLastDateChecked = time.time() if svnmanip.isSSHRepository(testfile): # in case of svn+ssh protocol, we do not even try to not block the process. self.svnLastRevisionChecked = current_rev if not silent: qt.QtGui.QMessageBox.information(self,"Lpy Update","You have a develop version of lpy.\nCannot check svn repository.\nProtocol 'SVN+SSH' not supported correctly by PySvn.") else: self.statusBar().showMessage("Cannot check version of svn repository of lpy. Protocol 'SVN+SSH' not supported correctly by PySvn.") else: try: if not svnmanip.svnIsUpToDate(testfile,self if not silent else None,True): qt.QtGui.QMessageBox.information(self,"Lpy Update","A new develop version of lpy seems available !\nPlease update sources of lpy, plantgl, vpltk and recompile.") self.svnLastRevisionChecked = current_rev elif not silent: qt.QtGui.QMessageBox.information(self,"Lpy Update","You have a develop version of lpy.\nYou are up-to-date.") else: self.statusBar().showMessage("L-Py is up-to-date.") except: if not silent: qt.QtGui.QMessageBox.information(self,"Lpy Update","You have a develop version of lpy.\nCannot check svn repository.") else: self.statusBar().showMessage('Cannot check version of svn repository of lpy.') else: # release version if silent: self.statusBar().showMessage("Cannot check update with release version of lpy for now.") else: qt.QtGui.QMessageBox.information(self,"Lpy Update","Cannot check update with release version of lpy for now.")
def generateIcon(self): import svnmanip if self.readonly is True: pixmap = QPixmap(":/images/icons/lock.png") elif self._edited: pixmap = QPixmap(":/images/icons/codefile-red.png") else: pixmap = QPixmap(":/images/icons/codefile.png") if not self.readonly and not self.fname is None and svnmanip.hasSvnSupport() : if svnmanip.isSvnFile(self.fname): status = svnmanip.svnFileTextStatus(self.fname) self.svnstatus = status if status == svnmanip.modified: pixmap2 = QPixmap(":/images/icons/svn-modified.png") elif status == svnmanip.normal: pixmap2 = QPixmap(":/images/icons/svn-normal.png") elif status == svnmanip.conflicted: pixmap2 = QPixmap(":/images/icons/svn-conflict.png") elif status == svnmanip.added: pixmap2 = QPixmap(":/images/icons/svn-add.png") else: pixmap2 = None if not pixmap2 is None: painter = QPainter(pixmap); painter.drawPixmap(pixmap.width()-pixmap2.width(),pixmap.height()-pixmap2.height(),pixmap2) painter.end() icon = QIcon() icon.addPixmap(pixmap.scaledToHeight(32),QIcon.Normal,QIcon.Off) return icon
def updateSvnStatus(self): import svnmanip if svnmanip.hasSvnSupport(): if (not hasattr(self, "svnstatus") and svnmanip.isSvnFile(self.fname)) or ( hasattr(self, "svnstatus") and svnmanip.svnFileTextStatus(self.fname) != self.svnstatus ): self.updateTabName(force=True)
def contextMenuEvent(self,event): self.selection = self.tabAt(event.pos()) if self.selection != -1: menu = qt.QtGui.QMenu(self) action = menu.addAction('Close') QObject.connect(action,SIGNAL('triggered(bool)'),self.close) action = menu.addAction('Close all except this ') QObject.connect(action,SIGNAL('triggered(bool)'),self.closeAllExcept) menu.addSeparator() if self.lpystudio.simulations[self.selection].readonly: action = menu.addAction('Remove Readonly ') QObject.connect(action,SIGNAL('triggered(bool)'),self.removeReadOnly) else: action = menu.addAction('Set Readonly ') QObject.connect(action,SIGNAL('triggered(bool)'),self.setReadOnly) menu.addSeparator() action = menu.addAction('Copy filename ') QObject.connect(action,SIGNAL('triggered(bool)'),self.copyFilename) action = menu.addAction('Open folder') QObject.connect(action,SIGNAL('triggered(bool)'),self.openFolder) action = menu.addAction('Open terminal') QObject.connect(action,SIGNAL('triggered(bool)'),self.openTerminalAtFolder) fname = self.lpystudio.simulations[self.selection].fname if fname and svnmanip.hasSvnSupport() : if svnmanip.isSvnFile(fname): menu.addSeparator() status = svnmanip.svnFileTextStatus(fname) if status != svnmanip.added: action = menu.addAction('SVN Update') QObject.connect(action,SIGNAL('triggered(bool)'),self.svnUpdate) if status in [svnmanip.added,svnmanip.modified]: action = menu.addAction('SVN Commit') QObject.connect(action,SIGNAL('triggered(bool)'),self.svnCommit) if status != svnmanip.normal: action = menu.addAction('SVN Revert') QObject.connect(action,SIGNAL('triggered(bool)'),self.svnRevert) if status != svnmanip.added: menu.addSeparator() action = menu.addAction('Is Up-to-date ?') QObject.connect(action,SIGNAL('triggered(bool)'),self.svnIsUpToDate) elif svnmanip.isSvnFile(os.path.dirname(fname)): menu.addSeparator() action = menu.addAction('SVN Add') QObject.connect(action,SIGNAL('triggered(bool)'),self.svnAdd) menu.exec_(event.globalPos())
def contextMenuEvent(self, event): self.selection = self.tabAt(event.pos()) if self.selection != -1: menu = QMenu(self) action = menu.addAction('Close') action.triggered.connect(self.close) action = menu.addAction('Close all except this ') action.triggered.connect(self.closeAllExcept) menu.addSeparator() if self.lpystudio.simulations[self.selection].readonly: action = menu.addAction('Remove Readonly ') action.triggered.connect(self.removeReadOnly) else: action = menu.addAction('Set Readonly ') action.triggered.connect(self.setReadOnly) menu.addSeparator() action = menu.addAction('Copy filename ') action.triggered.connect(self.copyFilename) action = menu.addAction('Open folder') action.triggered.connect(self.openFolder) action = menu.addAction('Open terminal') action.triggered.connect(self.openTerminalAtFolder) fname = self.lpystudio.simulations[self.selection].fname if fname and svnmanip.hasSvnSupport(): if svnmanip.isSvnFile(fname): menu.addSeparator() status = svnmanip.svnFileTextStatus(fname) if status != svnmanip.added: action = menu.addAction('SVN Update') action.triggered.connect(self.svnUpdate) if status in [svnmanip.added, svnmanip.modified]: action = menu.addAction('SVN Commit') action.triggered.connect(self.svnCommit) if status != svnmanip.normal: action = menu.addAction('SVN Revert') action.triggered.connect(self.svnRevert) if status != svnmanip.added: menu.addSeparator() action = menu.addAction('Is Up-to-date ?') action.triggered.connect(self.svnIsUpToDate) elif svnmanip.isSvnFile(os.path.dirname(fname)): menu.addSeparator() action = menu.addAction('SVN Add') action.triggered.connect(self.svnAdd) menu.exec_(event.globalPos())
def updateSVNMenu(self): import svnmanip, os if svnmanip.hasSvnSupport() : fname = self.currentSimulation().fname if not fname or not svnmanip.isSvnFile(fname): for action in [self.actionSVNUpdate, self.actionSVNCommit, self.actionSVNRevert, self.actionSVNIsUpToDate]: action.setEnabled(False) self.actionSVNAdd.setEnabled(not fname is None and svnmanip.isSvnFile(os.path.dirname(fname))) else : status = svnmanip.svnFileTextStatus(fname) isadded = (status == svnmanip.added) ismodified = (status == svnmanip.modified) isnormal = (status == svnmanip.normal) self.actionSVNUpdate.setEnabled(not isadded) self.actionSVNIsUpToDate.setEnabled(not isadded) self.actionSVNCommit.setEnabled(ismodified or isadded) self.actionSVNRevert.setEnabled(not isnormal) self.actionSVNAdd.setEnabled(False)
def check_lpy_update_available(self): import svnmanip, os available = False if svnmanip.hasSvnSupport() : import openalea.lpy.__version__ as lv testfile = os.path.dirname(lv.__file__)+'/__version__.py' #print testfile, svnmanip.isSvnFile(testfile) if svnmanip.isSvnFile(testfile): available = not svnmanip.isSSHRepository(testfile) if not available: self.actionCheckUpdate.setEnabled(False) return available
def updateSvnStatus(self): import svnmanip if svnmanip.hasSvnSupport(): if (not hasattr(self,'svnstatus') and svnmanip.isSvnFile(self.fname)) or (hasattr(self,'svnstatus') and svnmanip.svnFileTextStatus(self.fname) != self.svnstatus): self.updateTabName(force=True)