eric6_webbrowser.py

branch
maintenance
changeset 6646
51eefa621de4
parent 6645
ad476851d7e0
child 6702
793af5761910
--- a/eric6_webbrowser.py	Sat Dec 01 11:45:24 2018 +0100
+++ b/eric6_webbrowser.py	Thu Jan 10 14:22:59 2019 +0100
@@ -1,7 +1,7 @@
 #!/usr/bin/env python3
 # -*- coding: utf-8 -*-
 
-# Copyright (c) 2002 - 2018 Detlev Offenbach <detlev@die-offenbachs.de>
+# Copyright (c) 2002 - 2019 Detlev Offenbach <detlev@die-offenbachs.de>
 #
 
 """
@@ -36,17 +36,18 @@
 try:
     from PyQt5 import QtWebKit      # __IGNORE_WARNING__
 except ImportError:
-    from PyQt5.QtCore import qVersion, QTimer
-    from PyQt5.QtWidgets import QApplication
-    from E5Gui import E5MessageBox
-    app = QApplication([])
-    QTimer.singleShot(0, lambda: E5MessageBox.critical(
-        None,
-        "eric6 Web Browser (QtWebKit based)",
-        "QtWebKit is needed to run this variant of the eric6 Web Browser."
-        " However, it seems to be missing. You are using Qt {0}, which"
-        " doesn't include this anymore.".format(qVersion())))
-    app.exec_()
+    if "--quiet" not in sys.argv:
+        from PyQt5.QtCore import qVersion, QTimer
+        from PyQt5.QtWidgets import QApplication
+        from E5Gui import E5MessageBox
+        app = QApplication([])
+        QTimer.singleShot(0, lambda: E5MessageBox.critical(
+            None,
+            "eric6 Web Browser (QtWebKit based)",
+            "QtWebKit is needed to run this variant of the eric6 Web Browser."
+            " However, it seems to be missing. You are using Qt {0}, which"
+            " doesn't include this anymore.".format(qVersion())))
+        app.exec_()
     sys.exit(100)
 
 for arg in sys.argv[:]:
@@ -73,23 +74,48 @@
 import Globals
 from Globals import AppInfo
 
+from E5Gui.E5Application import E5Application
+
 from Toolbox import Startup
 
+from Helpviewer.HelpSingleApplication import HelpSingleApplicationClient
+
 
 def createMainWidget(argv):
     """
     Function to create the main widget.
     
-    @param argv list of commandline parameters (list of strings)
-    @return reference to the main widget (QWidget)
+    @param argv list of command line parameters
+    @type list of str
+    @return reference to the main widget
+    @rtype QWidget
     """
     from Helpviewer.HelpWindow import HelpWindow
     
     searchWord = None
+    qthelp = False
+    single = False
+    name = ""
+    
     for arg in reversed(argv):
         if arg.startswith("--search="):
             searchWord = argv[1].split("=", 1)[1]
             argv.remove(arg)
+        elif arg.startswith("--name="):
+            name = arg.replace("--name=", "")
+            argv.remove(arg)
+        elif arg.startswith("--newtab="):
+            # only used for single application client
+            argv.remove(arg)
+        elif arg == "--qthelp":
+            qthelp = True
+            argv.remove(arg)
+        elif arg == "--quiet":
+            # only needed until we reach this point
+            argv.remove(arg)
+        elif arg == "--single":
+            single = True
+            argv.remove(arg)
         elif arg.startswith("--"):
             argv.remove(arg)
     
@@ -99,7 +125,8 @@
         home = ""
     
     helpWindow = HelpWindow(home, '.', None, 'help viewer',
-                            searchWord=searchWord)
+                            searchWord=searchWord, qthelp=qthelp,
+                            single=single, saname=name)
     return helpWindow
 
 
@@ -110,9 +137,12 @@
     options = [
         ("--config=configDir",
          "use the given directory as the one containing the config files"),
+        ("--qthelp", "start the browser with support for QtHelp"),
+        ("--quiet", "don't show any startup error messages"),
         ("--search=word", "search for the given word"),
         ("--settings=settingsDir",
          "use the given directory to store the settings files"),
+        ("--single", "start the browser as a single application"),
     ]
     appinfo = AppInfo.makeAppInfo(sys.argv,
                                   "eric6 Web Browser",
@@ -123,10 +153,26 @@
     if not Globals.checkBlacklistedVersions():
         sys.exit(100)
     
+    # set the library paths for plugins
+    Startup.setLibraryPaths()
+    
+    app = E5Application(sys.argv)
+    client = HelpSingleApplicationClient()
+    res = client.connect()
+    if res > 0:
+        if len(sys.argv) > 1:
+            client.processArgs(sys.argv[1:])
+        sys.exit(0)
+    elif res < 0:
+        print("eric6_webbrowser: {0}".format(client.errstr()))
+        # __IGNORE_WARNING_M801__
+        sys.exit(res)
+    
     res = Startup.simpleAppStartup(sys.argv,
                                    appinfo,
                                    createMainWidget,
-                                   installErrorHandler=True)
+                                   installErrorHandler=True,
+                                   app=app)
     sys.exit(res)
 
 if __name__ == '__main__':

eric ide

mercurial