39 |
39 |
40 self.__engine = engine |
40 self.__engine = engine |
41 self.__expandDepth = -2 |
41 self.__expandDepth = -2 |
42 |
42 |
43 self.__tocWidget = self.__engine.contentWidget() |
43 self.__tocWidget = self.__engine.contentWidget() |
44 self.__tocWidget.setContextMenuPolicy(Qt.CustomContextMenu) |
44 self.__tocWidget.setContextMenuPolicy( |
|
45 Qt.ContextMenuPolicy.CustomContextMenu) |
45 self.__tocWidget.setSortingEnabled(True) |
46 self.__tocWidget.setSortingEnabled(True) |
46 |
47 |
47 self.__layout = QVBoxLayout(self) |
48 self.__layout = QVBoxLayout(self) |
48 self.__layout.addWidget(self.__tocWidget) |
49 self.__layout.addWidget(self.__tocWidget) |
49 |
50 |
64 """ |
65 """ |
65 if not url.isEmpty() and url.isValid(): |
66 if not url.isEmpty() and url.isValid(): |
66 buttons = QApplication.mouseButtons() |
67 buttons = QApplication.mouseButtons() |
67 modifiers = QApplication.keyboardModifiers() |
68 modifiers = QApplication.keyboardModifiers() |
68 |
69 |
69 if buttons & Qt.MidButton: |
70 if buttons & Qt.MouseButton.MidButton: |
70 self.newTab.emit(url) |
71 self.newTab.emit(url) |
71 else: |
72 else: |
72 if ( |
73 if ( |
73 modifiers & (Qt.ControlModifier | Qt.ShiftModifier) == |
74 modifiers & ( |
74 (Qt.ControlModifier | Qt.ShiftModifier) |
75 Qt.KeyboardModifier.ControlModifier | |
|
76 Qt.KeyboardModifier.ShiftModifier |
|
77 ) == ( |
|
78 Qt.KeyboardModifier.ControlModifier | |
|
79 Qt.KeyboardModifier.ShiftModifier |
|
80 ) |
75 ): |
81 ): |
76 self.newBackgroundTab.emit(url) |
82 self.newBackgroundTab.emit(url) |
77 elif modifiers & Qt.ControlModifier: |
83 elif modifiers & Qt.KeyboardModifier.ControlModifier: |
78 self.newTab.emit(url) |
84 self.newTab.emit(url) |
79 elif modifiers & Qt.ShiftModifier: |
85 elif modifiers & Qt.KeyboardModifier.ShiftModifier: |
80 self.newWindow.emit(url) |
86 self.newWindow.emit(url) |
81 else: |
87 else: |
82 self.openUrl.emit(url) |
88 self.openUrl.emit(url) |
83 |
89 |
84 def __contentsCreated(self): |
90 def __contentsCreated(self): |
85 """ |
91 """ |
86 Private slot to be run after the contents was generated. |
92 Private slot to be run after the contents was generated. |
87 """ |
93 """ |
88 self.__tocWidget.sortByColumn(0, Qt.AscendingOrder) |
94 self.__tocWidget.sortByColumn(0, Qt.SortOrder.AscendingOrder) |
89 self.__expandTOC() |
95 self.__expandTOC() |
90 |
96 |
91 def __expandTOC(self): |
97 def __expandTOC(self): |
92 """ |
98 """ |
93 Private slot to expand the table of contents. |
99 Private slot to expand the table of contents. |
112 """ |
118 """ |
113 Protected method handling focus in events. |
119 Protected method handling focus in events. |
114 |
120 |
115 @param evt reference to the focus event object (QFocusEvent) |
121 @param evt reference to the focus event object (QFocusEvent) |
116 """ |
122 """ |
117 if evt.reason() != Qt.MouseFocusReason: |
123 if evt.reason() != Qt.FocusReason.MouseFocusReason: |
118 self.__tocWidget.setFocus() |
124 self.__tocWidget.setFocus() |
119 |
125 |
120 def keyPressEvent(self, evt): |
126 def keyPressEvent(self, evt): |
121 """ |
127 """ |
122 Protected method handling key press events. |
128 Protected method handling key press events. |
123 |
129 |
124 @param evt reference to the key press event (QKeyEvent) |
130 @param evt reference to the key press event (QKeyEvent) |
125 """ |
131 """ |
126 if evt.key() == Qt.Key_Escape: |
132 if evt.key() == Qt.Key.Key_Escape: |
127 self.escapePressed.emit() |
133 self.escapePressed.emit() |
128 |
134 |
129 def syncToContent(self, url): |
135 def syncToContent(self, url): |
130 """ |
136 """ |
131 Public method to sync the TOC to the displayed page. |
137 Public method to sync the TOC to the displayed page. |