Graphics/PixmapDiagram.py

changeset 3190
a9a94491c4fd
parent 3160
209a07d7e401
child 3345
071afe8be2a1
equal deleted inserted replaced
3189:9a21c547de5f 3190:a9a94491c4fd
45 super().__init__(parent) 45 super().__init__(parent)
46 if name: 46 if name:
47 self.setObjectName(name) 47 self.setObjectName(name)
48 else: 48 else:
49 self.setObjectName("PixmapDiagram") 49 self.setObjectName("PixmapDiagram")
50 self.setWindowTitle(self.trUtf8("Pixmap-Viewer")) 50 self.setWindowTitle(self.tr("Pixmap-Viewer"))
51 51
52 self.pixmapLabel = QLabel() 52 self.pixmapLabel = QLabel()
53 self.pixmapLabel.setObjectName("pixmapLabel") 53 self.pixmapLabel.setObjectName("pixmapLabel")
54 self.pixmapLabel.setBackgroundRole(QPalette.Base) 54 self.pixmapLabel.setBackgroundRole(QPalette.Base)
55 self.pixmapLabel.setSizePolicy( 55 self.pixmapLabel.setSizePolicy(
88 """ 88 """
89 Private method to initialize the view actions. 89 Private method to initialize the view actions.
90 """ 90 """
91 self.closeAct = \ 91 self.closeAct = \
92 QAction(UI.PixmapCache.getIcon("close.png"), 92 QAction(UI.PixmapCache.getIcon("close.png"),
93 self.trUtf8("Close"), self) 93 self.tr("Close"), self)
94 self.closeAct.triggered[()].connect(self.close) 94 self.closeAct.triggered[()].connect(self.close)
95 95
96 self.printAct = \ 96 self.printAct = \
97 QAction(UI.PixmapCache.getIcon("print.png"), 97 QAction(UI.PixmapCache.getIcon("print.png"),
98 self.trUtf8("Print"), self) 98 self.tr("Print"), self)
99 self.printAct.triggered[()].connect(self.__printDiagram) 99 self.printAct.triggered[()].connect(self.__printDiagram)
100 100
101 self.printPreviewAct = \ 101 self.printPreviewAct = \
102 QAction(UI.PixmapCache.getIcon("printPreview.png"), 102 QAction(UI.PixmapCache.getIcon("printPreview.png"),
103 self.trUtf8("Print Preview"), self) 103 self.tr("Print Preview"), self)
104 self.printPreviewAct.triggered[()].connect(self.__printPreviewDiagram) 104 self.printPreviewAct.triggered[()].connect(self.__printPreviewDiagram)
105 105
106 def __initContextMenu(self): 106 def __initContextMenu(self):
107 """ 107 """
108 Private method to initialize the context menu. 108 Private method to initialize the context menu.
126 126
127 def __initToolBars(self): 127 def __initToolBars(self):
128 """ 128 """
129 Private method to populate the toolbars with our actions. 129 Private method to populate the toolbars with our actions.
130 """ 130 """
131 self.windowToolBar = QToolBar(self.trUtf8("Window"), self) 131 self.windowToolBar = QToolBar(self.tr("Window"), self)
132 self.windowToolBar.setIconSize(UI.Config.ToolBarIconSize) 132 self.windowToolBar.setIconSize(UI.Config.ToolBarIconSize)
133 self.windowToolBar.addAction(self.closeAct) 133 self.windowToolBar.addAction(self.closeAct)
134 134
135 self.graphicsToolBar = QToolBar(self.trUtf8("Graphics"), self) 135 self.graphicsToolBar = QToolBar(self.tr("Graphics"), self)
136 self.graphicsToolBar.setIconSize(UI.Config.ToolBarIconSize) 136 self.graphicsToolBar.setIconSize(UI.Config.ToolBarIconSize)
137 self.graphicsToolBar.addAction(self.printPreviewAct) 137 self.graphicsToolBar.addAction(self.printPreviewAct)
138 self.graphicsToolBar.addAction(self.printAct) 138 self.graphicsToolBar.addAction(self.printAct)
139 139
140 self.addToolBar(Qt.TopToolBarArea, self.windowToolBar) 140 self.addToolBar(Qt.TopToolBarArea, self.windowToolBar)
149 """ 149 """
150 image = QImage(filename) 150 image = QImage(filename)
151 if image.isNull(): 151 if image.isNull():
152 E5MessageBox.warning( 152 E5MessageBox.warning(
153 self, 153 self,
154 self.trUtf8("Pixmap-Viewer"), 154 self.tr("Pixmap-Viewer"),
155 self.trUtf8( 155 self.tr(
156 """<p>The file <b>{0}</b> cannot be displayed.""" 156 """<p>The file <b>{0}</b> cannot be displayed."""
157 """ The format is not supported.</p>""").format(filename)) 157 """ The format is not supported.</p>""").format(filename))
158 return False 158 return False
159 159
160 self.pixmapLabel.setPixmap(QPixmap.fromImage(image)) 160 self.pixmapLabel.setPixmap(QPixmap.fromImage(image))
375 height = printer.height() - fontHeight - 4 - marginY - \ 375 height = printer.height() - fontHeight - 4 - marginY - \
376 Preferences.getPrinter("BottomMargin") * \ 376 Preferences.getPrinter("BottomMargin") * \
377 int(printer.resolution() / 2.54) 377 int(printer.resolution() / 2.54)
378 378
379 # write a foot note 379 # write a foot note
380 s = self.trUtf8("Diagram: {0}").format(self.getDiagramName()) 380 s = self.tr("Diagram: {0}").format(self.getDiagramName())
381 tc = QColor(50, 50, 50) 381 tc = QColor(50, 50, 50)
382 painter.setPen(tc) 382 painter.setPen(tc)
383 painter.drawRect(marginX, marginY, width, height) 383 painter.drawRect(marginX, marginY, width, height)
384 painter.drawLine(marginX, marginY + height + 2, 384 painter.drawLine(marginX, marginY + height + 2,
385 marginX + width, marginY + height + 2) 385 marginX + width, marginY + height + 2)

eric ide

mercurial