Added a method to determine the Qt binaries path to the Globals package.

Wed, 24 Apr 2013 18:16:34 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 24 Apr 2013 18:16:34 +0200
changeset 2615
bdc9b4659826
parent 2614
9c49b4419ea7
child 2616
954b4069325b

Added a method to determine the Qt binaries path to the Globals package.

APIs/Python3/eric5.api file | annotate | diff | comparison | revisions
Documentation/Help/source.qch file | annotate | diff | comparison | revisions
Documentation/Help/source.qhp file | annotate | diff | comparison | revisions
Documentation/Source/eric5.Globals.__init__.html file | annotate | diff | comparison | revisions
DocumentationTools/QtHelpGenerator.py file | annotate | diff | comparison | revisions
Globals/__init__.py file | annotate | diff | comparison | revisions
Plugins/PluginEricdoc.py file | annotate | diff | comparison | revisions
Preferences/ProgramsDialog.py file | annotate | diff | comparison | revisions
Preferences/__init__.py file | annotate | diff | comparison | revisions
Project/ProjectTranslationsBrowser.py file | annotate | diff | comparison | revisions
UI/UserInterface.py file | annotate | diff | comparison | revisions
Utilities/__init__.py file | annotate | diff | comparison | revisions
--- a/APIs/Python3/eric5.api	Tue Apr 23 19:57:07 2013 +0200
+++ b/APIs/Python3/eric5.api	Wed Apr 24 18:16:34 2013 +0200
@@ -1751,6 +1751,7 @@
 eric5.Globals.getConfigDir?4()
 eric5.Globals.getPyQt4ModulesDirectory?4()
 eric5.Globals.getPythonModulesDirectory?4()
+eric5.Globals.getQtBinariesPath?4()
 eric5.Globals.isLinuxPlatform?4()
 eric5.Globals.isMacPlatform?4()
 eric5.Globals.isWindowsPlatform?4()
Binary file Documentation/Help/source.qch has changed
--- a/Documentation/Help/source.qhp	Tue Apr 23 19:57:07 2013 +0200
+++ b/Documentation/Help/source.qhp	Wed Apr 24 18:16:34 2013 +0200
@@ -12515,6 +12515,7 @@
       <keyword name="getQt4DocDir" id="getQt4DocDir" ref="eric5.Preferences.__init__.html#getQt4DocDir" />
       <keyword name="getQt4TranslationsDir" id="getQt4TranslationsDir" ref="eric5.Preferences.__init__.html#getQt4TranslationsDir" />
       <keyword name="getQt5DocDir" id="getQt5DocDir" ref="eric5.Preferences.__init__.html#getQt5DocDir" />
+      <keyword name="getQtBinariesPath" id="getQtBinariesPath" ref="eric5.Globals.__init__.html#getQtBinariesPath" />
       <keyword name="getQtMacBundle" id="getQtMacBundle" ref="eric5.Utilities.__init__.html#getQtMacBundle" />
       <keyword name="getRealName" id="getRealName" ref="eric5.Utilities.__init__.html#getRealName" />
       <keyword name="getRegistryData" id="getRegistryData" ref="eric5.Debugger.DebuggerInterfaceNone.html#getRegistryData" />
--- a/Documentation/Source/eric5.Globals.__init__.html	Tue Apr 23 19:57:07 2013 +0200
+++ b/Documentation/Source/eric5.Globals.__init__.html	Wed Apr 24 18:16:34 2013 +0200
@@ -49,6 +49,9 @@
 <td><a href="#getPythonModulesDirectory">getPythonModulesDirectory</a></td>
 <td>Function to determine the path to Python's modules directory.</td>
 </tr><tr>
+<td><a href="#getQtBinariesPath">getQtBinariesPath</a></td>
+<td>Module function to get the path of the Qt binaries.</td>
+</tr><tr>
 <td><a href="#isLinuxPlatform">isLinuxPlatform</a></td>
 <td>Function to check, if this is a Linux platform.</td>
 </tr><tr>
@@ -128,6 +131,19 @@
 </dl>
 <div align="right"><a href="#top">Up</a></div>
 <hr /><hr />
+<a NAME="getQtBinariesPath" ID="getQtBinariesPath"></a>
+<h2>getQtBinariesPath</h2>
+<b>getQtBinariesPath</b>(<i></i>)
+<p>
+    Module function to get the path of the Qt binaries.
+</p><dl>
+<dt>Returns:</dt>
+<dd>
+path of the Qt binaries (string)
+</dd>
+</dl>
+<div align="right"><a href="#top">Up</a></div>
+<hr /><hr />
 <a NAME="isLinuxPlatform" ID="isLinuxPlatform"></a>
 <h2>isLinuxPlatform</h2>
 <b>isLinuxPlatform</b>(<i></i>)
