28 @param outPix pixmap for the zoom out button (QPixmap) |
28 @param outPix pixmap for the zoom out button (QPixmap) |
29 @param inPix pixmap for the zoom in button (QPixmap) |
29 @param inPix pixmap for the zoom in button (QPixmap) |
30 @param resetPix pixmap for the zoom reset button (QPixmap) |
30 @param resetPix pixmap for the zoom reset button (QPixmap) |
31 @param parent reference to the parent widget (QWidget) |
31 @param parent reference to the parent widget (QWidget) |
32 """ |
32 """ |
33 super(E5ZoomWidget, self).__init__(parent) |
33 super().__init__(parent) |
34 self.setupUi(self) |
34 self.setupUi(self) |
35 |
35 |
36 self.zoomOutLabel.setPixmap(outPix.scaled(16, 16)) |
36 self.zoomOutLabel.setPixmap(outPix.scaled(16, 16)) |
37 self.zoomInLabel.setPixmap(inPix.scaled(16, 16)) |
37 self.zoomInLabel.setPixmap(inPix.scaled(16, 16)) |
38 self.zoomResetLabel.setPixmap(resetPix.scaled(16, 16)) |
38 self.zoomResetLabel.setPixmap(resetPix.scaled(16, 16)) |
268 """ |
268 """ |
269 Protected slot to handle changes of the slider value. |
269 Protected slot to handle changes of the slider value. |
270 |
270 |
271 @param value slider value (integer) |
271 @param value slider value (integer) |
272 """ |
272 """ |
273 if self.__mapped: |
273 val = self.__mapping[value] if self.__mapped else value |
274 val = self.__mapping[value] |
|
275 else: |
|
276 val = value |
|
277 fmtStr = "{0}%" if self.__percent else "{0}" |
274 fmtStr = "{0}%" if self.__percent else "{0}" |
278 self.valueLabel.setText(fmtStr.format(val)) |
275 self.valueLabel.setText(fmtStr.format(val)) |
279 self.valueChanged.emit(val) |
276 self.valueChanged.emit(val) |
280 |
277 |
281 def __setValueLabelWidth(self): |
278 def __setValueLabelWidth(self): |
282 """ |
279 """ |
283 Private slot to determine the width of the zoom value label. |
280 Private slot to determine the width of the zoom value label. |
284 """ |
281 """ |
285 if self.__mapped: |
282 labelLen = ( |
286 labelLen = max(len(str(v)) for v in self.__mapping) |
283 max(len(str(v)) for v in self.__mapping) |
287 else: |
284 if self.__mapped else |
288 labelLen = max( |
285 max(len(str(self.slider.maximum())), |
289 len(str(self.slider.maximum())), |
286 len(str(self.slider.minimum()))) |
290 len(str(self.slider.minimum())) |
287 ) |
291 ) |
|
292 fmtStr = "{0}%" if self.__percent else "{0}" |
288 fmtStr = "{0}%" if self.__percent else "{0}" |
293 label = fmtStr.format("0" * labelLen) |
289 label = fmtStr.format("0" * labelLen) |
294 try: |
290 try: |
295 width = self.valueLabel.fontMetrics().horizontalAdvance(label) |
291 width = self.valueLabel.fontMetrics().horizontalAdvance(label) |
296 except AttributeError: |
292 except AttributeError: |