Helpviewer/HelpBrowserWV.py

changeset 2334
fc69ad77e18a
parent 2302
f29e9405c851
child 2354
c63de4af553d
equal deleted inserted replaced
2331:9e623311630d 2334:fc69ad77e18a
572 @signal sourceChanged(QUrl) emitted after the current URL has changed 572 @signal sourceChanged(QUrl) emitted after the current URL has changed
573 @signal forwardAvailable(bool) emitted after the current URL has changed 573 @signal forwardAvailable(bool) emitted after the current URL has changed
574 @signal backwardAvailable(bool) emitted after the current URL has changed 574 @signal backwardAvailable(bool) emitted after the current URL has changed
575 @signal highlighted(str) emitted, when the mouse hovers over a link 575 @signal highlighted(str) emitted, when the mouse hovers over a link
576 @signal search(QUrl) emitted, when a search is requested 576 @signal search(QUrl) emitted, when a search is requested
577 @signal zoomValueChanged(int) emitted to signal a change of the zoom value
577 """ 578 """
578 sourceChanged = pyqtSignal(QUrl) 579 sourceChanged = pyqtSignal(QUrl)
579 forwardAvailable = pyqtSignal(bool) 580 forwardAvailable = pyqtSignal(bool)
580 backwardAvailable = pyqtSignal(bool) 581 backwardAvailable = pyqtSignal(bool)
581 highlighted = pyqtSignal(str) 582 highlighted = pyqtSignal(str)
582 search = pyqtSignal(QUrl) 583 search = pyqtSignal(QUrl)
584 zoomValueChanged = pyqtSignal(int)
585
586 ZoomLevels = [
587 30, 50, 67, 80, 90,
588 100,
589 110, 120, 133, 150, 170, 200, 240, 300,
590 ]
591 ZoomLevelDefault = 100
583 592
584 def __init__(self, mainWindow, parent=None, name=""): 593 def __init__(self, mainWindow, parent=None, name=""):
585 """ 594 """
586 Constructor 595 Constructor
587 596
605 self.ctrlPressed = False 614 self.ctrlPressed = False
606 self.__isLoading = False 615 self.__isLoading = False
607 self.__progress = 0 616 self.__progress = 0
608 617
609 self.__currentZoom = 100 618 self.__currentZoom = 100
610 self.__zoomLevels = [ 619 self.__zoomLevels = HelpBrowser.ZoomLevels[:]
611 30, 50, 67, 80, 90,
612 100,
613 110, 120, 133, 150, 170, 200, 240, 300,
614 ]
615 620
616 self.__javaScriptBinding = None 621 self.__javaScriptBinding = None
617 self.__javaScriptEricObject = None 622 self.__javaScriptEricObject = None
618 623
619 self.mw.zoomTextOnlyChanged.connect(self.__applyZoom) 624 self.mw.zoomTextOnlyChanged.connect(self.__applyZoom)
890 895
891 def __applyZoom(self): 896 def __applyZoom(self):
892 """ 897 """
893 Private slot to apply the current zoom factor. 898 Private slot to apply the current zoom factor.
894 """ 899 """
900 self.setZoomValue(self.__currentZoom)
901
902 def setZoomValue(self, value):
903 """
904 Public method to set the zoom value.
905
906 @param value zoom value (integer)
907 """
908 if value != self.zoomValue():
909 try:
910 self.setZoomFactor(value / 100.0)
911 except AttributeError:
912 self.setTextSizeMultiplier(value / 100.0)
913 self.zoomValueChanged.emit(value)
914
915 def zoomValue(self):
916 """
917 Public method to get the current zoom value.
918
919 @return zoom value (integer)
920 """
895 try: 921 try:
896 self.setZoomFactor(self.__currentZoom / 100.0) 922 val = self.zoomFactor() * 100
897 except AttributeError: 923 except AttributeError:
898 self.setTextSizeMultiplier(self.__currentZoom / 100.0) 924 val = self.textSizeMultiplier() * 100
925 return int(val)
899 926
900 def zoomIn(self): 927 def zoomIn(self):
901 """ 928 """
902 Public slot to zoom into the page. 929 Public slot to zoom into the page.
903 """ 930 """
917 944
918 def zoomReset(self): 945 def zoomReset(self):
919 """ 946 """
920 Public method to reset the zoom factor. 947 Public method to reset the zoom factor.
921 """ 948 """
922 self.__currentZoom = 100 949 self.__currentZoom = self.__zoomLevels[HelpBrowser.ZoomLevelDefault]
923 self.__applyZoom() 950 self.__applyZoom()
924 951
925 def hasSelection(self): 952 def hasSelection(self):
926 """ 953 """
927 Public method to determine, if there is some text selected. 954 Public method to determine, if there is some text selected.
1543 Protected method to handle wheel events. 1570 Protected method to handle wheel events.
1544 1571
1545 @param evt reference to the wheel event (QWheelEvent) 1572 @param evt reference to the wheel event (QWheelEvent)
1546 """ 1573 """
1547 if evt.modifiers() & Qt.ControlModifier: 1574 if evt.modifiers() & Qt.ControlModifier:
1548 degrees = evt.delta() // 8 1575 if evt.delta() < 0:
1549 steps = degrees // 15 1576 self.zoomOut()
1550 self.__currentZoom += steps * 10 1577 else:
1551 self.__applyZoom() 1578 self.zoomIn()
1552 evt.accept() 1579 evt.accept()
1553 return 1580 return
1554 1581
1555 if evt.modifiers() & Qt.ShiftModifier: 1582 if evt.modifiers() & Qt.ShiftModifier:
1556 if evt.delta() < 0: 1583 if evt.delta() < 0:

eric ide

mercurial