Utilities/__init__.py

changeset 1368
4489ee4feb59
parent 1348
38d4a35aa308
child 1465
3b459b88fcd4
--- a/Utilities/__init__.py	Sun Oct 16 13:35:19 2011 +0200
+++ b/Utilities/__init__.py	Mon Oct 17 19:36:51 2011 +0200
@@ -1418,6 +1418,26 @@
                              )
 
 
+def getQtMacBundle(toolname):
+    """
+    Module function to determine the correct Mac OS X bundle name for Qt tools.
+    
+    @param toolname  plain name of the tool (e.g. "designer") (string)
+    @return bundle name of the Qt tool (string)
+    """
+    qtDir = Preferences.getQt("Qt4Dir")
+    bundles = [
+        os.path.join(qtDir, 'bin', generateQtToolName(toolname.capitalize())) + ".app",
+        os.path.join(qtDir, 'bin', generateQtToolName(toolname)) + ".app",
+        os.path.join(qtDir, generateQtToolName(toolname.capitalize())) + ".app",
+        os.path.join(qtDir, generateQtToolName(toolname)) + ".app",
+    ]
+    for bundle in bundles:
+        if os.path.exists(bundle):
+            return bundle
+    return ""
+
+
 def prepareQtMacBundle(toolname, version, args):
     """
     Module function for starting Qt tools that are Mac OS X bundles.
@@ -1427,18 +1447,19 @@
     @param args    name of input file for tool, if any (list of strings)
     @return command-name and args for QProcess (tuple)
     """
-    if version == 4:
-        qtDir = Preferences.getQt("Qt4Dir")
-    else:
+    if version != 4:
         return ("", [])
     
-    fullBundle = os.path.join(qtDir, 'bin',
-        generateQtToolName(toolname)) + ".app"
+    fullBundle = getQtMacBundle(toolname)
+    if fullBundle == "":
+        return ("", [])
 
     newArgs = []
     newArgs.append("-a")
     newArgs.append(fullBundle)
-    newArgs += args
+    if args:
+        newArgs.append("--args")
+        newArgs += args
 
     return ("open", newArgs)
 

eric ide

mercurial