11 |
11 |
12 import os |
12 import os |
13 |
13 |
14 from PyQt5.QtCore import pyqtSignal, pyqtSlot, QFile, QFileInfo, QSize |
14 from PyQt5.QtCore import pyqtSignal, pyqtSlot, QFile, QFileInfo, QSize |
15 from PyQt5.QtGui import QKeySequence |
15 from PyQt5.QtGui import QKeySequence |
16 from PyQt5.QtWidgets import QWhatsThis, QLabel |
16 from PyQt5.QtWidgets import QWhatsThis, QLabel, QWidget, QVBoxLayout |
17 |
17 |
18 from E5Gui.E5Action import E5Action |
18 from E5Gui.E5Action import E5Action |
19 from E5Gui.E5MainWindow import E5MainWindow |
19 from E5Gui.E5MainWindow import E5MainWindow |
20 from E5Gui import E5FileDialog, E5MessageBox |
20 from E5Gui import E5FileDialog, E5MessageBox |
21 |
21 |
22 from .HexEditWidget import HexEditWidget |
22 from .HexEditWidget import HexEditWidget |
|
23 from .HexEditSearchReplaceWidget import HexEditSearchReplaceWidget |
23 |
24 |
24 import UI.PixmapCache |
25 import UI.PixmapCache |
25 import UI.Config |
26 import UI.Config |
26 |
27 |
27 import Preferences |
28 import Preferences |
57 if not self.fromEric: |
58 if not self.fromEric: |
58 self.setStyle(Preferences.getUI("Style"), |
59 self.setStyle(Preferences.getUI("Style"), |
59 Preferences.getUI("StyleSheet")) |
60 Preferences.getUI("StyleSheet")) |
60 |
61 |
61 self.__editor = HexEditWidget() |
62 self.__editor = HexEditWidget() |
62 self.setCentralWidget(self.__editor) |
63 self.__searchWidget = HexEditSearchReplaceWidget(self.__editor, False) |
|
64 self.__replaceWidget = HexEditSearchReplaceWidget(self.__editor, True) |
|
65 cw = QWidget() |
|
66 layout = QVBoxLayout(cw) |
|
67 layout.setContentsMargins(1, 1, 1, 1) |
|
68 layout.setSpacing(1) |
|
69 layout.addWidget(self.__editor) |
|
70 layout.addWidget(self.__searchWidget) |
|
71 cw.setLayout(layout) |
|
72 layout.addWidget(self.__replaceWidget) |
|
73 self.__searchWidget.hide() |
|
74 self.__replaceWidget.hide() |
|
75 self.setCentralWidget(cw) |
63 |
76 |
64 g = Preferences.getGeometry("HexEditorGeometry") |
77 g = Preferences.getGeometry("HexEditorGeometry") |
65 if g.isEmpty(): |
78 if g.isEmpty(): |
66 s = QSize(600, 500) |
79 s = QSize(600, 500) |
67 self.resize(s) |
80 self.resize(s) |
403 """ mode).</p>""" |
414 """ mode).</p>""" |
404 )) |
415 )) |
405 self.readonlyAct.setChecked(False) |
416 self.readonlyAct.setChecked(False) |
406 self.readonlyAct.toggled[bool].connect(self.__editor.setReadOnly) |
417 self.readonlyAct.toggled[bool].connect(self.__editor.setReadOnly) |
407 self.__actions.append(self.readonlyAct) |
418 self.__actions.append(self.readonlyAct) |
|
419 |
|
420 self.searchAct = E5Action( |
|
421 self.tr('Search'), |
|
422 UI.PixmapCache.getIcon("find.png"), |
|
423 self.tr('&Search...'), |
|
424 QKeySequence(self.tr("Ctrl+F", "Search|Search")), |
|
425 0, |
|
426 self, 'hexEditor_edit_search') |
|
427 self.searchAct.setStatusTip(self.tr('Search for a text')) |
|
428 self.searchAct.setWhatsThis(self.tr( |
|
429 """<b>Search</b>""" |
|
430 """<p>Search for some text in the current editor. A""" |
|
431 """ dialog is shown to enter the searchtext and options""" |
|
432 """ for the search.</p>""" |
|
433 )) |
|
434 self.searchAct.triggered.connect(self.__search) |
|
435 self.__actions.append(self.searchAct) |
|
436 |
|
437 self.searchNextAct = E5Action( |
|
438 self.tr('Search next'), |
|
439 UI.PixmapCache.getIcon("findNext.png"), |
|
440 self.tr('Search &next'), |
|
441 QKeySequence(self.tr("F3", "Search|Search next")), |
|
442 0, |
|
443 self, 'hexEditor_edit_search_next') |
|
444 self.searchNextAct.setStatusTip(self.tr( |
|
445 'Search next occurrence of text')) |
|
446 self.searchNextAct.setWhatsThis(self.tr( |
|
447 """<b>Search next</b>""" |
|
448 """<p>Search the next occurrence of some text in the current""" |
|
449 """ editor. The previously entered searchtext and options are""" |
|
450 """ reused.</p>""" |
|
451 )) |
|
452 self.searchNextAct.triggered.connect(self.__searchWidget.findPrevNext) |
|
453 self.__actions.append(self.searchNextAct) |
|
454 |
|
455 self.searchPrevAct = E5Action( |
|
456 self.tr('Search previous'), |
|
457 UI.PixmapCache.getIcon("findPrev.png"), |
|
458 self.tr('Search &previous'), |
|
459 QKeySequence(self.tr("Shift+F3", "Search|Search previous")), |
|
460 0, |
|
461 self, 'hexEditor_edit_search_previous') |
|
462 self.searchPrevAct.setStatusTip(self.tr( |
|
463 'Search previous occurrence of text')) |
|
464 self.searchPrevAct.setWhatsThis(self.tr( |
|
465 """<b>Search previous</b>""" |
|
466 """<p>Search the previous occurrence of some text in the current""" |
|
467 """ editor. The previously entered searchtext and options are""" |
|
468 """ reused.</p>""" |
|
469 )) |
|
470 self.searchPrevAct.triggered.connect( |
|
471 lambda: self.__searchWidget.findPrevNext(True)) |
|
472 self.__actions.append(self.searchPrevAct) |
|
473 |
|
474 self.replaceAct = E5Action( |
|
475 self.tr('Replace'), |
|
476 self.tr('&Replace...'), |
|
477 QKeySequence(self.tr("Ctrl+R", "Search|Replace")), |
|
478 0, |
|
479 self, 'hexEditor_edit_search_replace') |
|
480 self.replaceAct.setStatusTip(self.tr('Replace some text')) |
|
481 self.replaceAct.setWhatsThis(self.tr( |
|
482 """<b>Replace</b>""" |
|
483 """<p>Search for some text in the current editor and replace it.""" |
|
484 """ A dialog is shown to enter the searchtext, the replacement""" |
|
485 """ text and options for the search and replace.</p>""" |
|
486 )) |
|
487 self.replaceAct.triggered.connect(self.__replace) |
|
488 self.__actions.append(self.replaceAct) |
408 |
489 |
409 self.redoAct.setEnabled(False) |
490 self.redoAct.setEnabled(False) |
410 self.__editor.canRedoChanged.connect(self.redoAct.setEnabled) |
491 self.__editor.canRedoChanged.connect(self.redoAct.setEnabled) |
411 |
492 |
412 self.undoAct.setEnabled(False) |
493 self.undoAct.setEnabled(False) |
542 edittb.addAction(self.redoAct) |
628 edittb.addAction(self.redoAct) |
543 edittb.addSeparator() |
629 edittb.addSeparator() |
544 edittb.addAction(self.cutAct) |
630 edittb.addAction(self.cutAct) |
545 edittb.addAction(self.copyAct) |
631 edittb.addAction(self.copyAct) |
546 edittb.addAction(self.pasteAct) |
632 edittb.addAction(self.pasteAct) |
|
633 |
|
634 searchtb = self.addToolBar(self.tr("Find")) |
|
635 searchtb.setObjectName("SearchToolBar") |
|
636 searchtb.setIconSize(UI.Config.ToolBarIconSize) |
|
637 searchtb.addAction(self.searchAct) |
|
638 searchtb.addAction(self.searchNextAct) |
|
639 searchtb.addAction(self.searchPrevAct) |
547 |
640 |
548 helptb = self.addToolBar(self.tr("Help")) |
641 helptb = self.addToolBar(self.tr("Help")) |
549 helptb.setObjectName("HelpToolBar") |
642 helptb.setObjectName("HelpToolBar") |
550 helptb.setIconSize(UI.Config.ToolBarIconSize) |
643 helptb.setIconSize(UI.Config.ToolBarIconSize) |
551 helptb.addAction(self.whatsThisAct) |
644 helptb.addAction(self.whatsThisAct) |