src/eric7/Toolbox/Startup.py

Sun, 03 Nov 2024 17:50:34 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 03 Nov 2024 17:50:34 +0100
branch
eric7
changeset 11034
7b8a21fd2d58
parent 10933
95a15b70f7bb
child 11090
f5f5f5803935
permissions
-rw-r--r--

Extended the EricMessageBox module to determine a parent widget if none was given and extended the EricApplication class to store a reference to the main widget.

2087
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
10439
21c28b0f9e41 Updated copyright for 2024.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10431
diff changeset
3 # Copyright (c) 2002 - 2024 Detlev Offenbach <detlev@die-offenbachs.de>
2087
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
2965
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2683
diff changeset
7 Module implementing some startup helper funcions.
2087
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 import os
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11 import sys
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12
9473
3f23dbf37dbe Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9448
diff changeset
13 from PyQt6.QtCore import QDir, QLibraryInfo, QLocale, QTranslator
8318
962bce857696 Replaced all imports of PyQt5 to PyQt6 and started to replace code using obsoleted methods and adapt to the PyQt6 enum usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8314
diff changeset
14 from PyQt6.QtWidgets import QApplication
2087
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15
10926
9ef616cd220d Moved some functions from 'Globals' to 'EricUtilities'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10671
diff changeset
16 from eric7 import EricUtilities
9473
3f23dbf37dbe Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9448
diff changeset
17 from eric7.EricGui import EricPixmapCache
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
18 from eric7.EricWidgets.EricApplication import EricApplication
9448
ea215f7afab3 Fixed an issue importing the eric7config module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9413
diff changeset
19 from eric7.Globals import getConfig
9624
b47dfa7a137d Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9482
diff changeset
20 from eric7.SystemUtilities import QtUtilities
2087
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21
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
22 application = 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
23
2087
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24
7461
1f239d5f89b8 Added code to include the Breeze icons depending on window lightness factor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
25 def initializeResourceSearchPath(application):
2087
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 """
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 Module function to initialize the default mime source factory.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
28
7493
1696e91a5393 Added vector icons for the mercurial and subversion plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7461
diff changeset
29 @param application reference to the application object
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8318
diff changeset
30 @type EricApplication
2087
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 """
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
32 from eric7 import Preferences
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
33
10671
f2d75784e574 Corrected an issue related to icon handling (see new entry on Icons configuration page).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10439
diff changeset
34 EricPixmapCache.setPreferVectorIcons(Preferences.getIcons("PreferVectorIcons"))
f2d75784e574 Corrected an issue related to icon handling (see new entry on Icons configuration page).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10439
diff changeset
35
7527
b2ae47eaf0ae Startup: added some forgotten code to apply the user selected default icon set.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7521
diff changeset
36 defaultIconPaths = getDefaultIconPaths(application)
2087
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 iconPaths = Preferences.getIcons("Path")
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 for iconPath in iconPaths:
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 if iconPath:
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
40 EricPixmapCache.addSearchPath(iconPath)
2217
e80c74f2a25a Added some icons to the "Languages" and "End-of-Line Type" context menus of the editor and changed the status labels for programming language and end-of-line type of the main window to show an icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2087
diff changeset
41 for defaultIconPath in defaultIconPaths:
3621
15f23ed3f216 Fixed a few source code style issues found by the updated pe8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3539
diff changeset
42 if defaultIconPath not in iconPaths:
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
43 EricPixmapCache.addSearchPath(defaultIconPath)
2087
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45
7527
b2ae47eaf0ae Startup: added some forgotten code to apply the user selected default icon set.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7521
diff changeset
46 def getDefaultIconPaths(application):
b2ae47eaf0ae Startup: added some forgotten code to apply the user selected default icon set.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7521
diff changeset
47 """
b2ae47eaf0ae Startup: added some forgotten code to apply the user selected default icon set.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7521
diff changeset
48 Module function to determine the default icon paths.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
49
7527
b2ae47eaf0ae Startup: added some forgotten code to apply the user selected default icon set.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7521
diff changeset
50 @param application reference to the application object
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8318
diff changeset
51 @type EricApplication
7527
b2ae47eaf0ae Startup: added some forgotten code to apply the user selected default icon set.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7521
diff changeset
52 @return list of default icon paths
b2ae47eaf0ae Startup: added some forgotten code to apply the user selected default icon set.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7521
diff changeset
53 @rtype list of str
b2ae47eaf0ae Startup: added some forgotten code to apply the user selected default icon set.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7521
diff changeset
54 """
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
55 from eric7 import Preferences
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
56
7527
b2ae47eaf0ae Startup: added some forgotten code to apply the user selected default icon set.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7521
diff changeset
57 defaultIconsPath = Preferences.getIcons("DefaultIconsPath")
b2ae47eaf0ae Startup: added some forgotten code to apply the user selected default icon set.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7521
diff changeset
58 if defaultIconsPath == "automatic":
b2ae47eaf0ae Startup: added some forgotten code to apply the user selected default icon set.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7521
diff changeset
59 if application.usesDarkPalette():
b2ae47eaf0ae Startup: added some forgotten code to apply the user selected default icon set.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7521
diff changeset
60 # dark desktop
b2ae47eaf0ae Startup: added some forgotten code to apply the user selected default icon set.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7521
diff changeset
61 defaultIconsPath = "breeze-dark"
b2ae47eaf0ae Startup: added some forgotten code to apply the user selected default icon set.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7521
diff changeset
62 else:
b2ae47eaf0ae Startup: added some forgotten code to apply the user selected default icon set.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7521
diff changeset
63 # light desktop
b2ae47eaf0ae Startup: added some forgotten code to apply the user selected default icon set.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7521
diff changeset
64 defaultIconsPath = "breeze-light"
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
65
7527
b2ae47eaf0ae Startup: added some forgotten code to apply the user selected default icon set.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7521
diff changeset
66 return [
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
67 os.path.join(getConfig("ericIconDir"), defaultIconsPath),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
68 os.path.join(getConfig("ericIconDir"), defaultIconsPath, "languages"),
7527
b2ae47eaf0ae Startup: added some forgotten code to apply the user selected default icon set.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7521
diff changeset
69 ]
b2ae47eaf0ae Startup: added some forgotten code to apply the user selected default icon set.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7521
diff changeset
70
b2ae47eaf0ae Startup: added some forgotten code to apply the user selected default icon set.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7521
diff changeset
71
2087
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72 def setLibraryPaths():
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73 """
8718
3456fb2a2cb0 Corrected a source docu string.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8709
diff changeset
74 Module function to set the Qt library paths correctly.
2087
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 """
8709
41a9ecc5b17b Added code for all platforms to adjust the Qt library paths array.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8459
diff changeset
76 libPaths = (
9624
b47dfa7a137d Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9482
diff changeset
77 os.path.join(QtUtilities.getPyQt6ModulesDirectory(), "plugins"),
b47dfa7a137d Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9482
diff changeset
78 os.path.join(QtUtilities.getPyQt6ModulesDirectory(), "Qt6", "plugins"),
8709
41a9ecc5b17b Added code for all platforms to adjust the Qt library paths array.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8459
diff changeset
79 )
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
80
8709
41a9ecc5b17b Added code for all platforms to adjust the Qt library paths array.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8459
diff changeset
81 libraryPaths = QApplication.libraryPaths()
41a9ecc5b17b Added code for all platforms to adjust the Qt library paths array.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8459
diff changeset
82 for libPath in libPaths:
2087
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83 if os.path.exists(libPath):
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 libPath = QDir.fromNativeSeparators(libPath)
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85 if libPath not in libraryPaths:
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86 libraryPaths.insert(0, libPath)
8709
41a9ecc5b17b Added code for all platforms to adjust the Qt library paths array.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8459
diff changeset
87 QApplication.setLibraryPaths(libraryPaths)
2087
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
89
2087
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 # the translator must not be deleted, therefore we save them here
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91 loaded_translators = {}
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94 def loadTranslators(qtTransDir, app, translationFiles=()):
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95 """
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96 Module function to load all required translations.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
97
10303
ee1aadab1215 Changed code to use the 'argparse' module to parse the command line parameters instead of using own code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9674
diff changeset
98 @param qtTransDir directory of the Qt translations files
ee1aadab1215 Changed code to use the 'argparse' module to parse the command line parameters instead of using own code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9674
diff changeset
99 @type str
ee1aadab1215 Changed code to use the 'argparse' module to parse the command line parameters instead of using own code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9674
diff changeset
100 @param app reference to the application object
ee1aadab1215 Changed code to use the 'argparse' module to parse the command line parameters instead of using own code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9674
diff changeset
101 @type QApplication
2087
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102 @param translationFiles tuple of additional translations to
10303
ee1aadab1215 Changed code to use the 'argparse' module to parse the command line parameters instead of using own code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9674
diff changeset
103 be loaded
ee1aadab1215 Changed code to use the 'argparse' module to parse the command line parameters instead of using own code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9674
diff changeset
104 @type tuple of str
ee1aadab1215 Changed code to use the 'argparse' module to parse the command line parameters instead of using own code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9674
diff changeset
105 @return the requested locale
ee1aadab1215 Changed code to use the 'argparse' module to parse the command line parameters instead of using own code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9674
diff changeset
106 @rtype str
2087
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107 """
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
108 from eric7 import Preferences
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
109
2087
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110 global loaded_translators
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
111
7795
a4c2f0081879 Fixed an issue related to the splitting of the Qt translation files. Just loading the qt.qm file is not working.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7790
diff changeset
112 translations = (
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
113 "qt",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
114 "qt_help",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
115 "qtbase",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
116 "qtmultimedia",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
117 "qtserialport",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
118 "qtwebengine",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
119 "qtwebsockets",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
120 "eric7",
7795
a4c2f0081879 Fixed an issue related to the splitting of the Qt translation files. Just loading the qt.qm file is not working.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7790
diff changeset
121 ) + translationFiles
2087
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
122 loc = Preferences.getUILanguage()
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
123 if loc is None:
6891
93f82da09f22 Fixed some code style issues detected by the new 'return' checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6775
diff changeset
124 return ""
2087
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
125
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
126 if loc == "System":
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
127 loc = QLocale.system().name()
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128 if loc != "C":
10926
9ef616cd220d Moved some functions from 'Globals' to 'EricUtilities'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10671
diff changeset
129 dirs = [getConfig("ericTranslationsDir"), EricUtilities.getConfigDir()]
2087
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130 if qtTransDir is not None:
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
131 dirs.append(qtTransDir)
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
132
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
133 loca = loc
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
134 for tf in ["{0}_{1}".format(tr, loc) for tr in translations]:
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
135 translator, ok = loadTranslatorForLocale(dirs, tf)
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
136 loaded_translators[tf] = translator
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
137 if ok:
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
138 app.installTranslator(translator)
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
139 else:
8314
e3642a6a1e71 Finished renaming eric6 to eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8312
diff changeset
140 if tf.startswith("eric7"):
2087
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
141 loca = None
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
142 loc = loca
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
143 else:
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
144 loc = None
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
145 return loc
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
146
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
147
10303
ee1aadab1215 Changed code to use the 'argparse' module to parse the command line parameters instead of using own code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9674
diff changeset
148 def loadTranslatorForLocale(dirs, tn):
ee1aadab1215 Changed code to use the 'argparse' module to parse the command line parameters instead of using own code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9674
diff changeset
149 """
ee1aadab1215 Changed code to use the 'argparse' module to parse the command line parameters instead of using own code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9674
diff changeset
150 Module function to find and load a specific translation.
ee1aadab1215 Changed code to use the 'argparse' module to parse the command line parameters instead of using own code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9674
diff changeset
151
ee1aadab1215 Changed code to use the 'argparse' module to parse the command line parameters instead of using own code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9674
diff changeset
152 @param dirs searchpath for the translations
ee1aadab1215 Changed code to use the 'argparse' module to parse the command line parameters instead of using own code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9674
diff changeset
153 @type list of str
ee1aadab1215 Changed code to use the 'argparse' module to parse the command line parameters instead of using own code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9674
diff changeset
154 @param tn translation to be loaded
ee1aadab1215 Changed code to use the 'argparse' module to parse the command line parameters instead of using own code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9674
diff changeset
155 @type str
ee1aadab1215 Changed code to use the 'argparse' module to parse the command line parameters instead of using own code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9674
diff changeset
156 @return tuple containing a status flag and the loaded translator
ee1aadab1215 Changed code to use the 'argparse' module to parse the command line parameters instead of using own code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9674
diff changeset
157 @rtype tuple of (int, QTranslator)
ee1aadab1215 Changed code to use the 'argparse' module to parse the command line parameters instead of using own code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9674
diff changeset
158 """
ee1aadab1215 Changed code to use the 'argparse' module to parse the command line parameters instead of using own code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9674
diff changeset
159 trans = QTranslator(None)
ee1aadab1215 Changed code to use the 'argparse' module to parse the command line parameters instead of using own code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9674
diff changeset
160 for directory in dirs:
ee1aadab1215 Changed code to use the 'argparse' module to parse the command line parameters instead of using own code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9674
diff changeset
161 loaded = trans.load(tn, directory)
ee1aadab1215 Changed code to use the 'argparse' module to parse the command line parameters instead of using own code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9674
diff changeset
162 if loaded:
ee1aadab1215 Changed code to use the 'argparse' module to parse the command line parameters instead of using own code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9674
diff changeset
163 return (trans, True)
ee1aadab1215 Changed code to use the 'argparse' module to parse the command line parameters instead of using own code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9674
diff changeset
164
ee1aadab1215 Changed code to use the 'argparse' module to parse the command line parameters instead of using own code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9674
diff changeset
165 print("Warning: translation file '" + tn + "'could not be loaded.")
ee1aadab1215 Changed code to use the 'argparse' module to parse the command line parameters instead of using own code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9674
diff changeset
166 print("Using default.")
ee1aadab1215 Changed code to use the 'argparse' module to parse the command line parameters instead of using own code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9674
diff changeset
167 return (None, False)
ee1aadab1215 Changed code to use the 'argparse' module to parse the command line parameters instead of using own code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9674
diff changeset
168
ee1aadab1215 Changed code to use the 'argparse' module to parse the command line parameters instead of using own code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9674
diff changeset
169
ee1aadab1215 Changed code to use the 'argparse' module to parse the command line parameters instead of using own code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9674
diff changeset
170 def appStartup(
ee1aadab1215 Changed code to use the 'argparse' module to parse the command line parameters instead of using own code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9674
diff changeset
171 args,
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
172 mwFactory,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
173 quitOnLastWindowClosed=True,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
174 app=None,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
175 raiseIt=True,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
176 installErrorHandler=False,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
177 ):
2087
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
178 """
2965
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2683
diff changeset
179 Module function to start up an application that doesn't need a specialized
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2683
diff changeset
180 start up.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
181
7960
e8fc383322f7 Harmonized some user visible strings and changed the term 'eric6' to the more generic 'eric'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
182 This function is used by all of eric's helper programs.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
183
10303
ee1aadab1215 Changed code to use the 'argparse' module to parse the command line parameters instead of using own code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9674
diff changeset
184 @param args namespace object created by ArgumentParser.parse_args() containing
ee1aadab1215 Changed code to use the 'argparse' module to parse the command line parameters instead of using own code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9674
diff changeset
185 the parsed command line arguments
ee1aadab1215 Changed code to use the 'argparse' module to parse the command line parameters instead of using own code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9674
diff changeset
186 @type argparse.Namespace
2087
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
187 @param mwFactory factory function generating the main widget. This
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
188 function must accept the following parameter.
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
189 <dl>
10303
ee1aadab1215 Changed code to use the 'argparse' module to parse the command line parameters instead of using own code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9674
diff changeset
190 <dt>args</dt>
ee1aadab1215 Changed code to use the 'argparse' module to parse the command line parameters instead of using own code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9674
diff changeset
191 <dd>parsed command line arguments (argparse.Namespace)</dd>
2087
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
192 </dl>
10431
64157aeb0312 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10303
diff changeset
193 @type function
7900
72b88fb20261 Corrected the use of '@keyparam' in the source documentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7795
diff changeset
194 @param quitOnLastWindowClosed flag indicating to quit the application,
10303
ee1aadab1215 Changed code to use the 'argparse' module to parse the command line parameters instead of using own code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9674
diff changeset
195 if the last window was closed
ee1aadab1215 Changed code to use the 'argparse' module to parse the command line parameters instead of using own code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9674
diff changeset
196 @type bool
ee1aadab1215 Changed code to use the 'argparse' module to parse the command line parameters instead of using own code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9674
diff changeset
197 @param app reference to the application object
ee1aadab1215 Changed code to use the 'argparse' module to parse the command line parameters instead of using own code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9674
diff changeset
198 @type QApplication or None
7900
72b88fb20261 Corrected the use of '@keyparam' in the source documentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7795
diff changeset
199 @param raiseIt flag indicating to raise the generated application
10303
ee1aadab1215 Changed code to use the 'argparse' module to parse the command line parameters instead of using own code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9674
diff changeset
200 window
ee1aadab1215 Changed code to use the 'argparse' module to parse the command line parameters instead of using own code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9674
diff changeset
201 @type bool
7900
72b88fb20261 Corrected the use of '@keyparam' in the source documentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7795
diff changeset
202 @param installErrorHandler flag indicating to install an error
10303
ee1aadab1215 Changed code to use the 'argparse' module to parse the command line parameters instead of using own code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9674
diff changeset
203 handler dialog
ee1aadab1215 Changed code to use the 'argparse' module to parse the command line parameters instead of using own code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9674
diff changeset
204 @type bool
ee1aadab1215 Changed code to use the 'argparse' module to parse the command line parameters instead of using own code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9674
diff changeset
205 @return exit result
ee1aadab1215 Changed code to use the 'argparse' module to parse the command line parameters instead of using own code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9674
diff changeset
206 @rtype int
2087
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
207 """
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
208 global application
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
209
6775
a84449ccb414 eric6, Startup: get rid of the __PYVENV_LAUNCHER__ environment variable because it get in the way.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6702
diff changeset
210 if "__PYVENV_LAUNCHER__" in os.environ:
a84449ccb414 eric6, Startup: get rid of the __PYVENV_LAUNCHER__ environment variable because it get in the way.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6702
diff changeset
211 del os.environ["__PYVENV_LAUNCHER__"]
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
212
2087
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
213 if app is None:
4035
c38be891d0ab Fixed startup issues on Windows platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
214 # set the library paths for plugins
c38be891d0ab Fixed startup issues on Windows platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
215 setLibraryPaths()
10303
ee1aadab1215 Changed code to use the 'argparse' module to parse the command line parameters instead of using own code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9674
diff changeset
216 app = EricApplication(sys.argv)
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
217 application = app
2087
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
218 app.setQuitOnLastWindowClosed(quitOnLastWindowClosed)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
219
2087
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
220 # the following code depends upon a valid application object
9482
a2bc06a54d9d Corrected/acknowledged some bad import style and removed some obsolete code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9473
diff changeset
221 from eric7 import Preferences # __IGNORE_WARNING_I101__
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
222
8837
6b4b2acc5324 Added capability to configure the eric application palette via a QSS file (handled internally by eric).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8718
diff changeset
223 # set the application style sheet
6b4b2acc5324 Added capability to configure the eric application palette via a QSS file (handled internally by eric).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8718
diff changeset
224 app.setStyleSheetFile(Preferences.getUI("StyleSheet"))
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
225
7461
1f239d5f89b8 Added code to include the Breeze icons depending on window lightness factor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
226 initializeResourceSearchPath(app)
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
227 QApplication.setWindowIcon(EricPixmapCache.getIcon("eric"))
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
228
4714
03c5936c79e5 Change the prefference for the Qt translations directory because it still reflected Qt4.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
229 qtTransDir = Preferences.getQtTranslationsDir()
03c5936c79e5 Change the prefference for the Qt translations directory because it still reflected Qt4.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
230 if not qtTransDir:
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
231 qtTransDir = QLibraryInfo.path(QLibraryInfo.LibraryPath.TranslationsPath)
4714
03c5936c79e5 Change the prefference for the Qt translations directory because it still reflected Qt4.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
232 loadTranslators(qtTransDir, app, ("qscintilla",))
03c5936c79e5 Change the prefference for the Qt translations directory because it still reflected Qt4.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
233 # qscintilla needed for web browser
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
234
10303
ee1aadab1215 Changed code to use the 'argparse' module to parse the command line parameters instead of using own code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9674
diff changeset
235 w = mwFactory(args)
5283
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4714
diff changeset
236 if w is None:
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4714
diff changeset
237 return 100
11034
7b8a21fd2d58 Extended the EricMessageBox module to determine a parent widget if none was given and extended the EricApplication class to store a reference to the main widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10933
diff changeset
238 else:
7b8a21fd2d58 Extended the EricMessageBox module to determine a parent widget if none was given and extended the EricApplication class to store a reference to the main widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10933
diff changeset
239 app.setMainWindow(mainWindow=w)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
240
2087
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
241 if quitOnLastWindowClosed:
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
242 app.lastWindowClosed.connect(app.quit)
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
243 w.show()
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
244 if raiseIt:
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
245 w.raise_()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
246
2683
ef93fc7332a2 Added a specialized error message handler allowing to filter messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2614
diff changeset
247 if installErrorHandler:
ef93fc7332a2 Added a specialized error message handler allowing to filter messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2614
diff changeset
248 # generate a graphical error handler
9482
a2bc06a54d9d Corrected/acknowledged some bad import style and removed some obsolete code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9473
diff changeset
249 from eric7.EricWidgets import EricErrorMessage # __IGNORE_WARNING_I101__
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
250
10933
95a15b70f7bb Refactored some packages, modules and code to allow extracting the 'EricXxx' packages into a library project.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10926
diff changeset
251 eMsg = EricErrorMessage.qtHandler(
95a15b70f7bb Refactored some packages, modules and code to allow extracting the 'EricXxx' packages into a library project.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10926
diff changeset
252 minSeverity=Preferences.getUI("MinimumMessageTypeSeverity")
95a15b70f7bb Refactored some packages, modules and code to allow extracting the 'EricXxx' packages into a library project.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10926
diff changeset
253 )
2683
ef93fc7332a2 Added a specialized error message handler allowing to filter messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2614
diff changeset
254 eMsg.setMinimumSize(600, 400)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
255
7759
51aa6c6b66f7 Changed calls to exec_() into exec() (remainder of Python2 elimination).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
256 return app.exec()
4566
a2e8f3c420ec Dealt with the M801 code style checker messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4035
diff changeset
257
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
258
4566
a2e8f3c420ec Dealt with the M801 code style checker messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4035
diff changeset
259 #
a2e8f3c420ec Dealt with the M801 code style checker messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4035
diff changeset
260 # eflag: noqa = M801

eric ide

mercurial