132 @type HelpViewerImpl |
135 @type HelpViewerImpl |
133 @param background flag indicating to not change the current page |
136 @param background flag indicating to not change the current page |
134 (defaults to False) |
137 (defaults to False) |
135 @type bool (optional) |
138 @type bool (optional) |
136 """ |
139 """ |
137 self.__openPagesList.addItem(viewer.title()) |
140 self.__openPagesList.addItem(viewer.pageTitle()) |
138 viewer.titleChanged.connect( |
141 viewer.titleChanged.connect( |
139 lambda: self.__viewerTitleChanged(viewer)) |
142 lambda: self.__viewerTitleChanged(viewer)) |
140 |
143 |
141 if not background: |
144 if not background: |
142 self.__openPagesList.setCurrentRow( |
145 self.__openPagesList.setCurrentRow( |
155 @param background flag indicating to not change the current page |
158 @param background flag indicating to not change the current page |
156 (defaults to False) |
159 (defaults to False) |
157 @type bool (optional) |
160 @type bool (optional) |
158 """ |
161 """ |
159 currentRow = self.__openPagesList.currentRow() |
162 currentRow = self.__openPagesList.currentRow() |
160 self.__openPagesList.insertItem(index, viewer.title()) |
163 self.__openPagesList.insertItem(index, viewer.pageTitle()) |
161 viewer.titleChanged.connect( |
164 viewer.titleChanged.connect( |
162 lambda: self.__viewerTitleChanged(viewer)) |
165 lambda: self.__viewerTitleChanged(viewer)) |
163 |
166 |
164 if not background: |
167 if not background: |
165 self.__openPagesList.setCurrentRow(index) |
168 self.__openPagesList.setCurrentRow(index) |
173 @param viewer reference to the viewer that change title |
176 @param viewer reference to the viewer that change title |
174 @type HelpViewerImpl |
177 @type HelpViewerImpl |
175 """ |
178 """ |
176 index = self.__stack.indexOf(viewer) |
179 index = self.__stack.indexOf(viewer) |
177 itm = self.__openPagesList.item(index) |
180 itm = self.__openPagesList.item(index) |
178 itm.setText(viewer.title()) |
181 itm.setText(viewer.pageTitle()) |
179 self.currentChanged.emit(index) |
182 self.currentChanged.emit(index) |
180 |
183 |
181 ####################################################################### |
184 ####################################################################### |
182 ## Context menu action methods |
185 ## Context menu action methods |
183 ####################################################################### |
186 ####################################################################### |
184 |
187 |
185 @pyqtSlot() |
188 @pyqtSlot() |
186 def __contextMenuClose(self): |
189 def __contextMenuClose(self): |
187 """ |
190 """ |
188 Private slot to close a page. |
191 Private slot to close a page via the context menu. |
189 """ |
192 """ |
190 row = self.__openPagesList.currentRow() |
193 self.closeCurrentPage() |
191 self.__removeViewer(row) |
|
192 |
|
193 if self.__openPagesList.count() == 0: |
|
194 self.__helpViewer.addPage() |
|
195 |
194 |
196 @pyqtSlot() |
195 @pyqtSlot() |
197 def __contextMenuCloseOthers(self): |
196 def __contextMenuCloseOthers(self): |
198 """ |
197 """ |
199 Private slot to close all other pages. |
198 Private slot to close all other pages via the context menu. |
200 """ |
199 """ |
201 currentRow = self.__openPagesList.currentRow() |
200 self.closeOtherPages() |
202 for row in range(self.__openPagesList.count() - 1, -1, -1): |
|
203 if row != currentRow: |
|
204 self.__removeViewer(row) |
|
205 |
201 |
206 @pyqtSlot() |
202 @pyqtSlot() |
207 def __contextMenuCloseAll(self): |
203 def __contextMenuCloseAll(self): |
208 """ |
204 """ |
209 Private slot to close all pages. |
205 Private slot to close all pages via the context menu. |
210 """ |
206 """ |
211 while self.__openPagesList.count() != 0: |
207 self.closeAllPages() |
212 self.__removeViewer(0) |
|
213 self.__helpViewer.addPage() |
|
214 |
208 |
215 @pyqtSlot() |
209 @pyqtSlot() |
216 def __contextMenuCopyUrlToClipboard(self): |
210 def __contextMenuCopyUrlToClipboard(self): |
217 """ |
211 """ |
218 Private slot to copy the URL to the clipboard. |
212 Private slot to copy the URL to the clipboard. |
219 """ |
213 """ |
220 row = self.__openPagesList.currentRow() |
214 row = self.__openPagesList.currentRow() |
221 viewer = self.__stack.widget(row) |
215 viewer = self.__stack.widget(row) |
222 url = viewer.url() |
216 url = viewer.link() |
223 if url.isValid(): |
217 if url.isValid(): |
224 urlStr = url.toString() |
218 urlStr = url.toString() |
225 |
219 |
226 # copy the URL to both clipboard areas |
220 # copy the URL to both clipboard areas |
227 QGuiApplication.clipboard().setText( |
221 QGuiApplication.clipboard().setText( |
240 self.__stack.removeWidget(viewer) |
234 self.__stack.removeWidget(viewer) |
241 viewer.deleteLater() |
235 viewer.deleteLater() |
242 |
236 |
243 itm = self.__openPagesList.takeItem(row) |
237 itm = self.__openPagesList.takeItem(row) |
244 del itm |
238 del itm |
|
239 |
|
240 ####################################################################### |
|
241 ## Slots for external access below |
|
242 ####################################################################### |
|
243 |
|
244 @pyqtSlot() |
|
245 def closeCurrentPage(self): |
|
246 """ |
|
247 Public slot to close the current page. |
|
248 """ |
|
249 row = self.__openPagesList.currentRow() |
|
250 self.__removeViewer(row) |
|
251 |
|
252 if self.__openPagesList.count() == 0: |
|
253 self.__helpViewer.addPage() |
|
254 |
|
255 @pyqtSlot() |
|
256 def closeOtherPages(self): |
|
257 """ |
|
258 Public slot to close all other pages. |
|
259 """ |
|
260 currentRow = self.__openPagesList.currentRow() |
|
261 for row in range(self.__openPagesList.count() - 1, -1, -1): |
|
262 if row != currentRow: |
|
263 self.__removeViewer(row) |
|
264 |
|
265 @pyqtSlot() |
|
266 def closeAllPages(self): |
|
267 """ |
|
268 Public slot to close all pages. |
|
269 """ |
|
270 while self.__openPagesList.count() != 0: |
|
271 self.__removeViewer(0) |
|
272 self.__helpViewer.addPage() |