eric6/eric6_browser.py

Wed, 30 Dec 2020 11:00:44 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 30 Dec 2020 11:00:44 +0100
branch
maintenance
changeset 7924
8a96736d465e
parent 7781
607a6098cb44
child 7945
76daafe10009
permissions
-rw-r--r--

Updated copyright for 2021.

15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 #!/usr/bin/env python3
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2 # -*- coding: utf-8 -*-
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
3
7924
8a96736d465e Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
4 # Copyright (c) 2002 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5 #
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 """
3670
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3669
diff changeset
8 Eric6 Web Browser.
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 This is the main Python script that performs the necessary initialization
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11 of the web browser and starts the Qt event loop. This is a standalone version
4709
8612533a223f Started porting the eric web browser to use QtWebEngine.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
12 of the integrated web browser. It is based on QtWebEngine.
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13 """
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14
6949
a5255f1ba3f0 setup.py: continued implementing support for setup.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
15 import sys
a5255f1ba3f0 setup.py: continued implementing support for setup.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
16 import os
a5255f1ba3f0 setup.py: continued implementing support for setup.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
17
a5255f1ba3f0 setup.py: continued implementing support for setup.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
18 sys.path.insert(1, os.path.dirname(__file__))
a5255f1ba3f0 setup.py: continued implementing support for setup.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
19
3628
deb5973080a9 Added code to prevent possible segfaults when closing down.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3178
diff changeset
20 try:
6364
6a496f0886ad Prepared the "import sip" statements for PyQt 5.11.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6101
diff changeset
21 try:
7316
abe6dd39e4ee eric6_browser: moved the scheme registration to the main file to fulfill a Qt requirement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7257
diff changeset
22 from PyQt5 import sip # __IGNORE_EXCEPTION__
6364
6a496f0886ad Prepared the "import sip" statements for PyQt 5.11.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6101
diff changeset
23 except ImportError:
6365
85f8745427a6 Redid the "import sip" statements for PyQt 5.11.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6364
diff changeset
24 import sip
3628
deb5973080a9 Added code to prevent possible segfaults when closing down.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3178
diff changeset
25 sip.setdestroyonexit(False)
deb5973080a9 Added code to prevent possible segfaults when closing down.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3178
diff changeset
26 except AttributeError:
deb5973080a9 Added code to prevent possible segfaults when closing down.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3178
diff changeset
27 pass
deb5973080a9 Added code to prevent possible segfaults when closing down.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3178
diff changeset
28
6702
793af5761910 Changed some code to (hopefully) get rid of a crash with upcoming PyQt 5.12.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
29 app = None
4788
7076adec8ddd Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4787
diff changeset
30 SettingsDir = None
7076adec8ddd Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4787
diff changeset
31
4343
afe0da217745 Added the '--settings=' command line switch to store the settings files in a non-standard directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4289
diff changeset
32 for arg in sys.argv[:]:
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 if arg.startswith("--config="):
2087
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
34 import Globals
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 configDir = arg.replace("--config=", "")
2087
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
36 Globals.setConfigDir(configDir)
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 sys.argv.remove(arg)
4343
afe0da217745 Added the '--settings=' command line switch to store the settings files in a non-standard directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4289
diff changeset
38 elif arg.startswith("--settings="):
afe0da217745 Added the '--settings=' command line switch to store the settings files in a non-standard directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4289
diff changeset
39 from PyQt5.QtCore import QSettings
4788
7076adec8ddd Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4787
diff changeset
40 SettingsDir = os.path.expanduser(arg.replace("--settings=", ""))
7076adec8ddd Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4787
diff changeset
41 if not os.path.isdir(SettingsDir):
7076adec8ddd Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4787
diff changeset
42 os.makedirs(SettingsDir)
4343
afe0da217745 Added the '--settings=' command line switch to store the settings files in a non-standard directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4289
diff changeset
43 QSettings.setPath(QSettings.IniFormat, QSettings.UserScope,
4788
7076adec8ddd Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4787
diff changeset
44 SettingsDir)
4343
afe0da217745 Added the '--settings=' command line switch to store the settings files in a non-standard directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4289
diff changeset
45 sys.argv.remove(arg)
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 # make ThirdParty package available as a packages repository
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
48 sys.path.insert(2, os.path.join(os.path.dirname(__file__),
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
49 "ThirdParty", "Pygments"))
6101
b854a825d483 Continued implementing support for EditorConfig.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
50 sys.path.insert(2, os.path.join(os.path.dirname(__file__),
b854a825d483 Continued implementing support for EditorConfig.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
51 "ThirdParty", "EditorConfig"))
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52
4840
69ee7965ba27 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4831
diff changeset
53 try:
69ee7965ba27 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4831
diff changeset
54 from PyQt5 import QtWebEngineWidgets # __IGNORE_WARNING__
69ee7965ba27 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4831
diff changeset
55 except ImportError:
6628
c3f0f6bffd21 eric6_browser: added a '--quiet' option to suppress startup error messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6625
diff changeset
56 if "--quiet" not in sys.argv:
c3f0f6bffd21 eric6_browser: added a '--quiet' option to suppress startup error messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6625
diff changeset
57 from PyQt5.QtCore import QTimer
c3f0f6bffd21 eric6_browser: added a '--quiet' option to suppress startup error messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6625
diff changeset
58 from PyQt5.QtWidgets import QApplication
c3f0f6bffd21 eric6_browser: added a '--quiet' option to suppress startup error messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6625
diff changeset
59 from E5Gui import E5MessageBox # __IGNORE_WARNING__
c3f0f6bffd21 eric6_browser: added a '--quiet' option to suppress startup error messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6625
diff changeset
60 app = QApplication([])
c3f0f6bffd21 eric6_browser: added a '--quiet' option to suppress startup error messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6625
diff changeset
61 QTimer.singleShot(0, lambda: E5MessageBox.critical(
c3f0f6bffd21 eric6_browser: added a '--quiet' option to suppress startup error messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6625
diff changeset
62 None,
c3f0f6bffd21 eric6_browser: added a '--quiet' option to suppress startup error messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6625
diff changeset
63 "eric6 Web Browser",
c3f0f6bffd21 eric6_browser: added a '--quiet' option to suppress startup error messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6625
diff changeset
64 "QtWebEngineWidgets is not installed but needed to execute the"
c3f0f6bffd21 eric6_browser: added a '--quiet' option to suppress startup error messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6625
diff changeset
65 " web browser."))
7759
51aa6c6b66f7 Changed calls to exec_() into exec() (remainder of Python2 elimination).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7380
diff changeset
66 app.exec()
4840
69ee7965ba27 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4831
diff changeset
67 sys.exit(100)
4709
8612533a223f Started porting the eric web browser to use QtWebEngine.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
68
2087
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
69 import Globals
7316
abe6dd39e4ee eric6_browser: moved the scheme registration to the main file to fulfill a Qt requirement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7257
diff changeset
70 from Globals import AppInfo, qVersionTuple
2087
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
71
6623
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6365
diff changeset
72 from E5Gui.E5Application import E5Application
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6365
diff changeset
73
2087
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
74 from Toolbox import Startup
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75
7257
c4d0cac9b5c9 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
76 from WebBrowser.WebBrowserSingleApplication import (
6623
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6365
diff changeset
77 WebBrowserSingleApplicationClient
7257
c4d0cac9b5c9 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
78 )
6623
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6365
diff changeset
79
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 896
diff changeset
80
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 def createMainWidget(argv):
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82 """
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83 Function to create the main widget.
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84
6630
bddd12f27a4c Web Browser (QtWebKit): applied the changes of the new Web Brwoser to the QtWebKit based variant.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6628
diff changeset
85 @param argv list of command line parameters
bddd12f27a4c Web Browser (QtWebKit): applied the changes of the new Web Brwoser to the QtWebKit based variant.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6628
diff changeset
86 @type list of str
bddd12f27a4c Web Browser (QtWebKit): applied the changes of the new Web Brwoser to the QtWebKit based variant.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6628
diff changeset
87 @return reference to the main widget
bddd12f27a4c Web Browser (QtWebKit): applied the changes of the new Web Brwoser to the QtWebKit based variant.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6628
diff changeset
88 @rtype QWidget
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89 """
4709
8612533a223f Started porting the eric web browser to use QtWebEngine.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
90 from WebBrowser.WebBrowserWindow import WebBrowserWindow
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92 searchWord = None
4725
b19ff70ba509 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4709
diff changeset
93 private = False
4875
4ee26909ac0d Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4869
diff changeset
94 qthelp = False
6623
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6365
diff changeset
95 single = False
6625
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6623
diff changeset
96 name = ""
4875
4ee26909ac0d Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4869
diff changeset
97
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98 for arg in reversed(argv):
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99 if arg.startswith("--search="):
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100 searchWord = argv[1].split("=", 1)[1]
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101 argv.remove(arg)
6625
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6623
diff changeset
102 elif arg.startswith("--name="):
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6623
diff changeset
103 name = arg.replace("--name=", "")
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6623
diff changeset
104 argv.remove(arg)
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6623
diff changeset
105 elif arg.startswith("--newtab="):
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6623
diff changeset
106 # only used for single application client
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6623
diff changeset
107 argv.remove(arg)
4725
b19ff70ba509 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4709
diff changeset
108 elif arg == "--private":
b19ff70ba509 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4709
diff changeset
109 private = True
b19ff70ba509 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4709
diff changeset
110 argv.remove(arg)
4875
4ee26909ac0d Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4869
diff changeset
111 elif arg == "--qthelp":
4ee26909ac0d Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4869
diff changeset
112 qthelp = True
4ee26909ac0d Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4869
diff changeset
113 argv.remove(arg)
6628
c3f0f6bffd21 eric6_browser: added a '--quiet' option to suppress startup error messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6625
diff changeset
114 elif arg == "--quiet":
c3f0f6bffd21 eric6_browser: added a '--quiet' option to suppress startup error messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6625
diff changeset
115 # only needed until we reach this point
c3f0f6bffd21 eric6_browser: added a '--quiet' option to suppress startup error messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6625
diff changeset
116 argv.remove(arg)
6623
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6365
diff changeset
117 elif arg == "--single":
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6365
diff changeset
118 single = True
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6365
diff changeset
119 argv.remove(arg)
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120 elif arg.startswith("--"):
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
121 argv.remove(arg)
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
122
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
123 try:
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
124 home = argv[1]
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
125 except IndexError:
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
126 home = ""
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
127
4709
8612533a223f Started porting the eric web browser to use QtWebEngine.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
128 browser = WebBrowserWindow(home, '.', None, 'web_browser',
4788
7076adec8ddd Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4787
diff changeset
129 searchWord=searchWord, private=private,
6623
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6365
diff changeset
130 settingsDir=SettingsDir, qthelp=qthelp,
6625
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6623
diff changeset
131 single=single, saname=name)
4709
8612533a223f Started porting the eric web browser to use QtWebEngine.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
132 return browser
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
133
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 896
diff changeset
134
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
135 def main():
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
136 """
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
137 Main entry point into the application.
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
138 """
6702
793af5761910 Changed some code to (hopefully) get rid of a crash with upcoming PyQt 5.12.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
139 global app
793af5761910 Changed some code to (hopefully) get rid of a crash with upcoming PyQt 5.12.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
140
7380
c99320e859ca Fixed an issue related to showing the application name in the menu bar of Gnome desktop under Wayland.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
141 from PyQt5.QtGui import QGuiApplication
c99320e859ca Fixed an issue related to showing the application name in the menu bar of Gnome desktop under Wayland.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
142 QGuiApplication.setDesktopFileName("eric6_browser.desktop")
c99320e859ca Fixed an issue related to showing the application name in the menu bar of Gnome desktop under Wayland.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
143
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2992
diff changeset
144 options = [
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 896
diff changeset
145 ("--config=configDir",
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 896
diff changeset
146 "use the given directory as the one containing the config files"),
4831
bf53c06fa0fb Did some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
147 ("--private", "start the browser in private browsing mode"),
4875
4ee26909ac0d Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4869
diff changeset
148 ("--qthelp", "start the browser with support for QtHelp"),
6628
c3f0f6bffd21 eric6_browser: added a '--quiet' option to suppress startup error messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6625
diff changeset
149 ("--quiet", "don't show any startup error messages"),
4343
afe0da217745 Added the '--settings=' command line switch to store the settings files in a non-standard directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4289
diff changeset
150 ("--search=word", "search for the given word"),
afe0da217745 Added the '--settings=' command line switch to store the settings files in a non-standard directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4289
diff changeset
151 ("--settings=settingsDir",
afe0da217745 Added the '--settings=' command line switch to store the settings files in a non-standard directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4289
diff changeset
152 "use the given directory to store the settings files"),
6623
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6365
diff changeset
153 ("--single", "start the browser as a single application"),
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
154 ]
2087
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
155 appinfo = AppInfo.makeAppInfo(sys.argv,
3670
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3669
diff changeset
156 "eric6 Web Browser",
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
157 "file",
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
158 "web browser",
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
159 options)
565
21191e634b47 Added checks for blacklisted versions of sip, PyQt4 and QScintilla2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
160
6623
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6365
diff changeset
161 # set the library paths for plugins
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6365
diff changeset
162 Startup.setLibraryPaths()
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6365
diff changeset
163
7316
abe6dd39e4ee eric6_browser: moved the scheme registration to the main file to fulfill a Qt requirement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7257
diff changeset
164 if qVersionTuple() >= (5, 12, 0):
abe6dd39e4ee eric6_browser: moved the scheme registration to the main file to fulfill a Qt requirement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7257
diff changeset
165 from PyQt5.QtWebEngineCore import QWebEngineUrlScheme
abe6dd39e4ee eric6_browser: moved the scheme registration to the main file to fulfill a Qt requirement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7257
diff changeset
166 scheme = QWebEngineUrlScheme(b"eric")
abe6dd39e4ee eric6_browser: moved the scheme registration to the main file to fulfill a Qt requirement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7257
diff changeset
167 scheme.setSyntax(QWebEngineUrlScheme.Syntax.Path)
abe6dd39e4ee eric6_browser: moved the scheme registration to the main file to fulfill a Qt requirement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7257
diff changeset
168 scheme.setFlags(QWebEngineUrlScheme.SecureScheme |
abe6dd39e4ee eric6_browser: moved the scheme registration to the main file to fulfill a Qt requirement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7257
diff changeset
169 QWebEngineUrlScheme.ContentSecurityPolicyIgnored)
abe6dd39e4ee eric6_browser: moved the scheme registration to the main file to fulfill a Qt requirement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7257
diff changeset
170 QWebEngineUrlScheme.registerScheme(scheme)
abe6dd39e4ee eric6_browser: moved the scheme registration to the main file to fulfill a Qt requirement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7257
diff changeset
171 if "--qthelp" in sys.argv and qVersionTuple() >= (5, 12, 0):
abe6dd39e4ee eric6_browser: moved the scheme registration to the main file to fulfill a Qt requirement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7257
diff changeset
172 from PyQt5.QtWebEngineCore import QWebEngineUrlScheme
abe6dd39e4ee eric6_browser: moved the scheme registration to the main file to fulfill a Qt requirement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7257
diff changeset
173 scheme = QWebEngineUrlScheme(b"qthelp")
abe6dd39e4ee eric6_browser: moved the scheme registration to the main file to fulfill a Qt requirement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7257
diff changeset
174 scheme.setSyntax(QWebEngineUrlScheme.Syntax.Path)
abe6dd39e4ee eric6_browser: moved the scheme registration to the main file to fulfill a Qt requirement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7257
diff changeset
175 scheme.setFlags(QWebEngineUrlScheme.SecureScheme)
abe6dd39e4ee eric6_browser: moved the scheme registration to the main file to fulfill a Qt requirement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7257
diff changeset
176 QWebEngineUrlScheme.registerScheme(scheme)
abe6dd39e4ee eric6_browser: moved the scheme registration to the main file to fulfill a Qt requirement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7257
diff changeset
177
6623
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6365
diff changeset
178 app = E5Application(sys.argv)
6625
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6623
diff changeset
179 if "--private" not in sys.argv:
6623
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6365
diff changeset
180 client = WebBrowserSingleApplicationClient()
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6365
diff changeset
181 res = client.connect()
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6365
diff changeset
182 if res > 0:
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6365
diff changeset
183 if len(sys.argv) > 1:
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6365
diff changeset
184 client.processArgs(sys.argv[1:])
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6365
diff changeset
185 sys.exit(0)
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6365
diff changeset
186 elif res < 0:
6625
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6623
diff changeset
187 print("eric6_browser: {0}".format(client.errstr()))
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6623
diff changeset
188 # __IGNORE_WARNING_M801__
6623
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6365
diff changeset
189 sys.exit(res)
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6365
diff changeset
190
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
191 res = Startup.simpleAppStartup(sys.argv,
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
192 appinfo,
2683
ef93fc7332a2 Added a specialized error message handler allowing to filter messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2664
diff changeset
193 createMainWidget,
6623
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6365
diff changeset
194 installErrorHandler=True,
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6365
diff changeset
195 app=app)
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
196 sys.exit(res)
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
197
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
198 if __name__ == '__main__':
97
c4086afea02b Finished cleaning up the code supported by py3flakes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
199 main()

eric ide

mercurial