17 QPrinter, |
17 QPrinter, |
18 QPrintPreviewDialog, |
18 QPrintPreviewDialog, |
19 ) |
19 ) |
20 from PyQt6.QtWidgets import QDialog, QHBoxLayout, QMenu, QToolButton, QWidget |
20 from PyQt6.QtWidgets import QDialog, QHBoxLayout, QMenu, QToolButton, QWidget |
21 |
21 |
22 from eric7 import Globals, Preferences, Utilities |
22 from eric7 import Preferences |
23 from eric7.EricGui import EricPixmapCache |
23 from eric7.EricGui import EricPixmapCache |
24 from eric7.EricGui.EricOverrideCursor import EricOverrideCursor |
24 from eric7.EricGui.EricOverrideCursor import EricOverrideCursor |
25 from eric7.EricWidgets import EricMessageBox |
25 from eric7.EricWidgets import EricMessageBox |
26 from eric7.EricWidgets.EricApplication import ericApp |
26 from eric7.EricWidgets.EricApplication import ericApp |
27 from eric7.EricWidgets.EricTabWidget import EricTabWidget |
27 from eric7.EricWidgets.EricTabWidget import EricTabWidget |
|
28 from eric7.SystemUtilities import FileSystemUtilities, OSUtilities |
28 from eric7.WebBrowser.WebBrowserWindow import WebBrowserWindow |
29 from eric7.WebBrowser.WebBrowserWindow import WebBrowserWindow |
29 |
30 |
30 from . import WebInspector |
31 from . import WebInspector |
31 from .ClosedTabsManager import ClosedTabsManager |
32 from .ClosedTabsManager import ClosedTabsManager |
32 from .Tools import WebBrowserTools |
33 from .Tools import WebBrowserTools |
41 Static method to test the availability of CUPS. |
42 Static method to test the availability of CUPS. |
42 |
43 |
43 @return flag indicating the availability of CUPS |
44 @return flag indicating the availability of CUPS |
44 @rtype bool |
45 @rtype bool |
45 """ |
46 """ |
46 if Globals.isMacPlatform(): |
47 if OSUtilities.isMacPlatform(): |
47 # OS X/MacOS always have CUPS |
48 # OS X/MacOS always have CUPS |
48 return True |
49 return True |
49 elif Globals.isLinuxPlatform(): |
50 elif OSUtilities.isLinuxPlatform(): |
50 testPrinter = QPrinter() |
51 testPrinter = QPrinter() |
51 return testPrinter.supportsMultipleCopies() |
52 return testPrinter.supportsMultipleCopies() |
52 else: |
53 else: |
53 return False |
54 return False |
54 |
55 |
677 printDialog = QPrintDialog(printer, self) |
678 printDialog = QPrintDialog(printer, self) |
678 printDialog.setOptions( |
679 printDialog.setOptions( |
679 QAbstractPrintDialog.PrintDialogOption.PrintToFile |
680 QAbstractPrintDialog.PrintDialogOption.PrintToFile |
680 | QAbstractPrintDialog.PrintDialogOption.PrintShowPageSize |
681 | QAbstractPrintDialog.PrintDialogOption.PrintShowPageSize |
681 ) |
682 ) |
682 if not Globals.isWindowsPlatform(): |
683 if not OSUtilities.isWindowsPlatform(): |
683 if isCupsAvailable(): |
684 if isCupsAvailable(): |
684 printDialog.setOption( |
685 printDialog.setOption( |
685 QAbstractPrintDialog.PrintDialogOption.PrintCollateCopies |
686 QAbstractPrintDialog.PrintDialogOption.PrintCollateCopies |
686 ) |
687 ) |
687 printDialog.setOption(QAbstractPrintDialog.PrintDialogOption.PrintPageRange) |
688 printDialog.setOption(QAbstractPrintDialog.PrintDialogOption.PrintPageRange) |
727 return |
728 return |
728 browser.page().printToPdf( |
729 browser.page().printToPdf( |
729 lambda pdf: self.__pdfGeneratedForSave(filePath, pdf), |
730 lambda pdf: self.__pdfGeneratedForSave(filePath, pdf), |
730 pageLayout, |
731 pageLayout, |
731 ) |
732 ) |
732 elif Globals.isLinuxPlatform(): |
733 elif OSUtilities.isLinuxPlatform(): |
733 printer = QPrinter(mode=QPrinter.PrinterMode.HighResolution) |
734 printer = QPrinter(mode=QPrinter.PrinterMode.HighResolution) |
734 if Preferences.getPrinter("ColorMode"): |
735 if Preferences.getPrinter("ColorMode"): |
735 printer.setColorMode(QPrinter.ColorMode.Color) |
736 printer.setColorMode(QPrinter.ColorMode.Color) |
736 else: |
737 else: |
737 printer.setColorMode(QPrinter.ColorMode.GrayScale) |
738 printer.setColorMode(QPrinter.ColorMode.GrayScale) |
1055 |
1056 |
1056 @param path path string to guess an URL for (string) |
1057 @param path path string to guess an URL for (string) |
1057 @return guessed URL (QUrl) |
1058 @return guessed URL (QUrl) |
1058 """ |
1059 """ |
1059 manager = self.__mainWindow.openSearchManager() |
1060 manager = self.__mainWindow.openSearchManager() |
1060 path = Utilities.fromNativeSeparators(path) |
1061 path = FileSystemUtilities.fromNativeSeparators(path) |
1061 url = manager.convertKeywordSearchToUrl(path) |
1062 url = manager.convertKeywordSearchToUrl(path) |
1062 if url.isValid(): |
1063 if url.isValid(): |
1063 return url |
1064 return url |
1064 |
1065 |
1065 try: |
1066 try: |