Salome HOME
sauve du 9 mai
[tools/eficas.git] / InterfaceQT4 / gereIcones.py
index 8a5f69abbd8277afa217bd0c6847f48442686ccd..36d63a85ce904d266bbb6099f20669961fb002c2 100644 (file)
 # Modules Python
 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')
 
@@ -38,16 +45,24 @@ class FacultatifOuOptionnel:
          pass
       if hasattr(self,"RBRegle"):
         if listeRegles==() : self.RBRegle.close() 
-        else : self.connect( self.RBRegle,SIGNAL("clicked()"),self.viewRegles)
+        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)
 
 
@@ -78,15 +93,14 @@ class FacultatifOuOptionnel:
 
   def setIconePoubelle(self):
       if not(hasattr(self,"RBPoubelle")):return
-      icon1 = QtGui.QIcon()
-      repIcon=os.path.join(os.path.abspath(os.path.dirname(__file__)),'../Editeur/icons')
       if self.node.item.object.isoblig() : 
-         icon1.addPixmap(QtGui.QPixmap(repIcon+"/deleteRondVide.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
-         self.RBPoubelle.setIcon(icon1)
+         icon=QIcon(self.repIcon+"/deleteRondVide.png")
+         self.RBPoubelle.setIcon(icon)
          return
-      icon1.addPixmap(QtGui.QPixmap(repIcon+"/deleteRond.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
-      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
@@ -96,10 +110,22 @@ class FacultatifOuOptionnel:
        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:
-          self.connect(self.RBSalome,SIGNAL("pressed()"),self.BSalomePressed)
-          if not(('grma' in repr(mctype)) or ('grno' in repr(mctype))) or not(self.editor.salome): self.BView2D.close()
-          else : self.connect(self.RBSalomeVue,SIGNAL("clicked()"),self.BView2DPressed)
+          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()
@@ -111,18 +137,37 @@ class FacultatifOuOptionnel:
        mctype = mc.type[0]
        if mctype == "Repertoire":
           self.BRepertoire=self.BFichier
-          self.connect(self.BRepertoire,SIGNAL("clicked()"),self.BRepertoirePressed)
+          if monEnvQT5 : self.BRepertoire.clicked.connect(self.BRepertoirePressed)
+          else : self.connect(self.BRepertoire,SIGNAL("clicked()"),self.BRepertoirePressed)
           self.BVisuFichier.close()
        else :
-          self.connect(self.BFichier,SIGNAL("clicked()"),self.BFichierPressed)
-          self.connect(self.BVisuFichier,SIGNAL("clicked()"),self.BFichierVisu)
-
-
-
+          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
@@ -136,11 +181,10 @@ class FacultatifOuOptionnel:
       #print " c est le moment de gerer le passage au suivant"
       if not(hasattr (self,'RBValide')) : return
       icon = QIcon()
-      repIcon=os.path.join(os.path.abspath(os.path.dirname(__file__)),'../Editeur/icons')
       if self.node.item.object.isvalid() : 
-         icon=QIcon(repIcon+"/ast-green-ball.png")
+         icon=QIcon(self.repIcon+"/ast-green-ball.png")
       else :
-         icon=QIcon(repIcon+"/ast-red-ball.png")
+         icon=QIcon(self.repIcon+"/ast-red-ball.png")
       self.RBValide.setIcon(icon)
 
   # il faut chercher la bonne fenetre
@@ -190,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'),
@@ -202,7 +246,8 @@ 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)
@@ -216,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"):
@@ -274,18 +320,19 @@ 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: