src/eric7/PdfViewer/PdfPageSelector.py

branch
pdf_viewer
changeset 9722
63135ab601e7
parent 9700
b74a13a382a8
child 10439
21c28b0f9e41
equal deleted inserted replaced
9714:2a3c6f6f88b6 9722:63135ab601e7
7 Module implementing a widget to select a PDF page to be shown. 7 Module implementing a widget to select a PDF page to be shown.
8 """ 8 """
9 9
10 import contextlib 10 import contextlib
11 11
12 from PyQt6.QtCore import Qt, pyqtSlot, pyqtSignal 12 from PyQt6.QtCore import Qt, pyqtSignal, pyqtSlot
13 from PyQt6.QtGui import QIntValidator 13 from PyQt6.QtGui import QIntValidator
14 from PyQt6.QtPdf import QPdfDocument 14 from PyQt6.QtPdf import QPdfDocument
15 from PyQt6.QtWidgets import ( 15 from PyQt6.QtWidgets import (
16 QToolButton, QHBoxLayout, QWidget, QLabel, QLineEdit, QSizePolicy 16 QHBoxLayout,
17 QLabel,
18 QLineEdit,
19 QSizePolicy,
20 QToolButton,
21 QWidget,
17 ) 22 )
18 23
19 from eric7.EricGui import EricPixmapCache 24 from eric7.EricGui import EricPixmapCache
20 25
21 26
22 class PdfPageSelector(QWidget): 27 class PdfPageSelector(QWidget):
23 """ 28 """
24 Class implementing a widget to select a PDF page to be shown. 29 Class implementing a widget to select a PDF page to be shown.
30
31 @signal valueChanged(int) emitted to signal the new value of the selector
32 @signal gotoPage() emitted to indicate the want to enter a page number via the
33 Go To dialog
25 """ 34 """
26 35
27 valueChanged = pyqtSignal(int) 36 valueChanged = pyqtSignal(int)
28 gotoPage = pyqtSignal() 37 gotoPage = pyqtSignal()
29 38
53 self.__pageEntry.setAlignment(Qt.AlignmentFlag.AlignCenter) 62 self.__pageEntry.setAlignment(Qt.AlignmentFlag.AlignCenter)
54 self.__pageEntry.setSizePolicy( 63 self.__pageEntry.setSizePolicy(
55 QSizePolicy.Policy.Minimum, QSizePolicy.Policy.Fixed 64 QSizePolicy.Policy.Minimum, QSizePolicy.Policy.Fixed
56 ) 65 )
57 self.__pageLabel = QLabel() 66 self.__pageLabel = QLabel()
58 67
59 self.__layout = QHBoxLayout() 68 self.__layout = QHBoxLayout()
60 self.__layout.addWidget(self.__prevButton) 69 self.__layout.addWidget(self.__prevButton)
61 self.__layout.addWidget(self.__pageEntry) 70 self.__layout.addWidget(self.__pageEntry)
62 self.__layout.addWidget(self.__pageLabel) 71 self.__layout.addWidget(self.__pageLabel)
63 self.__layout.addWidget(QLabel(self.tr("of"))) 72 self.__layout.addWidget(QLabel(self.tr("of")))
129 @return current value 138 @return current value
130 @rtype int 139 @rtype int
131 """ 140 """
132 return self.__value 141 return self.__value
133 142
134 def setMaximum(self, max): 143 def setMaximum(self, maximum):
135 """ 144 """
136 Public method to set the maximum value. 145 Public method to set the maximum value.
137 146
138 Note: max is 0 based. 147 Note: maximum is 0 based.
139 148
140 @param max maximum value to be set 149 @param maximum maximum value to be set
141 @type int 150 @type int
142 """ 151 """
143 self.__maximum = max 152 self.__maximum = maximum
144 self.__nextButton.setEnabled(self.__value < self.__maximum) 153 self.__nextButton.setEnabled(self.__value < self.__maximum)
145 self.__pageButton.setText(str(max + 1)) 154 self.__pageButton.setText(str(maximum + 1))
146 155
147 @pyqtSlot() 156 @pyqtSlot()
148 def __pageEntered(self): 157 def __pageEntered(self):
149 """ 158 """
150 Private slot to handle the entering of a page value. 159 Private slot to handle the entering of a page value.

eric ide

mercurial