1 # Copyright (C) 2007-2013 EDF R&D
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License.
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # Lesser General Public License for more details.
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 from __future__ import absolute_import
23 from PyQt5.QtWidgets import QCheckBox, QWidget, QLabel, QPushButton
24 from PyQt5.QtCore import Qt, QRect
26 from Extensions.i18n import tr
27 from desGroupeOptionnel import Ui_groupeOptionnel
28 from desPBOptionnelMT import Ui_customPB
33 class monRBButtonCustom(QCheckBox):
35 def __init__(self,texte,monOptionnel,parent=None):
36 QCheckBox.__init__(self,tr(texte),parent)
37 self.mousePressed=True
39 self.monOptionnel=monOptionnel
40 self.setToolTip(tr("clicker: affichage aide, double-click: ajout"))
42 def mouseDoubleClickEvent(self, event):
43 #print "dans mouseDoubleClickEvent", self
44 if self not in self.monOptionnel.dicoCb:
47 listeCheckedMC="+"+self.monOptionnel.dicoCb[self]
48 self.monOptionnel.parentMC.ajoutMC(listeCheckedMC)
52 def mousePressEvent(self, event):
53 if not( event.button() != Qt.RightButton) :
56 if self.monOptionnel.cbPressed != None :
57 self.monOptionnel.cbPressed.setChecked(False)
58 self.monOptionnel.cbPressed=self
59 if self.mousePressed == False :
60 self.mousePressed=True
62 self.mousePressed=False
64 QCheckBox.mousePressEvent(self, event)
67 def ajoutAideMC(self):
69 maDefinition = self.monOptionnel.parentMC.definition.entites[self.texte]
70 maLangue = self.monOptionnel.parentMC.jdc.lang
71 if hasattr(maDefinition,maLangue):
72 monAide = getattr(maDefinition,self.monOptionnel.parentMC.jdc.lang)
77 self.monOptionnel.parentMC.editor.affiche_commentaire(monAide)
79 class monPBButtonCustom(QWidget,Ui_customPB):
81 def __init__(self,texte,monOptionnel,parent=None):
82 QWidget.__init__(self)
84 self.monPb.setText(texte)
85 self.monPb.clicked.connect(self.ajoutMC)
88 self.monOptionnel=monOptionnel
90 self.setToolTip(self.monAide)
93 listeCheckedMC="+"+self.monOptionnel.dicoCb[self]
94 self.monOptionnel.parentMC.ajoutMC(listeCheckedMC)
96 def definitAideMC(self):
98 maDefinition = self.monOptionnel.parentMC.definition.entites[self.texte]
99 maLangue = self.monOptionnel.parentMC.jdc.lang
100 if hasattr(maDefinition,maLangue):
101 self.monAide = getattr(maDefinition,self.monOptionnel.parentMC.jdc.lang)
105 class MonGroupeOptionnel (QWidget,Ui_groupeOptionnel):
108 def __init__(self,liste,parentQt,parentMC):
109 #print "dans init de monWidgetOptionnel ", parentQt, liste,parentMC
110 QWidget.__init__(self,None)
114 self.mousePressed=False
117 self.parentQt=parentQt
118 self.parentMC=parentMC
122 elif self.parentQt.parentQt.afficheOptionnelVide != False :
124 self.MCOptionnelLayout.insertWidget(0,QLabel(tr('Pas de MC Optionnel')))
126 self.frameLabelMC.close()
127 #print "dans fin de monWidgetOptionnel ", parentQt
130 def afficheTitre(self):
131 labeltext,fonte,couleur = self.parentMC.node.item.GetLabelText()
140 for l in li : texte+=l+"\n"
142 self.MCLabel.setText(texte)
144 def affiche(self,liste):
145 #print "dans Optionnel ____ affiche", liste
149 if self.parentQt.parentQt.simpleClic == False :
150 cb = monRBButtonCustom(mot,self)
151 cb.clicked.connect(cb.ajoutAideMC)
153 cb = monPBButtonCustom(mot,self)
155 self.MCOptionnelLayout.insertWidget(0,cb)
157 self.scrollAreaCommandesOptionnelles.horizontalScrollBar().setSliderPosition(0)