Preferences/__init__.py

branch
Py2 comp.
changeset 2550
e15087ddb41e
parent 2538
b2642e7a4c18
child 2552
1e893ea4e366
equal deleted inserted replaced
2547:bd6070462f4c 2550:e15087ddb41e
19 from __future__ import unicode_literals # __IGNORE_WARNING__ 19 from __future__ import unicode_literals # __IGNORE_WARNING__
20 20
21 import os 21 import os
22 import fnmatch 22 import fnmatch
23 import shutil 23 import shutil
24 import json
25 import sys
24 26
25 from PyQt4.QtCore import QDir, QPoint, QLocale, QSettings, QFileInfo, QCoreApplication, \ 27 from PyQt4.QtCore import QDir, QPoint, QLocale, QSettings, QFileInfo, QCoreApplication, \
26 QByteArray, QSize, QUrl, Qt, QLibraryInfo 28 QByteArray, QSize, QUrl, Qt, QLibraryInfo
27 from PyQt4.QtGui import QColor, QFont, QInputDialog, QPalette, QApplication 29 from PyQt4.QtGui import QColor, QFont, QInputDialog, QPalette, QApplication
28 from PyQt4.QtNetwork import QNetworkRequest 30 from PyQt4.QtNetwork import QNetworkRequest
129 # Debug-Viewer, Python-Shell, Log-Viewer, Task-Viewer, 131 # Debug-Viewer, Python-Shell, Log-Viewer, Task-Viewer,
130 # Templates-Viewer, Multiproject-Viewer, Terminal, Chat, Symbols, 132 # Templates-Viewer, Multiproject-Viewer, Terminal, Chat, Symbols,
131 # Numbers 133 # Numbers
132 "ViewProfiles": { 134 "ViewProfiles": {
133 "edit": [ 135 "edit": [
134 # visibility (0) 136 # visibility (0) OBSOLETE
135 [True, False, False, True, True, True, True, True, 137 [True, False, False, True, True, True, True, True,
136 True, True, True, True], 138 True, True, True, True],
137 # saved state main window with dock windows (1) OBSOLETE 139 # saved state main window with dock windows (1) OBSOLETE
138 b"", 140 b"",
139 # saved states floating windows (2) OBSOLETE 141 # saved states floating windows (2) OBSOLETE
150 # left splitter, vertical splitter, left sidebar, bottom sidebar, 152 # left splitter, vertical splitter, left sidebar, bottom sidebar,
151 # right splitter, right sidebar 153 # right splitter, right sidebar
152 [b"", b"", b"", b"", b"", b""], 154 [b"", b"", b"", b"", b"", b""],
153 ], 155 ],
154 "debug": [ 156 "debug": [
155 # visibility (0) 157 # visibility (0) OBSOLETE
156 [False, False, True, True, True, True, False, False, 158 [False, False, True, True, True, True, False, False,
157 True, False, False, False], 159 True, False, False, False],
158 # saved state main window with dock windows (1) OBSOLETE 160 # saved state main window with dock windows (1) OBSOLETE
159 b"", 161 b"",
160 # saved states floating windows (2) OBSOLETE 162 # saved states floating windows (2) OBSOLETE
169 # saved states of the splitters and sidebars of the 171 # saved states of the splitters and sidebars of the
170 # sidebars layout (6) 172 # sidebars layout (6)
171 # left splitter, vertical splitter, left sidebar, bottom sidebar, 173 # left splitter, vertical splitter, left sidebar, bottom sidebar,
172 # right splitter, right sidebar 174 # right splitter, right sidebar
173 [b"", b"", b"", b"", b"", b""], 175 [b"", b"", b"", b"", b"", b""],
176 ],
177 },
178 "ViewProfiles2": {
179 "edit": [
180 # saved state main window with toolbox windows (0)
181 QByteArray(),
182 # visibility of the toolboxes/sidebars (1)
183 # left, bottom, right
184 [True, True, True],
185 # saved states of the splitters and sidebars of the
186 # sidebars layout (2)
187 # left splitter, vertical splitter, left sidebar, bottom sidebar,
188 # right splitter, right sidebar
189 [QByteArray(), QByteArray(), QByteArray(),
190 QByteArray(), QByteArray(), QByteArray()],
191 ],
192 "debug": [
193 # saved state main window with toolbox windows (0)
194 QByteArray(),
195 # visibility of the toolboxes/sidebars (1)
196 # left, bottom, right
197 [False, True, True],
198 # saved states of the splitters and sidebars of the
199 # sidebars layout (2)
200 # left splitter, vertical splitter, left sidebar, bottom sidebar,
201 # right splitter, right sidebar
202 [QByteArray(), QByteArray(), QByteArray(),
203 QByteArray(), QByteArray(), QByteArray()],
174 ], 204 ],
175 }, 205 },
176 "ToolbarManagerState": QByteArray(), 206 "ToolbarManagerState": QByteArray(),
177 "PreviewSplitterState": QByteArray(), 207 "PreviewSplitterState": QByteArray(),
178 "ShowSplash": True, 208 "ShowSplash": True,
1433 viewProfiles[name][6].extend( 1463 viewProfiles[name][6].extend(
1434 prefClass.uiDefaults["ViewProfiles"][name][6][vpLength:]) 1464 prefClass.uiDefaults["ViewProfiles"][name][6][vpLength:])
1435 else: 1465 else:
1436 viewProfiles = prefClass.uiDefaults["ViewProfiles"] 1466 viewProfiles = prefClass.uiDefaults["ViewProfiles"]
1437 return viewProfiles 1467 return viewProfiles
1468 elif key in "ViewProfiles2":
1469 profiles = prefClass.settings.value("UI/ViewProfiles2")
1470 if profiles is not None:
1471 viewProfiles = {}
1472 profiles = json.loads(profiles)
1473 for name in ["edit", "debug"]:
1474 viewProfiles[name] = [
1475 QByteArray.fromBase64(profiles[name][0].encode()),
1476 profiles[name][1][:],
1477 []
1478 ]
1479 for bs in profiles[name][2]:
1480 viewProfiles[name][2].append(QByteArray.fromBase64(bs.encode()))
1481 else:
1482 # migrate from the old ViewProfiles settings
1483 try:
1484 profiles = prefClass.settings.value("UI/ViewProfiles")
1485 except TypeError:
1486 profiles = None
1487 if profiles is not None:
1488 viewProfiles = {}
1489 for name in ["edit", "debug"]:
1490 viewProfiles[name] = [
1491 QByteArray(profiles[name][4]),
1492 profiles[name][5][:],
1493 []
1494 ]
1495 for b in profiles[name][6]:
1496 viewProfiles[name][2].append(QByteArray(b))
1497 else:
1498 # use the defaults
1499 viewProfiles = prefClass.uiDefaults["ViewProfiles2"]
1500 # Remove unused setting in Python 2. Otherwise Eric 5.3 would get problems
1501 if sys.version_info[0] == 2:
1502 prefClass.settings.remove("UI/ViewProfiles")
1503 return viewProfiles
1438 elif key in ["ToolbarManagerState", "PreviewSplitterState"]: 1504 elif key in ["ToolbarManagerState", "PreviewSplitterState"]:
1439 state = prefClass.settings.value("UI/" + key) 1505 state = prefClass.settings.value("UI/" + key)
1440 if state is not None: 1506 if state is not None:
1441 return state 1507 return state
1442 else: 1508 else:
1459 @param value the value to be set 1525 @param value the value to be set
1460 @param prefClass preferences class used as the storage area 1526 @param prefClass preferences class used as the storage area
1461 """ 1527 """
1462 if key == "ViewProfiles": 1528 if key == "ViewProfiles":
1463 prefClass.settings.setValue("UI/" + key, value) 1529 prefClass.settings.setValue("UI/" + key, value)
1530 elif key == "ViewProfiles2":
1531 profiles = {}
1532 for name in ["edit", "debug"]:
1533 profiles[name] = [
1534 bytes(value[name][0].toBase64()).decode(),
1535 value[name][1][:],
1536 []
1537 ]
1538 for ba in value[name][2]:
1539 profiles[name][2].append(bytes(ba.toBase64()).decode())
1540 prefClass.settings.setValue("UI/" + key, json.dumps(profiles))
1464 elif key == "LogStdErrColour": 1541 elif key == "LogStdErrColour":
1465 prefClass.settings.setValue("UI/" + key, value.name()) 1542 prefClass.settings.setValue("UI/" + key, value.name())
1466 elif key in ["ProxyPassword/Http", "ProxyPassword/Https", 1543 elif key in ["ProxyPassword/Http", "ProxyPassword/Https",
1467 "ProxyPassword/Ftp", ]: 1544 "ProxyPassword/Ftp", ]:
1468 from Utilities.crypto import pwConvert 1545 from Utilities.crypto import pwConvert

eric ide

mercurial