src/eric7/eric7_browser.py

branch
eric7
changeset 10308
d19766190e17
parent 10303
ee1aadab1215
child 10321
4a017fdf316f
equal deleted inserted replaced
10307:c685f4e12916 10308:d19766190e17
10 This is the main Python script that performs the necessary initialization 10 This is the main Python script that performs the necessary initialization
11 of the web browser and starts the Qt event loop. This is a standalone version 11 of the web browser and starts the Qt event loop. This is a standalone version
12 of the integrated web browser. It is based on QtWebEngine. 12 of the integrated web browser. It is based on QtWebEngine.
13 """ 13 """
14 14
15 import argparse
16 import os 15 import os
17 import sys 16 import sys
18 17
19 from PyQt6.QtGui import QGuiApplication 18 from PyQt6.QtGui import QGuiApplication
20 19
21 from eric7 import Globals 20 from eric7 import Globals
22 21 from eric7.WebBrowser.WebBrowserArgumentsCreator import createArgparseNamespace
23
24 def createArgparseNamespace():
25 """
26 Function to create an argument parser.
27
28 @return created argument parser object
29 @rtype argparse.ArgumentParser
30 """
31 from eric7.UI.Info import Version
32
33 # 1. create the argument parser
34 parser = argparse.ArgumentParser(
35 description="Web Browser application of the eric tool suite.",
36 epilog="Copyright (c) 2002 - 2023 Detlev Offenbach <detlev@die-offenbachs.de>.",
37 )
38
39 # 2. add the arguments
40 parser.add_argument(
41 "-V",
42 "--version",
43 action="version",
44 version="%(prog)s {0}".format(Version),
45 help="show version information and exit",
46 )
47 parser.add_argument(
48 "--config",
49 metavar="config_dir",
50 help="use the given directory as the one containing the config files",
51 )
52 parser.add_argument(
53 "--settings",
54 metavar="settings_dir",
55 help="use the given directory to store the settings files",
56 )
57 parser.add_argument(
58 "--name",
59 metavar="browser name",
60 default="",
61 help="name to be used for the browser instance",
62 )
63 parser.add_argument(
64 "--new-tab",
65 metavar="URL",
66 action="append",
67 help="open a new tab for the given URL",
68 )
69 parser.add_argument(
70 "--private",
71 action="store_true",
72 help="start the browser in private browsing mode",
73 )
74 parser.add_argument(
75 "--qthelp",
76 action="store_true",
77 help="start the browser with support for QtHelp",
78 )
79 parser.add_argument(
80 "--quiet",
81 action="store_true",
82 help="don't show any startup error messages",
83 )
84 parser.add_argument(
85 "--search",
86 metavar="searchword",
87 help="search for the given word",
88 )
89 parser.add_argument(
90 "--shutdown",
91 action="store_true",
92 help="shut down the browser instance",
93 )
94 parser.add_argument(
95 "--single",
96 action="store_true",
97 help="start the browser as a single application",
98 )
99 parser.add_argument(
100 "home",
101 nargs="?",
102 default="",
103 metavar="file | URL",
104 help="open a file or URL",
105 )
106
107 # 3. create the Namespace object by parsing the command line
108 args = parser.parse_args()
109 return args
110
111 22
112 args = createArgparseNamespace() 23 args = createArgparseNamespace()
113 if args.config: 24 if args.config:
114 Globals.setConfigDir(args.config) 25 Globals.setConfigDir(args.config)
115 if args.settings: 26 if args.settings:
198 scheme.setFlags( 109 scheme.setFlags(
199 QWebEngineUrlScheme.Flag.SecureScheme 110 QWebEngineUrlScheme.Flag.SecureScheme
200 | QWebEngineUrlScheme.Flag.ContentSecurityPolicyIgnored 111 | QWebEngineUrlScheme.Flag.ContentSecurityPolicyIgnored
201 ) 112 )
202 QWebEngineUrlScheme.registerScheme(scheme) 113 QWebEngineUrlScheme.registerScheme(scheme)
203 if "--qthelp" in sys.argv: 114 if args.qthelp:
204 scheme = QWebEngineUrlScheme(b"qthelp") 115 scheme = QWebEngineUrlScheme(b"qthelp")
205 scheme.setSyntax(QWebEngineUrlScheme.Syntax.Path) 116 scheme.setSyntax(QWebEngineUrlScheme.Syntax.Path)
206 scheme.setFlags(QWebEngineUrlScheme.Flag.SecureScheme) 117 scheme.setFlags(QWebEngineUrlScheme.Flag.SecureScheme)
207 QWebEngineUrlScheme.registerScheme(scheme) 118 QWebEngineUrlScheme.registerScheme(scheme)
208 119

eric ide

mercurial