Tools/UIPreviewer.py

branch
Py2 comp.
changeset 3060
5883ce99ee12
parent 3058
0a02c433f52d
parent 3048
83f86da6344e
child 3145
a9de05d4a22f
equal deleted inserted replaced
3058:0a02c433f52d 3060:5883ce99ee12
131 self.trUtf8('&Open File'), self) 131 self.trUtf8('&Open File'), self)
132 self.openAct.setShortcut( 132 self.openAct.setShortcut(
133 QKeySequence(self.trUtf8("Ctrl+O", "File|Open"))) 133 QKeySequence(self.trUtf8("Ctrl+O", "File|Open")))
134 self.openAct.setStatusTip(self.trUtf8('Open a UI file for display')) 134 self.openAct.setStatusTip(self.trUtf8('Open a UI file for display'))
135 self.openAct.setWhatsThis(self.trUtf8( 135 self.openAct.setWhatsThis(self.trUtf8(
136 """<b>Open File</b>""" 136 """<b>Open File</b>"""
137 """<p>This opens a new UI file for display.</p>""" 137 """<p>This opens a new UI file for display.</p>"""
138 )) 138 ))
139 self.openAct.triggered[()].connect(self.__openFile) 139 self.openAct.triggered[()].connect(self.__openFile)
140 140
141 self.printAct = QAction( 141 self.printAct = QAction(
142 UI.PixmapCache.getIcon("print.png"), 142 UI.PixmapCache.getIcon("print.png"),
143 self.trUtf8('&Print'), self) 143 self.trUtf8('&Print'), self)
144 self.printAct.setShortcut( 144 self.printAct.setShortcut(
145 QKeySequence(self.trUtf8("Ctrl+P", "File|Print"))) 145 QKeySequence(self.trUtf8("Ctrl+P", "File|Print")))
146 self.printAct.setStatusTip(self.trUtf8('Print a screen capture')) 146 self.printAct.setStatusTip(self.trUtf8('Print a screen capture'))
147 self.printAct.setWhatsThis(self.trUtf8( 147 self.printAct.setWhatsThis(self.trUtf8(
148 """<b>Print</b>""" 148 """<b>Print</b>"""
149 """<p>Print a screen capture.</p>""" 149 """<p>Print a screen capture.</p>"""
150 )) 150 ))
151 self.printAct.triggered[()].connect(self.__printImage) 151 self.printAct.triggered[()].connect(self.__printImage)
152 152
153 self.printPreviewAct = QAction( 153 self.printPreviewAct = QAction(
154 UI.PixmapCache.getIcon("printPreview.png"), 154 UI.PixmapCache.getIcon("printPreview.png"),
155 self.trUtf8('Print Preview'), self) 155 self.trUtf8('Print Preview'), self)
156 self.printPreviewAct.setStatusTip(self.trUtf8( 156 self.printPreviewAct.setStatusTip(self.trUtf8(
157 'Print preview a screen capture')) 157 'Print preview a screen capture'))
158 self.printPreviewAct.setWhatsThis(self.trUtf8( 158 self.printPreviewAct.setWhatsThis(self.trUtf8(
159 """<b>Print Preview</b>""" 159 """<b>Print Preview</b>"""
160 """<p>Print preview a screen capture.</p>""" 160 """<p>Print preview a screen capture.</p>"""
161 )) 161 ))
162 self.printPreviewAct.triggered[()].connect(self.__printPreviewImage) 162 self.printPreviewAct.triggered[()].connect(self.__printPreviewImage)
163 163
164 self.imageAct = QAction( 164 self.imageAct = QAction(
165 UI.PixmapCache.getIcon("screenCapture.png"), 165 UI.PixmapCache.getIcon("screenCapture.png"),
167 self.imageAct.setShortcut( 167 self.imageAct.setShortcut(
168 QKeySequence(self.trUtf8("Ctrl+S", "File|Screen Capture"))) 168 QKeySequence(self.trUtf8("Ctrl+S", "File|Screen Capture")))
169 self.imageAct.setStatusTip(self.trUtf8( 169 self.imageAct.setStatusTip(self.trUtf8(
170 'Save a screen capture to an image file')) 170 'Save a screen capture to an image file'))
171 self.imageAct.setWhatsThis(self.trUtf8( 171 self.imageAct.setWhatsThis(self.trUtf8(
172 """<b>Screen Capture</b>""" 172 """<b>Screen Capture</b>"""
173 """<p>Save a screen capture to an image file.</p>""" 173 """<p>Save a screen capture to an image file.</p>"""
174 )) 174 ))
175 self.imageAct.triggered[()].connect(self.__saveImage) 175 self.imageAct.triggered[()].connect(self.__saveImage)
176 176
177 self.exitAct = QAction( 177 self.exitAct = QAction(
178 UI.PixmapCache.getIcon("exit.png"), self.trUtf8('&Quit'), self) 178 UI.PixmapCache.getIcon("exit.png"), self.trUtf8('&Quit'), self)
179 self.exitAct.setShortcut( 179 self.exitAct.setShortcut(
180 QKeySequence(self.trUtf8("Ctrl+Q", "File|Quit"))) 180 QKeySequence(self.trUtf8("Ctrl+Q", "File|Quit")))
181 self.exitAct.setStatusTip(self.trUtf8('Quit the application')) 181 self.exitAct.setStatusTip(self.trUtf8('Quit the application'))
182 self.exitAct.setWhatsThis(self.trUtf8( 182 self.exitAct.setWhatsThis(self.trUtf8(
183 """<b>Quit</b>""" 183 """<b>Quit</b>"""
184 """<p>Quit the application.</p>""" 184 """<p>Quit the application.</p>"""
185 )) 185 ))
186 self.exitAct.triggered[()].connect(qApp.closeAllWindows) 186 self.exitAct.triggered[()].connect(qApp.closeAllWindows)
187 187
188 self.copyAct = QAction( 188 self.copyAct = QAction(
189 UI.PixmapCache.getIcon("editCopy.png"), self.trUtf8('&Copy'), self) 189 UI.PixmapCache.getIcon("editCopy.png"), self.trUtf8('&Copy'), self)
190 self.copyAct.setShortcut( 190 self.copyAct.setShortcut(
191 QKeySequence(self.trUtf8("Ctrl+C", "Edit|Copy"))) 191 QKeySequence(self.trUtf8("Ctrl+C", "Edit|Copy")))
192 self.copyAct.setStatusTip( 192 self.copyAct.setStatusTip(
193 self.trUtf8('Copy screen capture to clipboard')) 193 self.trUtf8('Copy screen capture to clipboard'))
194 self.copyAct.setWhatsThis(self.trUtf8( 194 self.copyAct.setWhatsThis(self.trUtf8(
195 """<b>Copy</b>""" 195 """<b>Copy</b>"""
196 """<p>Copy screen capture to clipboard.</p>""" 196 """<p>Copy screen capture to clipboard.</p>"""
197 )) 197 ))
198 self.copyAct.triggered[()].connect(self.__copyImageToClipboard) 198 self.copyAct.triggered[()].connect(self.__copyImageToClipboard)
199 199
200 self.whatsThisAct = QAction( 200 self.whatsThisAct = QAction(
201 UI.PixmapCache.getIcon("whatsThis.png"), 201 UI.PixmapCache.getIcon("whatsThis.png"),
214 214
215 self.aboutAct = QAction(self.trUtf8('&About'), self) 215 self.aboutAct = QAction(self.trUtf8('&About'), self)
216 self.aboutAct.setStatusTip(self.trUtf8( 216 self.aboutAct.setStatusTip(self.trUtf8(
217 'Display information about this software')) 217 'Display information about this software'))
218 self.aboutAct.setWhatsThis(self.trUtf8( 218 self.aboutAct.setWhatsThis(self.trUtf8(
219 """<b>About</b>""" 219 """<b>About</b>"""
220 """<p>Display some information about this software.</p>""" 220 """<p>Display some information about this software.</p>"""
221 )) 221 ))
222 self.aboutAct.triggered[()].connect(self.__about) 222 self.aboutAct.triggered[()].connect(self.__about)
223 223
224 self.aboutQtAct = QAction(self.trUtf8('About &Qt'), self) 224 self.aboutQtAct = QAction(self.trUtf8('About &Qt'), self)
225 self.aboutQtAct.setStatusTip( 225 self.aboutQtAct.setStatusTip(
226 self.trUtf8('Display information about the Qt toolkit')) 226 self.trUtf8('Display information about the Qt toolkit'))
227 self.aboutQtAct.setWhatsThis(self.trUtf8( 227 self.aboutQtAct.setWhatsThis(self.trUtf8(
228 """<b>About Qt</b>""" 228 """<b>About Qt</b>"""
229 """<p>Display some information about the Qt toolkit.</p>""" 229 """<p>Display some information about the Qt toolkit.</p>"""
230 )) 230 ))
231 self.aboutQtAct.triggered[()].connect(self.__aboutQt) 231 self.aboutQtAct.triggered[()].connect(self.__aboutQt)
232 232
233 def __initMenus(self): 233 def __initMenus(self):
234 """ 234 """
360 else: 360 else:
361 E5MessageBox.warning( 361 E5MessageBox.warning(
362 self, 362 self,
363 self.trUtf8("Load UI File"), 363 self.trUtf8("Load UI File"),
364 self.trUtf8( 364 self.trUtf8(
365 """<p>The file <b>{0}</b> could not be loaded.</p>""")\ 365 """<p>The file <b>{0}</b> could not be loaded.</p>""")
366 .format(fn)) 366 .format(fn))
367 self.__updateActions() 367 self.__updateActions()
368 368
369 def __updateChildren(self, sstyle): 369 def __updateChildren(self, sstyle):
370 """ 370 """
371 Private slot to change the style of the show UI. 371 Private slot to change the style of the show UI.
483 E5MessageBox.critical( 483 E5MessageBox.critical(
484 self, 484 self,
485 self.trUtf8("Save Image"), 485 self.trUtf8("Save Image"),
486 self.trUtf8( 486 self.trUtf8(
487 """<p>The file <b>{0}</b> could not be saved.</p>""") 487 """<p>The file <b>{0}</b> could not be saved.</p>""")
488 .format(fname)) 488 .format(fname))
489 489
490 def __copyImageToClipboard(self): 490 def __copyImageToClipboard(self):
491 """ 491 """
492 Private slot to handle the Copy Image menu action. 492 Private slot to handle the Copy Image menu action.
493 """ 493 """
518 518
519 settings = Preferences.Prefs.settings 519 settings = Preferences.Prefs.settings
520 printer = QPrinter(QPrinter.HighResolution) 520 printer = QPrinter(QPrinter.HighResolution)
521 printer.setFullPage(True) 521 printer.setFullPage(True)
522 522
523 printer.setPrinterName(settings.value("UIPreviewer/printername")) 523 printerName = Preferences.getPrinter("UIPreviewer/printername")
524 if printerName:
525 self.setPrinterName(printerName)
524 printer.setPageSize( 526 printer.setPageSize(
525 QPrinter.PageSize(int(settings.value("UIPreviewer/pagesize")))) 527 QPrinter.PageSize(int(settings.value("UIPreviewer/pagesize"))))
526 printer.setPageOrder( 528 printer.setPageOrder(
527 QPrinter.PageOrder(int(settings.value("UIPreviewer/pageorder")))) 529 QPrinter.PageOrder(int(settings.value("UIPreviewer/pageorder"))))
528 printer.setOrientation(QPrinter.Orientation( 530 printer.setOrientation(QPrinter.Orientation(
559 561
560 settings = Preferences.Prefs.settings 562 settings = Preferences.Prefs.settings
561 printer = QPrinter(QPrinter.HighResolution) 563 printer = QPrinter(QPrinter.HighResolution)
562 printer.setFullPage(True) 564 printer.setFullPage(True)
563 565
564 printer.setPrinterName(settings.value("UIPreviewer/printername")) 566 printerName = Preferences.getPrinter("UIPreviewer/printername")
567 if printerName:
568 self.setPrinterName(printerName)
565 printer.setPageSize( 569 printer.setPageSize(
566 QPrinter.PageSize(int(settings.value("UIPreviewer/pagesize")))) 570 QPrinter.PageSize(int(settings.value("UIPreviewer/pagesize"))))
567 printer.setPageOrder( 571 printer.setPageOrder(
568 QPrinter.PageOrder(int(settings.value("UIPreviewer/pageorder")))) 572 QPrinter.PageOrder(int(settings.value("UIPreviewer/pageorder"))))
569 printer.setOrientation(QPrinter.Orientation( 573 printer.setOrientation(QPrinter.Orientation(

eric ide

mercurial