31 openUrl = pyqtSignal(QUrl) |
31 openUrl = pyqtSignal(QUrl) |
32 newTab = pyqtSignal(QUrl) |
32 newTab = pyqtSignal(QUrl) |
33 newBackgroundTab = pyqtSignal(QUrl) |
33 newBackgroundTab = pyqtSignal(QUrl) |
34 newWindow = pyqtSignal(QUrl) |
34 newWindow = pyqtSignal(QUrl) |
35 |
35 |
36 def __init__(self, engine, parent=None): |
36 def __init__(self, engine, internal=False, parent=None): |
37 """ |
37 """ |
38 Constructor |
38 Constructor |
39 |
39 |
40 @param engine reference to the help search engine (QHelpSearchEngine) |
40 @param engine reference to the help search engine |
41 @param parent reference to the parent widget (QWidget) |
41 @type QHelpSearchEngine |
|
42 @param internal flag indicating the internal help viewer |
|
43 @type bool |
|
44 @param parent reference to the parent widget |
|
45 @type QWidget |
42 """ |
46 """ |
43 super().__init__(parent) |
47 super().__init__(parent) |
44 |
48 |
45 self.__engine = engine |
49 self.__engine = engine |
|
50 self.__internal = internal |
46 |
51 |
47 self.__layout = QVBoxLayout(self) |
52 self.__layout = QVBoxLayout(self) |
|
53 if internal: |
|
54 # no margins for the internal variant |
|
55 self.__layout.setContentsMargins(0, 0, 0, 0) |
48 |
56 |
49 self.__result = self.__engine.resultWidget() |
57 self.__result = self.__engine.resultWidget() |
50 self.__query = self.__engine.queryWidget() |
58 self.__query = self.__engine.queryWidget() |
51 |
59 |
52 self.__layout.addWidget(self.__query) |
60 self.__layout.addWidget(self.__query) |
77 |
85 |
78 def __searchingFinished(self, hits): |
86 def __searchingFinished(self, hits): |
79 """ |
87 """ |
80 Private slot to handle the end of the search. |
88 Private slot to handle the end of the search. |
81 |
89 |
82 @param hits number of hits (integer) (unused) |
90 @param hits number of hits (unused) |
|
91 @type int |
83 """ |
92 """ |
84 QApplication.restoreOverrideCursor() |
93 QApplication.restoreOverrideCursor() |
85 |
94 |
86 @pyqtSlot(QUrl) |
95 @pyqtSlot(QUrl) |
87 def __linkActivated(self, url): |
96 def __linkActivated(self, url): |
108 ) |
117 ) |
109 ): |
118 ): |
110 self.newBackgroundTab.emit(url) |
119 self.newBackgroundTab.emit(url) |
111 elif modifiers & Qt.KeyboardModifier.ControlModifier: |
120 elif modifiers & Qt.KeyboardModifier.ControlModifier: |
112 self.newTab.emit(url) |
121 self.newTab.emit(url) |
113 elif modifiers & Qt.KeyboardModifier.ShiftModifier: |
122 elif ( |
|
123 modifiers & Qt.KeyboardModifier.ShiftModifier and |
|
124 not self.__internal |
|
125 ): |
114 self.newWindow.emit(url) |
126 self.newWindow.emit(url) |
115 else: |
127 else: |
116 self.openUrl.emit(url) |
128 self.openUrl.emit(url) |
117 |
129 |
118 def keyPressEvent(self, evt): |
130 def keyPressEvent(self, evt): |
119 """ |
131 """ |
120 Protected method handling key press events. |
132 Protected method handling key press events. |
121 |
133 |
122 @param evt reference to the key press event (QKeyEvent) |
134 @param evt reference to the key press event |
|
135 @type QKeyEvent |
123 """ |
136 """ |
124 if evt.key() == Qt.Key.Key_Escape: |
137 if evt.key() == Qt.Key.Key_Escape: |
125 self.escapePressed.emit() |
138 self.escapePressed.emit() |
126 else: |
139 else: |
127 evt.ignore() |
140 evt.ignore() |
146 if link.isEmpty() or not link.isValid(): |
159 if link.isEmpty() or not link.isValid(): |
147 return |
160 return |
148 |
161 |
149 menu = QMenu() |
162 menu = QMenu() |
150 curTab = menu.addAction(self.tr("Open Link")) |
163 curTab = menu.addAction(self.tr("Open Link")) |
151 newTab = menu.addAction(self.tr("Open Link in New Tab")) |
164 if self.__internal: |
152 newBackgroundTab = menu.addAction( |
165 newTab = menu.addAction(self.tr("Open Link in New Page")) |
153 self.tr("Open Link in Background Tab")) |
166 newBackgroundTab = menu.addAction( |
154 newWindow = menu.addAction(self.tr("Open Link in New Window")) |
167 self.tr("Open Link in Background Page")) |
|
168 else: |
|
169 newTab = menu.addAction(self.tr("Open Link in New Tab")) |
|
170 newBackgroundTab = menu.addAction( |
|
171 self.tr("Open Link in Background Tab")) |
|
172 newWindow = menu.addAction(self.tr("Open Link in New Window")) |
155 menu.move(evt.globalPos()) |
173 menu.move(evt.globalPos()) |
|
174 |
156 act = menu.exec() |
175 act = menu.exec() |
157 if act == curTab: |
176 if act == curTab: |
158 self.openUrl.emit(link) |
177 self.openUrl.emit(link) |
159 elif act == newTab: |
178 elif act == newTab: |
160 self.newTab.emit(link) |
179 self.newTab.emit(link) |
161 elif act == newBackgroundTab: |
180 elif act == newBackgroundTab: |
162 self.newBackgroundTab.emit(link) |
181 self.newBackgroundTab.emit(link) |
163 elif act == newWindow: |
182 elif not self.__internal and act == newWindow: |
164 self.newWindow.emit(link) |
183 self.newWindow.emit(link) |