Sun, 10 Jan 2016 18:03:35 +0100
Fixed a few bugs in the hex editor and added capability to save/restore the main window state.
HexEdit/HexEditMainWindow.py | file | annotate | diff | comparison | revisions | |
Preferences/__init__.py | file | annotate | diff | comparison | revisions |
--- a/HexEdit/HexEditMainWindow.py Sun Jan 10 17:16:20 2016 +0100 +++ b/HexEdit/HexEditMainWindow.py Sun Jan 10 18:03:35 2016 +0100 @@ -88,11 +88,15 @@ self.__class__.windows.append(self) + state = Preferences.getHexEditor("HexEditorState") + self.restoreState(state) + self.__editor.currentAddressChanged.connect(self.__showAddress) self.__editor.currentSizeChanged.connect(self.__showSize) self.__editor.dataChanged.connect(self.__modificationChanged) self.__editor.overwriteModeChanged.connect(self.__showEditMode) self.__editor.readOnlyChanged.connect(self.__showReadOnlyMode) + self.__editor.readOnlyChanged.connect(self.__modificationChanged) self.__project = project self.__lastOpenPath = "" @@ -415,6 +419,7 @@ )) self.readonlyAct.setChecked(False) self.readonlyAct.toggled[bool].connect(self.__editor.setReadOnly) + self.__editor.readOnlyChanged.connect(self.readonlyAct.setChecked) self.__actions.append(self.readonlyAct) self.searchAct = E5Action( @@ -731,6 +736,9 @@ @type QCloseEvent """ if self.__maybeSave(): + state = self.saveState() + Preferences.setHexEditor("HexEditorState", state) + Preferences.setGeometry("HexEditorGeometry", self.saveGeometry()) try: @@ -1075,6 +1083,7 @@ self.cutAct.setEnabled(not self.__editor.isReadOnly() and self.__editor.hasSelection()) self.pasteAct.setEnabled(not self.__editor.isReadOnly()) + self.replaceAct.setEnabled(not self.__editor.isReadOnly()) @pyqtSlot(bool) def __modificationChanged(self, m):
--- a/Preferences/__init__.py Sun Jan 10 17:16:20 2016 +0100 +++ b/Preferences/__init__.py Sun Jan 10 18:03:35 2016 +0100 @@ -1188,6 +1188,11 @@ "AskOnShutdown": True, } + + # defaults for Hex Editor + hexEditorDefaults = { + "HexEditorState": QByteArray(), + } def readToolGroups(prefClass=Prefs): @@ -2942,6 +2947,29 @@ @param prefClass preferences class used as the storage area """ prefClass.settings.setValue("IRC/" + key, value) + + +def getHexEditor(key, prefClass=Prefs): + """ + Module function to retrieve the Hex Editor related settings. + + @param key the key of the value to get + @param prefClass preferences class used as the storage area + @return the requested user setting + """ + return prefClass.settings.value( + "HexEditor/" + key, prefClass.hexEditorDefaults[key]) + + +def setHexEditor(key, value, prefClass=Prefs): + """ + Module function to store the Hex Editor related settings. + + @param key the key of the setting to be set + @param value the value to be set + @param prefClass preferences class used as the storage area + """ + prefClass.settings.setValue("HexEditor/" + key, value) def getGeometry(key, prefClass=Prefs):