300 """ |
300 """ |
301 Private slot to open a new browser tab. |
301 Private slot to open a new browser tab. |
302 """ |
302 """ |
303 self.newBrowser() |
303 self.newBrowser() |
304 |
304 |
305 def newBrowser(self, link=None, position=-1): |
305 def newBrowser(self, link=None, position=-1, background=False): |
306 """ |
306 """ |
307 Public method to create a new web browser tab. |
307 Public method to create a new web browser tab. |
308 |
308 |
309 @param link link to be shown (string or QUrl) |
309 @param link link to be shown (string or QUrl) |
310 @keyparam position position to create the new tab at or -1 to add it |
310 @keyparam position position to create the new tab at or -1 to add it |
311 to the end (integer) |
311 to the end (integer) |
|
312 @keyparam background flag indicating to open the tab in the |
|
313 background (bool) |
|
314 @return reference to the new browser |
|
315 @rtype WebBrowserView |
312 """ |
316 """ |
313 if link is None: |
317 if link is None: |
314 linkName = "" |
318 linkName = "" |
315 elif isinstance(link, QUrl): |
319 elif isinstance(link, QUrl): |
316 linkName = link.toString() |
320 linkName = link.toString() |
356 |
360 |
357 if position == -1: |
361 if position == -1: |
358 index = self.addTab(browser, self.tr("...")) |
362 index = self.addTab(browser, self.tr("...")) |
359 else: |
363 else: |
360 index = self.insertTab(position, browser, self.tr("...")) |
364 index = self.insertTab(position, browser, self.tr("...")) |
361 self.setCurrentIndex(index) |
365 if not background: |
|
366 self.setCurrentIndex(index) |
362 |
367 |
363 self.__mainWindow.closeAct.setEnabled(True) |
368 self.__mainWindow.closeAct.setEnabled(True) |
364 self.__mainWindow.closeAllAct.setEnabled(True) |
369 self.__mainWindow.closeAllAct.setEnabled(True) |
365 self.__closeButton.setEnabled(True) |
370 self.__closeButton.setEnabled(True) |
366 self.__navigationButton.setEnabled(True) |
371 self.__navigationButton.setEnabled(True) |
381 index, |
386 index, |
382 self.__elide(browser.documentTitle().replace("&", "&&"))) |
387 self.__elide(browser.documentTitle().replace("&", "&&"))) |
383 self.setTabToolTip(index, browser.documentTitle()) |
388 self.setTabToolTip(index, browser.documentTitle()) |
384 |
389 |
385 self.browserOpened.emit(browser) |
390 self.browserOpened.emit(browser) |
386 |
391 |
387 def newBrowserAfter(self, browser, link=None): |
392 return browser |
|
393 |
|
394 def newBrowserAfter(self, browser, link=None, background=False): |
388 """ |
395 """ |
389 Public method to create a new web browser tab after a given one. |
396 Public method to create a new web browser tab after a given one. |
390 |
397 |
391 @param browser reference to the browser to add after (WebBrowserView) |
398 @param browser reference to the browser to add after (WebBrowserView) |
392 @param link link to be shown (string or QUrl) |
399 @param link link to be shown (string or QUrl) |
|
400 @keyparam background flag indicating to open the tab in the |
|
401 background (bool) |
|
402 @return reference to the new browser |
|
403 @rtype WebBrowserView |
393 """ |
404 """ |
394 if browser: |
405 if browser: |
395 position = self.indexOf(browser) + 1 |
406 position = self.indexOf(browser) + 1 |
396 else: |
407 else: |
397 position = -1 |
408 position = -1 |
398 self.newBrowser(link, position) |
409 return self.newBrowser(link, position, background) |
399 |
410 |
400 def __showNavigationMenu(self): |
411 def __showNavigationMenu(self): |
401 """ |
412 """ |
402 Private slot to show the navigation button menu. |
413 Private slot to show the navigation button menu. |
403 """ |
414 """ |
595 if printDialog.exec_() == QDialog.Accepted: |
606 if printDialog.exec_() == QDialog.Accepted: |
596 browser.render(printer) |
607 browser.render(printer) |
597 |
608 |
598 def __pdfGenerated(self, filePath, pdfData): |
609 def __pdfGenerated(self, filePath, pdfData): |
599 """ |
610 """ |
600 Public slot handling the generated PDF data. |
611 Private slot handling the generated PDF data. |
601 |
612 |
602 @param filePath path to save the PDF to |
613 @param filePath path to save the PDF to |
603 @type str |
614 @type str |
604 @param pdfData generated PDF document |
615 @param pdfData generated PDF document |
605 @type QByteArray |
616 @type QByteArray |