124 """ |
124 """ |
125 Private method to define the user interface actions. |
125 Private method to define the user interface actions. |
126 """ |
126 """ |
127 self.openAct = QAction( |
127 self.openAct = QAction( |
128 UI.PixmapCache.getIcon("openUI.png"), |
128 UI.PixmapCache.getIcon("openUI.png"), |
129 self.trUtf8('&Open File'), self) |
129 self.tr('&Open File'), self) |
130 self.openAct.setShortcut( |
130 self.openAct.setShortcut( |
131 QKeySequence(self.trUtf8("Ctrl+O", "File|Open"))) |
131 QKeySequence(self.tr("Ctrl+O", "File|Open"))) |
132 self.openAct.setStatusTip(self.trUtf8('Open a UI file for display')) |
132 self.openAct.setStatusTip(self.tr('Open a UI file for display')) |
133 self.openAct.setWhatsThis(self.trUtf8( |
133 self.openAct.setWhatsThis(self.tr( |
134 """<b>Open File</b>""" |
134 """<b>Open File</b>""" |
135 """<p>This opens a new UI file for display.</p>""" |
135 """<p>This opens a new UI file for display.</p>""" |
136 )) |
136 )) |
137 self.openAct.triggered[()].connect(self.__openFile) |
137 self.openAct.triggered[()].connect(self.__openFile) |
138 |
138 |
139 self.printAct = QAction( |
139 self.printAct = QAction( |
140 UI.PixmapCache.getIcon("print.png"), |
140 UI.PixmapCache.getIcon("print.png"), |
141 self.trUtf8('&Print'), self) |
141 self.tr('&Print'), self) |
142 self.printAct.setShortcut( |
142 self.printAct.setShortcut( |
143 QKeySequence(self.trUtf8("Ctrl+P", "File|Print"))) |
143 QKeySequence(self.tr("Ctrl+P", "File|Print"))) |
144 self.printAct.setStatusTip(self.trUtf8('Print a screen capture')) |
144 self.printAct.setStatusTip(self.tr('Print a screen capture')) |
145 self.printAct.setWhatsThis(self.trUtf8( |
145 self.printAct.setWhatsThis(self.tr( |
146 """<b>Print</b>""" |
146 """<b>Print</b>""" |
147 """<p>Print a screen capture.</p>""" |
147 """<p>Print a screen capture.</p>""" |
148 )) |
148 )) |
149 self.printAct.triggered[()].connect(self.__printImage) |
149 self.printAct.triggered[()].connect(self.__printImage) |
150 |
150 |
151 self.printPreviewAct = QAction( |
151 self.printPreviewAct = QAction( |
152 UI.PixmapCache.getIcon("printPreview.png"), |
152 UI.PixmapCache.getIcon("printPreview.png"), |
153 self.trUtf8('Print Preview'), self) |
153 self.tr('Print Preview'), self) |
154 self.printPreviewAct.setStatusTip(self.trUtf8( |
154 self.printPreviewAct.setStatusTip(self.tr( |
155 'Print preview a screen capture')) |
155 'Print preview a screen capture')) |
156 self.printPreviewAct.setWhatsThis(self.trUtf8( |
156 self.printPreviewAct.setWhatsThis(self.tr( |
157 """<b>Print Preview</b>""" |
157 """<b>Print Preview</b>""" |
158 """<p>Print preview a screen capture.</p>""" |
158 """<p>Print preview a screen capture.</p>""" |
159 )) |
159 )) |
160 self.printPreviewAct.triggered[()].connect(self.__printPreviewImage) |
160 self.printPreviewAct.triggered[()].connect(self.__printPreviewImage) |
161 |
161 |
162 self.imageAct = QAction( |
162 self.imageAct = QAction( |
163 UI.PixmapCache.getIcon("screenCapture.png"), |
163 UI.PixmapCache.getIcon("screenCapture.png"), |
164 self.trUtf8('&Screen Capture'), self) |
164 self.tr('&Screen Capture'), self) |
165 self.imageAct.setShortcut( |
165 self.imageAct.setShortcut( |
166 QKeySequence(self.trUtf8("Ctrl+S", "File|Screen Capture"))) |
166 QKeySequence(self.tr("Ctrl+S", "File|Screen Capture"))) |
167 self.imageAct.setStatusTip(self.trUtf8( |
167 self.imageAct.setStatusTip(self.tr( |
168 'Save a screen capture to an image file')) |
168 'Save a screen capture to an image file')) |
169 self.imageAct.setWhatsThis(self.trUtf8( |
169 self.imageAct.setWhatsThis(self.tr( |
170 """<b>Screen Capture</b>""" |
170 """<b>Screen Capture</b>""" |
171 """<p>Save a screen capture to an image file.</p>""" |
171 """<p>Save a screen capture to an image file.</p>""" |
172 )) |
172 )) |
173 self.imageAct.triggered[()].connect(self.__saveImage) |
173 self.imageAct.triggered[()].connect(self.__saveImage) |
174 |
174 |
175 self.exitAct = QAction( |
175 self.exitAct = QAction( |
176 UI.PixmapCache.getIcon("exit.png"), self.trUtf8('&Quit'), self) |
176 UI.PixmapCache.getIcon("exit.png"), self.tr('&Quit'), self) |
177 self.exitAct.setShortcut( |
177 self.exitAct.setShortcut( |
178 QKeySequence(self.trUtf8("Ctrl+Q", "File|Quit"))) |
178 QKeySequence(self.tr("Ctrl+Q", "File|Quit"))) |
179 self.exitAct.setStatusTip(self.trUtf8('Quit the application')) |
179 self.exitAct.setStatusTip(self.tr('Quit the application')) |
180 self.exitAct.setWhatsThis(self.trUtf8( |
180 self.exitAct.setWhatsThis(self.tr( |
181 """<b>Quit</b>""" |
181 """<b>Quit</b>""" |
182 """<p>Quit the application.</p>""" |
182 """<p>Quit the application.</p>""" |
183 )) |
183 )) |
184 self.exitAct.triggered[()].connect(qApp.closeAllWindows) |
184 self.exitAct.triggered[()].connect(qApp.closeAllWindows) |
185 |
185 |
186 self.copyAct = QAction( |
186 self.copyAct = QAction( |
187 UI.PixmapCache.getIcon("editCopy.png"), self.trUtf8('&Copy'), self) |
187 UI.PixmapCache.getIcon("editCopy.png"), self.tr('&Copy'), self) |
188 self.copyAct.setShortcut( |
188 self.copyAct.setShortcut( |
189 QKeySequence(self.trUtf8("Ctrl+C", "Edit|Copy"))) |
189 QKeySequence(self.tr("Ctrl+C", "Edit|Copy"))) |
190 self.copyAct.setStatusTip( |
190 self.copyAct.setStatusTip( |
191 self.trUtf8('Copy screen capture to clipboard')) |
191 self.tr('Copy screen capture to clipboard')) |
192 self.copyAct.setWhatsThis(self.trUtf8( |
192 self.copyAct.setWhatsThis(self.tr( |
193 """<b>Copy</b>""" |
193 """<b>Copy</b>""" |
194 """<p>Copy screen capture to clipboard.</p>""" |
194 """<p>Copy screen capture to clipboard.</p>""" |
195 )) |
195 )) |
196 self.copyAct.triggered[()].connect(self.__copyImageToClipboard) |
196 self.copyAct.triggered[()].connect(self.__copyImageToClipboard) |
197 |
197 |
198 self.whatsThisAct = QAction( |
198 self.whatsThisAct = QAction( |
199 UI.PixmapCache.getIcon("whatsThis.png"), |
199 UI.PixmapCache.getIcon("whatsThis.png"), |
200 self.trUtf8('&What\'s This?'), self) |
200 self.tr('&What\'s This?'), self) |
201 self.whatsThisAct.setShortcut(QKeySequence(self.trUtf8("Shift+F1"))) |
201 self.whatsThisAct.setShortcut(QKeySequence(self.tr("Shift+F1"))) |
202 self.whatsThisAct.setStatusTip(self.trUtf8('Context sensitive help')) |
202 self.whatsThisAct.setStatusTip(self.tr('Context sensitive help')) |
203 self.whatsThisAct.setWhatsThis(self.trUtf8( |
203 self.whatsThisAct.setWhatsThis(self.tr( |
204 """<b>Display context sensitive help</b>""" |
204 """<b>Display context sensitive help</b>""" |
205 """<p>In What's This? mode, the mouse cursor shows an arrow""" |
205 """<p>In What's This? mode, the mouse cursor shows an arrow""" |
206 """ with a question mark, and you can click on the interface""" |
206 """ with a question mark, and you can click on the interface""" |
207 """ elements to get a short description of what they do and""" |
207 """ elements to get a short description of what they do and""" |
208 """ how to use them. In dialogs, this feature can be accessed""" |
208 """ how to use them. In dialogs, this feature can be accessed""" |
209 """ using the context help button in the titlebar.</p>""" |
209 """ using the context help button in the titlebar.</p>""" |
210 )) |
210 )) |
211 self.whatsThisAct.triggered[()].connect(self.__whatsThis) |
211 self.whatsThisAct.triggered[()].connect(self.__whatsThis) |
212 |
212 |
213 self.aboutAct = QAction(self.trUtf8('&About'), self) |
213 self.aboutAct = QAction(self.tr('&About'), self) |
214 self.aboutAct.setStatusTip(self.trUtf8( |
214 self.aboutAct.setStatusTip(self.tr( |
215 'Display information about this software')) |
215 'Display information about this software')) |
216 self.aboutAct.setWhatsThis(self.trUtf8( |
216 self.aboutAct.setWhatsThis(self.tr( |
217 """<b>About</b>""" |
217 """<b>About</b>""" |
218 """<p>Display some information about this software.</p>""" |
218 """<p>Display some information about this software.</p>""" |
219 )) |
219 )) |
220 self.aboutAct.triggered[()].connect(self.__about) |
220 self.aboutAct.triggered[()].connect(self.__about) |
221 |
221 |
222 self.aboutQtAct = QAction(self.trUtf8('About &Qt'), self) |
222 self.aboutQtAct = QAction(self.tr('About &Qt'), self) |
223 self.aboutQtAct.setStatusTip( |
223 self.aboutQtAct.setStatusTip( |
224 self.trUtf8('Display information about the Qt toolkit')) |
224 self.tr('Display information about the Qt toolkit')) |
225 self.aboutQtAct.setWhatsThis(self.trUtf8( |
225 self.aboutQtAct.setWhatsThis(self.tr( |
226 """<b>About Qt</b>""" |
226 """<b>About Qt</b>""" |
227 """<p>Display some information about the Qt toolkit.</p>""" |
227 """<p>Display some information about the Qt toolkit.</p>""" |
228 )) |
228 )) |
229 self.aboutQtAct.triggered[()].connect(self.__aboutQt) |
229 self.aboutQtAct.triggered[()].connect(self.__aboutQt) |
230 |
230 |
232 """ |
232 """ |
233 Private method to create the menus. |
233 Private method to create the menus. |
234 """ |
234 """ |
235 mb = self.menuBar() |
235 mb = self.menuBar() |
236 |
236 |
237 menu = mb.addMenu(self.trUtf8('&File')) |
237 menu = mb.addMenu(self.tr('&File')) |
238 menu.setTearOffEnabled(True) |
238 menu.setTearOffEnabled(True) |
239 menu.addAction(self.openAct) |
239 menu.addAction(self.openAct) |
240 menu.addAction(self.imageAct) |
240 menu.addAction(self.imageAct) |
241 menu.addSeparator() |
241 menu.addSeparator() |
242 menu.addAction(self.printPreviewAct) |
242 menu.addAction(self.printPreviewAct) |
243 menu.addAction(self.printAct) |
243 menu.addAction(self.printAct) |
244 menu.addSeparator() |
244 menu.addSeparator() |
245 menu.addAction(self.exitAct) |
245 menu.addAction(self.exitAct) |
246 |
246 |
247 menu = mb.addMenu(self.trUtf8("&Edit")) |
247 menu = mb.addMenu(self.tr("&Edit")) |
248 menu.setTearOffEnabled(True) |
248 menu.setTearOffEnabled(True) |
249 menu.addAction(self.copyAct) |
249 menu.addAction(self.copyAct) |
250 |
250 |
251 mb.addSeparator() |
251 mb.addSeparator() |
252 |
252 |
253 menu = mb.addMenu(self.trUtf8('&Help')) |
253 menu = mb.addMenu(self.tr('&Help')) |
254 menu.setTearOffEnabled(True) |
254 menu.setTearOffEnabled(True) |
255 menu.addAction(self.aboutAct) |
255 menu.addAction(self.aboutAct) |
256 menu.addAction(self.aboutQtAct) |
256 menu.addAction(self.aboutQtAct) |
257 menu.addSeparator() |
257 menu.addSeparator() |
258 menu.addAction(self.whatsThisAct) |
258 menu.addAction(self.whatsThisAct) |
259 |
259 |
260 def __initToolbars(self): |
260 def __initToolbars(self): |
261 """ |
261 """ |
262 Private method to create the toolbars. |
262 Private method to create the toolbars. |
263 """ |
263 """ |
264 filetb = self.addToolBar(self.trUtf8("File")) |
264 filetb = self.addToolBar(self.tr("File")) |
265 filetb.setIconSize(UI.Config.ToolBarIconSize) |
265 filetb.setIconSize(UI.Config.ToolBarIconSize) |
266 filetb.addAction(self.openAct) |
266 filetb.addAction(self.openAct) |
267 filetb.addAction(self.imageAct) |
267 filetb.addAction(self.imageAct) |
268 filetb.addSeparator() |
268 filetb.addSeparator() |
269 filetb.addAction(self.printPreviewAct) |
269 filetb.addAction(self.printPreviewAct) |
270 filetb.addAction(self.printAct) |
270 filetb.addAction(self.printAct) |
271 filetb.addSeparator() |
271 filetb.addSeparator() |
272 filetb.addAction(self.exitAct) |
272 filetb.addAction(self.exitAct) |
273 |
273 |
274 edittb = self.addToolBar(self.trUtf8("Edit")) |
274 edittb = self.addToolBar(self.tr("Edit")) |
275 edittb.setIconSize(UI.Config.ToolBarIconSize) |
275 edittb.setIconSize(UI.Config.ToolBarIconSize) |
276 edittb.addAction(self.copyAct) |
276 edittb.addAction(self.copyAct) |
277 |
277 |
278 helptb = self.addToolBar(self.trUtf8("Help")) |
278 helptb = self.addToolBar(self.tr("Help")) |
279 helptb.setIconSize(UI.Config.ToolBarIconSize) |
279 helptb.setIconSize(UI.Config.ToolBarIconSize) |
280 helptb.addAction(self.whatsThisAct) |
280 helptb.addAction(self.whatsThisAct) |
281 |
281 |
282 def __whatsThis(self): |
282 def __whatsThis(self): |
283 """ |
283 """ |
530 printer.setColorMode( |
530 printer.setColorMode( |
531 QPrinter.ColorMode(int(settings.value("UIPreviewer/colormode")))) |
531 QPrinter.ColorMode(int(settings.value("UIPreviewer/colormode")))) |
532 |
532 |
533 printDialog = QPrintDialog(printer, self) |
533 printDialog = QPrintDialog(printer, self) |
534 if printDialog.exec_() == QDialog.Accepted: |
534 if printDialog.exec_() == QDialog.Accepted: |
535 self.statusBar().showMessage(self.trUtf8("Printing the image...")) |
535 self.statusBar().showMessage(self.tr("Printing the image...")) |
536 self.__print(printer) |
536 self.__print(printer) |
537 |
537 |
538 settings.setValue("UIPreviewer/printername", printer.printerName()) |
538 settings.setValue("UIPreviewer/printername", printer.printerName()) |
539 settings.setValue("UIPreviewer/pagesize", printer.pageSize()) |
539 settings.setValue("UIPreviewer/pagesize", printer.pageSize()) |
540 settings.setValue("UIPreviewer/pageorder", printer.pageOrder()) |
540 settings.setValue("UIPreviewer/pageorder", printer.pageOrder()) |
541 settings.setValue("UIPreviewer/orientation", printer.orientation()) |
541 settings.setValue("UIPreviewer/orientation", printer.orientation()) |
542 settings.setValue("UIPreviewer/colormode", printer.colorMode()) |
542 settings.setValue("UIPreviewer/colormode", printer.colorMode()) |
543 |
543 |
544 self.statusBar().showMessage( |
544 self.statusBar().showMessage( |
545 self.trUtf8("Image sent to printer..."), 2000) |
545 self.tr("Image sent to printer..."), 2000) |
546 |
546 |
547 def __printPreviewImage(self): |
547 def __printPreviewImage(self): |
548 """ |
548 """ |
549 Private slot to handle the Print Preview menu action. |
549 Private slot to handle the Print Preview menu action. |
550 """ |
550 """ |
551 from PyQt4.QtGui import QPrintPreviewDialog |
551 from PyQt4.QtGui import QPrintPreviewDialog |
552 |
552 |
553 if self.mainWidget is None: |
553 if self.mainWidget is None: |
554 E5MessageBox.critical( |
554 E5MessageBox.critical( |
555 self, |
555 self, |
556 self.trUtf8("Print Preview"), |
556 self.tr("Print Preview"), |
557 self.trUtf8("""There is no UI file loaded.""")) |
557 self.tr("""There is no UI file loaded.""")) |
558 return |
558 return |
559 |
559 |
560 settings = Preferences.Prefs.settings |
560 settings = Preferences.Prefs.settings |
561 printer = QPrinter(QPrinter.HighResolution) |
561 printer = QPrinter(QPrinter.HighResolution) |
562 printer.setFullPage(True) |
562 printer.setFullPage(True) |