Wed, 27 Mar 2013 13:23:59 +0100
Changed handling of the ViewProfiles settings to get rid of obsolete entries and make it suitable for the Python2 compatibility changes.
--- a/APIs/Python3/eric5.api Mon Mar 25 18:27:06 2013 +0100 +++ b/APIs/Python3/eric5.api Wed Mar 27 13:23:59 2013 +0100 @@ -5907,8 +5907,8 @@ eric5.Preferences.ToolGroupConfigurationDialog.ToolGroupConfigurationDialog.on_newButton_clicked?4() eric5.Preferences.ToolGroupConfigurationDialog.ToolGroupConfigurationDialog.on_upButton_clicked?4() eric5.Preferences.ToolGroupConfigurationDialog.ToolGroupConfigurationDialog?1(toolGroups, currentGroup, parent=None) -eric5.Preferences.ViewProfileDialog.ViewProfileDialog.getProfiles?4() -eric5.Preferences.ViewProfileDialog.ViewProfileDialog?1(layout, profiles, separateShell, separateBrowser, parent=None) +eric5.Preferences.ViewProfileDialog.ViewProfileDialog.getVisibilities?4() +eric5.Preferences.ViewProfileDialog.ViewProfileDialog?1(layout, editVisibilities, debugVisibilities, parent=None) eric5.Preferences.convertPasswords?4(oldPassword, newPassword, prefClass=Prefs) eric5.Preferences.exportPreferences?4(prefClass=Prefs) eric5.Preferences.getCooperation?4(key, prefClass=Prefs)
--- a/Documentation/Help/source.qhp Mon Mar 25 18:27:06 2013 +0100 +++ b/Documentation/Help/source.qhp Wed Mar 27 13:23:59 2013 +0100 @@ -11968,7 +11968,7 @@ <keyword name="ViewProfileDialog" id="ViewProfileDialog" ref="eric5.Preferences.ViewProfileDialog.html#ViewProfileDialog" /> <keyword name="ViewProfileDialog (Constructor)" id="ViewProfileDialog (Constructor)" ref="eric5.Preferences.ViewProfileDialog.html#ViewProfileDialog.__init__" /> <keyword name="ViewProfileDialog (Module)" id="ViewProfileDialog (Module)" ref="eric5.Preferences.ViewProfileDialog.html" /> - <keyword name="ViewProfileDialog.getProfiles" id="ViewProfileDialog.getProfiles" ref="eric5.Preferences.ViewProfileDialog.html#ViewProfileDialog.getProfiles" /> + <keyword name="ViewProfileDialog.getVisibilities" id="ViewProfileDialog.getVisibilities" ref="eric5.Preferences.ViewProfileDialog.html#ViewProfileDialog.getVisibilities" /> <keyword name="ViewmanagerPage" id="ViewmanagerPage" ref="eric5.Preferences.ConfigurationPages.ViewmanagerPage.html#ViewmanagerPage" /> <keyword name="ViewmanagerPage (Constructor)" id="ViewmanagerPage (Constructor)" ref="eric5.Preferences.ConfigurationPages.ViewmanagerPage.html#ViewmanagerPage.__init__" /> <keyword name="ViewmanagerPage (Module)" id="ViewmanagerPage (Module)" ref="eric5.Preferences.ConfigurationPages.ViewmanagerPage.html" />
--- a/Documentation/Source/eric5.Preferences.ViewProfileDialog.html Mon Mar 25 18:27:06 2013 +0100 +++ b/Documentation/Source/eric5.Preferences.ViewProfileDialog.html Wed Mar 27 13:23:59 2013 +0100 @@ -60,8 +60,8 @@ <td><a href="#ViewProfileDialog.__init__">ViewProfileDialog</a></td> <td>Constructor</td> </tr><tr> -<td><a href="#ViewProfileDialog.getProfiles">getProfiles</a></td> -<td>Public method to retrieve the configured profiles.</td> +<td><a href="#ViewProfileDialog.getVisibilities">getVisibilities</a></td> +<td>Public method to retrieve the visibilities configuration.</td> </tr> </table> <h3>Static Methods</h3> @@ -70,39 +70,35 @@ </table> <a NAME="ViewProfileDialog.__init__" ID="ViewProfileDialog.__init__"></a> <h4>ViewProfileDialog (Constructor)</h4> -<b>ViewProfileDialog</b>(<i>layout, profiles, separateShell, separateBrowser, parent=None</i>) +<b>ViewProfileDialog</b>(<i>layout, editVisibilities, debugVisibilities, parent=None</i>) <p> Constructor </p><dl> <dt><i>layout</i></dt> <dd> type of the window layout (string) -</dd><dt><i>profiles</i></dt> -<dd> -dictionary of tuples containing the visibility - of the windows for the various profiles -</dd><dt><i>separateShell</i></dt> +</dd><dt><i>editVisibilities</i></dt> <dd> -flag indicating that the Python shell - is a separate window (boolean) -</dd><dt><i>separateBrowser</i></dt> +list of flags giving the visibilities + of the various parts for the 'edit' view profile (list of boolean) +</dd><dt><i>debugVisibilities</i></dt> <dd> -flag indicating that the file browser - is a separate window (boolean) +list of flags giving the visibilities + of the various parts for the 'debug' view profile (list of boolean) </dd><dt><i>parent</i></dt> <dd> parent widget of this dialog (QWidget) </dd> -</dl><a NAME="ViewProfileDialog.getProfiles" ID="ViewProfileDialog.getProfiles"></a> -<h4>ViewProfileDialog.getProfiles</h4> -<b>getProfiles</b>(<i></i>) +</dl><a NAME="ViewProfileDialog.getVisibilities" ID="ViewProfileDialog.getVisibilities"></a> +<h4>ViewProfileDialog.getVisibilities</h4> +<b>getVisibilities</b>(<i></i>) <p> - Public method to retrieve the configured profiles. + Public method to retrieve the visibilities configuration. </p><dl> <dt>Returns:</dt> <dd> -dictionary of tuples containing the visibility - of the windows for the various profiles +tuple of two lists giving the visibilities of the + various parts ( two lists of boolean) </dd> </dl> <div align="right"><a href="#top">Up</a></div>
--- a/Preferences/ViewProfileDialog.py Mon Mar 25 18:27:06 2013 +0100 +++ b/Preferences/ViewProfileDialog.py Wed Mar 27 13:23:59 2013 +0100 @@ -17,17 +17,15 @@ """ Class implementing a dialog to configure the various view profiles. """ - def __init__(self, layout, profiles, separateShell, separateBrowser, parent=None): + def __init__(self, layout, editVisibilities, debugVisibilities, parent=None): """ Constructor @param layout type of the window layout (string) - @param profiles dictionary of tuples containing the visibility - of the windows for the various profiles - @param separateShell flag indicating that the Python shell - is a separate window (boolean) - @param separateBrowser flag indicating that the file browser - is a separate window (boolean) + @param editVisibilities list of flags giving the visibilities + of the various parts for the 'edit' view profile (list of boolean) + @param debugVisibilities list of flags giving the visibilities + of the various parts for the 'debug' view profile (list of boolean) @param parent parent widget of this dialog (QWidget) """ super().__init__(parent) @@ -41,40 +39,36 @@ raise ValueError("Illegal layout given ({0}).".format(self.__layout)) self.ui.setupUi(self) - self.profiles = profiles - if self.__layout in ["Toolboxes", "Sidebars"]: # set the edit profile - profile = self.profiles["edit"][5] - self.ui.epltCheckBox.setChecked(profile[0]) - self.ui.ephtCheckBox.setChecked(profile[1]) - self.ui.eprtCheckBox.setChecked(profile[2]) + self.ui.epltCheckBox.setChecked(editVisibilities[0]) + self.ui.ephtCheckBox.setChecked(editVisibilities[1]) + self.ui.eprtCheckBox.setChecked(editVisibilities[2]) # set the debug profile - profile = self.profiles["debug"][5] - self.ui.dpltCheckBox.setChecked(profile[0]) - self.ui.dphtCheckBox.setChecked(profile[1]) - self.ui.dprtCheckBox.setChecked(profile[2]) + self.ui.dpltCheckBox.setChecked(debugVisibilities[0]) + self.ui.dphtCheckBox.setChecked(debugVisibilities[1]) + self.ui.dprtCheckBox.setChecked(debugVisibilities[2]) - def getProfiles(self): + def getVisibilities(self): """ - Public method to retrieve the configured profiles. + Public method to retrieve the visibilities configuration. - @return dictionary of tuples containing the visibility - of the windows for the various profiles + @return tuple of two lists giving the visibilities of the + various parts ( two lists of boolean) """ if self.__layout in ["Toolboxes", "Sidebars"]: - # get the edit profile - self.profiles["edit"][5] = [ - self.ui.epltCheckBox.isChecked(), - self.ui.ephtCheckBox.isChecked(), - self.ui.eprtCheckBox.isChecked(), - ] - # get the debug profile - self.profiles["debug"][5] = [ - self.ui.dpltCheckBox.isChecked(), - self.ui.dphtCheckBox.isChecked(), - self.ui.dprtCheckBox.isChecked(), - ] - - return self.profiles + return ( + # edit profile + [ + self.ui.epltCheckBox.isChecked(), + self.ui.ephtCheckBox.isChecked(), + self.ui.eprtCheckBox.isChecked(), + ], + # debug profile + [ + self.ui.dpltCheckBox.isChecked(), + self.ui.dphtCheckBox.isChecked(), + self.ui.dprtCheckBox.isChecked(), + ] + )
--- a/Preferences/__init__.py Mon Mar 25 18:27:06 2013 +0100 +++ b/Preferences/__init__.py Wed Mar 27 13:23:59 2013 +0100 @@ -19,6 +19,7 @@ import os import fnmatch import shutil +import json from PyQt4.QtCore import QDir, QPoint, QLocale, QSettings, QFileInfo, QCoreApplication, \ QByteArray, QSize, QUrl, Qt, QLibraryInfo @@ -129,7 +130,7 @@ # Numbers "ViewProfiles": { "edit": [ - # visibility (0) + # visibility (0) OBSOLETE [True, False, False, True, True, True, True, True, True, True, True, True], # saved state main window with dock windows (1) OBSOLETE @@ -150,7 +151,7 @@ [b"", b"", b"", b"", b"", b""], ], "debug": [ - # visibility (0) + # visibility (0) OBSOLETE [False, False, True, True, True, True, False, False, True, False, False, False], # saved state main window with dock windows (1) OBSOLETE @@ -171,6 +172,32 @@ [b"", b"", b"", b"", b"", b""], ], }, + "ViewProfiles2": { + "edit": [ + # saved state main window with toolbox windows (0) + QByteArray(), + # visibility of the toolboxes/sidebars (1) + # left, bottom, right + [True, True, True], + # saved states of the splitters and sidebars of the + # sidebars layout (2) + # left splitter, vertical splitter, left sidebar, bottom sidebar, + # right splitter, right sidebar + [QByteArray(), QByteArray(), QByteArray(), + QByteArray(), QByteArray(), QByteArray()], + ], + "debug": [ + # saved state main window with toolbox windows (0) + QByteArray(), + # visibility of the toolboxes/sidebars (1) + # left, bottom, right + [False, True, True], + # saved states of the splitters and sidebars of the + # sidebars layout (2) + # left splitter, vertical splitter, left sidebar, bottom sidebar, + # right splitter, right sidebar + ], + }, "ToolbarManagerState": QByteArray(), "PreviewSplitterState": QByteArray(), "ShowSplash": True, @@ -1433,6 +1460,39 @@ else: viewProfiles = prefClass.uiDefaults["ViewProfiles"] return viewProfiles + elif key in "ViewProfiles2": + profiles = prefClass.settings.value("UI/ViewProfiles2") + if profiles is not None: + viewProfiles = {} + profiles = json.loads(profiles) + for name in ["edit", "debug"]: + viewProfiles[name] = [ + QByteArray.fromBase64(profiles[name][0].encode()), + profiles[name][1][:], + [] + ] + for bs in profiles[name][2]: + viewProfiles[name][2].append(QByteArray.fromBase64(bs.encode())) + else: + # migrate from the old ViewProfiles settings + try: + profiles = prefClass.settings.value("UI/ViewProfiles") + except TypeError: + profiles = None + if profiles is not None: + viewProfiles = {} + for name in ["edit", "debug"]: + viewProfiles[name] = [ + QByteArray(profiles[name][4]), + profiles[name][5][:], + [] + ] + for b in profiles[name][6]: + viewProfiles[name][2].append(QByteArray(b)) + else: + # use the defaults + viewProfiles = prefClass.uiDefaults["ViewProfiles2"] + return viewProfiles elif key in ["ToolbarManagerState", "PreviewSplitterState"]: state = prefClass.settings.value("UI/" + key) if state is not None: @@ -1459,6 +1519,17 @@ """ if key == "ViewProfiles": prefClass.settings.setValue("UI/" + key, value) + elif key == "ViewProfiles2": + profiles = {} + for name in ["edit", "debug"]: + profiles[name] = [ + bytes(value[name][0].toBase64()).decode(), + value[name][1][:], + [] + ] + for ba in value[name][2]: + profiles[name][2].append(bytes(ba.toBase64()).decode()) + prefClass.settings.setValue("UI/" + key, json.dumps(profiles)) elif key == "LogStdErrColour": prefClass.settings.setValue("UI/" + key, value.name()) elif key in ["ProxyPassword/Http", "ProxyPassword/Https",
--- a/UI/UserInterface.py Mon Mar 25 18:27:06 2013 +0100 +++ b/UI/UserInterface.py Wed Mar 27 13:23:59 2013 +0100 @@ -12,7 +12,7 @@ import logging from PyQt4.QtCore import QTimer, QFile, QFileInfo, pyqtSignal, PYQT_VERSION_STR, QDate, \ - QIODevice, QByteArray, qVersion, QProcess, QSize, QUrl, QObject, Qt + QIODevice, qVersion, QProcess, QSize, QUrl, QObject, Qt from PyQt4.QtGui import QSizePolicy, QWidget, QKeySequence, QDesktopServices, \ QWhatsThis, QToolBar, QDialog, QSplitter, QApplication, QMenu, QProgressDialog, \ QVBoxLayout, QDockWidget, QAction, QLabel @@ -181,7 +181,7 @@ self.__setWindowCaption() # load the view profiles - self.profiles = Preferences.getUI("ViewProfiles") + self.profiles = Preferences.getUI("ViewProfiles2") # Generate the debug server object from Debugger.DebugServer import DebugServer @@ -3134,30 +3134,30 @@ # step 1: save the window geometries of the active profile if self.layout in ["Toolboxes", "Sidebars"]: state = self.saveState() - self.profiles[self.currentProfile][4] = bytes(state) + self.profiles[self.currentProfile][0] = state if self.layout == "Sidebars": state = self.leftSplitter.saveState() - self.profiles[self.currentProfile][6][0] = bytes(state) + self.profiles[self.currentProfile][2][0] = state state = self.verticalSplitter.saveState() - self.profiles[self.currentProfile][6][1] = bytes(state) + self.profiles[self.currentProfile][2][1] = state state = self.leftSidebar.saveState() - self.profiles[self.currentProfile][6][2] = bytes(state) + self.profiles[self.currentProfile][2][2] = state state = self.bottomSidebar.saveState() - self.profiles[self.currentProfile][6][3] = bytes(state) + self.profiles[self.currentProfile][2][3] = state state = self.rightSplitter.saveState() - self.profiles[self.currentProfile][6][4] = bytes(state) + self.profiles[self.currentProfile][2][4] = state state = self.rightSidebar.saveState() - self.profiles[self.currentProfile][6][5] = bytes(state) + self.profiles[self.currentProfile][2][5] = state # step 2: save the visibility of the windows of the active profile if self.layout == "Toolboxes": - self.profiles[self.currentProfile][5][0] = self.lToolboxDock.isVisible() - self.profiles[self.currentProfile][5][1] = self.hToolboxDock.isVisible() - self.profiles[self.currentProfile][5][2] = self.rToolboxDock.isVisible() + self.profiles[self.currentProfile][1][0] = self.lToolboxDock.isVisible() + self.profiles[self.currentProfile][1][1] = self.hToolboxDock.isVisible() + self.profiles[self.currentProfile][1][2] = self.rToolboxDock.isVisible() elif self.layout == "Sidebars": - self.profiles[self.currentProfile][5][0] = self.leftSidebar.isVisible() - self.profiles[self.currentProfile][5][1] = self.bottomSidebar.isVisible() - self.profiles[self.currentProfile][5][2] = self.rightSidebar.isVisible() - Preferences.setUI("ViewProfiles", self.profiles) + self.profiles[self.currentProfile][1][0] = self.leftSidebar.isVisible() + self.profiles[self.currentProfile][1][1] = self.bottomSidebar.isVisible() + self.profiles[self.currentProfile][1][2] = self.rightSidebar.isVisible() + Preferences.setUI("ViewProfiles2", self.profiles) def __activateViewProfile(self, name, save=True): """ @@ -3173,39 +3173,39 @@ # step 2: set the window geometries of the new profile if self.layout in ["Toolboxes", "Sidebars"]: - state = QByteArray(self.profiles[name][4]) + state = self.profiles[name][0] if not state.isEmpty(): self.restoreState(state) if self.layout == "Sidebars": - state = QByteArray(self.profiles[name][6][0]) + state = self.profiles[name][2][0] if not state.isEmpty(): self.leftSplitter.restoreState(state) - state = QByteArray(self.profiles[name][6][1]) + state = self.profiles[name][2][1] if not state.isEmpty(): self.verticalSplitter.restoreState(state) - state = QByteArray(self.profiles[name][6][2]) + state = self.profiles[name][2][2] if not state.isEmpty(): self.leftSidebar.restoreState(state) - state = QByteArray(self.profiles[name][6][3]) + state = self.profiles[name][2][3] if not state.isEmpty(): self.bottomSidebar.restoreState(state) - state = QByteArray(self.profiles[name][6][4]) + state = self.profiles[name][2][4] if not state.isEmpty(): self.rightSplitter.restoreState(state) - state = QByteArray(self.profiles[name][6][5]) + state = self.profiles[name][2][5] if not state.isEmpty(): self.rightSidebar.restoreState(state) self.__configureDockareaCornerUsage() # step 3: activate the windows of the new profile if self.layout == "Toolboxes": - self.lToolboxDock.setVisible(self.profiles[name][5][0]) - self.hToolboxDock.setVisible(self.profiles[name][5][1]) - self.rToolboxDock.setVisible(self.profiles[name][5][2]) + self.lToolboxDock.setVisible(self.profiles[name][1][0]) + self.hToolboxDock.setVisible(self.profiles[name][1][1]) + self.rToolboxDock.setVisible(self.profiles[name][1][2]) elif self.layout == "Sidebars": - self.leftSidebar.setVisible(self.profiles[name][5][0]) - self.bottomSidebar.setVisible(self.profiles[name][5][1]) - self.rightSidebar.setVisible(self.profiles[name][5][2]) + self.leftSidebar.setVisible(self.profiles[name][1][0]) + self.bottomSidebar.setVisible(self.profiles[name][1][1]) + self.rightSidebar.setVisible(self.profiles[name][1][2]) # step 4: remember the new profile self.currentProfile = name @@ -4727,11 +4727,13 @@ Private slot to configure the various view profiles. """ from Preferences.ViewProfileDialog import ViewProfileDialog - dlg = ViewProfileDialog(self.layout, self.profiles, - not self.embeddedShell, not self.embeddedFileBrowser) + dlg = ViewProfileDialog(self.layout, + self.profiles['edit'][1], self.profiles['debug'][1]) if dlg.exec_() == QDialog.Accepted: - self.profiles = dlg.getProfiles() - Preferences.setUI("ViewProfiles", self.profiles) + edit, debug = dlg.getVisibilities() + self.profiles['edit'][1] = edit + self.profiles['debug'][1] = debug + Preferences.setUI("ViewProfiles2", self.profiles) if self.currentProfile == "edit": self.__setEditProfile(False) elif self.currentProfile == "debug":