Fixed a few Mac OS X related issues.

Mon, 17 Oct 2011 19:36:51 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Mon, 17 Oct 2011 19:36:51 +0200
changeset 1368
4489ee4feb59
parent 1367
a652a6794953
child 1369
759ef1e3569e

Fixed a few Mac OS X related issues.

E5Gui/E5SideBar.py file | annotate | diff | comparison | revisions
Preferences/ProgramsDialog.py file | annotate | diff | comparison | revisions
Preferences/__init__.py file | annotate | diff | comparison | revisions
UI/UserInterface.py file | annotate | diff | comparison | revisions
Utilities/__init__.py file | annotate | diff | comparison | revisions
--- a/E5Gui/E5SideBar.py	Sun Oct 16 13:35:19 2011 +0200
+++ b/E5Gui/E5SideBar.py	Mon Oct 17 19:36:51 2011 +0200
@@ -88,6 +88,9 @@
         """
         self.splitter = splitter
         self.splitter.splitterMoved.connect(self.__splitterMoved)
+        self.splitter.setChildrenCollapsible(False)
+        index = self.splitter.indexOf(self)
+        self.splitter.setCollapsible(index, False)
     
     def __splitterMoved(self, pos, index):
         """
--- a/Preferences/ProgramsDialog.py	Sun Oct 16 13:35:19 2011 +0200
+++ b/Preferences/ProgramsDialog.py	Mon Oct 17 19:36:51 2011 +0200
@@ -82,19 +82,28 @@
         version = self.__createProgramEntry(self.trUtf8("Translation Converter (Qt4)"),
                     exe, '-version', 'lrelease', -1)
         # 1b. Qt4 Designer
-        exe = Utilities.isWindowsPlatform() and \
-            "{0}.exe".format(Utilities.generateQtToolName("designer")) or \
-            Utilities.generateQtToolName("designer")
+        if Utilities.isWindowsPlatform():
+            exe = "{0}.exe".format(Utilities.generateQtToolName("designer"))
+        elif Utilities.isMacPlatform():
+            exe = Utilities.getQtMacBundle("designer")
+        else:
+            exe = Utilities.generateQtToolName("designer")
         self.__createProgramEntry(self.trUtf8("Qt4 Designer"), exe, version=version)
         # 1c. Qt4 Linguist
-        exe = Utilities.isWindowsPlatform() and \
-            "{0}.exe".format(Utilities.generateQtToolName("linguist")) or \
-            Utilities.generateQtToolName("linguist")
+        if Utilities.isWindowsPlatform():
+            exe = "{0}.exe".format(Utilities.generateQtToolName("linguist"))
+        elif Utilities.isMacPlatform():
+            exe = Utilities.getQtMacBundle("linguist")
+        else:
+            exe = Utilities.generateQtToolName("linguist")
         self.__createProgramEntry(self.trUtf8("Qt4 Linguist"), exe, version=version)
         # 1d. Qt4 Assistant
-        exe = Utilities.isWindowsPlatform() and \
-            "{0}.exe".format(Utilities.generateQtToolName("assistant")) or \
-            Utilities.generateQtToolName("assistant")
+        if Utilities.isWindowsPlatform():
+            exe = "{0}.exe".format(Utilities.generateQtToolName("assistant"))
+        elif Utilities.isMacPlatform():
+            exe = Utilities.getQtMacBundle("assistant")
+        else:
+            exe = Utilities.generateQtToolName("assistant")
         self.__createProgramEntry(self.trUtf8("Qt4 Assistant"), exe, version=version)
         
         # 2. do the PyQt programs
--- a/Preferences/__init__.py	Sun Oct 16 13:35:19 2011 +0200
+++ b/Preferences/__init__.py	Mon Oct 17 19:36:51 2011 +0200
@@ -21,7 +21,7 @@
 import shutil
 
 from PyQt4.QtCore import QDir, QPoint, QLocale, QSettings, QFileInfo, QCoreApplication, \
-    QByteArray, QSize, QUrl, Qt
+    QByteArray, QSize, QUrl, Qt, QLibraryInfo
 from PyQt4.QtGui import QColor, QFont, QInputDialog
 from PyQt4.QtNetwork import QNetworkRequest
 from PyQt4.QtWebKit import QWebSettings