--- a/DocumentationTools/QtHelpGenerator.py	Tue Apr 23 19:57:07 2013 +0200
+++ b/DocumentationTools/QtHelpGenerator.py	Wed Apr 24 18:16:34 2013 +0200
@@ -12,9 +12,7 @@
 import shutil
 import subprocess
 
-from PyQt4.QtCore import QLibraryInfo
-
-from Utilities import joinext, relpath, html_encode
+from Utilities import joinext, relpath, html_encode, getQtBinariesPath
 
 HelpCollection = r"""<?xml version="1.0" encoding="utf-8" ?>
 <QHelpCollectionProject version="1.0">
@@ -261,8 +259,7 @@
         # generate the compressed files
         shutil.copy(os.path.join(self.outputDir, HelpProjectFile), self.htmlDir)
         os.chdir(self.htmlDir)
-        subprocess.call([os.path.join(QLibraryInfo.location(QLibraryInfo.BinariesPath),
-                            "qhelpgenerator"),
+        subprocess.call([os.path.join(getQtBinariesPath(), "qhelpgenerator"),
                          "source.qhp", "-o", os.path.join(self.outputDir, HelpHelpFile)])
         os.remove(HelpProjectFile)
         
@@ -271,9 +268,7 @@
             sys.stdout.flush()
             sys.stderr.flush()
             os.chdir(self.outputDir)
-            subprocess.call([os.path.join(
-                                QLibraryInfo.location(QLibraryInfo.BinariesPath),
-                                "qcollectiongenerator"),
+            subprocess.call([os.path.join(getQtBinariesPath(), "qcollectiongenerator"),
                              "source.qhcp", "-o", "collection.qhc"])
         
         os.chdir(cwd)
--- a/Globals/__init__.py	Tue Apr 23 19:57:07 2013 +0200
+++ b/Globals/__init__.py	Wed Apr 24 18:16:34 2013 +0200
@@ -10,7 +10,7 @@
 import sys
 import os
 
-from PyQt4.QtCore import QDir
+from PyQt4.QtCore import QDir, QLibraryInfo
 
 # names of the various settings objects
 settingsNameOrganization = "Eric5"
@@ -165,6 +165,29 @@
     return os.path.join(distutils.sysconfig.get_python_lib(True), "PyQt4")
     
 
+def getQtBinariesPath():
+    """
+    Module function to get the path of the Qt binaries.
+    
+    @return path of the Qt binaries (string)
+    """
+    path = ""
+    if isWindowsPlatform():
+        # check for PyQt4 installer first (designer is test object)
+        modDir = getPyQt4ModulesDirectory()
+        if os.path.exists(os.path.join(modDir, "bin", "designer.exe")):
+            path = os.path.join(modDir, "bin")
+        elif os.path.exists(os.path.join(modDir, "designer.exe")):
+            path = modDir
+    
+    if not path:
+        path = QLibraryInfo.location(QLibraryInfo.BinariesPath)
+        if not os.path.exists(path):
+            path = ""
+    
+    return QDir.toNativeSeparators(path)
+
+
 ################################################################################
 ## functions for searching a Python2 interpreter
 ################################################################################
--- a/Plugins/PluginEricdoc.py	Tue Apr 23 19:57:07 2013 +0200
+++ b/Plugins/PluginEricdoc.py	Wed Apr 24 18:16:34 2013 +0200
@@ -9,7 +9,7 @@
 
 import os
 
-from PyQt4.QtCore import QObject, QLibraryInfo
+from PyQt4.QtCore import QObject
 from PyQt4.QtGui import QDialog, QApplication
 
 from E5Gui.E5Application import e5App
@@ -64,8 +64,7 @@
     })
     
     # 2. Qt Help Generator
-    exe = os.path.join(QLibraryInfo.location(QLibraryInfo.BinariesPath),
-                       'qhelpgenerator')
+    exe = os.path.join(Utilities.getQtBinariesPath(), 'qhelpgenerator')
     if Utilities.isWindowsPlatform():
         exe += '.exe'
     dataList.append({
@@ -81,8 +80,7 @@
     })
     
     # 3. Qt Collection Generator
-    exe = os.path.join(QLibraryInfo.location(QLibraryInfo.BinariesPath),
-                       'qcollectiongenerator')
+    exe = os.path.join(Utilities.getQtBinariesPath(), 'qcollectiongenerator')
     if Utilities.isWindowsPlatform():
         exe += '.exe'
     dataList.append({
--- a/Preferences/ProgramsDialog.py	Tue Apr 23 19:57:07 2013 +0200
+++ b/Preferences/ProgramsDialog.py	Wed Apr 24 18:16:34 2013 +0200
@@ -10,7 +10,7 @@
 import os
 import re
 
-from PyQt4.QtCore import pyqtSlot, Qt, QProcess, QLibraryInfo
+from PyQt4.QtCore import pyqtSlot, Qt, QProcess
 from PyQt4.QtGui import QApplication, QTreeWidgetItem, QHeaderView, QCursor, \
     QDialog, QDialogButtonBox
 
@@ -79,37 +79,37 @@
         exe = Utilities.isWindowsPlatform() and \
             "{0}.exe".format(Utilities.generateQtToolName("lrelease")) or \
             Utilities.generateQtToolName("lrelease")
-        exe = os.path.join(QLibraryInfo.location(QLibraryInfo.BinariesPath), exe)
+        exe = os.path.join(Utilities.getQtBinariesPath(), exe)
         version = self.__createProgramEntry(self.trUtf8("Translation Converter (Qt)"),
                     exe, '-version', 'lrelease', -1)
         # 1b. Qt Designer
         if Utilities.isWindowsPlatform():
-            exe = os.path.join(QLibraryInfo.location(QLibraryInfo.BinariesPath),
+            exe = os.path.join(Utilities.getQtBinariesPath(),
                 "{0}.exe".format(Utilities.generateQtToolName("designer")))
         elif Utilities.isMacPlatform():
             exe = Utilities.getQtMacBundle("designer")
         else:
-            exe = os.path.join(QLibraryInfo.location(QLibraryInfo.BinariesPath),
+            exe = os.path.join(Utilities.getQtBinariesPath(),
                 Utilities.generateQtToolName("designer"))
         self.__createProgramEntry(self.trUtf8("Qt Designer"), exe, version=version)
         # 1c. Qt Linguist
         if Utilities.isWindowsPlatform():
-            exe = os.path.join(QLibraryInfo.location(QLibraryInfo.BinariesPath),
+            exe = os.path.join(Utilities.getQtBinariesPath(),
                 "{0}.exe".format(Utilities.generateQtToolName("linguist")))
         elif Utilities.isMacPlatform():
             exe = Utilities.getQtMacBundle("linguist")
         else:
-            exe = os.path.join(QLibraryInfo.location(QLibraryInfo.BinariesPath),
+            exe = os.path.join(Utilities.getQtBinariesPath(),
                 Utilities.generateQtToolName("linguist"))
         self.__createProgramEntry(self.trUtf8("Qt Linguist"), exe, version=version)
         # 1d. Qt Assistant
         if Utilities.isWindowsPlatform():
-            exe = os.path.join(QLibraryInfo.location(QLibraryInfo.BinariesPath),
+            exe = os.path.join(Utilities.getQtBinariesPath(),
                 "{0}.exe".format(Utilities.generateQtToolName("assistant")))
         elif Utilities.isMacPlatform():
             exe = Utilities.getQtMacBundle("assistant")
         else:
-            exe = os.path.join(QLibraryInfo.location(QLibraryInfo.BinariesPath),
+            exe = os.path.join(Utilities.getQtBinariesPath(),
                 Utilities.generateQtToolName("assistant"))
         self.__createProgramEntry(self.trUtf8("Qt Assistant"), exe, version=version)
         
--- a/Preferences/__init__.py	Tue Apr 23 19:57:07 2013 +0200
+++ b/Preferences/__init__.py	Wed Apr 24 18:16:34 2013 +0200
@@ -33,7 +33,8 @@
 from E5Network.E5Ftp import E5FtpProxyType
 
 from Globals import settingsNameOrganization, settingsNameGlobal, settingsNameRecent, \
-    isWindowsPlatform, findPython2Interpreters, getPyQt4ModulesDirectory
+    isWindowsPlatform, findPython2Interpreters, getPyQt4ModulesDirectory, \
+    getQtBinariesPath
 
 from Project.ProjectBrowserFlags import SourcesBrowserFlag, FormsBrowserFlag, \
     ResourcesBrowserFlag, TranslationsBrowserFlag, InterfacesBrowserFlag, \
@@ -2351,7 +2352,7 @@
     elif key == "Qt4Dir":
         p = prefClass.settings.value("Qt/" + key, prefClass.qtDefaults[key])
         if p == "":
-            p = QLibraryInfo.location(QLibraryInfo.BinariesPath)
+            p = getQtBinariesPath()
         return p
     else:
         return prefClass.settings.value("Qt/" + key, prefClass.qtDefaults[key])
--- a/Project/ProjectTranslationsBrowser.py	Tue Apr 23 19:57:07 2013 +0200
+++ b/Project/ProjectTranslationsBrowser.py	Wed Apr 24 18:16:34 2013 +0200
@@ -11,7 +11,7 @@
 import shutil
 import fnmatch
 
-from PyQt4.QtCore import pyqtSignal, QProcess, QLibraryInfo
+from PyQt4.QtCore import pyqtSignal, QProcess
 from PyQt4.QtGui import QDialog, QMenu
 
 from E5Gui import E5MessageBox
@@ -1054,7 +1054,7 @@
         if self.project.getProjectType() in \
                 ["Qt4", "Qt4C", "E4Plugin", "PySide", "PySideC"]:
             lrelease = os.path.join(
-                    QLibraryInfo.location(QLibraryInfo.BinariesPath),
+                    Utilities.getQtBinariesPath(),
                     Utilities.generateQtToolName("lrelease"))
         else:
             return
--- a/UI/UserInterface.py	Tue Apr 23 19:57:07 2013 +0200
+++ b/UI/UserInterface.py	Wed Apr 24 18:16:34 2013 +0200
@@ -12,7 +12,7 @@
 import logging
 
 from PyQt4.QtCore import QTimer, QFile, QFileInfo, pyqtSignal, PYQT_VERSION_STR, QDate, \
-    QIODevice, qVersion, QProcess, QSize, QUrl, QObject, Qt, QLibraryInfo
+    QIODevice, qVersion, QProcess, QSize, QUrl, QObject, Qt
 from PyQt4.QtGui import QSizePolicy, QWidget, QKeySequence, QDesktopServices, \
     QWhatsThis, QToolBar, QDialog, QSplitter, QApplication, QMenu, QProgressDialog, \
     QVBoxLayout, QDockWidget, QAction, QLabel
@@ -1597,12 +1597,12 @@
         
         # check for Qt4/Qt5 designer and linguist
         if Utilities.isWindowsPlatform():
-            designerExe = os.path.join(QLibraryInfo.location(QLibraryInfo.BinariesPath),
+            designerExe = os.path.join(Utilities.getQtBinariesPath(),
                 "{0}.exe".format(Utilities.generateQtToolName("designer")))
         elif Utilities.isMacPlatform():
             designerExe = Utilities.getQtMacBundle("designer")
         else:
-            designerExe = os.path.join(QLibraryInfo.location(QLibraryInfo.BinariesPath),
+            designerExe = os.path.join(Utilities.getQtBinariesPath(),
                 Utilities.generateQtToolName("designer"))
         if os.path.exists(designerExe):
             self.designer4Act = E5Action(self.trUtf8('Qt-Designer'),
@@ -1619,12 +1619,12 @@
             self.designer4Act = None
         
         if Utilities.isWindowsPlatform():
-            linguistExe = os.path.join(QLibraryInfo.location(QLibraryInfo.BinariesPath),
+            linguistExe = os.path.join(Utilities.getQtBinariesPath(),
                 "{0}.exe".format(Utilities.generateQtToolName("linguist")))
         elif Utilities.isMacPlatform():
             linguistExe = Utilities.getQtMacBundle("linguist")
         else:
-            linguistExe = os.path.join(QLibraryInfo.location(QLibraryInfo.BinariesPath),
+            linguistExe = os.path.join(Utilities.getQtBinariesPath(),
                 Utilities.generateQtToolName("linguist"))
         if os.path.exists(linguistExe):
             self.linguist4Act = E5Action(self.trUtf8('Qt-Linguist'),
@@ -3756,7 +3756,7 @@
         else:
             if version == 4:
                 designer = os.path.join(
-                    QLibraryInfo.location(QLibraryInfo.BinariesPath),
+                    Utilities.getQtBinariesPath(),
                     Utilities.generateQtToolName("designer"))
             if Utilities.isWindowsPlatform():
                 designer += '.exe'
@@ -3815,7 +3815,7 @@
         else:
             if version == 4:
                 linguist = os.path.join(
-                    QLibraryInfo.location(QLibraryInfo.BinariesPath),
+                    Utilities.getQtBinariesPath(),
                     Utilities.generateQtToolName("linguist"))
             if Utilities.isWindowsPlatform():
                 linguist += '.exe'
@@ -3861,7 +3861,7 @@
         else:
             if version == 4:
                 assistant = os.path.join(
-                    QLibraryInfo.location(QLibraryInfo.BinariesPath),
+                    Utilities.getQtBinariesPath(),
                     Utilities.generateQtToolName("assistant"))
             if Utilities.isWindowsPlatform():
                 assistant += '.exe'
--- a/Utilities/__init__.py	Tue Apr 23 19:57:07 2013 +0200
+++ b/Utilities/__init__.py	Wed Apr 24 18:16:34 2013 +0200
@@ -45,6 +45,7 @@
 from Globals import isWindowsPlatform, isLinuxPlatform, isMacPlatform  # __IGNORE_WARNING__
 from Globals import getConfigDir, setConfigDir  # __IGNORE_WARNING__
 from Globals import getPythonModulesDirectory, getPyQt4ModulesDirectory  # __IGNORE_WARNING__
+from Globals import getQtBinariesPath  # __IGNORE_WARNING__
 # import these methods into the Utilities namespace
 
 from E5Gui.E5Application import e5App

eric ide

mercurial