Tools/UIPreviewer.py

branch
Py2 comp.
changeset 3484
645c12de6b0c
parent 3178
f25fc1364c88
parent 3345
071afe8be2a1
child 3591
2f2a4a76dd22
equal deleted inserted replaced
3456:96232974dcdb 3484:645c12de6b0c
48 48
49 self.setStyle(Preferences.getUI("Style"), 49 self.setStyle(Preferences.getUI("Style"),
50 Preferences.getUI("StyleSheet")) 50 Preferences.getUI("StyleSheet"))
51 51
52 self.resize(QSize(600, 480).expandedTo(self.minimumSizeHint())) 52 self.resize(QSize(600, 480).expandedTo(self.minimumSizeHint()))
53 self.setAttribute(Qt.WA_DeleteOnClose)
54 self.statusBar() 53 self.statusBar()
55 54
56 self.setWindowIcon(UI.PixmapCache.getIcon("eric.png")) 55 self.setWindowIcon(UI.PixmapCache.getIcon("eric.png"))
57 self.setWindowTitle(self.trUtf8("UI Previewer")) 56 self.setWindowTitle(self.tr("UI Previewer"))
58 57
59 self.cw = QWidget(self) 58 self.cw = QWidget(self)
60 self.cw.setObjectName("centralWidget") 59 self.cw.setObjectName("centralWidget")
61 60
62 self.UIPreviewerLayout = QVBoxLayout(self.cw) 61 self.UIPreviewerLayout = QVBoxLayout(self.cw)
67 self.styleLayout = QHBoxLayout() 66 self.styleLayout = QHBoxLayout()
68 self.styleLayout.setContentsMargins(0, 0, 0, 0) 67 self.styleLayout.setContentsMargins(0, 0, 0, 0)
69 self.styleLayout.setSpacing(6) 68 self.styleLayout.setSpacing(6)
70 self.styleLayout.setObjectName("styleLayout") 69 self.styleLayout.setObjectName("styleLayout")
71 70
72 self.styleLabel = QLabel(self.trUtf8("Select GUI Theme"), self.cw) 71 self.styleLabel = QLabel(self.tr("Select GUI Theme"), self.cw)
73 self.styleLabel.setObjectName("styleLabel") 72 self.styleLabel.setObjectName("styleLabel")
74 self.styleLayout.addWidget(self.styleLabel) 73 self.styleLayout.addWidget(self.styleLabel)
75 74
76 self.styleCombo = QComboBox(self.cw) 75 self.styleCombo = QComboBox(self.cw)
77 self.styleCombo.setObjectName("styleCombo") 76 self.styleCombo.setObjectName("styleCombo")
78 self.styleCombo.setEditable(False) 77 self.styleCombo.setEditable(False)
79 self.styleCombo.setToolTip(self.trUtf8("Select the GUI Theme")) 78 self.styleCombo.setToolTip(self.tr("Select the GUI Theme"))
80 self.styleLayout.addWidget(self.styleCombo) 79 self.styleLayout.addWidget(self.styleCombo)
81 self.styleCombo.addItems(list(QStyleFactory().keys())) 80 self.styleCombo.addItems(list(QStyleFactory().keys()))
82 currentStyle = Preferences.Prefs.settings.value('UIPreviewer/style') 81 currentStyle = Preferences.Prefs.settings.value('UIPreviewer/style')
83 if currentStyle is not None: 82 if currentStyle is not None:
84 self.styleCombo.setCurrentIndex(int(currentStyle)) 83 self.styleCombo.setCurrentIndex(int(currentStyle))
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 """
300 """ 299 """
301 Private slot to show the about information. 300 Private slot to show the about information.
302 """ 301 """
303 E5MessageBox.about( 302 E5MessageBox.about(
304 self, 303 self,
305 self.trUtf8("UI Previewer"), 304 self.tr("UI Previewer"),
306 self.trUtf8( 305 self.tr(
307 """<h3> About UI Previewer </h3>""" 306 """<h3> About UI Previewer </h3>"""
308 """<p>The UI Previewer loads and displays Qt User-Interface""" 307 """<p>The UI Previewer loads and displays Qt User-Interface"""
309 """ files with various styles, which are selectable via a""" 308 """ files with various styles, which are selectable via a"""
310 """ selection list.</p>""" 309 """ selection list.</p>"""
311 ) 310 )
313 312
314 def __aboutQt(self): 313 def __aboutQt(self):
315 """ 314 """
316 Private slot to show info about Qt. 315 Private slot to show info about Qt.
317 """ 316 """
318 E5MessageBox.aboutQt(self, self.trUtf8("UI Previewer")) 317 E5MessageBox.aboutQt(self, self.tr("UI Previewer"))
319 318
320 def __openFile(self): 319 def __openFile(self):
321 """ 320 """
322 Private slot to load a new file. 321 Private slot to load a new file.
323 """ 322 """
324 fn = E5FileDialog.getOpenFileName( 323 fn = E5FileDialog.getOpenFileName(
325 self, 324 self,
326 self.trUtf8("Select UI file"), 325 self.tr("Select UI file"),
327 self.currentFile, 326 self.currentFile,
328 self.trUtf8("Qt User-Interface Files (*.ui)")) 327 self.tr("Qt User-Interface Files (*.ui)"))
329 if fn: 328 if fn:
330 self.__loadFile(fn) 329 self.__loadFile(fn)
331 330
332 def __loadFile(self, fn): 331 def __loadFile(self, fn):
333 """ 332 """
358 self.previewSV.setWidget(self.mainWidget) 357 self.previewSV.setWidget(self.mainWidget)
359 self.mainWidget.show() 358 self.mainWidget.show()
360 else: 359 else:
361 E5MessageBox.warning( 360 E5MessageBox.warning(
362 self, 361 self,
363 self.trUtf8("Load UI File"), 362 self.tr("Load UI File"),
364 self.trUtf8( 363 self.tr(
365 """<p>The file <b>{0}</b> could not be loaded.</p>""") 364 """<p>The file <b>{0}</b> could not be loaded.</p>""")
366 .format(fn)) 365 .format(fn))
367 self.__updateActions() 366 self.__updateActions()
368 367
369 def __updateChildren(self, sstyle): 368 def __updateChildren(self, sstyle):
447 Private slot to handle the Save Image menu action. 446 Private slot to handle the Save Image menu action.
448 """ 447 """
449 if self.mainWidget is None: 448 if self.mainWidget is None:
450 E5MessageBox.critical( 449 E5MessageBox.critical(
451 self, 450 self,
452 self.trUtf8("Save Image"), 451 self.tr("Save Image"),
453 self.trUtf8("""There is no UI file loaded.""")) 452 self.tr("""There is no UI file loaded."""))
454 return 453 return
455 454
456 defaultExt = "PNG" 455 defaultExt = "PNG"
457 filters = "" 456 filters = ""
458 formats = QImageWriter.supportedImageFormats() 457 formats = QImageWriter.supportedImageFormats()
459 for format in formats: 458 for format in formats:
460 filters = "{0}*.{1} ".format( 459 filters = "{0}*.{1} ".format(
461 filters, bytes(format).decode().lower()) 460 filters, bytes(format).decode().lower())
462 filter = self.trUtf8("Images ({0})").format(filters[:-1]) 461 filter = self.tr("Images ({0})").format(filters[:-1])
463 462
464 fname = E5FileDialog.getSaveFileName( 463 fname = E5FileDialog.getSaveFileName(
465 self, 464 self,
466 self.trUtf8("Save Image"), 465 self.tr("Save Image"),
467 "", 466 "",
468 filter) 467 filter)
469 if not fname: 468 if not fname:
470 return 469 return
471 470
480 pix = QPixmap.grabWidget(self.mainWidget) 479 pix = QPixmap.grabWidget(self.mainWidget)
481 self.__updateChildren(self.lastStyle) 480 self.__updateChildren(self.lastStyle)
482 if not pix.save(fname, str(ext)): 481 if not pix.save(fname, str(ext)):
483 E5MessageBox.critical( 482 E5MessageBox.critical(
484 self, 483 self,
485 self.trUtf8("Save Image"), 484 self.tr("Save Image"),
486 self.trUtf8( 485 self.tr(
487 """<p>The file <b>{0}</b> could not be saved.</p>""") 486 """<p>The file <b>{0}</b> could not be saved.</p>""")
488 .format(fname)) 487 .format(fname))
489 488
490 def __copyImageToClipboard(self): 489 def __copyImageToClipboard(self):
491 """ 490 """
492 Private slot to handle the Copy Image menu action. 491 Private slot to handle the Copy Image menu action.
493 """ 492 """
494 if self.mainWidget is None: 493 if self.mainWidget is None:
495 E5MessageBox.critical( 494 E5MessageBox.critical(
496 self, 495 self,
497 self.trUtf8("Save Image"), 496 self.tr("Save Image"),
498 self.trUtf8("""There is no UI file loaded.""")) 497 self.tr("""There is no UI file loaded."""))
499 return 498 return
500 499
501 cb = QApplication.clipboard() 500 cb = QApplication.clipboard()
502 if qVersion() >= "5.0.0": 501 if qVersion() >= "5.0.0":
503 cb.setPixmap(self.mainWidget.grab()) 502 cb.setPixmap(self.mainWidget.grab())
510 Private slot to handle the Print Image menu action. 509 Private slot to handle the Print Image menu action.
511 """ 510 """
512 if self.mainWidget is None: 511 if self.mainWidget is None:
513 E5MessageBox.critical( 512 E5MessageBox.critical(
514 self, 513 self,
515 self.trUtf8("Print Image"), 514 self.tr("Print Image"),
516 self.trUtf8("""There is no UI file loaded.""")) 515 self.tr("""There is no UI file loaded."""))
517 return 516 return
518 517
519 settings = Preferences.Prefs.settings 518 settings = Preferences.Prefs.settings
520 printer = QPrinter(QPrinter.HighResolution) 519 printer = QPrinter(QPrinter.HighResolution)
521 printer.setFullPage(True) 520 printer.setFullPage(True)
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)

eric ide

mercurial