Sat, 09 Jan 2016 19:44:31 +0100
Integrated the hex editor into the eric IDE.
--- a/HexEdit/HexEditMainWindow.py Sat Jan 09 19:04:34 2016 +0100 +++ b/HexEdit/HexEditMainWindow.py Sat Jan 09 19:44:31 2016 +0100 @@ -28,7 +28,6 @@ # TODO: implement a configuration page for the hex editor -# TODO: implement an action in the eric IDE to open a hex editor class HexEditMainWindow(E5MainWindow): """ Class implementing the web browser main window.
--- a/Project/ProjectOthersBrowser.py Sat Jan 09 19:04:34 2016 +0100 +++ b/Project/ProjectOthersBrowser.py Sat Jan 09 19:44:31 2016 +0100 @@ -34,6 +34,7 @@ @signal pixmapFile(str) emitted to open a pixmap file @signal pixmapEditFile(str) emitted to edit a pixmap file @signal svgFile(str) emitted to open a SVG file + @signal binaryFile(str) emitted to open a file as binary @signal closeSourceWindow(str) emitted after a file has been removed/deleted from the project @signal showMenu(str, QMenu) emitted when a menu is about to be shown. @@ -74,6 +75,8 @@ """ ProjectBaseBrowser._createPopupMenus(self) + self.menu.addAction( + self.tr('Open in Hex Editor'), self._openHexEditor) self.editPixmapAct = self.menu.addAction( self.tr('Open in Icon Editor'), self._editPixmap) self.menu.addSeparator() @@ -232,6 +235,16 @@ if itm.isPixmapFile(): self.pixmapEditFile.emit(itm.fileName()) + def _openHexEditor(self): + """ + Protected slot to handle the open in hex editor popup menu entry. + """ + itmList = self.getSelectedItems() + + for itm in itmList: + if isinstance(itm, ProjectBrowserFileItem): + self.binaryFile.emit(itm.fileName()) + def _openItem(self): """ Protected slot to handle the open popup menu entry.
--- a/UI/Browser.py Sat Jan 09 19:04:34 2016 +0100 +++ b/UI/Browser.py Sat Jan 09 19:44:31 2016 +0100 @@ -53,6 +53,7 @@ @signal pixmapFile(str) emitted to open a pixmap file @signal pixmapEditFile(str) emitted to edit a pixmap file @signal svgFile(str) emitted to open a SVG file + @signal binaryFile(str) emitted to open a file as binary @signal unittestOpen(str) emitted to open a Python file for a unittest """ sourceFile = pyqtSignal((str, ), (str, int), (str, list), (str, int, str)) @@ -64,6 +65,7 @@ pixmapFile = pyqtSignal(str) pixmapEditFile = pyqtSignal(str) svgFile = pyqtSignal(str) + binaryFile = pyqtSignal(str) unittestOpen = pyqtSignal(str) def __init__(self, parent=None): @@ -212,6 +214,9 @@ self.menu = QMenu(self) self.menu.addAction( QCoreApplication.translate('Browser', 'Open'), self._openItem) + self.menu.addAction( + QCoreApplication.translate('Browser', 'Open in Hex Editor'), + self._openHexEditor) self.editPixmapAct = self.menu.addAction( QCoreApplication.translate('Browser', 'Open in Icon Editor'), self._editPixmap) @@ -517,6 +522,16 @@ if itm.isPixmapFile(): self.pixmapEditFile.emit(itm.fileName()) + def _openHexEditor(self): + """ + Protected slot to handle the open in hex editor popup menu entry. + """ + itmList = self.getSelectedItems([BrowserFileItem]) + + for itm in itmList: + if isinstance(itm, BrowserFileItem): + self.binaryFile.emit(itm.fileName()) + def _copyToClipboard(self): """ Protected method to copy the text shown for an entry to the clipboard.
--- a/UI/UserInterface.py Sat Jan 09 19:04:34 2016 +0100 +++ b/UI/UserInterface.py Sat Jan 09 19:44:31 2016 +0100 @@ -278,6 +278,7 @@ self.browser.pixmapEditFile.connect(self.__editPixmap) self.browser.pixmapFile.connect(self.__showPixmap) self.browser.svgFile.connect(self.__showSvg) + self.browser.binaryFile.connect(self.__openHexEditor) self.browser.unittestOpen.connect(self.__unittestScript) self.browser.trpreview.connect(self.__TRPreviewer) @@ -344,6 +345,7 @@ self.projectBrowser.poBrowser.pixmapEditFile.connect(self.__editPixmap) self.projectBrowser.poBrowser.pixmapFile.connect(self.__showPixmap) self.projectBrowser.poBrowser.svgFile.connect(self.__showSvg) + self.projectBrowser.poBrowser.binaryFile.connect(self.__openHexEditor) self.project.sourceFile.connect(self.viewmanager.openSourceFile) self.project.projectOpened.connect(self.viewmanager.projectOpened) @@ -1908,6 +1910,20 @@ self.miniEditorAct.triggered.connect(self.__openMiniEditor) self.actions.append(self.miniEditorAct) + self.hexEditorAct = E5Action( + self.tr('Hex Editor'), + UI.PixmapCache.getIcon("hexEditor.png"), + self.tr('&Hex Editor...'), + 0, 0, self, 'hex_editor') + self.hexEditorAct.setStatusTip(self.tr( + 'Start the eric6 Hex Editor')) + self.hexEditorAct.setWhatsThis(self.tr( + """<b>Hex Editor</b>""" + """<p>Starts the eric6 Hex Editor for editing binary files.</p>""" + )) + self.hexEditorAct.triggered.connect(self.__openHexEditor) + self.actions.append(self.hexEditorAct) + if WEBKIT_AVAILABLE: self.webBrowserAct = E5Action( self.tr('eric6 Web Browser'), @@ -2645,6 +2661,7 @@ toolstb.addAction(self.sqlBrowserAct) toolstb.addSeparator() toolstb.addAction(self.miniEditorAct) + toolstb.addAction(self.hexEditorAct) toolstb.addAction(self.iconEditorAct) toolstb.addAction(self.snapshotAct) if self.webBrowserAct: @@ -3347,6 +3364,7 @@ btMenu.addAction(self.compareAct) btMenu.addAction(self.sqlBrowserAct) btMenu.addAction(self.miniEditorAct) + btMenu.addAction(self.hexEditorAct) btMenu.addAction(self.iconEditorAct) btMenu.addAction(self.snapshotAct) if self.webBrowserAct: @@ -4554,6 +4572,18 @@ @pyqtSlot() @pyqtSlot(str) + def __openHexEditor(self, fn=""): + """ + Private slot to open the hex editor window. + + @param fn filename of the file to show (string) + """ + from HexEdit.HexEditMainWindow import HexEditMainWindow + dlg = HexEditMainWindow(fn, self, fromEric=True, project=self.project) + dlg.show() + + @pyqtSlot() + @pyqtSlot(str) def __editPixmap(self, fn=""): """ Private slot to show a pixmap in a dialog.