eric6/Globals/__init__.py

Sun, 01 Sep 2019 17:43:03 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 01 Sep 2019 17:43:03 +0200
branch
without_py2_and_pyqt4
changeset 7196
ab0a91b82b37
parent 7192
a22eee00b052
child 7198
684261ef2165
permissions
-rw-r--r--

Removed support for QtWebKit and the old web rowser.

0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
6645
ad476851d7e0 Updated copyright for 2019.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6630
diff changeset
3 # Copyright (c) 2006 - 2019 Detlev Offenbach <detlev@die-offenbachs.de>
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module defining common data to be used by all modules.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
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: 4241
diff changeset
10 #
afe0da217745 Added the '--settings=' command line switch to store the settings files in a non-standard directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4241
diff changeset
11 # Note: Do not import any eric stuff in here!!!!!!!
afe0da217745 Added the '--settings=' command line switch to store the settings files in a non-standard directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4241
diff changeset
12 #
afe0da217745 Added the '--settings=' command line switch to store the settings files in a non-standard directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4241
diff changeset
13
3145
a9de05d4a22f # __IGNORE_WARNING__ added/ removed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3060
diff changeset
14 from __future__ import unicode_literals
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
15
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16 import sys
1162
ab292b7f4f8a Added code to search for a Python2 interpreter in some known places. If none is found, the user can configure it on the Debugger, Python config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
17 import os
5736
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
18 import re
6474
72c063cc730b Globals.__init__: fixed an issue that caused startup issues on Windows if both _eric6 and .eric6 were existing.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6366
diff changeset
19 import shutil
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20
5736
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
21 from PyQt5.QtCore import QDir, QLibraryInfo, QByteArray, QCoreApplication, \
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: 6589
diff changeset
22 QT_VERSION_STR, QT_VERSION, QProcess, qVersion
2087
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
23
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 # names of the various settings objects
3670
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
25 settingsNameOrganization = "Eric6"
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
26 settingsNameGlobal = "eric6"
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
27 settingsNameRecent = "eric6recent"
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 # key names of the various recent entries
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 recentNameMultiProject = "MultiProjects"
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 recentNameProject = "Projects"
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 recentNameFiles = "Files"
4695
9dc08852de25 Added a 'Recent Files' menu to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4686
diff changeset
33 recentNameHexFiles = "HexFiles"
1221
291dc0a51947 Added code to the cooperation functions to support IPv6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1162
diff changeset
34 recentNameHosts = "Hosts6"
6034
4f88f70d2cd4 Added the capability to remember the most recently used file names and conditions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5859
diff changeset
35 recentNameBreakpointFiles = "BreakPointFiles"
4f88f70d2cd4 Added the capability to remember the most recently used file names and conditions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5859
diff changeset
36 recentNameBreakpointConditions = "BreakPointConditions"
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37
2087
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
38 configDir = None
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
39
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
40
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 def isWindowsPlatform():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 Function to check, if this is a Windows platform.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 @return flag indicating Windows platform (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 """
6289
f481df37413c Extended the error report to send the desktop environment in use (Linux only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
47 return sys.platform.startswith(("win", "cygwin"))
882
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
48
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
49
882
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
50 def isMacPlatform():
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
51 """
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
52 Function to check, if this is a Mac platform.
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
53
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
54 @return flag indicating Mac platform (boolean)
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
55 """
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
56 return sys.platform == "darwin"
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
57
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
58
882
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
59 def isLinuxPlatform():
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
60 """
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
61 Function to check, if this is a Linux platform.
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
62
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
63 @return flag indicating Linux platform (boolean)
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
64 """
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
65 return sys.platform.startswith("linux")
1162
ab292b7f4f8a Added code to search for a Python2 interpreter in some known places. If none is found, the user can configure it on the Debugger, Python config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
66
ab292b7f4f8a Added code to search for a Python2 interpreter in some known places. If none is found, the user can configure it on the Debugger, Python config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
67
6289
f481df37413c Extended the error report to send the desktop environment in use (Linux only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
68 def desktopName():
f481df37413c Extended the error report to send the desktop environment in use (Linux only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
69 """
f481df37413c Extended the error report to send the desktop environment in use (Linux only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
70 Function to determine the name of the desktop environment used
f481df37413c Extended the error report to send the desktop environment in use (Linux only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
71 (Linux only).
f481df37413c Extended the error report to send the desktop environment in use (Linux only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
72
f481df37413c Extended the error report to send the desktop environment in use (Linux only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
73 @return name of the desktop environment
f481df37413c Extended the error report to send the desktop environment in use (Linux only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
74 @rtype str
f481df37413c Extended the error report to send the desktop environment in use (Linux only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
75 """
f481df37413c Extended the error report to send the desktop environment in use (Linux only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
76 if not isLinuxPlatform():
f481df37413c Extended the error report to send the desktop environment in use (Linux only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
77 return ""
f481df37413c Extended the error report to send the desktop environment in use (Linux only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
78
f481df37413c Extended the error report to send the desktop environment in use (Linux only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
79 currDesktop = os.environ.get("XDG_CURRENT_DESKTOP", "")
f481df37413c Extended the error report to send the desktop environment in use (Linux only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
80 if currDesktop:
f481df37413c Extended the error report to send the desktop environment in use (Linux only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
81 return currDesktop
f481df37413c Extended the error report to send the desktop environment in use (Linux only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
82
f481df37413c Extended the error report to send the desktop environment in use (Linux only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
83 currDesktop = os.environ.get("XDG_SESSION_DESKTOP", "")
f481df37413c Extended the error report to send the desktop environment in use (Linux only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
84 if currDesktop:
f481df37413c Extended the error report to send the desktop environment in use (Linux only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
85 return currDesktop
f481df37413c Extended the error report to send the desktop environment in use (Linux only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
86
f481df37413c Extended the error report to send the desktop environment in use (Linux only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
87 currDesktop = os.environ.get("GDMSESSION", "")
f481df37413c Extended the error report to send the desktop environment in use (Linux only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
88 if currDesktop:
f481df37413c Extended the error report to send the desktop environment in use (Linux only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
89 return currDesktop
f481df37413c Extended the error report to send the desktop environment in use (Linux only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
90
6914
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
91 currDesktop = os.environ.get("GNOME_DESKTOP_SESSION_ID", "")
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
92 if currDesktop:
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
93 return currDesktop
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
94
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
95 currDesktop = os.environ.get("KDE_FULL_SESSION", "")
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
96 if currDesktop:
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
97 return currDesktop
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
98
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
99 currDesktop = os.environ.get("DESKTOP_SESSION", "")
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
100 if currDesktop:
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
101 return currDesktop
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
102
6289
f481df37413c Extended the error report to send the desktop environment in use (Linux only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
103 return ""
f481df37413c Extended the error report to send the desktop environment in use (Linux only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
104
f481df37413c Extended the error report to send the desktop environment in use (Linux only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
105
6914
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
106 def isKdeDesktop():
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
107 """
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
108 Function to check, if the current session is a KDE desktop (Linux only).
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
109
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
110 @return flag indicating a KDE desktop
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
111 @rtype bool
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
112 """
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
113 if not isLinuxPlatform():
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
114 return False
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
115
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
116 isKDE = False
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
117
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
118 desktop = os.environ.get("XDG_CURRENT_DESKTOP", "").lower() or \
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
119 os.environ.get("XDG_SESSION_DESKTOP", "").lower() or \
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
120 os.environ.get("DESKTOP_SESSION", "").lower()
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
121 if desktop:
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
122 isKDE = "kde" in desktop or "plasma" in desktop
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
123 else:
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
124 isKDE = bool(os.environ.get("KDE_FULL_SESSION", ""))
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
125
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
126 return isKDE
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
127
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
128
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
129 def isGnomeDesktop():
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
130 """
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
131 Function to check, if the current session is a Gnome desktop (Linux only).
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
132
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
133 @return flag indicating a Gnome desktop
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
134 @rtype bool
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
135 """
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
136 if not isLinuxPlatform():
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
137 return False
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
138
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
139 isGnome = False
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
140
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
141 desktop = os.environ.get("XDG_CURRENT_DESKTOP", "").lower() or \
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
142 os.environ.get("XDG_SESSION_DESKTOP", "").lower() or \
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
143 os.environ.get("GDMSESSION", "").lower()
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
144 if desktop:
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
145 isGnome = "gnome" in desktop
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
146 else:
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
147 isGnome = bool(os.environ.get("GNOME_DESKTOP_SESSION_ID", ""))
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
148
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
149 return isGnome
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
150
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
151
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
152 def sessionType():
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
153 """
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
154 Function to determine the name of the running session (Linux only).
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
155
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
156 @return name of the desktop environment
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
157 @rtype str
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
158 """
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
159 if not isLinuxPlatform():
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
160 return ""
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
161
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
162 sessionType = os.environ.get("XDG_SESSION_TYPE").lower()
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
163 if "x11" in sessionType:
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
164 return "X11"
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
165 elif "wayland" in sessionType:
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
166 return "Wayland"
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
167
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
168 sessionType = os.environ.get("WAYLAND_DISPLAY", "").lower()
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
169 if "wayland" in sessionType:
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
170 return "Wayland"
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
171
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
172 return ""
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
173
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
174
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
175 def isWaylandSession():
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
176 """
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
177 Function to check, if the current session is a wayland session.
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
178
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
179 @return flag indicating a wayland session
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
180 @rtype bool
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
181 """
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
182 return sessionType() == "Wayland"
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
183
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
184
2087
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
185 def getConfigDir():
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
186 """
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
187 Module function to get the name of the directory storing the config data.
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
188
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
189 @return directory name of the config dir (string)
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
190 """
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
191 if configDir is not None and os.path.exists(configDir):
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
192 hp = configDir
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
193 else:
6303
ec9ebaf206fb Got rid of the Windows "DotNet"-Hack (i.e. using _ instead of . as first character of special directories).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6289
diff changeset
194 cdn = ".eric6"
2087
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
195 if isWindowsPlatform():
6303
ec9ebaf206fb Got rid of the Windows "DotNet"-Hack (i.e. using _ instead of . as first character of special directories).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6289
diff changeset
196 # migrate the old config directory (< v18.06)
ec9ebaf206fb Got rid of the Windows "DotNet"-Hack (i.e. using _ instead of . as first character of special directories).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6289
diff changeset
197 cdnOld = "_eric6"
ec9ebaf206fb Got rid of the Windows "DotNet"-Hack (i.e. using _ instead of . as first character of special directories).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6289
diff changeset
198 hpOld = os.path.join(os.path.expanduser("~"), cdnOld)
ec9ebaf206fb Got rid of the Windows "DotNet"-Hack (i.e. using _ instead of . as first character of special directories).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6289
diff changeset
199 if os.path.exists(hpOld):
ec9ebaf206fb Got rid of the Windows "DotNet"-Hack (i.e. using _ instead of . as first character of special directories).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6289
diff changeset
200 hpNew = os.path.join(os.path.expanduser("~"), cdn)
6474
72c063cc730b Globals.__init__: fixed an issue that caused startup issues on Windows if both _eric6 and .eric6 were existing.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6366
diff changeset
201 if os.path.exists(hpNew):
72c063cc730b Globals.__init__: fixed an issue that caused startup issues on Windows if both _eric6 and .eric6 were existing.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6366
diff changeset
202 # simply delete the old config directory
6530
25b9dcfd6fcc Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6474
diff changeset
203 shutil.rmtree(hpOld, True)
6474
72c063cc730b Globals.__init__: fixed an issue that caused startup issues on Windows if both _eric6 and .eric6 were existing.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6366
diff changeset
204 else:
72c063cc730b Globals.__init__: fixed an issue that caused startup issues on Windows if both _eric6 and .eric6 were existing.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6366
diff changeset
205 os.rename(hpOld, hpNew)
6303
ec9ebaf206fb Got rid of the Windows "DotNet"-Hack (i.e. using _ instead of . as first character of special directories).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6289
diff changeset
206
5823
70dfe6a4aa03 Fixed an issue getting the home directory during uninstallation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
207 hp = os.path.join(os.path.expanduser("~"), cdn)
70dfe6a4aa03 Fixed an issue getting the home directory during uninstallation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
208 if not os.path.exists(hp):
70dfe6a4aa03 Fixed an issue getting the home directory during uninstallation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
209 os.mkdir(hp)
70dfe6a4aa03 Fixed an issue getting the home directory during uninstallation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
210 return hp
2087
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
211
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
212
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
213 def setConfigDir(d):
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
214 """
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
215 Module function to set the name of the directory storing the config data.
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
216
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
217 @param d name of an existing directory (string)
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
218 """
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
219 global configDir
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
220 configDir = os.path.expanduser(d)
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
221
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
222
2608
01118174a2f5 Changed code to be compatible with latest PyQt4 Windows installers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
223 def getPythonModulesDirectory():
01118174a2f5 Changed code to be compatible with latest PyQt4 Windows installers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
224 """
01118174a2f5 Changed code to be compatible with latest PyQt4 Windows installers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
225 Function to determine the path to Python's modules directory.
01118174a2f5 Changed code to be compatible with latest PyQt4 Windows installers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
226
01118174a2f5 Changed code to be compatible with latest PyQt4 Windows installers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
227 @return path to the Python modules directory (string)
01118174a2f5 Changed code to be compatible with latest PyQt4 Windows installers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
228 """
01118174a2f5 Changed code to be compatible with latest PyQt4 Windows installers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
229 import distutils.sysconfig
01118174a2f5 Changed code to be compatible with latest PyQt4 Windows installers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
230 return distutils.sysconfig.get_python_lib(True)
2614
9c49b4419ea7 Changed the logic for detecting and using the PyQt4 module directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2608
diff changeset
231
9c49b4419ea7 Changed the logic for detecting and using the PyQt4 module directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2608
diff changeset
232
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3178
diff changeset
233 def getPyQt5ModulesDirectory():
2614
9c49b4419ea7 Changed the logic for detecting and using the PyQt4 module directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2608
diff changeset
234 """
3807
91fc2089c401 Added some more PyQt4 compatibility code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
235 Function to determine the path to PyQt5's (or PyQt4's) modules directory.
2614
9c49b4419ea7 Changed the logic for detecting and using the PyQt4 module directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2608
diff changeset
236
3807
91fc2089c401 Added some more PyQt4 compatibility code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
237 @return path to the PyQt5/PyQt4 modules directory (string)
2614
9c49b4419ea7 Changed the logic for detecting and using the PyQt4 module directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2608
diff changeset
238 """
9c49b4419ea7 Changed the logic for detecting and using the PyQt4 module directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2608
diff changeset
239 import distutils.sysconfig
3807
91fc2089c401 Added some more PyQt4 compatibility code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
240 for pyqt in ["PyQt5", "PyQt4"]:
91fc2089c401 Added some more PyQt4 compatibility code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
241 pyqtPath = os.path.join(distutils.sysconfig.get_python_lib(True), pyqt)
91fc2089c401 Added some more PyQt4 compatibility code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
242 if os.path.exists(pyqtPath):
91fc2089c401 Added some more PyQt4 compatibility code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
243 return pyqtPath
91fc2089c401 Added some more PyQt4 compatibility code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
244
91fc2089c401 Added some more PyQt4 compatibility code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
245 return ""
2608
01118174a2f5 Changed code to be compatible with latest PyQt4 Windows installers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
246
01118174a2f5 Changed code to be compatible with latest PyQt4 Windows installers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
247
5696
68af0e9c57ad Started implementing the capability to configure the path to the PyQt tools or determine it based on the current Python interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5401
diff changeset
248 def getPyQtToolsPath(version=5):
68af0e9c57ad Started implementing the capability to configure the path to the PyQt tools or determine it based on the current Python interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5401
diff changeset
249 """
68af0e9c57ad Started implementing the capability to configure the path to the PyQt tools or determine it based on the current Python interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5401
diff changeset
250 Module function to get the path of the PyQt tools.
68af0e9c57ad Started implementing the capability to configure the path to the PyQt tools or determine it based on the current Python interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5401
diff changeset
251
68af0e9c57ad Started implementing the capability to configure the path to the PyQt tools or determine it based on the current Python interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5401
diff changeset
252 @param version PyQt major version
68af0e9c57ad Started implementing the capability to configure the path to the PyQt tools or determine it based on the current Python interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5401
diff changeset
253 @type int
68af0e9c57ad Started implementing the capability to configure the path to the PyQt tools or determine it based on the current Python interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5401
diff changeset
254 @return path to the PyQt tools
68af0e9c57ad Started implementing the capability to configure the path to the PyQt tools or determine it based on the current Python interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5401
diff changeset
255 @rtype str
68af0e9c57ad Started implementing the capability to configure the path to the PyQt tools or determine it based on the current Python interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5401
diff changeset
256 """
68af0e9c57ad Started implementing the capability to configure the path to the PyQt tools or determine it based on the current Python interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5401
diff changeset
257 import Preferences
68af0e9c57ad Started implementing the capability to configure the path to the PyQt tools or determine it based on the current Python interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5401
diff changeset
258
68af0e9c57ad Started implementing the capability to configure the path to the PyQt tools or determine it based on the current Python interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5401
diff changeset
259 path = ""
68af0e9c57ad Started implementing the capability to configure the path to the PyQt tools or determine it based on the current Python interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5401
diff changeset
260
68af0e9c57ad Started implementing the capability to configure the path to the PyQt tools or determine it based on the current Python interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5401
diff changeset
261 # step 1: check, if the user has configured a tools path
68af0e9c57ad Started implementing the capability to configure the path to the PyQt tools or determine it based on the current Python interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5401
diff changeset
262 path = Preferences.getQt("PyQtToolsDir")
68af0e9c57ad Started implementing the capability to configure the path to the PyQt tools or determine it based on the current Python interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5401
diff changeset
263
68af0e9c57ad Started implementing the capability to configure the path to the PyQt tools or determine it based on the current Python interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5401
diff changeset
264 # step 2: determine from used Python interpreter (pyrcc is test object)
68af0e9c57ad Started implementing the capability to configure the path to the PyQt tools or determine it based on the current Python interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5401
diff changeset
265 if not path:
68af0e9c57ad Started implementing the capability to configure the path to the PyQt tools or determine it based on the current Python interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5401
diff changeset
266 program = "pyrcc{0}".format(version)
68af0e9c57ad Started implementing the capability to configure the path to the PyQt tools or determine it based on the current Python interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5401
diff changeset
267 if isWindowsPlatform():
68af0e9c57ad Started implementing the capability to configure the path to the PyQt tools or determine it based on the current Python interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5401
diff changeset
268 program += ".exe"
68af0e9c57ad Started implementing the capability to configure the path to the PyQt tools or determine it based on the current Python interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5401
diff changeset
269 dirName = os.path.dirname(sys.executable)
68af0e9c57ad Started implementing the capability to configure the path to the PyQt tools or determine it based on the current Python interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5401
diff changeset
270 if os.path.exists(os.path.join(dirName, program)):
68af0e9c57ad Started implementing the capability to configure the path to the PyQt tools or determine it based on the current Python interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5401
diff changeset
271 path = dirName
68af0e9c57ad Started implementing the capability to configure the path to the PyQt tools or determine it based on the current Python interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5401
diff changeset
272 elif os.path.exists(os.path.join(dirName, "Scripts", program)):
68af0e9c57ad Started implementing the capability to configure the path to the PyQt tools or determine it based on the current Python interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5401
diff changeset
273 path = os.path.join(dirName, "Scripts")
68af0e9c57ad Started implementing the capability to configure the path to the PyQt tools or determine it based on the current Python interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5401
diff changeset
274 else:
68af0e9c57ad Started implementing the capability to configure the path to the PyQt tools or determine it based on the current Python interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5401
diff changeset
275 dirName = os.path.dirname(sys.executable)
68af0e9c57ad Started implementing the capability to configure the path to the PyQt tools or determine it based on the current Python interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5401
diff changeset
276 if os.path.exists(os.path.join(dirName, program)):
68af0e9c57ad Started implementing the capability to configure the path to the PyQt tools or determine it based on the current Python interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5401
diff changeset
277 path = dirName
68af0e9c57ad Started implementing the capability to configure the path to the PyQt tools or determine it based on the current Python interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5401
diff changeset
278
68af0e9c57ad Started implementing the capability to configure the path to the PyQt tools or determine it based on the current Python interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5401
diff changeset
279 return path
68af0e9c57ad Started implementing the capability to configure the path to the PyQt tools or determine it based on the current Python interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5401
diff changeset
280
68af0e9c57ad Started implementing the capability to configure the path to the PyQt tools or determine it based on the current Python interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5401
diff changeset
281
2615
bdc9b4659826 Added a method to determine the Qt binaries path to the Globals package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2614
diff changeset
282 def getQtBinariesPath():
bdc9b4659826 Added a method to determine the Qt binaries path to the Globals package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2614
diff changeset
283 """
bdc9b4659826 Added a method to determine the Qt binaries path to the Globals package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2614
diff changeset
284 Module function to get the path of the Qt binaries.
bdc9b4659826 Added a method to determine the Qt binaries path to the Globals package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2614
diff changeset
285
bdc9b4659826 Added a method to determine the Qt binaries path to the Globals package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2614
diff changeset
286 @return path of the Qt binaries (string)
bdc9b4659826 Added a method to determine the Qt binaries path to the Globals package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2614
diff changeset
287 """
5070
4e4651e88674 Added capability to set the path to the Qt tools manually (because they are not included in the PyQt5 wheels).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4828
diff changeset
288 import Preferences
4e4651e88674 Added capability to set the path to the Qt tools manually (because they are not included in the PyQt5 wheels).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4828
diff changeset
289
2615
bdc9b4659826 Added a method to determine the Qt binaries path to the Globals package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2614
diff changeset
290 path = ""
5070
4e4651e88674 Added capability to set the path to the Qt tools manually (because they are not included in the PyQt5 wheels).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4828
diff changeset
291
4e4651e88674 Added capability to set the path to the Qt tools manually (because they are not included in the PyQt5 wheels).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4828
diff changeset
292 # step 1: check, if the user has configured a tools path
4e4651e88674 Added capability to set the path to the Qt tools manually (because they are not included in the PyQt5 wheels).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4828
diff changeset
293 path = Preferences.getQt("QtToolsDir")
4e4651e88674 Added capability to set the path to the Qt tools manually (because they are not included in the PyQt5 wheels).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4828
diff changeset
294
4e4651e88674 Added capability to set the path to the Qt tools manually (because they are not included in the PyQt5 wheels).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4828
diff changeset
295 if not path and isWindowsPlatform():
4e4651e88674 Added capability to set the path to the Qt tools manually (because they are not included in the PyQt5 wheels).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4828
diff changeset
296 # step 2.1: check for PyQt5 Windows installer (designer is test object)
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3178
diff changeset
297 modDir = getPyQt5ModulesDirectory()
2615
bdc9b4659826 Added a method to determine the Qt binaries path to the Globals package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2614
diff changeset
298 if os.path.exists(os.path.join(modDir, "bin", "designer.exe")):
bdc9b4659826 Added a method to determine the Qt binaries path to the Globals package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2614
diff changeset
299 path = os.path.join(modDir, "bin")
bdc9b4659826 Added a method to determine the Qt binaries path to the Globals package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2614
diff changeset
300 elif os.path.exists(os.path.join(modDir, "designer.exe")):
bdc9b4659826 Added a method to determine the Qt binaries path to the Globals package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2614
diff changeset
301 path = modDir
5735
f606dbe20be6 Added code to auto-discover the presence of the new 'pyqt5-tools' wheel (Windows only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5696
diff changeset
302
f606dbe20be6 Added code to auto-discover the presence of the new 'pyqt5-tools' wheel (Windows only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5696
diff changeset
303 if not path:
f606dbe20be6 Added code to auto-discover the presence of the new 'pyqt5-tools' wheel (Windows only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5696
diff changeset
304 import distutils.sysconfig
6589
613426e62983 Globals, UserInterface: improved the detection of the Qt tools.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6530
diff changeset
305 # step 2.2.1: check for the pyqt5-tools wheel (new variant)
613426e62983 Globals, UserInterface: improved the detection of the Qt tools.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6530
diff changeset
306 # (Windows only)
5735
f606dbe20be6 Added code to auto-discover the presence of the new 'pyqt5-tools' wheel (Windows only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5696
diff changeset
307 pyqt5ToolsPath = os.path.join(
6589
613426e62983 Globals, UserInterface: improved the detection of the Qt tools.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6530
diff changeset
308 distutils.sysconfig.get_python_lib(True), "pyqt5_tools")
5735
f606dbe20be6 Added code to auto-discover the presence of the new 'pyqt5-tools' wheel (Windows only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5696
diff changeset
309 if os.path.exists(os.path.join(pyqt5ToolsPath, "designer.exe")):
f606dbe20be6 Added code to auto-discover the presence of the new 'pyqt5-tools' wheel (Windows only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5696
diff changeset
310 path = pyqt5ToolsPath
6589
613426e62983 Globals, UserInterface: improved the detection of the Qt tools.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6530
diff changeset
311 if not path:
613426e62983 Globals, UserInterface: improved the detection of the Qt tools.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6530
diff changeset
312 # step 2.2.2: check for the pyqt5-tools wheel (old variant)
613426e62983 Globals, UserInterface: improved the detection of the Qt tools.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6530
diff changeset
313 # (Windows only)
613426e62983 Globals, UserInterface: improved the detection of the Qt tools.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6530
diff changeset
314 pyqt5ToolsPath = os.path.join(
613426e62983 Globals, UserInterface: improved the detection of the Qt tools.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6530
diff changeset
315 distutils.sysconfig.get_python_lib(True), "pyqt5-tools")
613426e62983 Globals, UserInterface: improved the detection of the Qt tools.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6530
diff changeset
316 if os.path.exists(os.path.join(pyqt5ToolsPath,
613426e62983 Globals, UserInterface: improved the detection of the Qt tools.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6530
diff changeset
317 "designer.exe")):
613426e62983 Globals, UserInterface: improved the detection of the Qt tools.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6530
diff changeset
318 path = pyqt5ToolsPath
2615
bdc9b4659826 Added a method to determine the Qt binaries path to the Globals package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2614
diff changeset
319
bdc9b4659826 Added a method to determine the Qt binaries path to the Globals package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2614
diff changeset
320 if not path:
5735
f606dbe20be6 Added code to auto-discover the presence of the new 'pyqt5-tools' wheel (Windows only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5696
diff changeset
321 # step 3: get the path from Qt
f606dbe20be6 Added code to auto-discover the presence of the new 'pyqt5-tools' wheel (Windows only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5696
diff changeset
322 # Note: no Qt tools are to be found there for PyQt 5.7.0
2615
bdc9b4659826 Added a method to determine the Qt binaries path to the Globals package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2614
diff changeset
323 path = QLibraryInfo.location(QLibraryInfo.BinariesPath)
bdc9b4659826 Added a method to determine the Qt binaries path to the Globals package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2614
diff changeset
324 if not os.path.exists(path):
bdc9b4659826 Added a method to determine the Qt binaries path to the Globals package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2614
diff changeset
325 path = ""
bdc9b4659826 Added a method to determine the Qt binaries path to the Globals package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2614
diff changeset
326
bdc9b4659826 Added a method to determine the Qt binaries path to the Globals package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2614
diff changeset
327 return QDir.toNativeSeparators(path)
bdc9b4659826 Added a method to determine the Qt binaries path to the Globals package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2614
diff changeset
328
bdc9b4659826 Added a method to determine the Qt binaries path to the Globals package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2614
diff changeset
329
4828
b313794f46a2 updated pep8 to 1.7.0
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4724
diff changeset
330 def translate(*args):
b313794f46a2 updated pep8 to 1.7.0
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4724
diff changeset
331 """
b313794f46a2 updated pep8 to 1.7.0
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4724
diff changeset
332 Module function to handle different PyQt 4/5 QCoreApplication.translate
b313794f46a2 updated pep8 to 1.7.0
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4724
diff changeset
333 parameter.
b313794f46a2 updated pep8 to 1.7.0
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4724
diff changeset
334
b313794f46a2 updated pep8 to 1.7.0
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4724
diff changeset
335 @param args tuple of arguments from QCoreApplication.translate (tuple)
b313794f46a2 updated pep8 to 1.7.0
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4724
diff changeset
336 @return translated string (string)
b313794f46a2 updated pep8 to 1.7.0
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4724
diff changeset
337 """
5848
56388f41b1e6 Fixed an issue sending input to the mercurial and subversion processes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5823
diff changeset
338 if QT_VERSION_STR.startswith('4.'):
4828
b313794f46a2 updated pep8 to 1.7.0
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4724
diff changeset
339 args = list(args)
b313794f46a2 updated pep8 to 1.7.0
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4724
diff changeset
340 args.insert(3, QCoreApplication.CodecForTr)
b313794f46a2 updated pep8 to 1.7.0
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4724
diff changeset
341 return QCoreApplication.translate(*args)
b313794f46a2 updated pep8 to 1.7.0
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4724
diff changeset
342
b313794f46a2 updated pep8 to 1.7.0
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4724
diff changeset
343
2997
7f0ef975da9e Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2992
diff changeset
344 ###############################################################################
5848
56388f41b1e6 Fixed an issue sending input to the mercurial and subversion processes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5823
diff changeset
345 ## functions for version handling
4686
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
346 ###############################################################################
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
347
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
348
5736
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
349 def versionToTuple(version):
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
350 """
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
351 Module function to convert a version string into a tuple.
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
352
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
353 Note: A version string consists of non-negative decimals separated by "."
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
354 optionally followed by a suffix. Suffix is everything after the last
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
355 decimal.
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
356
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
357 @param version version string
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
358 @type str
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
359 @return version tuple without the suffix
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
360 @rtype tuple of int
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
361 """
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
362 versionParts = []
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
363
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
364 # step 1: extract suffix
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
365 version = re.split(r"[^\d.]", version)[0]
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
366 for part in version.split("."):
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
367 versionParts.append(int(part))
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
368
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
369 return tuple(versionParts)
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
370
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
371
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
372 def qVersionTuple():
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
373 """
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
374 Module function to get the Qt version as a tuple.
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
375
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
376 @return Qt version as a tuple
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
377 @rtype tuple of int
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
378 """
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
379 return (
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
380 (QT_VERSION & 0xff0000) >> 16,
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
381 (QT_VERSION & 0xff00) >> 8,
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
382 QT_VERSION & 0xff,
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
383 )
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
384
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
385
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
386 ###############################################################################
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
387 ## functions for extended string handling
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
388 ###############################################################################
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
389
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
390
4686
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
391 def strGroup(txt, sep, groupLen=4):
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
392 """
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
393 Module function to group a string into sub-strings separated by a
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
394 separator.
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
395
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
396 @param txt text to be grouped
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
397 @type str
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
398 @param sep separator string
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
399 @type str
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
400 @param groupLen length of each group
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
401 @type int
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
402 @return result string
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
403 @rtype str
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
404 """
4724
682f009d086d Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4695
diff changeset
405 groups = []
4686
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
406
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
407 while len(txt) // groupLen != 0:
4724
682f009d086d Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4695
diff changeset
408 groups.insert(0, txt[-groupLen:])
4686
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
409 txt = txt[:-groupLen]
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
410 if len(txt) > 0:
4724
682f009d086d Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4695
diff changeset
411 groups.insert(0, txt)
682f009d086d Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4695
diff changeset
412 return sep.join(groups)
4686
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
413
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
414
5848
56388f41b1e6 Fixed an issue sending input to the mercurial and subversion processes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5823
diff changeset
415 def strToQByteArray(txt):
56388f41b1e6 Fixed an issue sending input to the mercurial and subversion processes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5823
diff changeset
416 """
56388f41b1e6 Fixed an issue sending input to the mercurial and subversion processes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5823
diff changeset
417 Module function to convert a Python string into a QByteArray.
56388f41b1e6 Fixed an issue sending input to the mercurial and subversion processes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5823
diff changeset
418
56388f41b1e6 Fixed an issue sending input to the mercurial and subversion processes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5823
diff changeset
419 @param txt Python string to be converted
56388f41b1e6 Fixed an issue sending input to the mercurial and subversion processes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5823
diff changeset
420 @type str, bytes, bytearray, unicode
5859
28282fa0df7b Corrected some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5848
diff changeset
421 @return converted QByteArray
28282fa0df7b Corrected some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5848
diff changeset
422 @rtype QByteArray
5848
56388f41b1e6 Fixed an issue sending input to the mercurial and subversion processes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5823
diff changeset
423 """
7192
a22eee00b052 Started removing runtime support for Python2 and PyQt4.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7085
diff changeset
424 if isinstance(txt, str):
a22eee00b052 Started removing runtime support for Python2 and PyQt4.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7085
diff changeset
425 txt = txt.encode("utf-8")
5848
56388f41b1e6 Fixed an issue sending input to the mercurial and subversion processes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5823
diff changeset
426
56388f41b1e6 Fixed an issue sending input to the mercurial and subversion processes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5823
diff changeset
427 return QByteArray(txt)
56388f41b1e6 Fixed an issue sending input to the mercurial and subversion processes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5823
diff changeset
428
56388f41b1e6 Fixed an issue sending input to the mercurial and subversion processes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5823
diff changeset
429
6682
4326e802ff56 Globals: added the dataString() function to format a size into a human readable string.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
430 def dataString(size):
4326e802ff56 Globals: added the dataString() function to format a size into a human readable string.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
431 """
4326e802ff56 Globals: added the dataString() function to format a size into a human readable string.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
432 Module function to generate a formatted size string.
4326e802ff56 Globals: added the dataString() function to format a size into a human readable string.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
433
4326e802ff56 Globals: added the dataString() function to format a size into a human readable string.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
434 @param size size to be formatted
4326e802ff56 Globals: added the dataString() function to format a size into a human readable string.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
435 @type int
4326e802ff56 Globals: added the dataString() function to format a size into a human readable string.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
436 @return formatted data string
4326e802ff56 Globals: added the dataString() function to format a size into a human readable string.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
437 @rtype str
4326e802ff56 Globals: added the dataString() function to format a size into a human readable string.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
438 """
4326e802ff56 Globals: added the dataString() function to format a size into a human readable string.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
439 if size < 1024:
4326e802ff56 Globals: added the dataString() function to format a size into a human readable string.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
440 return QCoreApplication.translate(
7085
328f0f44aa95 Globals: changed format of the data size output and added branch for TiB.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
441 "Globals", "{0:4.2f} Bytes").format(size)
6682
4326e802ff56 Globals: added the dataString() function to format a size into a human readable string.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
442 elif size < 1024 * 1024:
4326e802ff56 Globals: added the dataString() function to format a size into a human readable string.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
443 size /= 1024
4326e802ff56 Globals: added the dataString() function to format a size into a human readable string.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
444 return QCoreApplication.translate(
7085
328f0f44aa95 Globals: changed format of the data size output and added branch for TiB.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
445 "Globals", "{0:4.2f} KiB").format(size)
6682
4326e802ff56 Globals: added the dataString() function to format a size into a human readable string.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
446 elif size < 1024 * 1024 * 1024:
4326e802ff56 Globals: added the dataString() function to format a size into a human readable string.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
447 size /= 1024 * 1024
4326e802ff56 Globals: added the dataString() function to format a size into a human readable string.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
448 return QCoreApplication.translate(
7085
328f0f44aa95 Globals: changed format of the data size output and added branch for TiB.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
449 "Globals", "{0:4.2f} MiB").format(size)
328f0f44aa95 Globals: changed format of the data size output and added branch for TiB.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
450 elif size < 1024 * 1024 * 1024 * 1024:
6682
4326e802ff56 Globals: added the dataString() function to format a size into a human readable string.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
451 size /= 1024 * 1024 * 1024
4326e802ff56 Globals: added the dataString() function to format a size into a human readable string.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
452 return QCoreApplication.translate(
7085
328f0f44aa95 Globals: changed format of the data size output and added branch for TiB.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
453 "Globals", "{0:4.2f} GiB").format(size)
328f0f44aa95 Globals: changed format of the data size output and added branch for TiB.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
454 else:
328f0f44aa95 Globals: changed format of the data size output and added branch for TiB.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
455 size /= 1024 * 1024 * 1024 * 1024
328f0f44aa95 Globals: changed format of the data size output and added branch for TiB.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
456 return QCoreApplication.translate(
328f0f44aa95 Globals: changed format of the data size output and added branch for TiB.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
457 "Globals", "{0:4.2f} TiB").format(size)
6682
4326e802ff56 Globals: added the dataString() function to format a size into a human readable string.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
458
4326e802ff56 Globals: added the dataString() function to format a size into a human readable string.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
459
4686
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
460 ###############################################################################
4241
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
461 ## functions for converting QSetting return types to valid types
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
462 ###############################################################################
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
463
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
464
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
465 def toBool(value):
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
466 """
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
467 Module function to convert a value to bool.
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
468
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
469 @param value value to be converted
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
470 @return converted data
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
471 """
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
472 if value in ["true", "1", "True"]:
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
473 return True
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
474 elif value in ["false", "0", "False"]:
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
475 return False
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
476 else:
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
477 return bool(value)
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
478
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
479
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
480 def toList(value):
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
481 """
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
482 Module function to convert a value to a list.
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
483
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
484 @param value value to be converted
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
485 @return converted data
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
486 """
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
487 if value is None:
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
488 return []
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
489 elif not isinstance(value, list):
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
490 return [value]
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
491 else:
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
492 return value
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
493
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
494
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
495 def toByteArray(value):
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
496 """
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
497 Module function to convert a value to a byte array.
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
498
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
499 @param value value to be converted
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
500 @return converted data
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
501 """
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
502 if value is None:
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
503 return QByteArray()
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
504 else:
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
505 return value
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
506
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
507
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
508 def toDict(value):
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
509 """
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
510 Module function to convert a value to a dictionary.
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
511
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
512 @param value value to be converted
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
513 @return converted data
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
514 """
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
515 if value is None:
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
516 return {}
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
517 else:
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
518 return value
4566
a2e8f3c420ec Dealt with the M801 code style checker messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4343
diff changeset
519
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: 6589
diff changeset
520
bddd12f27a4c Web Browser (QtWebKit): applied the changes of the new Web Brwoser to the QtWebKit based variant.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6589
diff changeset
521 ###############################################################################
bddd12f27a4c Web Browser (QtWebKit): applied the changes of the new Web Brwoser to the QtWebKit based variant.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6589
diff changeset
522 ## functions for web browser variant detection
bddd12f27a4c Web Browser (QtWebKit): applied the changes of the new Web Brwoser to the QtWebKit based variant.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6589
diff changeset
523 ###############################################################################
bddd12f27a4c Web Browser (QtWebKit): applied the changes of the new Web Brwoser to the QtWebKit based variant.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6589
diff changeset
524
bddd12f27a4c Web Browser (QtWebKit): applied the changes of the new Web Brwoser to the QtWebKit based variant.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6589
diff changeset
525
bddd12f27a4c Web Browser (QtWebKit): applied the changes of the new Web Brwoser to the QtWebKit based variant.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6589
diff changeset
526 def getWebBrowserSupport():
bddd12f27a4c Web Browser (QtWebKit): applied the changes of the new Web Brwoser to the QtWebKit based variant.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6589
diff changeset
527 """
bddd12f27a4c Web Browser (QtWebKit): applied the changes of the new Web Brwoser to the QtWebKit based variant.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6589
diff changeset
528 Module function to determine the supported web browser variant.
bddd12f27a4c Web Browser (QtWebKit): applied the changes of the new Web Brwoser to the QtWebKit based variant.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6589
diff changeset
529
bddd12f27a4c Web Browser (QtWebKit): applied the changes of the new Web Brwoser to the QtWebKit based variant.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6589
diff changeset
530 @return string indicating the supported web browser variant ("QtWebEngine",
7196
ab0a91b82b37 Removed support for QtWebKit and the old web rowser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7192
diff changeset
531 or "None")
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: 6589
diff changeset
532 @rtype 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: 6589
diff changeset
533 """
bddd12f27a4c Web Browser (QtWebKit): applied the changes of the new Web Brwoser to the QtWebKit based variant.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6589
diff changeset
534 from eric6config import getConfig
bddd12f27a4c Web Browser (QtWebKit): applied the changes of the new Web Brwoser to the QtWebKit based variant.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6589
diff changeset
535 scriptPath = os.path.join(getConfig("ericDir"), "Tools",
bddd12f27a4c Web Browser (QtWebKit): applied the changes of the new Web Brwoser to the QtWebKit based variant.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6589
diff changeset
536 "webBrowserSupport.py")
bddd12f27a4c Web Browser (QtWebKit): applied the changes of the new Web Brwoser to the QtWebKit based variant.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6589
diff changeset
537 proc = QProcess()
bddd12f27a4c Web Browser (QtWebKit): applied the changes of the new Web Brwoser to the QtWebKit based variant.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6589
diff changeset
538 proc.start(sys.executable, [scriptPath, qVersion()])
bddd12f27a4c Web Browser (QtWebKit): applied the changes of the new Web Brwoser to the QtWebKit based variant.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6589
diff changeset
539 if proc.waitForFinished(10000):
bddd12f27a4c Web Browser (QtWebKit): applied the changes of the new Web Brwoser to the QtWebKit based variant.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6589
diff changeset
540 variant = str(proc.readAllStandardOutput(), "utf-8", 'replace').strip()
bddd12f27a4c Web Browser (QtWebKit): applied the changes of the new Web Brwoser to the QtWebKit based variant.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6589
diff changeset
541 else:
bddd12f27a4c Web Browser (QtWebKit): applied the changes of the new Web Brwoser to the QtWebKit based variant.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6589
diff changeset
542 variant = "None"
bddd12f27a4c Web Browser (QtWebKit): applied the changes of the new Web Brwoser to the QtWebKit based variant.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6589
diff changeset
543 return variant
4566
a2e8f3c420ec Dealt with the M801 code style checker messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4343
diff changeset
544 #
a2e8f3c420ec Dealt with the M801 code style checker messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4343
diff changeset
545 # eflag: noqa = M801

eric ide

mercurial