eric6/QScintilla/MiniEditor.py

changeset 7533
88261c96484b
parent 7436
66112fb43a1d
child 7628
f904d0eef264
equal deleted inserted replaced
7532:1358e9d67a1c 7533:88261c96484b
127 @param name object name of the window (string) 127 @param name object name of the window (string)
128 """ 128 """
129 super(MiniEditor, self).__init__(parent) 129 super(MiniEditor, self).__init__(parent)
130 if name is not None: 130 if name is not None:
131 self.setObjectName(name) 131 self.setObjectName(name)
132 self.setWindowIcon(UI.PixmapCache.getIcon("editor.png")) 132 self.setWindowIcon(UI.PixmapCache.getIcon("editor"))
133 133
134 self.setStyle(Preferences.getUI("Style"), 134 self.setStyle(Preferences.getUI("Style"),
135 Preferences.getUI("StyleSheet")) 135 Preferences.getUI("StyleSheet"))
136 136
137 self.__textEdit = MiniScintilla(self) 137 self.__textEdit = MiniScintilla(self)
397 """ 397 """
398 Private method to create the File actions. 398 Private method to create the File actions.
399 """ 399 """
400 self.newAct = E5Action( 400 self.newAct = E5Action(
401 self.tr('New'), 401 self.tr('New'),
402 UI.PixmapCache.getIcon("new.png"), 402 UI.PixmapCache.getIcon("new"),
403 self.tr('&New'), 403 self.tr('&New'),
404 QKeySequence(self.tr("Ctrl+N", "File|New")), 404 QKeySequence(self.tr("Ctrl+N", "File|New")),
405 0, self, 'vm_file_new') 405 0, self, 'vm_file_new')
406 self.newAct.setStatusTip(self.tr('Open an empty editor window')) 406 self.newAct.setStatusTip(self.tr('Open an empty editor window'))
407 self.newAct.setWhatsThis(self.tr( 407 self.newAct.setWhatsThis(self.tr(
411 self.newAct.triggered.connect(self.__newFile) 411 self.newAct.triggered.connect(self.__newFile)
412 self.fileActions.append(self.newAct) 412 self.fileActions.append(self.newAct)
413 413
414 self.openAct = E5Action( 414 self.openAct = E5Action(
415 self.tr('Open'), 415 self.tr('Open'),
416 UI.PixmapCache.getIcon("open.png"), 416 UI.PixmapCache.getIcon("open"),
417 self.tr('&Open...'), 417 self.tr('&Open...'),
418 QKeySequence(self.tr("Ctrl+O", "File|Open")), 418 QKeySequence(self.tr("Ctrl+O", "File|Open")),
419 0, self, 'vm_file_open') 419 0, self, 'vm_file_open')
420 self.openAct.setStatusTip(self.tr('Open a file')) 420 self.openAct.setStatusTip(self.tr('Open a file'))
421 self.openAct.setWhatsThis(self.tr( 421 self.openAct.setWhatsThis(self.tr(
425 self.openAct.triggered.connect(self.__open) 425 self.openAct.triggered.connect(self.__open)
426 self.fileActions.append(self.openAct) 426 self.fileActions.append(self.openAct)
427 427
428 self.saveAct = E5Action( 428 self.saveAct = E5Action(
429 self.tr('Save'), 429 self.tr('Save'),
430 UI.PixmapCache.getIcon("fileSave.png"), 430 UI.PixmapCache.getIcon("fileSave"),
431 self.tr('&Save'), 431 self.tr('&Save'),
432 QKeySequence(self.tr("Ctrl+S", "File|Save")), 432 QKeySequence(self.tr("Ctrl+S", "File|Save")),
433 0, self, 'vm_file_save') 433 0, self, 'vm_file_save')
434 self.saveAct.setStatusTip(self.tr('Save the current file')) 434 self.saveAct.setStatusTip(self.tr('Save the current file'))
435 self.saveAct.setWhatsThis(self.tr( 435 self.saveAct.setWhatsThis(self.tr(
439 self.saveAct.triggered.connect(self.__save) 439 self.saveAct.triggered.connect(self.__save)
440 self.fileActions.append(self.saveAct) 440 self.fileActions.append(self.saveAct)
441 441
442 self.saveAsAct = E5Action( 442 self.saveAsAct = E5Action(
443 self.tr('Save as'), 443 self.tr('Save as'),
444 UI.PixmapCache.getIcon("fileSaveAs.png"), 444 UI.PixmapCache.getIcon("fileSaveAs"),
445 self.tr('Save &as...'), 445 self.tr('Save &as...'),
446 QKeySequence(self.tr("Shift+Ctrl+S", "File|Save As")), 446 QKeySequence(self.tr("Shift+Ctrl+S", "File|Save As")),
447 0, self, 'vm_file_save_as') 447 0, self, 'vm_file_save_as')
448 self.saveAsAct.setStatusTip(self.tr( 448 self.saveAsAct.setStatusTip(self.tr(
449 'Save the current file to a new one')) 449 'Save the current file to a new one'))
455 self.saveAsAct.triggered.connect(self.__saveAs) 455 self.saveAsAct.triggered.connect(self.__saveAs)
456 self.fileActions.append(self.saveAsAct) 456 self.fileActions.append(self.saveAsAct)
457 457
458 self.saveCopyAct = E5Action( 458 self.saveCopyAct = E5Action(
459 self.tr('Save Copy'), 459 self.tr('Save Copy'),
460 UI.PixmapCache.getIcon("fileSaveCopy.png"), 460 UI.PixmapCache.getIcon("fileSaveCopy"),
461 self.tr('Save &Copy...'), 461 self.tr('Save &Copy...'),
462 0, 0, self, 'vm_file_save_copy') 462 0, 0, self, 'vm_file_save_copy')
463 self.saveCopyAct.setStatusTip(self.tr( 463 self.saveCopyAct.setStatusTip(self.tr(
464 'Save a copy of the current file')) 464 'Save a copy of the current file'))
465 self.saveCopyAct.setWhatsThis(self.tr( 465 self.saveCopyAct.setWhatsThis(self.tr(
470 self.saveCopyAct.triggered.connect(self.__saveCopy) 470 self.saveCopyAct.triggered.connect(self.__saveCopy)
471 self.fileActions.append(self.saveCopyAct) 471 self.fileActions.append(self.saveCopyAct)
472 472
473 self.closeAct = E5Action( 473 self.closeAct = E5Action(
474 self.tr('Close'), 474 self.tr('Close'),
475 UI.PixmapCache.getIcon("close.png"), 475 UI.PixmapCache.getIcon("close"),
476 self.tr('&Close'), 476 self.tr('&Close'),
477 QKeySequence(self.tr("Ctrl+W", "File|Close")), 477 QKeySequence(self.tr("Ctrl+W", "File|Close")),
478 0, self, 'vm_file_close') 478 0, self, 'vm_file_close')
479 self.closeAct.setStatusTip(self.tr('Close the editor window')) 479 self.closeAct.setStatusTip(self.tr('Close the editor window'))
480 self.closeAct.setWhatsThis(self.tr( 480 self.closeAct.setWhatsThis(self.tr(
484 self.closeAct.triggered.connect(self.close) 484 self.closeAct.triggered.connect(self.close)
485 self.fileActions.append(self.closeAct) 485 self.fileActions.append(self.closeAct)
486 486
487 self.printAct = E5Action( 487 self.printAct = E5Action(
488 self.tr('Print'), 488 self.tr('Print'),
489 UI.PixmapCache.getIcon("print.png"), 489 UI.PixmapCache.getIcon("print"),
490 self.tr('&Print'), 490 self.tr('&Print'),
491 QKeySequence(self.tr("Ctrl+P", "File|Print")), 491 QKeySequence(self.tr("Ctrl+P", "File|Print")),
492 0, self, 'vm_file_print') 492 0, self, 'vm_file_print')
493 self.printAct.setStatusTip(self.tr('Print the current file')) 493 self.printAct.setStatusTip(self.tr('Print the current file'))
494 self.printAct.setWhatsThis(self.tr( 494 self.printAct.setWhatsThis(self.tr(
498 self.printAct.triggered.connect(self.__printFile) 498 self.printAct.triggered.connect(self.__printFile)
499 self.fileActions.append(self.printAct) 499 self.fileActions.append(self.printAct)
500 500
501 self.printPreviewAct = E5Action( 501 self.printPreviewAct = E5Action(
502 self.tr('Print Preview'), 502 self.tr('Print Preview'),
503 UI.PixmapCache.getIcon("printPreview.png"), 503 UI.PixmapCache.getIcon("printPreview"),
504 QCoreApplication.translate('ViewManager', 'Print Preview'), 504 QCoreApplication.translate('ViewManager', 'Print Preview'),
505 0, 0, self, 'vm_file_print_preview') 505 0, 0, self, 'vm_file_print_preview')
506 self.printPreviewAct.setStatusTip(self.tr( 506 self.printPreviewAct.setStatusTip(self.tr(
507 'Print preview of the current file')) 507 'Print preview of the current file'))
508 self.printPreviewAct.setWhatsThis(self.tr( 508 self.printPreviewAct.setWhatsThis(self.tr(
516 """ 516 """
517 Private method to create the Edit actions. 517 Private method to create the Edit actions.
518 """ 518 """
519 self.undoAct = E5Action( 519 self.undoAct = E5Action(
520 self.tr('Undo'), 520 self.tr('Undo'),
521 UI.PixmapCache.getIcon("editUndo.png"), 521 UI.PixmapCache.getIcon("editUndo"),
522 self.tr('&Undo'), 522 self.tr('&Undo'),
523 QKeySequence(self.tr("Ctrl+Z", "Edit|Undo")), 523 QKeySequence(self.tr("Ctrl+Z", "Edit|Undo")),
524 QKeySequence(self.tr("Alt+Backspace", "Edit|Undo")), 524 QKeySequence(self.tr("Alt+Backspace", "Edit|Undo")),
525 self, 'vm_edit_undo') 525 self, 'vm_edit_undo')
526 self.undoAct.setStatusTip(self.tr('Undo the last change')) 526 self.undoAct.setStatusTip(self.tr('Undo the last change'))
531 self.undoAct.triggered.connect(self.__undo) 531 self.undoAct.triggered.connect(self.__undo)
532 self.editActions.append(self.undoAct) 532 self.editActions.append(self.undoAct)
533 533
534 self.redoAct = E5Action( 534 self.redoAct = E5Action(
535 self.tr('Redo'), 535 self.tr('Redo'),
536 UI.PixmapCache.getIcon("editRedo.png"), 536 UI.PixmapCache.getIcon("editRedo"),
537 self.tr('&Redo'), 537 self.tr('&Redo'),
538 QKeySequence(self.tr("Ctrl+Shift+Z", "Edit|Redo")), 538 QKeySequence(self.tr("Ctrl+Shift+Z", "Edit|Redo")),
539 0, self, 'vm_edit_redo') 539 0, self, 'vm_edit_redo')
540 self.redoAct.setStatusTip(self.tr('Redo the last change')) 540 self.redoAct.setStatusTip(self.tr('Redo the last change'))
541 self.redoAct.setWhatsThis(self.tr( 541 self.redoAct.setWhatsThis(self.tr(
545 self.redoAct.triggered.connect(self.__redo) 545 self.redoAct.triggered.connect(self.__redo)
546 self.editActions.append(self.redoAct) 546 self.editActions.append(self.redoAct)
547 547
548 self.cutAct = E5Action( 548 self.cutAct = E5Action(
549 self.tr('Cut'), 549 self.tr('Cut'),
550 UI.PixmapCache.getIcon("editCut.png"), 550 UI.PixmapCache.getIcon("editCut"),
551 self.tr('Cu&t'), 551 self.tr('Cu&t'),
552 QKeySequence(self.tr("Ctrl+X", "Edit|Cut")), 552 QKeySequence(self.tr("Ctrl+X", "Edit|Cut")),
553 QKeySequence(self.tr("Shift+Del", "Edit|Cut")), 553 QKeySequence(self.tr("Shift+Del", "Edit|Cut")),
554 self, 'vm_edit_cut') 554 self, 'vm_edit_cut')
555 self.cutAct.setStatusTip(self.tr('Cut the selection')) 555 self.cutAct.setStatusTip(self.tr('Cut the selection'))
561 self.cutAct.triggered.connect(self.__textEdit.cut) 561 self.cutAct.triggered.connect(self.__textEdit.cut)
562 self.editActions.append(self.cutAct) 562 self.editActions.append(self.cutAct)
563 563
564 self.copyAct = E5Action( 564 self.copyAct = E5Action(
565 self.tr('Copy'), 565 self.tr('Copy'),
566 UI.PixmapCache.getIcon("editCopy.png"), 566 UI.PixmapCache.getIcon("editCopy"),
567 self.tr('&Copy'), 567 self.tr('&Copy'),
568 QKeySequence(self.tr("Ctrl+C", "Edit|Copy")), 568 QKeySequence(self.tr("Ctrl+C", "Edit|Copy")),
569 QKeySequence(self.tr("Ctrl+Ins", "Edit|Copy")), 569 QKeySequence(self.tr("Ctrl+Ins", "Edit|Copy")),
570 self, 'vm_edit_copy') 570 self, 'vm_edit_copy')
571 self.copyAct.setStatusTip(self.tr('Copy the selection')) 571 self.copyAct.setStatusTip(self.tr('Copy the selection'))
577 self.copyAct.triggered.connect(self.__textEdit.copy) 577 self.copyAct.triggered.connect(self.__textEdit.copy)
578 self.editActions.append(self.copyAct) 578 self.editActions.append(self.copyAct)
579 579
580 self.pasteAct = E5Action( 580 self.pasteAct = E5Action(
581 self.tr('Paste'), 581 self.tr('Paste'),
582 UI.PixmapCache.getIcon("editPaste.png"), 582 UI.PixmapCache.getIcon("editPaste"),
583 self.tr('&Paste'), 583 self.tr('&Paste'),
584 QKeySequence(self.tr("Ctrl+V", "Edit|Paste")), 584 QKeySequence(self.tr("Ctrl+V", "Edit|Paste")),
585 QKeySequence(self.tr("Shift+Ins", "Edit|Paste")), 585 QKeySequence(self.tr("Shift+Ins", "Edit|Paste")),
586 self, 'vm_edit_paste') 586 self, 'vm_edit_paste')
587 self.pasteAct.setStatusTip(self.tr( 587 self.pasteAct.setStatusTip(self.tr(
594 self.pasteAct.triggered.connect(self.__textEdit.paste) 594 self.pasteAct.triggered.connect(self.__textEdit.paste)
595 self.editActions.append(self.pasteAct) 595 self.editActions.append(self.pasteAct)
596 596
597 self.deleteAct = E5Action( 597 self.deleteAct = E5Action(
598 self.tr('Clear'), 598 self.tr('Clear'),
599 UI.PixmapCache.getIcon("editDelete.png"), 599 UI.PixmapCache.getIcon("editDelete"),
600 self.tr('Cl&ear'), 600 self.tr('Cl&ear'),
601 QKeySequence(self.tr("Alt+Shift+C", "Edit|Clear")), 601 QKeySequence(self.tr("Alt+Shift+C", "Edit|Clear")),
602 0, 602 0,
603 self, 'vm_edit_clear') 603 self, 'vm_edit_clear')
604 self.deleteAct.setStatusTip(self.tr('Clear all text')) 604 self.deleteAct.setStatusTip(self.tr('Clear all text'))
1955 Private method defining the user interface actions for the search 1955 Private method defining the user interface actions for the search
1956 commands. 1956 commands.
1957 """ 1957 """
1958 self.searchAct = E5Action( 1958 self.searchAct = E5Action(
1959 QCoreApplication.translate('ViewManager', 'Search'), 1959 QCoreApplication.translate('ViewManager', 'Search'),
1960 UI.PixmapCache.getIcon("find.png"), 1960 UI.PixmapCache.getIcon("find"),
1961 QCoreApplication.translate('ViewManager', '&Search...'), 1961 QCoreApplication.translate('ViewManager', '&Search...'),
1962 QKeySequence(QCoreApplication.translate( 1962 QKeySequence(QCoreApplication.translate(
1963 'ViewManager', "Ctrl+F", "Search|Search")), 1963 'ViewManager', "Ctrl+F", "Search|Search")),
1964 0, 1964 0,
1965 self, 'vm_search') 1965 self, 'vm_search')
1975 self.searchAct.triggered.connect(self.showSearchWidget) 1975 self.searchAct.triggered.connect(self.showSearchWidget)
1976 self.searchActions.append(self.searchAct) 1976 self.searchActions.append(self.searchAct)
1977 1977
1978 self.searchNextAct = E5Action( 1978 self.searchNextAct = E5Action(
1979 QCoreApplication.translate('ViewManager', 'Search next'), 1979 QCoreApplication.translate('ViewManager', 'Search next'),
1980 UI.PixmapCache.getIcon("findNext.png"), 1980 UI.PixmapCache.getIcon("findNext"),
1981 QCoreApplication.translate('ViewManager', 'Search &next'), 1981 QCoreApplication.translate('ViewManager', 'Search &next'),
1982 QKeySequence(QCoreApplication.translate( 1982 QKeySequence(QCoreApplication.translate(
1983 'ViewManager', "F3", "Search|Search next")), 1983 'ViewManager', "F3", "Search|Search next")),
1984 0, 1984 0,
1985 self, 'vm_search_next') 1985 self, 'vm_search_next')
1995 self.searchNextAct.triggered.connect(self.__searchNext) 1995 self.searchNextAct.triggered.connect(self.__searchNext)
1996 self.searchActions.append(self.searchNextAct) 1996 self.searchActions.append(self.searchNextAct)
1997 1997
1998 self.searchPrevAct = E5Action( 1998 self.searchPrevAct = E5Action(
1999 QCoreApplication.translate('ViewManager', 'Search previous'), 1999 QCoreApplication.translate('ViewManager', 'Search previous'),
2000 UI.PixmapCache.getIcon("findPrev.png"), 2000 UI.PixmapCache.getIcon("findPrev"),
2001 QCoreApplication.translate('ViewManager', 'Search &previous'), 2001 QCoreApplication.translate('ViewManager', 'Search &previous'),
2002 QKeySequence(QCoreApplication.translate( 2002 QKeySequence(QCoreApplication.translate(
2003 'ViewManager', "Shift+F3", "Search|Search previous")), 2003 'ViewManager', "Shift+F3", "Search|Search previous")),
2004 0, 2004 0,
2005 self, 'vm_search_previous') 2005 self, 'vm_search_previous')
2016 self.searchActions.append(self.searchPrevAct) 2016 self.searchActions.append(self.searchPrevAct)
2017 2017
2018 self.searchClearMarkersAct = E5Action( 2018 self.searchClearMarkersAct = E5Action(
2019 QCoreApplication.translate('ViewManager', 2019 QCoreApplication.translate('ViewManager',
2020 'Clear search markers'), 2020 'Clear search markers'),
2021 UI.PixmapCache.getIcon("findClear.png"), 2021 UI.PixmapCache.getIcon("findClear"),
2022 QCoreApplication.translate('ViewManager', 'Clear search markers'), 2022 QCoreApplication.translate('ViewManager', 'Clear search markers'),
2023 QKeySequence(QCoreApplication.translate( 2023 QKeySequence(QCoreApplication.translate(
2024 'ViewManager', "Ctrl+3", "Search|Clear search markers")), 2024 'ViewManager', "Ctrl+3", "Search|Clear search markers")),
2025 0, 2025 0,
2026 self, 'vm_clear_search_markers') 2026 self, 'vm_clear_search_markers')
2055 self.searchActions.append(self.replaceAct) 2055 self.searchActions.append(self.replaceAct)
2056 2056
2057 self.replaceAndSearchAct = E5Action( 2057 self.replaceAndSearchAct = E5Action(
2058 QCoreApplication.translate( 2058 QCoreApplication.translate(
2059 'ViewManager', 'Replace and Search'), 2059 'ViewManager', 'Replace and Search'),
2060 UI.PixmapCache.getIcon("editReplaceSearch.png"), 2060 UI.PixmapCache.getIcon("editReplaceSearch"),
2061 QCoreApplication.translate( 2061 QCoreApplication.translate(
2062 'ViewManager', 'Replace and Search'), 2062 'ViewManager', 'Replace and Search'),
2063 QKeySequence(QCoreApplication.translate( 2063 QKeySequence(QCoreApplication.translate(
2064 'ViewManager', "Meta+R", "Search|Replace and Search")), 2064 'ViewManager', "Meta+R", "Search|Replace and Search")),
2065 0, 2065 0,
2079 self.searchActions.append(self.replaceAndSearchAct) 2079 self.searchActions.append(self.replaceAndSearchAct)
2080 2080
2081 self.replaceSelectionAct = E5Action( 2081 self.replaceSelectionAct = E5Action(
2082 QCoreApplication.translate( 2082 QCoreApplication.translate(
2083 'ViewManager', 'Replace Occurrence'), 2083 'ViewManager', 'Replace Occurrence'),
2084 UI.PixmapCache.getIcon("editReplace.png"), 2084 UI.PixmapCache.getIcon("editReplace"),
2085 QCoreApplication.translate( 2085 QCoreApplication.translate(
2086 'ViewManager', 'Replace Occurrence'), 2086 'ViewManager', 'Replace Occurrence'),
2087 QKeySequence(QCoreApplication.translate( 2087 QKeySequence(QCoreApplication.translate(
2088 'ViewManager', "Ctrl+Meta+R", "Search|Replace Occurrence")), 2088 'ViewManager', "Ctrl+Meta+R", "Search|Replace Occurrence")),
2089 0, 2089 0,
2101 self.searchActions.append(self.replaceSelectionAct) 2101 self.searchActions.append(self.replaceSelectionAct)
2102 2102
2103 self.replaceAllAct = E5Action( 2103 self.replaceAllAct = E5Action(
2104 QCoreApplication.translate( 2104 QCoreApplication.translate(
2105 'ViewManager', 'Replace All'), 2105 'ViewManager', 'Replace All'),
2106 UI.PixmapCache.getIcon("editReplaceAll.png"), 2106 UI.PixmapCache.getIcon("editReplaceAll"),
2107 QCoreApplication.translate( 2107 QCoreApplication.translate(
2108 'ViewManager', 'Replace All'), 2108 'ViewManager', 'Replace All'),
2109 QKeySequence(QCoreApplication.translate( 2109 QKeySequence(QCoreApplication.translate(
2110 'ViewManager', "Shift+Meta+R", "Search|Replace All")), 2110 'ViewManager', "Shift+Meta+R", "Search|Replace All")),
2111 0, 2111 0,
2151 self.aboutQtAct.triggered.connect(self.__aboutQt) 2151 self.aboutQtAct.triggered.connect(self.__aboutQt)
2152 self.helpActions.append(self.aboutQtAct) 2152 self.helpActions.append(self.aboutQtAct)
2153 2153
2154 self.whatsThisAct = E5Action( 2154 self.whatsThisAct = E5Action(
2155 self.tr('What\'s This?'), 2155 self.tr('What\'s This?'),
2156 UI.PixmapCache.getIcon("whatsThis.png"), 2156 UI.PixmapCache.getIcon("whatsThis"),
2157 self.tr('&What\'s This?'), 2157 self.tr('&What\'s This?'),
2158 QKeySequence(self.tr("Shift+F1", "Help|What's This?'")), 2158 QKeySequence(self.tr("Shift+F1", "Help|What's This?'")),
2159 0, self, 'help_help_whats_this') 2159 0, self, 'help_help_whats_this')
2160 self.whatsThisAct.setStatusTip(self.tr('Context sensitive help')) 2160 self.whatsThisAct.setStatusTip(self.tr('Context sensitive help'))
2161 self.whatsThisAct.setWhatsThis(self.tr( 2161 self.whatsThisAct.setWhatsThis(self.tr(

eric ide

mercurial