Added functionality to modify pyuic options. 5_5_x

Fri, 03 Oct 2014 16:39:04 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Fri, 03 Oct 2014 16:39:04 +0200
branch
5_5_x
changeset 3847
4a946734fd27
parent 3844
6ba315c68a8b
child 3848
df49a5ab1c9c

Added functionality to modify pyuic options.
(grafted from 949682ceda5413bc9d6b00c3b1b3a9a2971e9b33)

Preferences/ConfigurationPages/QtPage.py file | annotate | diff | comparison | revisions
Preferences/ConfigurationPages/QtPage.ui file | annotate | diff | comparison | revisions
Preferences/__init__.py file | annotate | diff | comparison | revisions
Project/ProjectFormsBrowser.py file | annotate | diff | comparison | revisions
--- a/Preferences/ConfigurationPages/QtPage.py	Fri Oct 03 14:47:32 2014 +0200
+++ b/Preferences/ConfigurationPages/QtPage.py	Fri Oct 03 16:39:04 2014 +0200
@@ -43,6 +43,9 @@
         self.qt4PrefixEdit.setText(Preferences.getQt("QtToolsPrefix4"))
         self.qt4PostfixEdit.setText(Preferences.getQt("QtToolsPostfix4"))
         self.__updateQt4Sample()
+        self.pyuicIndentSpinBox.setValue(Preferences.getQt("PyuicIndent"))
+        self.pyuicImportsCheckBox.setChecked(
+            Preferences.getQt("PyuicFromImports"))
         
     def save(self):
         """
@@ -51,6 +54,9 @@
         Preferences.setQt("Qt4TranslationsDir", self.qt4TransEdit.text())
         Preferences.setQt("QtToolsPrefix4", self.qt4PrefixEdit.text())
         Preferences.setQt("QtToolsPostfix4", self.qt4PostfixEdit.text())
+        Preferences.setQt("PyuicIndent", self.pyuicIndentSpinBox.value())
+        Preferences.setQt("PyuicFromImports",
+                          self.pyuicImportsCheckBox.isChecked())
         
     @pyqtSlot()
     def on_qt4TransButton_clicked(self):
--- a/Preferences/ConfigurationPages/QtPage.ui	Fri Oct 03 14:47:32 2014 +0200
+++ b/Preferences/ConfigurationPages/QtPage.ui	Fri Oct 03 16:39:04 2014 +0200
@@ -135,6 +135,61 @@
     </widget>
    </item>
    <item>
+    <widget class="QGroupBox" name="groupBox">
+     <property name="title">
+      <string>pyuic / pyside-uic Options</string>
+     </property>
+     <layout class="QGridLayout" name="gridLayout">
+      <item row="0" column="0">
+       <widget class="QLabel" name="label_2">
+        <property name="text">
+         <string>Indent Width:</string>
+        </property>
+       </widget>
+      </item>
+      <item row="0" column="1">
+       <widget class="QSpinBox" name="pyuicIndentSpinBox">
+        <property name="toolTip">
+         <string>Select the indent width (default: 4)</string>
+        </property>
+        <property name="alignment">
+         <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+        </property>
+        <property name="minimum">
+         <number>2</number>
+        </property>
+        <property name="maximum">
+         <number>16</number>
+        </property>
+        <property name="value">
+         <number>4</number>
+        </property>
+       </widget>
+      </item>
+      <item row="0" column="2">
+       <spacer name="horizontalSpacer">
+        <property name="orientation">
+         <enum>Qt::Horizontal</enum>
+        </property>
+        <property name="sizeHint" stdset="0">
+         <size>
+          <width>448</width>
+          <height>20</height>
+         </size>
+        </property>
+       </spacer>
+      </item>
+      <item row="1" column="0" colspan="3">
+       <widget class="QCheckBox" name="pyuicImportsCheckBox">
+        <property name="text">
+         <string>Generate imports relative to '.'</string>
+        </property>
+       </widget>
+      </item>
+     </layout>
+    </widget>
+   </item>
+   <item>
     <spacer>
      <property name="orientation">
       <enum>Qt::Vertical</enum>
@@ -154,6 +209,8 @@
   <tabstop>qt4TransButton</tabstop>
   <tabstop>qt4PrefixEdit</tabstop>
   <tabstop>qt4PostfixEdit</tabstop>
+  <tabstop>pyuicIndentSpinBox</tabstop>
+  <tabstop>pyuicImportsCheckBox</tabstop>
  </tabstops>
  <resources/>
  <connections/>
--- a/Preferences/__init__.py	Fri Oct 03 14:47:32 2014 +0200
+++ b/Preferences/__init__.py	Fri Oct 03 16:39:04 2014 +0200
@@ -864,6 +864,8 @@
         "Qt4TranslationsDir": "",
         "QtToolsPrefix4": "",
         "QtToolsPostfix4": "",
+        "PyuicIndent": 4,
+        "PyuicFromImports": False,
     }
     
     # defaults for corba related stuff
@@ -2392,6 +2394,12 @@
     """
     if key == "Qt4TranslationsDir":
         return getQt4TranslationsDir(prefClass)
+    elif key in ["PyuicIndent"]:
+        return int(prefClass.settings.value(
+            "Qt/" + key, prefClass.qtDefaults[key]))
+    elif key in ["PyuicFromImports"]:
+        return toBool(prefClass.settings.value(
+            "Qt/" + key, prefClass.qtDefaults[key]))
     else:
         return prefClass.settings.value("Qt/" + key, prefClass.qtDefaults[key])
     
--- a/Project/ProjectFormsBrowser.py	Fri Oct 03 14:47:32 2014 +0200
+++ b/Project/ProjectFormsBrowser.py	Fri Oct 03 16:39:04 2014 +0200
@@ -59,6 +59,8 @@
     showMenu = pyqtSignal(str, QMenu)
     menusAboutToBeCreated = pyqtSignal()
     
+    PyuicIndentDefault = 4
+    
     def __init__(self, project, parent=None):
         """
         Constructor
@@ -784,6 +786,11 @@
             dirname, filename = os.path.split(ofn)
             self.compiledFile = os.path.join(dirname, "Ui_" + filename + ".py")
             args.append("-x")
+            indentWidth = Preferences.getQt("PyuicIndent")
+            if indentWidth != self.PyuicIndentDefault:
+                args.append("--indent={0}".format(indentWidth))
+            if Preferences.getQt("PyuicFromImports"):
+                args.append("--from-imports")
         elif self.project.pdata["PROGLANGUAGE"][0] == "Ruby":
             self.compiledFile = ofn + '.rb'
             args.append('-x')

eric ide

mercurial