6 """ |
6 """ |
7 Module implementing the Printer configuration page. |
7 Module implementing the Printer configuration page. |
8 """ |
8 """ |
9 |
9 |
10 from PyQt6.QtCore import pyqtSlot |
10 from PyQt6.QtCore import pyqtSlot |
|
11 from PyQt6.QtWidgets import QButtonGroup |
11 |
12 |
12 from eric7 import Preferences |
13 from eric7 import Preferences |
|
14 from eric7.QScintilla.QsciScintillaCompat import QsciScintillaPrintColorMode |
13 |
15 |
|
16 from ..ConfigurationDialog import ConfigurationMode |
14 from .ConfigurationPageBase import ConfigurationPageBase |
17 from .ConfigurationPageBase import ConfigurationPageBase |
15 from .Ui_PrinterPage import Ui_PrinterPage |
18 from .Ui_PrinterPage import Ui_PrinterPage |
16 |
19 |
17 |
20 |
18 class PrinterPage(ConfigurationPageBase, Ui_PrinterPage): |
21 class PrinterPage(ConfigurationPageBase, Ui_PrinterPage): |
25 Constructor |
28 Constructor |
26 """ |
29 """ |
27 super().__init__() |
30 super().__init__() |
28 self.setupUi(self) |
31 self.setupUi(self) |
29 self.setObjectName("PrinterPage") |
32 self.setObjectName("PrinterPage") |
|
33 |
|
34 self.__displayMode = None |
|
35 |
|
36 self.__printColorModeGroup = QButtonGroup() |
|
37 self.__printColorModeGroup.addButton( |
|
38 self.normalModeButton, QsciScintillaPrintColorMode.Normal |
|
39 ) |
|
40 self.__printColorModeGroup.addButton( |
|
41 self.invertLightModeButton, QsciScintillaPrintColorMode.InvertLight |
|
42 ) |
|
43 self.__printColorModeGroup.addButton( |
|
44 self.blackOnWhiteModeButton, QsciScintillaPrintColorMode.BlackOnWhite |
|
45 ) |
|
46 self.__printColorModeGroup.addButton( |
|
47 self.colorOnWhiteModeButton, QsciScintillaPrintColorMode.ColorOnWhite |
|
48 ) |
|
49 self.__printColorModeGroup.addButton( |
|
50 self.colorOnWhiteDefaultModeButton, |
|
51 QsciScintillaPrintColorMode.ColorOnWhiteDefaultBackground, |
|
52 ) |
|
53 self.__printColorModeGroup.addButton( |
|
54 self.screenColorsModeButton, QsciScintillaPrintColorMode.ScreenColors |
|
55 ) |
30 |
56 |
31 # set initial values |
57 # set initial values |
32 self.printerNameEdit.setText(Preferences.getPrinter("PrinterName")) |
58 self.printerNameEdit.setText(Preferences.getPrinter("PrinterName")) |
33 if Preferences.getPrinter("ColorMode"): |
59 if Preferences.getPrinter("ColorMode"): |
34 self.printerColorButton.setChecked(True) |
60 self.printerColorButton.setChecked(True) |
44 self.leftMarginSpinBox.setValue(Preferences.getPrinter("LeftMargin")) |
70 self.leftMarginSpinBox.setValue(Preferences.getPrinter("LeftMargin")) |
45 self.rightMarginSpinBox.setValue(Preferences.getPrinter("RightMargin")) |
71 self.rightMarginSpinBox.setValue(Preferences.getPrinter("RightMargin")) |
46 self.topMarginSpinBox.setValue(Preferences.getPrinter("TopMargin")) |
72 self.topMarginSpinBox.setValue(Preferences.getPrinter("TopMargin")) |
47 self.bottomMarginSpinBox.setValue(Preferences.getPrinter("BottomMargin")) |
73 self.bottomMarginSpinBox.setValue(Preferences.getPrinter("BottomMargin")) |
48 self.resolutionSpinBox.setValue(Preferences.getPrinter("Resolution")) |
74 self.resolutionSpinBox.setValue(Preferences.getPrinter("Resolution")) |
|
75 |
|
76 # editor related printer setting |
|
77 self.__printColorModeGroup.button( |
|
78 Preferences.getEditor("PrintColorMode") |
|
79 ).setChecked(True) |
|
80 |
|
81 def setMode(self, displayMode): |
|
82 """ |
|
83 Public method to perform mode dependent setups. |
|
84 |
|
85 @param displayMode mode of the configuration dialog |
|
86 @type ConfigurationMode |
|
87 """ |
|
88 self.__displayMode = displayMode |
|
89 self.printColorModeBox.setVisible( |
|
90 self.__displayMode |
|
91 in ( |
|
92 ConfigurationMode.DEFAULTMODE, |
|
93 ConfigurationMode.EDITORMODE, |
|
94 ) |
|
95 ) |
49 |
96 |
50 def save(self): |
97 def save(self): |
51 """ |
98 """ |
52 Public slot to save the Printer configuration. |
99 Public slot to save the Printer configuration. |
53 """ |
100 """ |
65 Preferences.setPrinter("LeftMargin", self.leftMarginSpinBox.value()) |
112 Preferences.setPrinter("LeftMargin", self.leftMarginSpinBox.value()) |
66 Preferences.setPrinter("RightMargin", self.rightMarginSpinBox.value()) |
113 Preferences.setPrinter("RightMargin", self.rightMarginSpinBox.value()) |
67 Preferences.setPrinter("TopMargin", self.topMarginSpinBox.value()) |
114 Preferences.setPrinter("TopMargin", self.topMarginSpinBox.value()) |
68 Preferences.setPrinter("BottomMargin", self.bottomMarginSpinBox.value()) |
115 Preferences.setPrinter("BottomMargin", self.bottomMarginSpinBox.value()) |
69 Preferences.setPrinter("Resolution", self.resolutionSpinBox.value()) |
116 Preferences.setPrinter("Resolution", self.resolutionSpinBox.value()) |
|
117 |
|
118 if self.__displayMode in ( |
|
119 ConfigurationMode.DEFAULTMODE, |
|
120 ConfigurationMode.EDITORMODE, |
|
121 ): |
|
122 # editor related printer setting |
|
123 Preferences.setEditor( |
|
124 "PrintColorMode", |
|
125 QsciScintillaPrintColorMode(self.__printColorModeGroup.checkedId()), |
|
126 ) |
70 |
127 |
71 @pyqtSlot() |
128 @pyqtSlot() |
72 def on_printheaderFontButton_clicked(self): |
129 def on_printheaderFontButton_clicked(self): |
73 """ |
130 """ |
74 Private method used to select the font for the page header. |
131 Private method used to select the font for the page header. |