8 """ |
8 """ |
9 |
9 |
10 |
10 |
11 from PyQt5.QtCore import Qt, QSize, QEvent |
11 from PyQt5.QtCore import Qt, QSize, QEvent |
12 from PyQt5.QtGui import QPalette, QImage, QPixmap, QPainter, QFont, QColor |
12 from PyQt5.QtGui import QPalette, QImage, QPixmap, QPainter, QFont, QColor |
13 from PyQt5.QtWidgets import QLabel, QSizePolicy, QScrollArea, QAction, QMenu, \ |
13 from PyQt5.QtWidgets import ( |
14 QToolBar |
14 QLabel, QSizePolicy, QScrollArea, QAction, QMenu, QToolBar |
|
15 ) |
15 from PyQt5.QtPrintSupport import QPrinter, QPrintDialog |
16 from PyQt5.QtPrintSupport import QPrinter, QPrintDialog |
16 |
17 |
17 from E5Gui import E5MessageBox |
18 from E5Gui import E5MessageBox |
18 from E5Gui.E5MainWindow import E5MainWindow |
19 from E5Gui.E5MainWindow import E5MainWindow |
19 from E5Gui.E5ZoomWidget import E5ZoomWidget |
20 from E5Gui.E5ZoomWidget import E5ZoomWidget |
88 |
89 |
89 def __initActions(self): |
90 def __initActions(self): |
90 """ |
91 """ |
91 Private method to initialize the view actions. |
92 Private method to initialize the view actions. |
92 """ |
93 """ |
93 self.closeAct = \ |
94 self.closeAct = QAction( |
94 QAction(UI.PixmapCache.getIcon("close.png"), |
95 UI.PixmapCache.getIcon("close.png"), |
95 self.tr("Close"), self) |
96 self.tr("Close"), self) |
96 self.closeAct.triggered.connect(self.close) |
97 self.closeAct.triggered.connect(self.close) |
97 |
98 |
98 self.printAct = \ |
99 self.printAct = QAction( |
99 QAction(UI.PixmapCache.getIcon("print.png"), |
100 UI.PixmapCache.getIcon("print.png"), |
100 self.tr("Print"), self) |
101 self.tr("Print"), self) |
101 self.printAct.triggered.connect(self.__printDiagram) |
102 self.printAct.triggered.connect(self.__printDiagram) |
102 |
103 |
103 self.printPreviewAct = \ |
104 self.printPreviewAct = QAction( |
104 QAction(UI.PixmapCache.getIcon("printPreview.png"), |
105 UI.PixmapCache.getIcon("printPreview.png"), |
105 self.tr("Print Preview"), self) |
106 self.tr("Print Preview"), self) |
106 self.printPreviewAct.triggered.connect(self.__printPreviewDiagram) |
107 self.printPreviewAct.triggered.connect(self.__printPreviewDiagram) |
107 |
108 |
108 def __initContextMenu(self): |
109 def __initContextMenu(self): |
109 """ |
110 """ |
110 Private method to initialize the context menu. |
111 Private method to initialize the context menu. |
364 font = QFont("times", 10) |
365 font = QFont("times", 10) |
365 painter.setFont(font) |
366 painter.setFont(font) |
366 fm = painter.fontMetrics() |
367 fm = painter.fontMetrics() |
367 fontHeight = fm.lineSpacing() |
368 fontHeight = fm.lineSpacing() |
368 marginX = printer.pageRect().x() - printer.paperRect().x() |
369 marginX = printer.pageRect().x() - printer.paperRect().x() |
369 marginX = Preferences.getPrinter("LeftMargin") * \ |
370 marginX = ( |
|
371 Preferences.getPrinter("LeftMargin") * |
370 int(printer.resolution() / 2.54) - marginX |
372 int(printer.resolution() / 2.54) - marginX |
|
373 ) |
371 marginY = printer.pageRect().y() - printer.paperRect().y() |
374 marginY = printer.pageRect().y() - printer.paperRect().y() |
372 marginY = Preferences.getPrinter("TopMargin") * \ |
375 marginY = ( |
|
376 Preferences.getPrinter("TopMargin") * |
373 int(printer.resolution() / 2.54) - marginY |
377 int(printer.resolution() / 2.54) - marginY |
374 |
378 ) |
375 width = printer.width() - marginX - \ |
379 |
376 Preferences.getPrinter("RightMargin") * \ |
380 width = ( |
|
381 printer.width() - marginX - |
|
382 Preferences.getPrinter("RightMargin") * |
377 int(printer.resolution() / 2.54) |
383 int(printer.resolution() / 2.54) |
378 height = printer.height() - fontHeight - 4 - marginY - \ |
384 ) |
379 Preferences.getPrinter("BottomMargin") * \ |
385 height = ( |
|
386 printer.height() - fontHeight - 4 - marginY - |
|
387 Preferences.getPrinter("BottomMargin") * |
380 int(printer.resolution() / 2.54) |
388 int(printer.resolution() / 2.54) |
|
389 ) |
381 |
390 |
382 # write a foot note |
391 # write a foot note |
383 s = self.tr("Diagram: {0}").format(self.getDiagramName()) |
392 s = self.tr("Diagram: {0}").format(self.getDiagramName()) |
384 tc = QColor(50, 50, 50) |
393 tc = QColor(50, 50, 50) |
385 painter.setPen(tc) |
394 painter.setPen(tc) |