18 |
18 |
19 class EditorExportersPage(ConfigurationPageBase, Ui_EditorExportersPage): |
19 class EditorExportersPage(ConfigurationPageBase, Ui_EditorExportersPage): |
20 """ |
20 """ |
21 Class implementing the Editor Typing configuration page. |
21 Class implementing the Editor Typing configuration page. |
22 """ |
22 """ |
|
23 |
23 def __init__(self): |
24 def __init__(self): |
24 """ |
25 """ |
25 Constructor |
26 Constructor |
26 """ |
27 """ |
27 super().__init__() |
28 super().__init__() |
28 self.setupUi(self) |
29 self.setupUi(self) |
29 self.setObjectName("EditorExportersPage") |
30 self.setObjectName("EditorExportersPage") |
30 |
31 |
31 # set initial values |
32 # set initial values |
32 self.pageIds = {} |
33 self.pageIds = {} |
33 self.pageIds[' '] = self.stackedWidget.indexOf(self.emptyPage) |
34 self.pageIds[" "] = self.stackedWidget.indexOf(self.emptyPage) |
34 self.pageIds['HTML'] = self.stackedWidget.indexOf(self.htmlPage) |
35 self.pageIds["HTML"] = self.stackedWidget.indexOf(self.htmlPage) |
35 self.pageIds['ODT'] = self.stackedWidget.indexOf(self.odtPage) |
36 self.pageIds["ODT"] = self.stackedWidget.indexOf(self.odtPage) |
36 self.pageIds['PDF'] = self.stackedWidget.indexOf(self.pdfPage) |
37 self.pageIds["PDF"] = self.stackedWidget.indexOf(self.pdfPage) |
37 self.pageIds['RTF'] = self.stackedWidget.indexOf(self.rtfPage) |
38 self.pageIds["RTF"] = self.stackedWidget.indexOf(self.rtfPage) |
38 self.pageIds['TeX'] = self.stackedWidget.indexOf(self.texPage) |
39 self.pageIds["TeX"] = self.stackedWidget.indexOf(self.texPage) |
39 exporters = sorted(self.pageIds.keys()) |
40 exporters = sorted(self.pageIds.keys()) |
40 for exporter in exporters: |
41 for exporter in exporters: |
41 self.exportersCombo.addItem(exporter, self.pageIds[exporter]) |
42 self.exportersCombo.addItem(exporter, self.pageIds[exporter]) |
42 |
43 |
43 self.pdfFontCombo.addItem(self.tr("Courier"), "Courier") |
44 self.pdfFontCombo.addItem(self.tr("Courier"), "Courier") |
44 self.pdfFontCombo.addItem(self.tr("Helvetica"), "Helvetica") |
45 self.pdfFontCombo.addItem(self.tr("Helvetica"), "Helvetica") |
45 self.pdfFontCombo.addItem(self.tr("Times"), "Times") |
46 self.pdfFontCombo.addItem(self.tr("Times"), "Times") |
46 |
47 |
47 self.pdfPageSizeCombo.addItem(self.tr("A4"), "A4") |
48 self.pdfPageSizeCombo.addItem(self.tr("A4"), "A4") |
48 self.pdfPageSizeCombo.addItem(self.tr("Letter"), "Letter") |
49 self.pdfPageSizeCombo.addItem(self.tr("Letter"), "Letter") |
49 |
50 |
50 # HTML |
51 # HTML |
51 self.htmlWysiwygCheckBox.setChecked( |
52 self.htmlWysiwygCheckBox.setChecked( |
52 Preferences.getEditorExporter("HTML/WYSIWYG")) |
53 Preferences.getEditorExporter("HTML/WYSIWYG") |
|
54 ) |
53 self.htmlFoldingCheckBox.setChecked( |
55 self.htmlFoldingCheckBox.setChecked( |
54 Preferences.getEditorExporter("HTML/Folding")) |
56 Preferences.getEditorExporter("HTML/Folding") |
|
57 ) |
55 self.htmlStylesCheckBox.setChecked( |
58 self.htmlStylesCheckBox.setChecked( |
56 Preferences.getEditorExporter("HTML/OnlyStylesUsed")) |
59 Preferences.getEditorExporter("HTML/OnlyStylesUsed") |
|
60 ) |
57 self.htmlTitleCheckBox.setChecked( |
61 self.htmlTitleCheckBox.setChecked( |
58 Preferences.getEditorExporter("HTML/FullPathAsTitle")) |
62 Preferences.getEditorExporter("HTML/FullPathAsTitle") |
59 self.htmlTabsCheckBox.setChecked( |
63 ) |
60 Preferences.getEditorExporter("HTML/UseTabs")) |
64 self.htmlTabsCheckBox.setChecked(Preferences.getEditorExporter("HTML/UseTabs")) |
61 |
65 |
62 # ODT |
66 # ODT |
63 self.odtWysiwygCheckBox.setChecked( |
67 self.odtWysiwygCheckBox.setChecked(Preferences.getEditorExporter("ODT/WYSIWYG")) |
64 Preferences.getEditorExporter("ODT/WYSIWYG")) |
|
65 self.odtStylesCheckBox.setChecked( |
68 self.odtStylesCheckBox.setChecked( |
66 Preferences.getEditorExporter("ODT/OnlyStylesUsed")) |
69 Preferences.getEditorExporter("ODT/OnlyStylesUsed") |
67 self.odtTabsCheckBox.setChecked( |
70 ) |
68 Preferences.getEditorExporter("ODT/UseTabs")) |
71 self.odtTabsCheckBox.setChecked(Preferences.getEditorExporter("ODT/UseTabs")) |
69 |
72 |
70 # PDF |
73 # PDF |
71 self.pdfMagnificationSlider.setValue( |
74 self.pdfMagnificationSlider.setValue( |
72 Preferences.getEditorExporter("PDF/Magnification")) |
75 Preferences.getEditorExporter("PDF/Magnification") |
73 ind = self.pdfFontCombo.findData( |
76 ) |
74 Preferences.getEditorExporter("PDF/Font")) |
77 ind = self.pdfFontCombo.findData(Preferences.getEditorExporter("PDF/Font")) |
75 self.pdfFontCombo.setCurrentIndex(ind) |
78 self.pdfFontCombo.setCurrentIndex(ind) |
76 ind = self.pdfPageSizeCombo.findData( |
79 ind = self.pdfPageSizeCombo.findData( |
77 Preferences.getEditorExporter("PDF/PageSize")) |
80 Preferences.getEditorExporter("PDF/PageSize") |
|
81 ) |
78 self.pdfPageSizeCombo.setCurrentIndex(ind) |
82 self.pdfPageSizeCombo.setCurrentIndex(ind) |
79 self.pdfMarginTopSpin.setValue( |
83 self.pdfMarginTopSpin.setValue(Preferences.getEditorExporter("PDF/MarginTop")) |
80 Preferences.getEditorExporter("PDF/MarginTop")) |
|
81 self.pdfMarginBottomSpin.setValue( |
84 self.pdfMarginBottomSpin.setValue( |
82 Preferences.getEditorExporter("PDF/MarginBottom")) |
85 Preferences.getEditorExporter("PDF/MarginBottom") |
83 self.pdfMarginLeftSpin.setValue( |
86 ) |
84 Preferences.getEditorExporter("PDF/MarginLeft")) |
87 self.pdfMarginLeftSpin.setValue(Preferences.getEditorExporter("PDF/MarginLeft")) |
85 self.pdfMarginRightSpin.setValue( |
88 self.pdfMarginRightSpin.setValue( |
86 Preferences.getEditorExporter("PDF/MarginRight")) |
89 Preferences.getEditorExporter("PDF/MarginRight") |
87 |
90 ) |
|
91 |
88 # RTF |
92 # RTF |
89 self.rtfWysiwygCheckBox.setChecked( |
93 self.rtfWysiwygCheckBox.setChecked(Preferences.getEditorExporter("RTF/WYSIWYG")) |
90 Preferences.getEditorExporter("RTF/WYSIWYG")) |
94 self.rtfTabsCheckBox.setChecked(Preferences.getEditorExporter("RTF/UseTabs")) |
91 self.rtfTabsCheckBox.setChecked( |
|
92 Preferences.getEditorExporter("RTF/UseTabs")) |
|
93 self.rtfFont = Preferences.getEditorExporter("RTF/Font") |
95 self.rtfFont = Preferences.getEditorExporter("RTF/Font") |
94 self.rtfFontSample.setFont(self.rtfFont) |
96 self.rtfFontSample.setFont(self.rtfFont) |
95 |
97 |
96 # TeX |
98 # TeX |
97 self.texStylesCheckBox.setChecked( |
99 self.texStylesCheckBox.setChecked( |
98 Preferences.getEditorExporter("TeX/OnlyStylesUsed")) |
100 Preferences.getEditorExporter("TeX/OnlyStylesUsed") |
|
101 ) |
99 self.texTitleCheckBox.setChecked( |
102 self.texTitleCheckBox.setChecked( |
100 Preferences.getEditorExporter("TeX/FullPathAsTitle")) |
103 Preferences.getEditorExporter("TeX/FullPathAsTitle") |
101 |
104 ) |
|
105 |
102 self.on_exportersCombo_activated(0) |
106 self.on_exportersCombo_activated(0) |
103 |
107 |
104 def save(self): |
108 def save(self): |
105 """ |
109 """ |
106 Public slot to save the Editor Typing configuration. |
110 Public slot to save the Editor Typing configuration. |
107 """ |
111 """ |
108 # HTML |
112 # HTML |
109 Preferences.setEditorExporter( |
113 Preferences.setEditorExporter( |
110 "HTML/WYSIWYG", |
114 "HTML/WYSIWYG", self.htmlWysiwygCheckBox.isChecked() |
111 self.htmlWysiwygCheckBox.isChecked()) |
115 ) |
112 Preferences.setEditorExporter( |
116 Preferences.setEditorExporter( |
113 "HTML/Folding", |
117 "HTML/Folding", self.htmlFoldingCheckBox.isChecked() |
114 self.htmlFoldingCheckBox.isChecked()) |
118 ) |
115 Preferences.setEditorExporter( |
119 Preferences.setEditorExporter( |
116 "HTML/OnlyStylesUsed", |
120 "HTML/OnlyStylesUsed", self.htmlStylesCheckBox.isChecked() |
117 self.htmlStylesCheckBox.isChecked()) |
121 ) |
118 Preferences.setEditorExporter( |
122 Preferences.setEditorExporter( |
119 "HTML/FullPathAsTitle", |
123 "HTML/FullPathAsTitle", self.htmlTitleCheckBox.isChecked() |
120 self.htmlTitleCheckBox.isChecked()) |
124 ) |
121 Preferences.setEditorExporter( |
125 Preferences.setEditorExporter("HTML/UseTabs", self.htmlTabsCheckBox.isChecked()) |
122 "HTML/UseTabs", |
126 |
123 self.htmlTabsCheckBox.isChecked()) |
|
124 |
|
125 # ODT |
127 # ODT |
126 Preferences.setEditorExporter( |
128 Preferences.setEditorExporter( |
127 "ODT/WYSIWYG", |
129 "ODT/WYSIWYG", self.odtWysiwygCheckBox.isChecked() |
128 self.odtWysiwygCheckBox.isChecked()) |
130 ) |
129 Preferences.setEditorExporter( |
131 Preferences.setEditorExporter( |
130 "ODT/OnlyStylesUsed", |
132 "ODT/OnlyStylesUsed", self.odtStylesCheckBox.isChecked() |
131 self.odtStylesCheckBox.isChecked()) |
133 ) |
132 Preferences.setEditorExporter( |
134 Preferences.setEditorExporter("ODT/UseTabs", self.odtTabsCheckBox.isChecked()) |
133 "ODT/UseTabs", |
135 |
134 self.odtTabsCheckBox.isChecked()) |
|
135 |
|
136 # PDF |
136 # PDF |
137 Preferences.setEditorExporter( |
137 Preferences.setEditorExporter( |
138 "PDF/Magnification", |
138 "PDF/Magnification", self.pdfMagnificationSlider.value() |
139 self.pdfMagnificationSlider.value()) |
139 ) |
140 Preferences.setEditorExporter( |
140 Preferences.setEditorExporter( |
141 "PDF/Font", |
141 "PDF/Font", self.pdfFontCombo.itemData(self.pdfFontCombo.currentIndex()) |
142 self.pdfFontCombo.itemData(self.pdfFontCombo.currentIndex())) |
142 ) |
143 Preferences.setEditorExporter( |
143 Preferences.setEditorExporter( |
144 "PDF/PageSize", |
144 "PDF/PageSize", |
145 self.pdfPageSizeCombo.itemData( |
145 self.pdfPageSizeCombo.itemData(self.pdfPageSizeCombo.currentIndex()), |
146 self.pdfPageSizeCombo.currentIndex())) |
146 ) |
147 Preferences.setEditorExporter( |
147 Preferences.setEditorExporter("PDF/MarginTop", self.pdfMarginTopSpin.value()) |
148 "PDF/MarginTop", |
148 Preferences.setEditorExporter( |
149 self.pdfMarginTopSpin.value()) |
149 "PDF/MarginBottom", self.pdfMarginBottomSpin.value() |
150 Preferences.setEditorExporter( |
150 ) |
151 "PDF/MarginBottom", |
151 Preferences.setEditorExporter("PDF/MarginLeft", self.pdfMarginLeftSpin.value()) |
152 self.pdfMarginBottomSpin.value()) |
152 Preferences.setEditorExporter( |
153 Preferences.setEditorExporter( |
153 "PDF/MarginRight", self.pdfMarginRightSpin.value() |
154 "PDF/MarginLeft", |
154 ) |
155 self.pdfMarginLeftSpin.value()) |
155 |
156 Preferences.setEditorExporter( |
|
157 "PDF/MarginRight", |
|
158 self.pdfMarginRightSpin.value()) |
|
159 |
|
160 # RTF |
156 # RTF |
161 Preferences.setEditorExporter( |
157 Preferences.setEditorExporter( |
162 "RTF/WYSIWYG", |
158 "RTF/WYSIWYG", self.rtfWysiwygCheckBox.isChecked() |
163 self.rtfWysiwygCheckBox.isChecked()) |
159 ) |
164 Preferences.setEditorExporter( |
160 Preferences.setEditorExporter("RTF/UseTabs", self.rtfTabsCheckBox.isChecked()) |
165 "RTF/UseTabs", |
|
166 self.rtfTabsCheckBox.isChecked()) |
|
167 Preferences.setEditorExporter("RTF/Font", self.rtfFont) |
161 Preferences.setEditorExporter("RTF/Font", self.rtfFont) |
168 |
162 |
169 # TeX |
163 # TeX |
170 Preferences.setEditorExporter( |
164 Preferences.setEditorExporter( |
171 "TeX/OnlyStylesUsed", |
165 "TeX/OnlyStylesUsed", self.texStylesCheckBox.isChecked() |
172 self.texStylesCheckBox.isChecked()) |
166 ) |
173 Preferences.setEditorExporter( |
167 Preferences.setEditorExporter( |
174 "TeX/FullPathAsTitle", |
168 "TeX/FullPathAsTitle", self.texTitleCheckBox.isChecked() |
175 self.texTitleCheckBox.isChecked()) |
169 ) |
176 |
170 |
177 @pyqtSlot(int) |
171 @pyqtSlot(int) |
178 def on_exportersCombo_activated(self, index): |
172 def on_exportersCombo_activated(self, index): |
179 """ |
173 """ |
180 Private slot to select the page related to the selected exporter. |
174 Private slot to select the page related to the selected exporter. |
181 |
175 |
182 @param index index of the selected entry |
176 @param index index of the selected entry |
183 @type int |
177 @type int |
184 """ |
178 """ |
185 exporter = self.exportersCombo.itemText(index) |
179 exporter = self.exportersCombo.itemText(index) |
186 try: |
180 try: |
187 index = self.pageIds[exporter] |
181 index = self.pageIds[exporter] |
188 except KeyError: |
182 except KeyError: |
189 index = self.pageIds[' '] |
183 index = self.pageIds[" "] |
190 self.stackedWidget.setCurrentIndex(index) |
184 self.stackedWidget.setCurrentIndex(index) |
191 |
185 |
192 @pyqtSlot() |
186 @pyqtSlot() |
193 def on_rtfFontButton_clicked(self): |
187 def on_rtfFontButton_clicked(self): |
194 """ |
188 """ |
195 Private method used to select the font for the RTF export. |
189 Private method used to select the font for the RTF export. |
196 """ |
190 """ |