Tools/UIPreviewer.py

changeset 537
72b32daeb8d6
parent 500
c3abc7895a01
child 539
87f9bce38a44
equal deleted inserted replaced
536:6d8d39753c82 537:72b32daeb8d6
9 9
10 from PyQt4.QtCore import * 10 from PyQt4.QtCore import *
11 from PyQt4.QtGui import * 11 from PyQt4.QtGui import *
12 from PyQt4 import uic 12 from PyQt4 import uic
13 13
14 from E5Gui import E5MessageBox
15
14 import Preferences 16 import Preferences
15 import UI.PixmapCache 17 import UI.PixmapCache
16 import UI.Config 18 import UI.Config
17
18 19
19 class UIPreviewer(QMainWindow): 20 class UIPreviewer(QMainWindow):
20 """ 21 """
21 Class implementing the UI Previewer main window. 22 Class implementing the UI Previewer main window.
22 """ 23 """
410 def __saveImage(self): 411 def __saveImage(self):
411 """ 412 """
412 Private slot to handle the Save Image menu action. 413 Private slot to handle the Save Image menu action.
413 """ 414 """
414 if self.mainWidget is None: 415 if self.mainWidget is None:
415 QMessageBox.critical(self, 416 E5MessageBox.critical(self,
416 self.trUtf8("Save Image"), 417 self.trUtf8("Save Image"),
417 self.trUtf8("""There is no UI file loaded.""")) 418 self.trUtf8("""There is no UI file loaded."""))
418 return 419 return
419 420
420 defaultExt = "PNG" 421 defaultExt = "PNG"
438 fname.append(".{0}".format(defaultExt.lower())) 439 fname.append(".{0}".format(defaultExt.lower()))
439 440
440 pix = QPixmap.grabWidget(self.mainWidget) 441 pix = QPixmap.grabWidget(self.mainWidget)
441 self.__updateChildren(self.lastStyle) 442 self.__updateChildren(self.lastStyle)
442 if not pix.save(fname, str(ext)): 443 if not pix.save(fname, str(ext)):
443 QMessageBox.critical(None, 444 E5MessageBox.critical(self,
444 self.trUtf8("Save Image"), 445 self.trUtf8("Save Image"),
445 self.trUtf8("""<p>The file <b>{0}</b> could not be saved.</p>""") 446 self.trUtf8("""<p>The file <b>{0}</b> could not be saved.</p>""")
446 .format(fname)) 447 .format(fname))
447 448
448 def __copyImageToClipboard(self): 449 def __copyImageToClipboard(self):
449 """ 450 """
450 Private slot to handle the Copy Image menu action. 451 Private slot to handle the Copy Image menu action.
451 """ 452 """
452 if self.mainWidget is None: 453 if self.mainWidget is None:
453 QMessageBox.critical(None, 454 E5MessageBox.critical(self,
454 self.trUtf8("Save Image"), 455 self.trUtf8("Save Image"),
455 self.trUtf8("""There is no UI file loaded.""")) 456 self.trUtf8("""There is no UI file loaded."""))
456 return 457 return
457 458
458 cb = QApplication.clipboard() 459 cb = QApplication.clipboard()
462 def __printImage(self): 463 def __printImage(self):
463 """ 464 """
464 Private slot to handle the Print Image menu action. 465 Private slot to handle the Print Image menu action.
465 """ 466 """
466 if self.mainWidget is None: 467 if self.mainWidget is None:
467 QMessageBox.critical(None, 468 E5MessageBox.critical(self,
468 self.trUtf8("Print Image"), 469 self.trUtf8("Print Image"),
469 self.trUtf8("""There is no UI file loaded.""")) 470 self.trUtf8("""There is no UI file loaded."""))
470 return 471 return
471 472
472 settings = Preferences.Prefs.settings 473 settings = Preferences.Prefs.settings
501 Private slot to handle the Print Preview menu action. 502 Private slot to handle the Print Preview menu action.
502 """ 503 """
503 from PyQt4.QtGui import QPrintPreviewDialog 504 from PyQt4.QtGui import QPrintPreviewDialog
504 505
505 if self.mainWidget is None: 506 if self.mainWidget is None:
506 QMessageBox.critical(None, 507 E5MessageBox.critical(self,
507 self.trUtf8("Print Preview"), 508 self.trUtf8("Print Preview"),
508 self.trUtf8("""There is no UI file loaded.""")) 509 self.trUtf8("""There is no UI file loaded."""))
509 return 510 return
510 511
511 settings = Preferences.Prefs.settings 512 settings = Preferences.Prefs.settings

eric ide

mercurial