X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=InterfaceQT4%2FgereIcones.py;h=36d63a85ce904d266bbb6099f20669961fb002c2;hb=39b7b166eb606b80c9ac427811651b20db79bde2;hp=05378eb3cc7a32a9c8becc86c54474544c19ed5e;hpb=45496e147f519f4e64795eff3f414cc65b72c1fd;p=tools%2Feficas.git diff --git a/InterfaceQT4/gereIcones.py b/InterfaceQT4/gereIcones.py index 05378eb3..36d63a85 100644 --- a/InterfaceQT4/gereIcones.py +++ b/InterfaceQT4/gereIcones.py @@ -18,12 +18,19 @@ # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # # Modules Python -import string,types,os,re +import string,types,os,re,sys import traceback +from determine import monEnvQT5 +if monEnvQT5 : + from PyQt5.QtWidgets import QMessageBox, QFileDialog + from PyQt5.QtGui import QIcon + from PyQt5.QtCore import QFileInfo, Qt, QSize + +else: + from PyQt4.QtGui import * + from PyQt4.QtCore import * + -from PyQt4 import * -from PyQt4.QtGui import * -from PyQt4.QtCore import * from Extensions.i18n import tr listeSuffixe=('bmp','png','jpg' ,'txt','med') @@ -31,20 +38,31 @@ listeSuffixe=('bmp','png','jpg' ,'txt','med') class FacultatifOuOptionnel: def setReglesEtAide(self): - from monWidgetCommande import MonWidgetCommande listeRegles=() try : listeRegles = self.node.item.get_regles() except : pass - if listeRegles==() and hasattr(self,"RBRegle"): self.RBRegle.close() + if hasattr(self,"RBRegle"): + if listeRegles==() : self.RBRegle.close() + else : + icon3=QIcon(self.repIcon+"/lettreRblanc30.png") + self.RBRegle.setIcon(icon3) + if monEnvQT5 :self.RBRegle.clicked.connect(self.viewRegles) + else : self.connect( self.RBRegle,SIGNAL("clicked()"),self.viewRegles) + cle_doc=None if not hasattr(self,"RBInfo"):return + icon=QIcon(self.repIcon+"/point-interrogation30.png") + self.RBInfo.setIcon(icon) + + from monWidgetCommande import MonWidgetCommande if isinstance(self,MonWidgetCommande) and self.editor.code =="MAP": self.cle_doc = self.chercheDocMAP() else : self.cle_doc = self.node.item.get_docu() if self.cle_doc == None : self.RBInfo.close() + elif monEnvQT5 : self.RBInfo.clicked.connect (self.viewDoc) else : self.connect (self.RBInfo,SIGNAL("clicked()"),self.viewDoc) @@ -63,25 +81,93 @@ class FacultatifOuOptionnel: def viewDoc(self): try : - cmd="xdg-open "+self.cle_doc + if sys.platform[0:5]=="linux" : cmd="xdg-open "+self.cle_doc + else : cmd="start "+self.cle_doc os.system(cmd) except: QMessageBox.warning( self,tr( "Aide Indisponible"),tr( "l'aide n est pas installee ")) + def viewRegles(self): + self.node.AppelleBuildLBRegles() + - def setPoubelle(self): + def setIconePoubelle(self): if not(hasattr(self,"RBPoubelle")):return if self.node.item.object.isoblig() : - icon1 = QtGui.QIcon() - icon1.addPixmap(QtGui.QPixmap("/home/A96028/Install_EficasV1/KarineEficas/Editeur/icons/deleteRondVide.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) - self.RBPoubelle.setIcon(icon1) + icon=QIcon(self.repIcon+"/deleteRondVide.png") + self.RBPoubelle.setIcon(icon) return - self.RBPoubelle.show() - self.connect(self.RBPoubelle,SIGNAL("clicked()"),self.aDetruire) + icon=QIcon(self.repIcon+"/deleteRond.png") + self.RBPoubelle.setIcon(icon) + if monEnvQT5 : self.RBPoubelle.clicked.connect(self.aDetruire) + else : self.connect(self.RBPoubelle,SIGNAL("clicked()"),self.aDetruire) + + def setIconesSalome(self): + if not (hasattr(self,"RBSalome")): return + from Accas import SalomeEntry + mc = self.node.item.get_definition() + mctype = mc.type[0] + enable_salome_selection = self.editor.salome and \ + (('grma' in repr(mctype)) or ('grno' in repr(mctype)) or ('SalomeEntry' in repr(mctype)) or \ + (hasattr(mctype, "enable_salome_selection") and mctype.enable_salome_selection)) + + if enable_salome_selection: + icon=QIcon(self.repIcon+"/flecheSalome.png") + self.RBSalome.setIcon(icon) + if monEnvQT5 : self.RBSalome.pressed.connect(self.BSalomePressed) + else : self.connect(self.RBSalome,SIGNAL("pressed()"),self.BSalomePressed) + +#PNPN --> Telemac A revoir surement +# cela ou le catalogue grpma ou salomeEntry + if not(('grma' in repr(mctype)) or ('grno' in repr(mctype))) or not(self.editor.salome): + if hasattr(self,"RBSalomeVue") : self.RBSalomeVue.close() + else : + icon1=QIcon(self.repIcon+"/eye.png") + self.RBSalomeVue.setIcon(icon1) + if monEnvQT5 : self.RBSalomeVue.clicked.connect(self.BView2DPressed) + else : self.connect(self.RBSalomeVue,SIGNAL("clicked()"),self.BView2DPressed) + else: + self.RBSalome.close() + self.RBSalomeVue.close() + + + def setIconesFichier(self): + if not ( hasattr(self,"BFichier")): return + mc = self.node.item.get_definition() + mctype = mc.type[0] + if mctype == "Repertoire": + self.BRepertoire=self.BFichier + if monEnvQT5 : self.BRepertoire.clicked.connect(self.BRepertoirePressed) + else : self.connect(self.BRepertoire,SIGNAL("clicked()"),self.BRepertoirePressed) + self.BVisuFichier.close() + else : + if monEnvQT5 : self.BFichier.clicked.connect(self.BFichierPressed) + else : self.connect(self.BFichier,SIGNAL("clicked()"),self.BFichierPressed) + if monEnvQT5 : self.BVisuFichier.clicked.connect(self.BFichierVisu) + else : self.connect(self.BVisuFichier,SIGNAL("clicked()"),self.BFichierVisu) + + + + def setIconesGenerales(self): + repIcon=self.node.editor.appliEficas.repIcon + if hasattr(self,"BVisuListe") : + fichier=os.path.join(repIcon, 'plusnode.png') + icon = QIcon(fichier) + self.BVisuListe.setIcon(icon) + if hasattr(self,"RBDeplie") : + fichier=os.path.join(repIcon, 'plusnode.png') + icon = QIcon(fichier) + self.RBDeplie.setIcon(icon) + if hasattr(self,"RBPlie") : + fichier=os.path.join(repIcon, 'minusnode.png') + icon = QIcon(fichier) + self.RBPlie.setIcon(icon) + + def setRun(self): if hasattr(self.editor.appliEficas, 'mesScripts'): - if self.tree.currentItem().item.get_nom() in self.appliEficas.mesScripts.dict_commandes.keys() : + if hasattr(self.editor,'tree') and self.editor.tree.currentItem().item.get_nom() in self.appliEficas.mesScripts.dict_commandes.keys() : print 'il faut programmer le self.ajoutScript()' print '#PNPNPNPN' return @@ -101,9 +187,18 @@ class FacultatifOuOptionnel: icon=QIcon(self.repIcon+"/ast-red-ball.png") self.RBValide.setIcon(icon) + # il faut chercher la bonne fenetre def rendVisible(self): - self.editor.fenetreCentraleAffichee.scrollAreaCommandes.ensureWidgetVisible(self) - self.setFocus() + #print "je passe par rendVisible de FacultatifOuOptionnel" + #print self + #print self.node.fenetre + #print "return pour etre sure" + return + #PNPN + newNode=self.node.treeParent.chercheNoeudCorrespondant(self.node.item.object) + #print newNode + self.editor.fenetreCentraleAffichee.scrollAreaCommandes.ensureWidgetVisible(newNode.fenetre) + #newNode.fenetre.setFocus() class ContientIcones: @@ -111,10 +206,13 @@ class ContientIcones: def BFichierVisu(self): fichier=self.lineEditVal.text() if fichier == None or str(fichier)=="" : return - from qtCommun import ViewText + from monViewTexte import ViewText try : - cmd="xdg-open "+str(fichier) - os.system(cmd) + if sys.platform[0:5]=="linux" : + cmd="xdg-open "+ str(fichier) + os.system(cmd) + else : + os.startfile(str(fichier)) except: try : fp=open(fichier) @@ -136,7 +234,7 @@ class ContientIcones: elif hasattr(mctype[0], "filters"): filters = mctype[0].filters else: - filters = QString() + filters = None if len(mctype) > 2 and mctype[2] == "Sauvegarde": fichier = QFileDialog.getSaveFileName(self.appliEficas, tr('Sauvegarder Fichier'), @@ -148,11 +246,12 @@ class ContientIcones: self.appliEficas.CONFIGURATION.savedir, filters) - if not(fichier.isNull()): + if monEnvQT5 : fichier=fichier[0] + if not(fichier): ulfile = os.path.abspath(unicode(fichier)) self.appliEficas.CONFIGURATION.savedir=os.path.split(ulfile)[0] self.lineEditVal.setText(fichier) - self.editor.affiche_infos(tr("Fichier selectionne")) + self.editor.affiche_commentaire(tr("Fichier selectionne")) self.LEValeurPressed() if (QFileInfo(fichier).suffix() in listeSuffixe ): self.image=fichier @@ -162,7 +261,8 @@ class ContientIcones: self.BSelectInFile.setObjectName("BSelectInFile") self.gridLayout.addWidget(self.BSelectInFile,1,1,1,1) self.BSelectInFile.setText(tr("Selection")) - self.connect(self.BSelectInFile,SIGNAL("clicked()"),self.BSelectInFilePressed) + if monEnvQT5 : self.BSelectInFile.clicked.connect(self.BSelectInFilePressed) + else : self.connect(self.BSelectInFile,SIGNAL("clicked()"),self.BSelectInFilePressed) else : self.BSelectInFile.setVisible(1) elif hasattr(self, "BSelectInFile"): @@ -186,7 +286,7 @@ class ContientIcones: def BSalomePressed(self): - self.editor.affiche_infos(QString("")) + self.editor.affiche_commentaire(QString("")) selection=[] commentaire="" genea=self.node.item.get_genealogie() @@ -220,22 +320,23 @@ class ContientIcones: selection, commentaire = self.appliEficas.selectEntryFromSalome(kwType,editor=self.editor) if commentaire !="" : - self.editor.affiche_infos(tr(QString(commentaire))) + self.editor.affiche_infos(QString(tr(str(commentaire)))) monTexte="" if selection == [] : return for geomElt in selection: monTexte=geomElt+"," monTexte= monTexte[0:-1] self.lineEditVal.setText(QString(monTexte)) + self.LEValeurPressed() def BView2DPressed(self): valeur=self.lineEditVal.text() - if valeur == QString("") : return valeur = str(valeur) + if valeur == str("") : return if valeur : ok, msgError = self.appliEficas.displayShape(valeur) if not ok: - self.appliEficas.affiche_infos(msgError,Qt.red) + self.editor.affiche_infos(msgError,Qt.red) def BParametresPressed(self): liste=self.node.item.get_liste_param_possible()