WebBrowser/WebBrowserWindow.py

changeset 5181
1948b27d7b21
parent 5108
f5cb9cb98e6a
child 5182
e2782c9a43d4
equal deleted inserted replaced
5176:30547e9a19e3 5181:1948b27d7b21
16 import os 16 import os
17 import shutil 17 import shutil
18 import sys 18 import sys
19 19
20 from PyQt5.QtCore import pyqtSlot, pyqtSignal, Qt, QByteArray, QSize, QTimer, \ 20 from PyQt5.QtCore import pyqtSlot, pyqtSignal, Qt, QByteArray, QSize, QTimer, \
21 QUrl, QTextCodec, QProcess, QEvent 21 QUrl, QTextCodec, QProcess, QEvent, qVersion
22 from PyQt5.QtGui import QDesktopServices, QKeySequence, QFont, QFontMetrics 22 from PyQt5.QtGui import QDesktopServices, QKeySequence, QFont, QFontMetrics
23 from PyQt5.QtWidgets import QWidget, QVBoxLayout, QSizePolicy, QDockWidget, \ 23 from PyQt5.QtWidgets import QWidget, QVBoxLayout, QSizePolicy, QDockWidget, \
24 QComboBox, QLabel, QSplitter, QMenu, QToolButton, QLineEdit, \ 24 QComboBox, QLabel, QSplitter, QMenu, QToolButton, QLineEdit, \
25 QApplication, QWhatsThis, QDialog, QHBoxLayout, QProgressBar, QAction, \ 25 QApplication, QWhatsThis, QDialog, QHBoxLayout, QProgressBar, QAction, \
26 QInputDialog 26 QInputDialog
699 if not self.__initShortcutsOnly: 699 if not self.__initShortcutsOnly:
700 self.exportBookmarksAct.triggered.connect( 700 self.exportBookmarksAct.triggered.connect(
701 bookmarksManager.exportBookmarks) 701 bookmarksManager.exportBookmarks)
702 self.__actions.append(self.exportBookmarksAct) 702 self.__actions.append(self.exportBookmarksAct)
703 703
704 self.printAct = E5Action( 704 if not Globals.isWindowsPlatform():
705 self.tr('Print'), 705 # TODO: implement printing based on printToPdf()
706 UI.PixmapCache.getIcon("print.png"), 706 self.printAct = E5Action(
707 self.tr('&Print'), 707 self.tr('Print'),
708 QKeySequence(self.tr("Ctrl+P", "File|Print")), 708 UI.PixmapCache.getIcon("print.png"),
709 0, self, 'webbrowser_file_print') 709 self.tr('&Print'),
710 self.printAct.setStatusTip(self.tr('Print the displayed help')) 710 QKeySequence(self.tr("Ctrl+P", "File|Print")),
711 self.printAct.setWhatsThis(self.tr( 711 0, self, 'webbrowser_file_print')
712 """<b>Print</b>""" 712 self.printAct.setStatusTip(self.tr('Print the displayed help'))
713 """<p>Print the displayed help text.</p>""" 713 self.printAct.setWhatsThis(self.tr(
714 )) 714 """<b>Print</b>"""
715 if not self.__initShortcutsOnly: 715 """<p>Print the displayed help text.</p>"""
716 self.printAct.triggered.connect(self.__tabWidget.printBrowser) 716 ))
717 self.__actions.append(self.printAct) 717 if not self.__initShortcutsOnly:
718 718 self.printAct.triggered.connect(self.__tabWidget.printBrowser)
719 if Globals.isLinuxPlatform(): 719 self.__actions.append(self.printAct)
720 else:
721 self.printAct = None
722
723 if Globals.isLinuxPlatform() or qVersion() >= "5.7.0":
720 self.printPdfAct = E5Action( 724 self.printPdfAct = E5Action(
721 self.tr('Print as PDF'), 725 self.tr('Print as PDF'),
722 UI.PixmapCache.getIcon("printPdf.png"), 726 UI.PixmapCache.getIcon("printPdf.png"),
723 self.tr('Print as PDF'), 727 self.tr('Print as PDF'),
724 0, 0, self, 'webbrowser_file_print_pdf') 728 0, 0, self, 'webbrowser_file_print_pdf')
733 self.__tabWidget.printBrowserPdf) 737 self.__tabWidget.printBrowserPdf)
734 self.__actions.append(self.printPdfAct) 738 self.__actions.append(self.printPdfAct)
735 else: 739 else:
736 self.printPdfAct = None 740 self.printPdfAct = None
737 741
738 self.printPreviewAct = E5Action( 742 if not Globals.isWindowsPlatform():
739 self.tr('Print Preview'), 743 self.printPreviewAct = E5Action(
740 UI.PixmapCache.getIcon("printPreview.png"), 744 self.tr('Print Preview'),
741 self.tr('Print Preview'), 745 UI.PixmapCache.getIcon("printPreview.png"),
742 0, 0, self, 'webbrowser_file_print_preview') 746 self.tr('Print Preview'),
743 self.printPreviewAct.setStatusTip(self.tr( 747 0, 0, self, 'webbrowser_file_print_preview')
744 'Print preview of the displayed help')) 748 self.printPreviewAct.setStatusTip(self.tr(
745 self.printPreviewAct.setWhatsThis(self.tr( 749 'Print preview of the displayed help'))
746 """<b>Print Preview</b>""" 750 self.printPreviewAct.setWhatsThis(self.tr(
747 """<p>Print preview of the displayed help text.</p>""" 751 """<b>Print Preview</b>"""
748 )) 752 """<p>Print preview of the displayed help text.</p>"""
749 if not self.__initShortcutsOnly: 753 ))
750 self.printPreviewAct.triggered.connect( 754 if not self.__initShortcutsOnly:
751 self.__tabWidget.printPreviewBrowser) 755 self.printPreviewAct.triggered.connect(
752 self.__actions.append(self.printPreviewAct) 756 self.__tabWidget.printPreviewBrowser)
757 self.__actions.append(self.printPreviewAct)
758 else:
759 self.printPreviewAct = None
753 760
754 self.closeAct = E5Action( 761 self.closeAct = E5Action(
755 self.tr('Close'), 762 self.tr('Close'),
756 UI.PixmapCache.getIcon("close.png"), 763 UI.PixmapCache.getIcon("close.png"),
757 self.tr('&Close'), 764 self.tr('&Close'),
1772 if self.saveAsAct is not None: 1779 if self.saveAsAct is not None:
1773 menu.addAction(self.saveAsAct) 1780 menu.addAction(self.saveAsAct)
1774 menu.addAction(self.savePageScreenAct) 1781 menu.addAction(self.savePageScreenAct)
1775 menu.addAction(self.saveVisiblePageScreenAct) 1782 menu.addAction(self.saveVisiblePageScreenAct)
1776 menu.addSeparator() 1783 menu.addSeparator()
1777 menu.addAction(self.printPreviewAct) 1784 if self.printPreviewAct:
1778 menu.addAction(self.printAct) 1785 menu.addAction(self.printPreviewAct)
1786 if self.printAct:
1787 menu.addAction(self.printAct)
1779 if self.printPdfAct: 1788 if self.printPdfAct:
1780 menu.addAction(self.printPdfAct) 1789 menu.addAction(self.printPdfAct)
1781 menu.addSeparator() 1790 menu.addSeparator()
1782 menu.addAction(self.closeAct) 1791 menu.addAction(self.closeAct)
1783 menu.addAction(self.closeAllAct) 1792 menu.addAction(self.closeAllAct)
1939 filetb.addSeparator() 1948 filetb.addSeparator()
1940 if self.saveAsAct is not None: 1949 if self.saveAsAct is not None:
1941 filetb.addAction(self.saveAsAct) 1950 filetb.addAction(self.saveAsAct)
1942 filetb.addAction(self.savePageScreenAct) 1951 filetb.addAction(self.savePageScreenAct)
1943 filetb.addSeparator() 1952 filetb.addSeparator()
1944 filetb.addAction(self.printPreviewAct) 1953 if self.printPreviewAct:
1945 filetb.addAction(self.printAct) 1954 filetb.addAction(self.printPreviewAct)
1955 if self.printAct:
1956 filetb.addAction(self.printAct)
1946 if self.printPdfAct: 1957 if self.printPdfAct:
1947 filetb.addAction(self.printPdfAct) 1958 filetb.addAction(self.printPdfAct)
1948 filetb.addSeparator() 1959 filetb.addSeparator()
1949 filetb.addAction(self.closeAct) 1960 filetb.addAction(self.closeAct)
1950 filetb.addAction(self.exitAct) 1961 filetb.addAction(self.exitAct)

eric ide

mercurial