eric6_webbrowser.py

changeset 6630
bddd12f27a4c
parent 6365
85f8745427a6
child 6645
ad476851d7e0
equal deleted inserted replaced
6629:643ec3a53d17 6630:bddd12f27a4c
34 import os 34 import os
35 35
36 try: 36 try:
37 from PyQt5 import QtWebKit # __IGNORE_WARNING__ 37 from PyQt5 import QtWebKit # __IGNORE_WARNING__
38 except ImportError: 38 except ImportError:
39 from PyQt5.QtCore import qVersion, QTimer 39 if "--quiet" not in sys.argv:
40 from PyQt5.QtWidgets import QApplication 40 from PyQt5.QtCore import qVersion, QTimer
41 from E5Gui import E5MessageBox 41 from PyQt5.QtWidgets import QApplication
42 app = QApplication([]) 42 from E5Gui import E5MessageBox
43 QTimer.singleShot(0, lambda: E5MessageBox.critical( 43 app = QApplication([])
44 None, 44 QTimer.singleShot(0, lambda: E5MessageBox.critical(
45 "eric6 Web Browser (QtWebKit based)", 45 None,
46 "QtWebKit is needed to run this variant of the eric6 Web Browser." 46 "eric6 Web Browser (QtWebKit based)",
47 " However, it seems to be missing. You are using Qt {0}, which" 47 "QtWebKit is needed to run this variant of the eric6 Web Browser."
48 " doesn't include this anymore.".format(qVersion()))) 48 " However, it seems to be missing. You are using Qt {0}, which"
49 app.exec_() 49 " doesn't include this anymore.".format(qVersion())))
50 app.exec_()
50 sys.exit(100) 51 sys.exit(100)
51 52
52 for arg in sys.argv[:]: 53 for arg in sys.argv[:]:
53 if arg.startswith("--config="): 54 if arg.startswith("--config="):
54 import Globals 55 import Globals
71 "ThirdParty", "EditorConfig")) 72 "ThirdParty", "EditorConfig"))
72 73
73 import Globals 74 import Globals
74 from Globals import AppInfo 75 from Globals import AppInfo
75 76
77 from E5Gui.E5Application import E5Application
78
76 from Toolbox import Startup 79 from Toolbox import Startup
80
81 from Helpviewer.HelpSingleApplication import HelpSingleApplicationClient
77 82
78 83
79 def createMainWidget(argv): 84 def createMainWidget(argv):
80 """ 85 """
81 Function to create the main widget. 86 Function to create the main widget.
82 87
83 @param argv list of commandline parameters (list of strings) 88 @param argv list of command line parameters
84 @return reference to the main widget (QWidget) 89 @type list of str
90 @return reference to the main widget
91 @rtype QWidget
85 """ 92 """
86 from Helpviewer.HelpWindow import HelpWindow 93 from Helpviewer.HelpWindow import HelpWindow
87 94
88 searchWord = None 95 searchWord = None
96 qthelp = False
97 single = False
98 name = ""
99
89 for arg in reversed(argv): 100 for arg in reversed(argv):
90 if arg.startswith("--search="): 101 if arg.startswith("--search="):
91 searchWord = argv[1].split("=", 1)[1] 102 searchWord = argv[1].split("=", 1)[1]
103 argv.remove(arg)
104 elif arg.startswith("--name="):
105 name = arg.replace("--name=", "")
106 argv.remove(arg)
107 elif arg.startswith("--newtab="):
108 # only used for single application client
109 argv.remove(arg)
110 elif arg == "--qthelp":
111 qthelp = True
112 argv.remove(arg)
113 elif arg == "--quiet":
114 # only needed until we reach this point
115 argv.remove(arg)
116 elif arg == "--single":
117 single = True
92 argv.remove(arg) 118 argv.remove(arg)
93 elif arg.startswith("--"): 119 elif arg.startswith("--"):
94 argv.remove(arg) 120 argv.remove(arg)
95 121
96 try: 122 try:
97 home = argv[1] 123 home = argv[1]
98 except IndexError: 124 except IndexError:
99 home = "" 125 home = ""
100 126
101 helpWindow = HelpWindow(home, '.', None, 'help viewer', 127 helpWindow = HelpWindow(home, '.', None, 'help viewer',
102 searchWord=searchWord) 128 searchWord=searchWord, qthelp=qthelp,
129 single=single, saname=name)
103 return helpWindow 130 return helpWindow
104 131
105 132
106 def main(): 133 def main():
107 """ 134 """
108 Main entry point into the application. 135 Main entry point into the application.
109 """ 136 """
110 options = [ 137 options = [
111 ("--config=configDir", 138 ("--config=configDir",
112 "use the given directory as the one containing the config files"), 139 "use the given directory as the one containing the config files"),
140 ("--qthelp", "start the browser with support for QtHelp"),
141 ("--quiet", "don't show any startup error messages"),
113 ("--search=word", "search for the given word"), 142 ("--search=word", "search for the given word"),
114 ("--settings=settingsDir", 143 ("--settings=settingsDir",
115 "use the given directory to store the settings files"), 144 "use the given directory to store the settings files"),
145 ("--single", "start the browser as a single application"),
116 ] 146 ]
117 appinfo = AppInfo.makeAppInfo(sys.argv, 147 appinfo = AppInfo.makeAppInfo(sys.argv,
118 "eric6 Web Browser", 148 "eric6 Web Browser",
119 "file", 149 "file",
120 "web browser", 150 "web browser",
121 options) 151 options)
122 152
123 if not Globals.checkBlacklistedVersions(): 153 if not Globals.checkBlacklistedVersions():
124 sys.exit(100) 154 sys.exit(100)
125 155
156 # set the library paths for plugins
157 Startup.setLibraryPaths()
158
159 app = E5Application(sys.argv)
160 client = HelpSingleApplicationClient()
161 res = client.connect()
162 if res > 0:
163 if len(sys.argv) > 1:
164 client.processArgs(sys.argv[1:])
165 sys.exit(0)
166 elif res < 0:
167 print("eric6_webbrowser: {0}".format(client.errstr()))
168 # __IGNORE_WARNING_M801__
169 sys.exit(res)
170
126 res = Startup.simpleAppStartup(sys.argv, 171 res = Startup.simpleAppStartup(sys.argv,
127 appinfo, 172 appinfo,
128 createMainWidget, 173 createMainWidget,
129 installErrorHandler=True) 174 installErrorHandler=True,
175 app=app)
130 sys.exit(res) 176 sys.exit(res)
131 177
132 if __name__ == '__main__': 178 if __name__ == '__main__':
133 main() 179 main()

eric ide

mercurial