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