Plugins/WizardPlugins/FontDialogWizard/FontDialogWizardDialog.py

branch
Py2 comp.
changeset 3142
55030c09e142
parent 3056
9986ec0e559a
parent 3125
385a62b53725
child 3145
a9de05d4a22f
diff -r 72f3bde98c58 -r 55030c09e142 Plugins/WizardPlugins/FontDialogWizard/FontDialogWizardDialog.py
--- a/Plugins/WizardPlugins/FontDialogWizard/FontDialogWizardDialog.py	Fri Dec 13 22:45:47 2013 +0100
+++ b/Plugins/WizardPlugins/FontDialogWizard/FontDialogWizardDialog.py	Fri Dec 13 23:39:14 2013 +0100
@@ -91,17 +91,44 @@
         @param indString string used for indentation (space or tab) (string)
         @return generated code (string)
         """
+        # calculate our indentation level and the indentation string
+        il = indLevel + 1
+        istring = il * indString
         estring = os.linesep + indLevel * indString
         
         # generate the code
-        code = 'QFontDialog.getFont('
-        if not self.eVariable.text():
-            if self.font is not None:
-                code += 'QFont("{0}", {1:d}, {2:d}, {3:d})'.format(
-                    self.font.family(), self.font.pointSize(),
-                    self.font.weight(), self.font.italic())
-        else:
-            code += self.eVariable.text()
+        resvar = self.eResultVar.text()
+        if not resvar:
+            resvar = "font"
+        title = self.eCaption.text()
+        if self.parentSelf.isChecked():
+            parent = "self"
+        elif self.parentNone.isChecked():
+            parent = "None"
+        elif self.parentOther.isChecked():
+            parent = self.parentEdit.text()
+            if parent == "":
+                parent = "None"
+        
+        code = '{0}, ok = QFontDialog.getFont('.format(resvar)
+        if self.eVariable.text() or self.font is not None:
+            if title or parent != "None":
+                code += '{0}{1}'.format(os.linesep, istring)
+            if not self.eVariable.text():
+                if self.font is not None:
+                    code += 'QFont("{0}", {1:d}, {2:d}, {3:d})'.format(
+                        self.font.family(), self.font.pointSize(),
+                        self.font.weight(), self.font.italic())
+            else:
+                code += self.eVariable.text()
+            if title:
+                code += ',{0}{1}{2}'.format(
+                    os.linesep, istring, parent)
+                code += ',{0}{1}self.trUtf8("{2}")'.format(
+                    os.linesep, istring, title)
+            elif parent != "None":
+                code += ',{0}{1}{2}'.format(
+                    os.linesep, istring, parent)
         code += '){0}'.format(estring)
-            
+        
         return code

eric ide

mercurial