Changeset 11103:132819392fe4 in orange


Ignore:
Timestamp:
10/10/12 14:56:35 (18 months ago)
Author:
Ales Erjavec <ales.erjavec@…>
Branch:
default
Message:

Use button's clicked signal instead of triggered.

triggered gets emmited whenever the action is triggered not just
when the button is clicked.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Orange/OrangeCanvas/gui/toolgrid.py

    r11100 r11103  
    1111) 
    1212 
    13 from PyQt4.QtCore import Qt, QObject, QSize, QVariant, QEvent 
     13from PyQt4.QtCore import Qt, QObject, QSize, QVariant, QEvent, QSignalMapper 
    1414from PyQt4.QtCore import pyqtSignal as Signal 
    1515 
     
    129129                self._onButtonEnter) 
    130130 
     131        self.__mapper = QSignalMapper() 
     132        self.__mapper.mapped[QObject].connect(self.__onClicked) 
     133 
    131134        self.setupUi() 
    132135 
     
    203206        ) 
    204207 
    205         button.triggered.connect(self.actionTriggered) 
     208        self.__mapper.setMapping(button, action) 
     209        button.clicked.connect(self.__mapper.map) 
    206210        button.installEventFilter(self._buttonListener) 
    207211 
     
    222226 
    223227        slot.button.removeEventFilter(self._buttonListener) 
     228        self.__mapper.removeMappings(slot.button) 
    224229 
    225230        self.layout().removeWidget(slot.button) 
    226231        self._shiftGrid(index + 1, -1) 
    227232 
    228         slot.button.triggered.disconnect(self.actionTriggered) 
    229233        slot.button.deleteLater() 
    230234 
     
    324328        action = button.defaultAction() 
    325329        self.actionHovered.emit(action) 
     330 
     331    def __onClicked(self, action): 
     332        self.actionTriggered.emit(action) 
    326333 
    327334#    def keyPressEvent(self, event): 
Note: See TracChangeset for help on using the changeset viewer.