Graphics/UMLDialog.py

branch
Py2 comp.
changeset 3484
645c12de6b0c
parent 3178
f25fc1364c88
parent 3345
071afe8be2a1
child 3656
441956d8fce5
diff -r 96232974dcdb -r 645c12de6b0c Graphics/UMLDialog.py
--- a/Graphics/UMLDialog.py	Sun Mar 30 22:00:14 2014 +0200
+++ b/Graphics/UMLDialog.py	Thu Apr 03 23:05:31 2014 +0200
@@ -9,7 +9,7 @@
 
 from __future__ import unicode_literals
 
-from PyQt4.QtCore import Qt, QFileInfo
+from PyQt4.QtCore import pyqtSlot, Qt, QFileInfo
 from PyQt4.QtGui import QAction, QToolBar, QGraphicsScene
 
 from E5Gui import E5MessageBox, E5FileDialog
@@ -76,49 +76,49 @@
         """
         self.closeAct = \
             QAction(UI.PixmapCache.getIcon("close.png"),
-                    self.trUtf8("Close"), self)
-        self.closeAct.triggered[()].connect(self.close)
+                    self.tr("Close"), self)
+        self.closeAct.triggered.connect(self.close)
         
         self.openAct = \
             QAction(UI.PixmapCache.getIcon("open.png"),
-                    self.trUtf8("Load"), self)
-        self.openAct.triggered[()].connect(self.load)
+                    self.tr("Load"), self)
+        self.openAct.triggered.connect(self.load)
         
         self.saveAct = \
             QAction(UI.PixmapCache.getIcon("fileSave.png"),
-                    self.trUtf8("Save"), self)
-        self.saveAct.triggered[()].connect(self.__save)
+                    self.tr("Save"), self)
+        self.saveAct.triggered.connect(self.__save)
         
         self.saveAsAct = \
             QAction(UI.PixmapCache.getIcon("fileSaveAs.png"),
-                    self.trUtf8("Save As..."), self)
-        self.saveAsAct.triggered[()].connect(self.__saveAs)
+                    self.tr("Save As..."), self)
+        self.saveAsAct.triggered.connect(self.__saveAs)
         
         self.saveImageAct = \
             QAction(UI.PixmapCache.getIcon("fileSavePixmap.png"),
-                    self.trUtf8("Save as Image"), self)
-        self.saveImageAct.triggered[()].connect(self.umlView.saveImage)
+                    self.tr("Save as Image"), self)
+        self.saveImageAct.triggered.connect(self.umlView.saveImage)
         
         self.printAct = \
             QAction(UI.PixmapCache.getIcon("print.png"),
-                    self.trUtf8("Print"), self)
-        self.printAct.triggered[()].connect(self.umlView.printDiagram)
+                    self.tr("Print"), self)
+        self.printAct.triggered.connect(self.umlView.printDiagram)
         
         self.printPreviewAct = \
             QAction(UI.PixmapCache.getIcon("printPreview.png"),
-                    self.trUtf8("Print Preview"), self)
-        self.printPreviewAct.triggered[()].connect(
+                    self.tr("Print Preview"), self)
+        self.printPreviewAct.triggered.connect(
             self.umlView.printPreviewDiagram)
     
     def __initToolBars(self):
         """
         Private slot to initialize the toolbars.
         """
-        self.windowToolBar = QToolBar(self.trUtf8("Window"), self)
+        self.windowToolBar = QToolBar(self.tr("Window"), self)
         self.windowToolBar.setIconSize(UI.Config.ToolBarIconSize)
         self.windowToolBar.addAction(self.closeAct)
         
-        self.fileToolBar = QToolBar(self.trUtf8("File"), self)
+        self.fileToolBar = QToolBar(self.tr("File"), self)
         self.fileToolBar.setIconSize(UI.Config.ToolBarIconSize)
         self.fileToolBar.addAction(self.openAct)
         self.fileToolBar.addSeparator()
@@ -184,7 +184,7 @@
         elif diagramType == UMLDialog.NoDiagram:
             return None
         else:
-            raise ValueError(self.trUtf8(
+            raise ValueError(self.tr(
                 "Illegal diagram type '{0}' given.").format(diagramType))
     
     def __diagramTypeString(self):
@@ -210,6 +210,7 @@
         """
         self.__saveAs(self.__fileName)
     
+    @pyqtSlot()
     def __saveAs(self, filename=""):
         """
         Private slot to save the diagram.
@@ -219,9 +220,9 @@
         if not filename:
             fname, selectedFilter = E5FileDialog.getSaveFileNameAndFilter(
                 self,
-                self.trUtf8("Save Diagram"),
+                self.tr("Save Diagram"),
                 "",
-                self.trUtf8("Eric5 Graphics File (*.e5g);;All Files (*)"),
+                self.tr("Eric5 Graphics File (*.e5g);;All Files (*)"),
                 "",
                 E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite))
             if not fname:
@@ -234,9 +235,9 @@
             if QFileInfo(fname).exists():
                 res = E5MessageBox.yesNo(
                     self,
-                    self.trUtf8("Save Diagram"),
-                    self.trUtf8("<p>The file <b>{0}</b> already exists."
-                                " Overwrite it?</p>").format(fname),
+                    self.tr("Save Diagram"),
+                    self.tr("<p>The file <b>{0}</b> already exists."
+                            " Overwrite it?</p>").format(fname),
                     icon=E5MessageBox.Warning)
                 if not res:
                     return
@@ -261,8 +262,8 @@
         except (IOError, OSError) as err:
             E5MessageBox.critical(
                 self,
-                self.trUtf8("Save Diagram"),
-                self.trUtf8(
+                self.tr("Save Diagram"),
+                self.tr(
                     """<p>The file <b>{0}</b> could not be saved.</p>"""
                     """<p>Reason: {1}</p>""").format(filename, str(err)))
             return
@@ -277,9 +278,9 @@
         """
         filename = E5FileDialog.getOpenFileName(
             self,
-            self.trUtf8("Load Diagram"),
+            self.tr("Load Diagram"),
             "",
-            self.trUtf8("Eric5 Graphics File (*.e5g);;All Files (*)"))
+            self.tr("Eric5 Graphics File (*.e5g);;All Files (*)"))
         if not filename:
             # Cancelled by user
             return False
@@ -291,8 +292,8 @@
         except (IOError, OSError) as err:
             E5MessageBox.critical(
                 self,
-                self.trUtf8("Load Diagram"),
-                self.trUtf8(
+                self.tr("Load Diagram"),
+                self.tr(
                     """<p>The file <b>{0}</b> could not be read.</p>"""
                     """<p>Reason: {1}</p>""").format(filename, str(err)))
             return False
@@ -373,10 +374,10 @@
         @param linenum number of the invalid line (integer)
         """
         if linenum < 0:
-            msg = self.trUtf8("""<p>The file <b>{0}</b> does not contain"""
-                              """ valid data.</p>""").format(filename)
+            msg = self.tr("""<p>The file <b>{0}</b> does not contain"""
+                          """ valid data.</p>""").format(filename)
         else:
-            msg = self.trUtf8("""<p>The file <b>{0}</b> does not contain"""
-                              """ valid data.</p><p>Invalid line: {1}</p>"""
-                              ).format(filename, linenum + 1)
-        E5MessageBox.critical(self, self.trUtf8("Load Diagram"), msg)
+            msg = self.tr("""<p>The file <b>{0}</b> does not contain"""
+                          """ valid data.</p><p>Invalid line: {1}</p>"""
+                          ).format(filename, linenum + 1)
+        E5MessageBox.critical(self, self.tr("Load Diagram"), msg)

eric ide

mercurial