eric6/eric6_browser.py

Wed, 29 May 2019 22:14:02 +0200

author
T.Rzepka <Tobias.Rzepka@gmail.com>
date
Wed, 29 May 2019 22:14:02 +0200
branch
Variables Viewer
changeset 7030
73779c4c135a
parent 6964
0b8908ba12d3
child 7192
a22eee00b052
permissions
-rw-r--r--

Bugfix displaying to many characters as default_factory type.

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
6645
ad476851d7e0 Updated copyright for 2019.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6630
diff changeset
4 # Copyright (c) 2002 - 2019 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
3145
a9de05d4a22f # __IGNORE_WARNING__ added/ removed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3060
diff changeset
15 from __future__ import unicode_literals
3778
0c5bc18da740 Added more changes to make eric6 usable with PyQt4 as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3670
diff changeset
16
6949
a5255f1ba3f0 setup.py: continued implementing support for setup.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
17 import sys
a5255f1ba3f0 setup.py: continued implementing support for setup.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
18 import os
a5255f1ba3f0 setup.py: continued implementing support for setup.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
19
a5255f1ba3f0 setup.py: continued implementing support for setup.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
20 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
21
4289
6c1ab651c9ce Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
22 import Toolbox.PyQt4ImportHook # __IGNORE_WARNING__
3778
0c5bc18da740 Added more changes to make eric6 usable with PyQt4 as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3670
diff changeset
23
2538
b2642e7a4c18 Fixed a few PEP-8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2526
diff changeset
24 try: # Only for Py2
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
25 import Globals.compatibility_fixes # __IGNORE_WARNING__
2526
a91cba8291b9 Minimum modifications to start Eric5 with Py2.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2525
diff changeset
26 except (ImportError):
a91cba8291b9 Minimum modifications to start Eric5 with Py2.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2525
diff changeset
27 pass
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2302
diff changeset
28
3628
deb5973080a9 Added code to prevent possible segfaults when closing down.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3178
diff changeset
29 try:
6364
6a496f0886ad Prepared the "import sip" statements for PyQt 5.11.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6101
diff changeset
30 try:
6365
85f8745427a6 Redid the "import sip" statements for PyQt 5.11.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6364
diff changeset
31 from PyQt5 import sip
6364
6a496f0886ad Prepared the "import sip" statements for PyQt 5.11.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6101
diff changeset
32 except ImportError:
6365
85f8745427a6 Redid the "import sip" statements for PyQt 5.11.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6364
diff changeset
33 import sip
3628
deb5973080a9 Added code to prevent possible segfaults when closing down.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3178
diff changeset
34 sip.setdestroyonexit(False)
deb5973080a9 Added code to prevent possible segfaults when closing down.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3178
diff changeset
35 except AttributeError:
deb5973080a9 Added code to prevent possible segfaults when closing down.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3178
diff changeset
36 pass
deb5973080a9 Added code to prevent possible segfaults when closing down.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3178
diff changeset
37
5736
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
38 from Globals import qVersionTuple
4709
8612533a223f Started porting the eric web browser to use QtWebEngine.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
39
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
40 app = None
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
41
5736
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
42
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
43 if qVersionTuple() < (5, 6, 0):
6628
c3f0f6bffd21 eric6_browser: added a '--quiet' option to suppress startup error messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6625
diff changeset
44 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
45 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
46 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
47 from E5Gui import E5MessageBox
c3f0f6bffd21 eric6_browser: added a '--quiet' option to suppress startup error messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6625
diff changeset
48 app = QApplication([])
c3f0f6bffd21 eric6_browser: added a '--quiet' option to suppress startup error messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6625
diff changeset
49 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
50 None,
c3f0f6bffd21 eric6_browser: added a '--quiet' option to suppress startup error messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6625
diff changeset
51 "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
52 "You need at least Qt Version 5.6.0 to execute the web browser.")
c3f0f6bffd21 eric6_browser: added a '--quiet' option to suppress startup error messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6625
diff changeset
53 )
c3f0f6bffd21 eric6_browser: added a '--quiet' option to suppress startup error messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6625
diff changeset
54 app.exec_()
4709
8612533a223f Started porting the eric web browser to use QtWebEngine.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
55 sys.exit(100)
8612533a223f Started porting the eric web browser to use QtWebEngine.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
56
4788
7076adec8ddd Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4787
diff changeset
57 SettingsDir = None
7076adec8ddd Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4787
diff changeset
58
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
59 for arg in sys.argv[:]:
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 if arg.startswith("--config="):
2087
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
61 import Globals
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 configDir = arg.replace("--config=", "")
2087
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
63 Globals.setConfigDir(configDir)
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 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
65 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
66 from PyQt5.QtCore import QSettings
4788
7076adec8ddd Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4787
diff changeset
67 SettingsDir = os.path.expanduser(arg.replace("--settings=", ""))
7076adec8ddd Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4787
diff changeset
68 if not os.path.isdir(SettingsDir):
7076adec8ddd Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4787
diff changeset
69 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
70 QSettings.setPath(QSettings.IniFormat, QSettings.UserScope,
4788
7076adec8ddd Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4787
diff changeset
71 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
72 sys.argv.remove(arg)
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 # 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
75 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
76 "ThirdParty", "Pygments"))
6101
b854a825d483 Continued implementing support for EditorConfig.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
77 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
78 "ThirdParty", "EditorConfig"))
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79
4840
69ee7965ba27 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4831
diff changeset
80 try:
69ee7965ba27 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4831
diff changeset
81 from PyQt5 import QtWebEngineWidgets # __IGNORE_WARNING__
69ee7965ba27 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4831
diff changeset
82 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
83 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
84 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
85 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
86 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
87 app = QApplication([])
c3f0f6bffd21 eric6_browser: added a '--quiet' option to suppress startup error messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6625
diff changeset
88 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
89 None,
c3f0f6bffd21 eric6_browser: added a '--quiet' option to suppress startup error messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6625
diff changeset
90 "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
91 "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
92 " web browser."))
c3f0f6bffd21 eric6_browser: added a '--quiet' option to suppress startup error messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6625
diff changeset
93 app.exec_()
4840
69ee7965ba27 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4831
diff changeset
94 sys.exit(100)
4709
8612533a223f Started porting the eric web browser to use QtWebEngine.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
95
2087
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
96 import Globals
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
97 from Globals import AppInfo
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
98
6623
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6365
diff changeset
99 from E5Gui.E5Application import E5Application
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6365
diff changeset
100
2087
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
101 from Toolbox import Startup
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102
6623
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6365
diff changeset
103 from WebBrowser.WebBrowserSingleApplication import \
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6365
diff changeset
104 WebBrowserSingleApplicationClient
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6365
diff changeset
105
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 896
diff changeset
106
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107 def createMainWidget(argv):
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108 """
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109 Function to create the main widget.
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110
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
111 @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
112 @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
113 @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
114 @rtype QWidget
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
115 """
4709
8612533a223f Started porting the eric web browser to use QtWebEngine.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
116 from WebBrowser.WebBrowserWindow import WebBrowserWindow
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118 searchWord = None
4725
b19ff70ba509 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4709
diff changeset
119 private = False
4875
4ee26909ac0d Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4869
diff changeset
120 qthelp = False
6623
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6365
diff changeset
121 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
122 name = ""
4875
4ee26909ac0d Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4869
diff changeset
123
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
124 for arg in reversed(argv):
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
125 if arg.startswith("--search="):
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
126 searchWord = argv[1].split("=", 1)[1]
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
127 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
128 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
129 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
130 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
131 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
132 # 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
133 argv.remove(arg)
4725
b19ff70ba509 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4709
diff changeset
134 elif arg == "--private":
b19ff70ba509 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4709
diff changeset
135 private = True
b19ff70ba509 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4709
diff changeset
136 argv.remove(arg)
4875
4ee26909ac0d Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4869
diff changeset
137 elif arg == "--qthelp":
4ee26909ac0d Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4869
diff changeset
138 qthelp = True
4ee26909ac0d Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4869
diff changeset
139 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
140 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
141 # 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
142 argv.remove(arg)
6623
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6365
diff changeset
143 elif arg == "--single":
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6365
diff changeset
144 single = True
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6365
diff changeset
145 argv.remove(arg)
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
146 elif arg.startswith("--"):
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
147 argv.remove(arg)
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
148
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
149 try:
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
150 home = argv[1]
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
151 except IndexError:
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
152 home = ""
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
153
4709
8612533a223f Started porting the eric web browser to use QtWebEngine.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
154 browser = WebBrowserWindow(home, '.', None, 'web_browser',
4788
7076adec8ddd Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4787
diff changeset
155 searchWord=searchWord, private=private,
6623
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6365
diff changeset
156 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
157 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
158 return browser
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
159
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 896
diff changeset
160
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
161 def main():
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
162 """
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
163 Main entry point into the application.
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
164 """
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
165 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
166
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2992
diff changeset
167 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
168 ("--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
169 "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
170 ("--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
171 ("--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
172 ("--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
173 ("--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
174 ("--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
175 "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
176 ("--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
177 ]
2087
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
178 appinfo = AppInfo.makeAppInfo(sys.argv,
3670
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3669
diff changeset
179 "eric6 Web Browser",
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
180 "file",
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
181 "web browser",
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
182 options)
565
21191e634b47 Added checks for blacklisted versions of sip, PyQt4 and QScintilla2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
183
6623
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6365
diff changeset
184 # set the library paths for plugins
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6365
diff changeset
185 Startup.setLibraryPaths()
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6365
diff changeset
186
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6365
diff changeset
187 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
188 if "--private" not in sys.argv:
6623
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6365
diff changeset
189 client = WebBrowserSingleApplicationClient()
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6365
diff changeset
190 res = client.connect()
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6365
diff changeset
191 if res > 0:
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6365
diff changeset
192 if len(sys.argv) > 1:
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6365
diff changeset
193 client.processArgs(sys.argv[1:])
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6365
diff changeset
194 sys.exit(0)
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6365
diff changeset
195 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
196 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
197 # __IGNORE_WARNING_M801__
6623
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6365
diff changeset
198 sys.exit(res)
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6365
diff changeset
199
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
200 res = Startup.simpleAppStartup(sys.argv,
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
201 appinfo,
2683
ef93fc7332a2 Added a specialized error message handler allowing to filter messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2664
diff changeset
202 createMainWidget,
6623
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6365
diff changeset
203 installErrorHandler=True,
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6365
diff changeset
204 app=app)
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
205 sys.exit(res)
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
206
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
207 if __name__ == '__main__':
97
c4086afea02b Finished cleaning up the code supported by py3flakes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
208 main()

eric ide

mercurial