src/eric7/HexEdit/HexEditMainWindow.py

branch
eric7
changeset 9413
80c06d472826
parent 9221
bf71ee032bb4
child 9473
3f23dbf37dbe
equal deleted inserted replaced
9412:45e7bb09c120 9413:80c06d472826
21 QDialog, 21 QDialog,
22 QFrame, 22 QFrame,
23 QMenu, 23 QMenu,
24 ) 24 )
25 25
26 from EricGui.EricAction import EricAction 26 from eric7.EricGui.EricAction import EricAction
27 from EricWidgets.EricMainWindow import EricMainWindow 27 from eric7.EricWidgets.EricMainWindow import EricMainWindow
28 from EricWidgets import EricFileDialog, EricMessageBox 28 from eric7.EricWidgets import EricFileDialog, EricMessageBox
29 from EricWidgets.EricClickableLabel import EricClickableLabel 29 from eric7.EricWidgets.EricClickableLabel import EricClickableLabel
30 30
31 from Globals import strGroup, recentNameHexFiles 31 from eric7.Globals import strGroup, recentNameHexFiles
32 32
33 from .HexEditWidget import HexEditWidget 33 from .HexEditWidget import HexEditWidget
34 from .HexEditSearchReplaceWidget import HexEditSearchReplaceWidget 34 from .HexEditSearchReplaceWidget import HexEditSearchReplaceWidget
35 from .HexEditGotoWidget import HexEditGotoWidget 35 from .HexEditGotoWidget import HexEditGotoWidget
36 36
37 import UI.PixmapCache 37 from eric7.EricGui import EricPixmapCache
38 import UI.Config 38 from eric7.UI import Config
39 39
40 import Preferences 40 from eric7 import Preferences, Utilities
41 import Utilities
42 41
43 42
44 class HexEditMainWindow(EricMainWindow): 43 class HexEditMainWindow(EricMainWindow):
45 """ 44 """
46 Class implementing the web browser main window. 45 Class implementing the web browser main window.
75 # list of recent replaces (tuple of format type index and 74 # list of recent replaces (tuple of format type index and
76 # replace term 75 # replace term
77 } 76 }
78 77
79 self.__fromEric = fromEric 78 self.__fromEric = fromEric
80 self.setWindowIcon(UI.PixmapCache.getIcon("hexEditor")) 79 self.setWindowIcon(EricPixmapCache.getIcon("hexEditor"))
81 80
82 if not self.__fromEric: 81 if not self.__fromEric:
83 self.setStyle(Preferences.getUI("Style"), Preferences.getUI("StyleSheet")) 82 self.setStyle(Preferences.getUI("Style"), Preferences.getUI("StyleSheet"))
84 83
85 self.__editor = HexEditWidget() 84 self.__editor = HexEditWidget()
158 """ 157 """
159 Private method to define the file related user interface actions. 158 Private method to define the file related user interface actions.
160 """ 159 """
161 self.newWindowAct = EricAction( 160 self.newWindowAct = EricAction(
162 self.tr("New Window"), 161 self.tr("New Window"),
163 UI.PixmapCache.getIcon("newWindow"), 162 EricPixmapCache.getIcon("newWindow"),
164 self.tr("New &Window"), 163 self.tr("New &Window"),
165 0, 164 0,
166 0, 165 0,
167 self, 166 self,
168 "hexEditor_file_new_window", 167 "hexEditor_file_new_window",
181 self.__actions.append(self.newWindowAct) 180 self.__actions.append(self.newWindowAct)
182 181
183 # correct texts will be set later 182 # correct texts will be set later
184 self.openAct = EricAction( 183 self.openAct = EricAction(
185 self.tr("Open"), 184 self.tr("Open"),
186 UI.PixmapCache.getIcon("open"), 185 EricPixmapCache.getIcon("open"),
187 self.tr("&Open..."), 186 self.tr("&Open..."),
188 QKeySequence(self.tr("Ctrl+O", "File|Open")), 187 QKeySequence(self.tr("Ctrl+O", "File|Open")),
189 0, 188 0,
190 self, 189 self,
191 "hexEditor_file_open", 190 "hexEditor_file_open",
200 self.openReadOnlyAct.triggered.connect(self.__openHexFileReadOnly) 199 self.openReadOnlyAct.triggered.connect(self.__openHexFileReadOnly)
201 self.__actions.append(self.openReadOnlyAct) 200 self.__actions.append(self.openReadOnlyAct)
202 201
203 self.saveAct = EricAction( 202 self.saveAct = EricAction(
204 self.tr("Save"), 203 self.tr("Save"),
205 UI.PixmapCache.getIcon("fileSave"), 204 EricPixmapCache.getIcon("fileSave"),
206 self.tr("&Save"), 205 self.tr("&Save"),
207 QKeySequence(self.tr("Ctrl+S", "File|Save")), 206 QKeySequence(self.tr("Ctrl+S", "File|Save")),
208 0, 207 0,
209 self, 208 self,
210 "hexEditor_file_save", 209 "hexEditor_file_save",
219 self.saveAct.triggered.connect(self.__saveHexFile) 218 self.saveAct.triggered.connect(self.__saveHexFile)
220 self.__actions.append(self.saveAct) 219 self.__actions.append(self.saveAct)
221 220
222 self.saveAsAct = EricAction( 221 self.saveAsAct = EricAction(
223 self.tr("Save As"), 222 self.tr("Save As"),
224 UI.PixmapCache.getIcon("fileSaveAs"), 223 EricPixmapCache.getIcon("fileSaveAs"),
225 self.tr("Save &As..."), 224 self.tr("Save &As..."),
226 QKeySequence(self.tr("Shift+Ctrl+S", "File|Save As")), 225 QKeySequence(self.tr("Shift+Ctrl+S", "File|Save As")),
227 0, 226 0,
228 self, 227 self,
229 "hexEditor_file_save_as", 228 "hexEditor_file_save_as",
263 self.saveReadableAct.triggered.connect(self.__saveHexFileReadable) 262 self.saveReadableAct.triggered.connect(self.__saveHexFileReadable)
264 self.__actions.append(self.saveReadableAct) 263 self.__actions.append(self.saveReadableAct)
265 264
266 self.closeAct = EricAction( 265 self.closeAct = EricAction(
267 self.tr("Close"), 266 self.tr("Close"),
268 UI.PixmapCache.getIcon("close"), 267 EricPixmapCache.getIcon("close"),
269 self.tr("&Close"), 268 self.tr("&Close"),
270 QKeySequence(self.tr("Ctrl+W", "File|Close")), 269 QKeySequence(self.tr("Ctrl+W", "File|Close")),
271 0, 270 0,
272 self, 271 self,
273 "hexEditor_file_close", 272 "hexEditor_file_close",
314 self.closeOthersAct.triggered.connect(self.__closeOthers) 313 self.closeOthersAct.triggered.connect(self.__closeOthers)
315 self.__actions.append(self.closeOthersAct) 314 self.__actions.append(self.closeOthersAct)
316 315
317 self.exitAct = EricAction( 316 self.exitAct = EricAction(
318 self.tr("Quit"), 317 self.tr("Quit"),
319 UI.PixmapCache.getIcon("exit"), 318 EricPixmapCache.getIcon("exit"),
320 self.tr("&Quit"), 319 self.tr("&Quit"),
321 QKeySequence(self.tr("Ctrl+Q", "File|Quit")), 320 QKeySequence(self.tr("Ctrl+Q", "File|Quit")),
322 0, 321 0,
323 self, 322 self,
324 "hexEditor_file_quit", 323 "hexEditor_file_quit",
335 """ 334 """
336 Private method to create the Edit actions. 335 Private method to create the Edit actions.
337 """ 336 """
338 self.undoAct = EricAction( 337 self.undoAct = EricAction(
339 self.tr("Undo"), 338 self.tr("Undo"),
340 UI.PixmapCache.getIcon("editUndo"), 339 EricPixmapCache.getIcon("editUndo"),
341 self.tr("&Undo"), 340 self.tr("&Undo"),
342 QKeySequence(self.tr("Ctrl+Z", "Edit|Undo")), 341 QKeySequence(self.tr("Ctrl+Z", "Edit|Undo")),
343 QKeySequence(self.tr("Alt+Backspace", "Edit|Undo")), 342 QKeySequence(self.tr("Alt+Backspace", "Edit|Undo")),
344 self, 343 self,
345 "hexEditor_edit_undo", 344 "hexEditor_edit_undo",
351 self.undoAct.triggered.connect(self.__editor.undo) 350 self.undoAct.triggered.connect(self.__editor.undo)
352 self.__actions.append(self.undoAct) 351 self.__actions.append(self.undoAct)
353 352
354 self.redoAct = EricAction( 353 self.redoAct = EricAction(
355 self.tr("Redo"), 354 self.tr("Redo"),
356 UI.PixmapCache.getIcon("editRedo"), 355 EricPixmapCache.getIcon("editRedo"),
357 self.tr("&Redo"), 356 self.tr("&Redo"),
358 QKeySequence(self.tr("Ctrl+Shift+Z", "Edit|Redo")), 357 QKeySequence(self.tr("Ctrl+Shift+Z", "Edit|Redo")),
359 0, 358 0,
360 self, 359 self,
361 "hexEditor_edit_redo", 360 "hexEditor_edit_redo",
386 self.revertAct.triggered.connect(self.__editor.revertToUnmodified) 385 self.revertAct.triggered.connect(self.__editor.revertToUnmodified)
387 self.__actions.append(self.revertAct) 386 self.__actions.append(self.revertAct)
388 387
389 self.cutAct = EricAction( 388 self.cutAct = EricAction(
390 self.tr("Cut"), 389 self.tr("Cut"),
391 UI.PixmapCache.getIcon("editCut"), 390 EricPixmapCache.getIcon("editCut"),
392 self.tr("Cu&t"), 391 self.tr("Cu&t"),
393 QKeySequence(self.tr("Ctrl+X", "Edit|Cut")), 392 QKeySequence(self.tr("Ctrl+X", "Edit|Cut")),
394 QKeySequence(self.tr("Shift+Del", "Edit|Cut")), 393 QKeySequence(self.tr("Shift+Del", "Edit|Cut")),
395 self, 394 self,
396 "hexEditor_edit_cut", 395 "hexEditor_edit_cut",
405 self.cutAct.triggered.connect(self.__editor.cut) 404 self.cutAct.triggered.connect(self.__editor.cut)
406 self.__actions.append(self.cutAct) 405 self.__actions.append(self.cutAct)
407 406
408 self.copyAct = EricAction( 407 self.copyAct = EricAction(
409 self.tr("Copy"), 408 self.tr("Copy"),
410 UI.PixmapCache.getIcon("editCopy"), 409 EricPixmapCache.getIcon("editCopy"),
411 self.tr("&Copy"), 410 self.tr("&Copy"),
412 QKeySequence(self.tr("Ctrl+C", "Edit|Copy")), 411 QKeySequence(self.tr("Ctrl+C", "Edit|Copy")),
413 QKeySequence(self.tr("Ctrl+Ins", "Edit|Copy")), 412 QKeySequence(self.tr("Ctrl+Ins", "Edit|Copy")),
414 self, 413 self,
415 "hexEditor_edit_copy", 414 "hexEditor_edit_copy",
424 self.copyAct.triggered.connect(self.__editor.copy) 423 self.copyAct.triggered.connect(self.__editor.copy)
425 self.__actions.append(self.copyAct) 424 self.__actions.append(self.copyAct)
426 425
427 self.pasteAct = EricAction( 426 self.pasteAct = EricAction(
428 self.tr("Paste"), 427 self.tr("Paste"),
429 UI.PixmapCache.getIcon("editPaste"), 428 EricPixmapCache.getIcon("editPaste"),
430 self.tr("&Paste"), 429 self.tr("&Paste"),
431 QKeySequence(self.tr("Ctrl+V", "Edit|Paste")), 430 QKeySequence(self.tr("Ctrl+V", "Edit|Paste")),
432 QKeySequence(self.tr("Shift+Ins", "Edit|Paste")), 431 QKeySequence(self.tr("Shift+Ins", "Edit|Paste")),
433 self, 432 self,
434 "hexEditor_edit_paste", 433 "hexEditor_edit_paste",
440 self.pasteAct.triggered.connect(self.__editor.paste) 439 self.pasteAct.triggered.connect(self.__editor.paste)
441 self.__actions.append(self.pasteAct) 440 self.__actions.append(self.pasteAct)
442 441
443 self.selectAllAct = EricAction( 442 self.selectAllAct = EricAction(
444 self.tr("Select All"), 443 self.tr("Select All"),
445 UI.PixmapCache.getIcon("editSelectAll"), 444 EricPixmapCache.getIcon("editSelectAll"),
446 self.tr("&Select All"), 445 self.tr("&Select All"),
447 QKeySequence(self.tr("Ctrl+A", "Edit|Select All")), 446 QKeySequence(self.tr("Ctrl+A", "Edit|Select All")),
448 0, 447 0,
449 self, 448 self,
450 "hexEditor_edit_select_all", 449 "hexEditor_edit_select_all",
521 self.__editor.readOnlyChanged.connect(self.readonlyAct.setChecked) 520 self.__editor.readOnlyChanged.connect(self.readonlyAct.setChecked)
522 self.__actions.append(self.readonlyAct) 521 self.__actions.append(self.readonlyAct)
523 522
524 self.searchAct = EricAction( 523 self.searchAct = EricAction(
525 self.tr("Search"), 524 self.tr("Search"),
526 UI.PixmapCache.getIcon("find"), 525 EricPixmapCache.getIcon("find"),
527 self.tr("&Search..."), 526 self.tr("&Search..."),
528 QKeySequence(self.tr("Ctrl+F", "Search|Search")), 527 QKeySequence(self.tr("Ctrl+F", "Search|Search")),
529 0, 528 0,
530 self, 529 self,
531 "hexEditor_edit_search", 530 "hexEditor_edit_search",
541 self.searchAct.triggered.connect(self.__search) 540 self.searchAct.triggered.connect(self.__search)
542 self.__actions.append(self.searchAct) 541 self.__actions.append(self.searchAct)
543 542
544 self.searchNextAct = EricAction( 543 self.searchNextAct = EricAction(
545 self.tr("Search next"), 544 self.tr("Search next"),
546 UI.PixmapCache.getIcon("findNext"), 545 EricPixmapCache.getIcon("findNext"),
547 self.tr("Search &next"), 546 self.tr("Search &next"),
548 QKeySequence(self.tr("F3", "Search|Search next")), 547 QKeySequence(self.tr("F3", "Search|Search next")),
549 0, 548 0,
550 self, 549 self,
551 "hexEditor_edit_search_next", 550 "hexEditor_edit_search_next",
561 self.searchNextAct.triggered.connect(self.__searchWidget.findPrevNext) 560 self.searchNextAct.triggered.connect(self.__searchWidget.findPrevNext)
562 self.__actions.append(self.searchNextAct) 561 self.__actions.append(self.searchNextAct)
563 562
564 self.searchPrevAct = EricAction( 563 self.searchPrevAct = EricAction(
565 self.tr("Search previous"), 564 self.tr("Search previous"),
566 UI.PixmapCache.getIcon("findPrev"), 565 EricPixmapCache.getIcon("findPrev"),
567 self.tr("Search &previous"), 566 self.tr("Search &previous"),
568 QKeySequence(self.tr("Shift+F3", "Search|Search previous")), 567 QKeySequence(self.tr("Shift+F3", "Search|Search previous")),
569 0, 568 0,
570 self, 569 self,
571 "hexEditor_edit_search_previous", 570 "hexEditor_edit_search_previous",
603 self.replaceAct.triggered.connect(self.__replace) 602 self.replaceAct.triggered.connect(self.__replace)
604 self.__actions.append(self.replaceAct) 603 self.__actions.append(self.replaceAct)
605 604
606 self.gotoAct = EricAction( 605 self.gotoAct = EricAction(
607 self.tr("Goto Offset"), 606 self.tr("Goto Offset"),
608 UI.PixmapCache.getIcon("goto"), 607 EricPixmapCache.getIcon("goto"),
609 self.tr("&Goto Offset..."), 608 self.tr("&Goto Offset..."),
610 QKeySequence( 609 QKeySequence(
611 QCoreApplication.translate( 610 QCoreApplication.translate(
612 "ViewManager", "Ctrl+G", "Search|Goto Offset" 611 "ViewManager", "Ctrl+G", "Search|Goto Offset"
613 ) 612 )
682 self.aboutQtAct.triggered.connect(self.__aboutQt) 681 self.aboutQtAct.triggered.connect(self.__aboutQt)
683 self.__actions.append(self.aboutQtAct) 682 self.__actions.append(self.aboutQtAct)
684 683
685 self.whatsThisAct = EricAction( 684 self.whatsThisAct = EricAction(
686 self.tr("What's This?"), 685 self.tr("What's This?"),
687 UI.PixmapCache.getIcon("whatsThis"), 686 EricPixmapCache.getIcon("whatsThis"),
688 self.tr("&What's This?"), 687 self.tr("&What's This?"),
689 QKeySequence(self.tr("Shift+F1", "Help|What's This?'")), 688 QKeySequence(self.tr("Shift+F1", "Help|What's This?'")),
690 0, 689 0,
691 self, 690 self,
692 "hexEditor_help_whats_this", 691 "hexEditor_help_whats_this",
709 """ 708 """
710 Private method to create the Settings actions. 709 Private method to create the Settings actions.
711 """ 710 """
712 self.prefAct = EricAction( 711 self.prefAct = EricAction(
713 self.tr("Preferences"), 712 self.tr("Preferences"),
714 UI.PixmapCache.getIcon("configure"), 713 EricPixmapCache.getIcon("configure"),
715 self.tr("&Preferences..."), 714 self.tr("&Preferences..."),
716 0, 715 0,
717 0, 716 0,
718 self, 717 self,
719 "hexEditor_settings_preferences", 718 "hexEditor_settings_preferences",
845 """ 844 """
846 Private method to create the toolbars. 845 Private method to create the toolbars.
847 """ 846 """
848 filetb = self.addToolBar(self.tr("File")) 847 filetb = self.addToolBar(self.tr("File"))
849 filetb.setObjectName("FileToolBar") 848 filetb.setObjectName("FileToolBar")
850 filetb.setIconSize(UI.Config.ToolBarIconSize) 849 filetb.setIconSize(Config.ToolBarIconSize)
851 filetb.addAction(self.newWindowAct) 850 filetb.addAction(self.newWindowAct)
852 filetb.addAction(self.openAct) 851 filetb.addAction(self.openAct)
853 filetb.addSeparator() 852 filetb.addSeparator()
854 filetb.addAction(self.saveAct) 853 filetb.addAction(self.saveAct)
855 filetb.addAction(self.saveAsAct) 854 filetb.addAction(self.saveAsAct)
858 if not self.__fromEric: 857 if not self.__fromEric:
859 filetb.addAction(self.exitAct) 858 filetb.addAction(self.exitAct)
860 859
861 edittb = self.addToolBar(self.tr("Edit")) 860 edittb = self.addToolBar(self.tr("Edit"))
862 edittb.setObjectName("EditToolBar") 861 edittb.setObjectName("EditToolBar")
863 edittb.setIconSize(UI.Config.ToolBarIconSize) 862 edittb.setIconSize(Config.ToolBarIconSize)
864 edittb.addAction(self.undoAct) 863 edittb.addAction(self.undoAct)
865 edittb.addAction(self.redoAct) 864 edittb.addAction(self.redoAct)
866 edittb.addSeparator() 865 edittb.addSeparator()
867 edittb.addAction(self.cutAct) 866 edittb.addAction(self.cutAct)
868 edittb.addAction(self.copyAct) 867 edittb.addAction(self.copyAct)
869 edittb.addAction(self.pasteAct) 868 edittb.addAction(self.pasteAct)
870 869
871 searchtb = self.addToolBar(self.tr("Find")) 870 searchtb = self.addToolBar(self.tr("Find"))
872 searchtb.setObjectName("SearchToolBar") 871 searchtb.setObjectName("SearchToolBar")
873 searchtb.setIconSize(UI.Config.ToolBarIconSize) 872 searchtb.setIconSize(Config.ToolBarIconSize)
874 searchtb.addAction(self.searchAct) 873 searchtb.addAction(self.searchAct)
875 searchtb.addAction(self.searchNextAct) 874 searchtb.addAction(self.searchNextAct)
876 searchtb.addAction(self.searchPrevAct) 875 searchtb.addAction(self.searchPrevAct)
877 876
878 if not self.__fromEric: 877 if not self.__fromEric:
879 settingstb = self.addToolBar(self.tr("Settings")) 878 settingstb = self.addToolBar(self.tr("Settings"))
880 settingstb.setObjectName("SettingsToolBar") 879 settingstb.setObjectName("SettingsToolBar")
881 settingstb.setIconSize(UI.Config.ToolBarIconSize) 880 settingstb.setIconSize(Config.ToolBarIconSize)
882 settingstb.addAction(self.prefAct) 881 settingstb.addAction(self.prefAct)
883 882
884 helptb = self.addToolBar(self.tr("Help")) 883 helptb = self.addToolBar(self.tr("Help"))
885 helptb.setObjectName("HelpToolBar") 884 helptb.setObjectName("HelpToolBar")
886 helptb.setIconSize(UI.Config.ToolBarIconSize) 885 helptb.setIconSize(Config.ToolBarIconSize)
887 helptb.addAction(self.whatsThisAct) 886 helptb.addAction(self.whatsThisAct)
888 887
889 def __createStatusBar(self): 888 def __createStatusBar(self):
890 """ 889 """
891 Private method to initialize the status bar. 890 Private method to initialize the status bar.
1487 1486
1488 def __showPreferences(self): 1487 def __showPreferences(self):
1489 """ 1488 """
1490 Private slot to set the preferences. 1489 Private slot to set the preferences.
1491 """ 1490 """
1492 from Preferences.ConfigurationDialog import ( 1491 from eric7.Preferences.ConfigurationDialog import (
1493 ConfigurationDialog, 1492 ConfigurationDialog,
1494 ConfigurationMode, 1493 ConfigurationMode,
1495 ) 1494 )
1496 1495
1497 dlg = ConfigurationDialog( 1496 dlg = ConfigurationDialog(

eric ide

mercurial