@@ -1934,10 +1934,11 @@
     s = prefClass.settings.value("Help/Qt4DocDir",
         prefClass.helpDefaults["Qt4DocDir"])
     if s == "":
-        return os.getenv("QT4DOCDIR", "")
-    else:
-        return s
-    
+        s = os.getenv("QT4DOCDIR", "")
+    if s == "":
+        s = QLibraryInfo.location(QLibraryInfo.DocumentationPath)
+    return s
+
 
 def getHelp(key, prefClass=Prefs):
     """
@@ -2090,6 +2091,8 @@
         prefClass.qtDefaults["Qt4TranslationsDir"])
     if s == "":
         s = os.getenv("QT4TRANSLATIONSDIR", "")
+    if s == "":
+        s = QLibraryInfo.location(QLibraryInfo.TranslationsPath)
     if s == "" and isWindowsPlatform():
         from PyQt4 import pyqtconfig
         transPath = os.path.join(pyqtconfig._pkg_config["pyqt_mod_dir"], "translations")
@@ -2108,6 +2111,11 @@
     """
     if key == "Qt4TranslationsDir":
         return getQt4TranslationsDir(prefClass)
+    elif key == "Qt4Dir":
+        p = prefClass.settings.value("Qt/" + key, prefClass.qtDefaults[key])
+        if p == "":
+            p = QLibraryInfo.location(QLibraryInfo.BinariesPath)
+        return p
     else:
         return prefClass.settings.value("Qt/" + key, prefClass.qtDefaults[key])
     
--- a/UI/UserInterface.py	Sun Oct 16 13:35:19 2011 +0200
+++ b/UI/UserInterface.py	Mon Oct 17 19:36:51 2011 +0200
@@ -1799,9 +1799,12 @@
         self.actions.append(self.utProjectAct)
         
         # check for Qt4 designer and linguist
-        designerExe = Utilities.isWindowsPlatform() and \
-            "{0}.exe".format(Utilities.generateQtToolName("designer")) or \
-            Utilities.generateQtToolName("designer")
+        if Utilities.isWindowsPlatform():
+            designerExe = "{0}.exe".format(Utilities.generateQtToolName("designer"))
+        elif Utilities.isMacPlatform():
+            designerExe = Utilities.getQtMacBundle("designer")
+        else:
+            designerExe = Utilities.generateQtToolName("designer")
         if Utilities.isinpath(designerExe):
             self.designer4Act = E5Action(self.trUtf8('Qt-Designer 4'),
                     UI.PixmapCache.getIcon("designer4.png"),
@@ -1816,9 +1819,12 @@
         else:
             self.designer4Act = None
         
-        linguistExe = Utilities.isWindowsPlatform() and \
-            "{0}.exe".format(Utilities.generateQtToolName("linguist")) or \
-            Utilities.generateQtToolName("linguist")
+        if Utilities.isWindowsPlatform():
+            linguistExe = "{0}.exe".format(Utilities.generateQtToolName("linguist"))
+        elif Utilities.isMacPlatform():
+            linguistExe = Utilities.getQtMacBundle("linguist")
+        else:
+            linguistExe = Utilities.generateQtToolName("linguist")
         if Utilities.isinpath(linguistExe):
             self.linguist4Act = E5Action(self.trUtf8('Qt-Linguist 4'),
                     UI.PixmapCache.getIcon("linguist4.png"),
@@ -4651,6 +4657,8 @@
         qt4DocDir = Preferences.getHelp("Qt4DocDir")
         if not qt4DocDir:
             qt4DocDir = Utilities.getEnvironmentEntry("QT4DOCDIR", "")
+            if not qt4DocDir:
+                qt4DocDir = os.path.join(Preferences.getQt4DocDir(), "html")
         
         if qt4DocDir.startswith("qthelp://"):
             if not os.path.splitext(qt4DocDir)[1]:
@@ -4913,7 +4921,7 @@
         
         @param pageName name of the configuration page to show (string)
         """
-        dlg = ConfigurationDialog(self, 'Configuration', True)
+        dlg = ConfigurationDialog(self, 'Configuration') ##, True)
         dlg.preferencesChanged.connect(self.__preferencesChanged)
         dlg.masterPasswordChanged.connect(self.__masterPasswordChanged)
         dlg.show()
--- 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