eric6/eric6_browser.py

Wed, 06 Jan 2021 13:47:01 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 06 Jan 2021 13:47:01 +0100
changeset 7960
e8fc383322f7
parent 7945
76daafe10009
child 8143
2c730d5fd177
permissions
-rw-r--r--

Harmonized some user visible strings and changed the term 'eric6' to the more generic 'eric'.

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
7923
91e843545d9a 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 """
7960
e8fc383322f7 Harmonized some user visible strings and changed the term 'eric6' to the more generic 'eric'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7945
diff changeset
8 eric 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,
7960
e8fc383322f7 Harmonized some user visible strings and changed the term 'eric6' to the more generic 'eric'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7945
diff changeset
63 "eric Web Browser",
6628
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
7945
76daafe10009 Removed code dealing with Qt versions less than the required one and removed use of QDesktopWidget or QApplication.desktop().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
69 from PyQt5.QtWebEngineCore import QWebEngineUrlScheme
76daafe10009 Removed code dealing with Qt versions less than the required one and removed use of QDesktopWidget or QApplication.desktop().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
70
2087
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
71 import Globals
7945
76daafe10009 Removed code dealing with Qt versions less than the required one and removed use of QDesktopWidget or QApplication.desktop().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
72 from Globals import AppInfo
2087
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
73
6623
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6365
diff changeset
74 from E5Gui.E5Application import E5Application
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6365
diff changeset
75
2087
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
76 from Toolbox import Startup
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77
7257
c4d0cac9b5c9 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
78 from WebBrowser.WebBrowserSingleApplication import (
6623
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6365
diff changeset
79 WebBrowserSingleApplicationClient
7257
c4d0cac9b5c9 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
80 )
6623
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6365
diff changeset
81
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 896
diff changeset
82
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83 def createMainWidget(argv):
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 """
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85 Function to create the main widget.
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86
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
87 @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
88 @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
89 @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
90 @rtype QWidget
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91 """
4709
8612533a223f Started porting the eric web browser to use QtWebEngine.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
92 from WebBrowser.WebBrowserWindow import WebBrowserWindow
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94 searchWord = None
4725
b19ff70ba509 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4709
diff changeset
95 private = False
4875
4ee26909ac0d Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4869
diff changeset
96 qthelp = False
6623
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6365
diff changeset
97 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
98 name = ""
4875
4ee26909ac0d Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4869
diff changeset
99
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100 for arg in reversed(argv):
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101 if arg.startswith("--search="):
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102 searchWord = argv[1].split("=", 1)[1]
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
103 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
104 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
105 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
106 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
107 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
108 # 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
109 argv.remove(arg)
4725
b19ff70ba509 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4709
diff changeset
110 elif arg == "--private":
b19ff70ba509 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4709
diff changeset
111 private = True
b19ff70ba509 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4709
diff changeset
112 argv.remove(arg)
4875
4ee26909ac0d Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4869
diff changeset
113 elif arg == "--qthelp":
4ee26909ac0d Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4869
diff changeset
114 qthelp = True
4ee26909ac0d Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4869
diff changeset
115 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
116 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
117 # 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
118 argv.remove(arg)
6623
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6365
diff changeset
119 elif arg == "--single":
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6365
diff changeset
120 single = True
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6365
diff changeset
121 argv.remove(arg)
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
122 elif arg.startswith("--"):
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
123 argv.remove(arg)
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
124
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
125 try:
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
126 home = argv[1]
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
127 except IndexError:
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128 home = ""
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129
4709
8612533a223f Started porting the eric web browser to use QtWebEngine.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
130 browser = WebBrowserWindow(home, '.', None, 'web_browser',
4788
7076adec8ddd Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4787
diff changeset
131 searchWord=searchWord, private=private,
6623
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6365
diff changeset
132 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
133 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
134 return browser
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
135
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 896
diff changeset
136
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
137 def main():
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
138 """
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
139 Main entry point into the application.
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
140 """
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
141 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
142
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
143 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
144 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
145
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2992
diff changeset
146 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
147 ("--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
148 "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
149 ("--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
150 ("--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
151 ("--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
152 ("--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
153 ("--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
154 "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
155 ("--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
156 ]
2087
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
157 appinfo = AppInfo.makeAppInfo(sys.argv,
7960
e8fc383322f7 Harmonized some user visible strings and changed the term 'eric6' to the more generic 'eric'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7945
diff changeset
158 "eric Web Browser",
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
159 "file",
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
160 "web browser",
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
161 options)
565
21191e634b47 Added checks for blacklisted versions of sip, PyQt4 and QScintilla2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
162
6623
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6365
diff changeset
163 # set the library paths for plugins
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6365
diff changeset
164 Startup.setLibraryPaths()
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6365
diff changeset
165
7945
76daafe10009 Removed code dealing with Qt versions less than the required one and removed use of QDesktopWidget or QApplication.desktop().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
166 scheme = QWebEngineUrlScheme(b"eric")
76daafe10009 Removed code dealing with Qt versions less than the required one and removed use of QDesktopWidget or QApplication.desktop().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
167 scheme.setSyntax(QWebEngineUrlScheme.Syntax.Path)
76daafe10009 Removed code dealing with Qt versions less than the required one and removed use of QDesktopWidget or QApplication.desktop().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
168 scheme.setFlags(QWebEngineUrlScheme.SecureScheme |
76daafe10009 Removed code dealing with Qt versions less than the required one and removed use of QDesktopWidget or QApplication.desktop().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
169 QWebEngineUrlScheme.ContentSecurityPolicyIgnored)
76daafe10009 Removed code dealing with Qt versions less than the required one and removed use of QDesktopWidget or QApplication.desktop().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
170 QWebEngineUrlScheme.registerScheme(scheme)
76daafe10009 Removed code dealing with Qt versions less than the required one and removed use of QDesktopWidget or QApplication.desktop().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
171 if "--qthelp" in sys.argv:
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
172 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
173 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
174 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
175 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
176
6623
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6365
diff changeset
177 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
178 if "--private" not in sys.argv:
6623
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6365
diff changeset
179 client = WebBrowserSingleApplicationClient()
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6365
diff changeset
180 res = client.connect()
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6365
diff changeset
181 if res > 0:
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6365
diff changeset
182 if len(sys.argv) > 1:
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6365
diff changeset
183 client.processArgs(sys.argv[1:])
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6365
diff changeset
184 sys.exit(0)
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6365
diff changeset
185 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
186 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
187 # __IGNORE_WARNING_M801__
6623
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6365
diff changeset
188 sys.exit(res)
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6365
diff changeset
189
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
190 res = Startup.simpleAppStartup(sys.argv,
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
191 appinfo,
2683
ef93fc7332a2 Added a specialized error message handler allowing to filter messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2664
diff changeset
192 createMainWidget,
6623
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6365
diff changeset
193 installErrorHandler=True,
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6365
diff changeset
194 app=app)
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
195 sys.exit(res)
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
196
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
197 if __name__ == '__main__':
97
c4086afea02b Finished cleaning up the code supported by py3flakes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
198 main()

eric ide

mercurial