src/eric7/PdfViewer/PdfInfoWidget.py

branch
pdf_viewer
changeset 9705
7629a6f23b2e
parent 9704
6e1650b9b3b5
child 9722
63135ab601e7
equal deleted inserted replaced
9704:6e1650b9b3b5 9705:7629a6f23b2e
28 @param parent reference to the parent widget (defaults to None) 28 @param parent reference to the parent widget (defaults to None)
29 @type QWidget (optional) 29 @type QWidget (optional)
30 """ 30 """
31 super().__init__(parent) 31 super().__init__(parent)
32 32
33 self.__document = document 33 self.__document = None
34 34
35 self.__layout = QFormLayout(self) 35 self.__layout = QFormLayout(self)
36 self.__layout.setRowWrapPolicy(QFormLayout.RowWrapPolicy.WrapLongRows) 36 self.__layout.setRowWrapPolicy(QFormLayout.RowWrapPolicy.WrapLongRows)
37 self.__layout.setFieldGrowthPolicy( 37 self.__layout.setFieldGrowthPolicy(
38 QFormLayout.FieldGrowthPolicy.AllNonFixedFieldsGrow 38 QFormLayout.FieldGrowthPolicy.AllNonFixedFieldsGrow
73 self.__layout.addRow(self.tr("Keywords:"), self.__infoLabels["keywords"]) 73 self.__layout.addRow(self.tr("Keywords:"), self.__infoLabels["keywords"])
74 self.__layout.addRow(self.tr("Security:"), self.__infoLabels["security"]) 74 self.__layout.addRow(self.tr("Security:"), self.__infoLabels["security"])
75 75
76 self.setLayout(self.__layout) 76 self.setLayout(self.__layout)
77 77
78 self.__document.statusChanged.connect(self.__populateInfoLabels) 78 self.setDocument(document)
79 self.__document.pageCountChanged.connect(self.__handlePageCountChanged) 79
80 self.__document.passwordChanged.connect(self.__handlePasswordChanged) 80 def setDocument(self, document):
81 """
82 Public method to set the reference to the PDF document.
83
84 @param document reference to the document
85 @type QPdfDocument
86 """
87 if self.__document is not None:
88 self.__document.statusChanged.disconnect(self.__populateInfoLabels)
89 self.__document.pageCountChanged.disconnect(self.__handlePageCountChanged)
90 self.__document.passwordChanged.disconnect(self.__handlePasswordChanged)
91
92 self.__document = document
93
94 if document is not None:
95 self.__document.statusChanged.connect(self.__populateInfoLabels)
96 self.__document.pageCountChanged.connect(self.__handlePageCountChanged)
97 self.__document.passwordChanged.connect(self.__handlePasswordChanged)
81 98
82 @pyqtSlot(QPdfDocument.Status) 99 @pyqtSlot(QPdfDocument.Status)
83 def __populateInfoLabels(self, status): 100 def __populateInfoLabels(self, status):
84 """ 101 """
85 Private slot to populate the info labels upon a change of the document status. 102 Private slot to populate the info labels upon a change of the document status.

eric ide

mercurial