src/eric7/Debugger/DebugUI.py

branch
eric7
changeset 9413
80c06d472826
parent 9409
fab36282c912
child 9473
3f23dbf37dbe
equal deleted inserted replaced
9412:45e7bb09c120 9413:80c06d472826
13 13
14 from PyQt6.QtCore import pyqtSignal, pyqtSlot, QObject, Qt, QKeyCombination 14 from PyQt6.QtCore import pyqtSignal, pyqtSlot, QObject, Qt, QKeyCombination
15 from PyQt6.QtGui import QKeySequence 15 from PyQt6.QtGui import QKeySequence
16 from PyQt6.QtWidgets import QMenu, QToolBar, QApplication, QDialog 16 from PyQt6.QtWidgets import QMenu, QToolBar, QApplication, QDialog
17 17
18 from EricGui.EricAction import EricAction, createActionGroup 18 from eric7.EricGui.EricAction import EricAction, createActionGroup
19 from EricWidgets import EricMessageBox 19 from eric7.EricWidgets import EricMessageBox
20 20
21 from UI.Info import Program 21 from eric7.UI.Info import Program
22 from UI.NotificationWidget import NotificationTypes 22 from eric7.UI.NotificationWidget import NotificationTypes
23 23
24 from .DebugClientCapabilities import ( 24 from .DebugClientCapabilities import (
25 HasDebugger, 25 HasDebugger,
26 HasInterpreter, 26 HasInterpreter,
27 HasProfiler, 27 HasProfiler,
28 HasCoverage, 28 HasCoverage,
29 ) 29 )
30 30
31 from Globals import recentNameBreakpointConditions 31 from eric7.Globals import recentNameBreakpointConditions
32 32
33 import Preferences 33 from eric7 import Preferences, Utilities
34 import Utilities 34 from eric7.EricGui import EricPixmapCache
35 import UI.PixmapCache 35 from eric7.UI import Config
36 import UI.Config
37 36
38 37
39 class DebugUI(QObject): 38 class DebugUI(QObject):
40 """ 39 """
41 Class implementing the debugger part of the UI. 40 Class implementing the debugger part of the UI.
208 @param timeout timeout for the notification (None = use configured 207 @param timeout timeout for the notification (None = use configured
209 default, 0 = indefinitely) 208 default, 0 = indefinitely)
210 @type int 209 @type int
211 """ 210 """
212 self.ui.showNotification( 211 self.ui.showNotification(
213 UI.PixmapCache.getPixmap("debug48"), 212 EricPixmapCache.getPixmap("debug48"),
214 self.tr("Notification"), 213 self.tr("Notification"),
215 notification, 214 notification,
216 kind=kind, 215 kind=kind,
217 timeout=timeout, 216 timeout=timeout,
218 ) 217 )
236 """ 235 """
237 self.actions = [] 236 self.actions = []
238 237
239 self.runAct = EricAction( 238 self.runAct = EricAction(
240 self.tr("Run Script"), 239 self.tr("Run Script"),
241 UI.PixmapCache.getIcon("runScript"), 240 EricPixmapCache.getIcon("runScript"),
242 self.tr("&Run Script..."), 241 self.tr("&Run Script..."),
243 Qt.Key.Key_F2, 242 Qt.Key.Key_F2,
244 0, 243 0,
245 self, 244 self,
246 "dbg_run_script", 245 "dbg_run_script",
257 self.runAct.triggered.connect(self.__runScript) 256 self.runAct.triggered.connect(self.__runScript)
258 self.actions.append(self.runAct) 257 self.actions.append(self.runAct)
259 258
260 self.runProjectAct = EricAction( 259 self.runProjectAct = EricAction(
261 self.tr("Run Project"), 260 self.tr("Run Project"),
262 UI.PixmapCache.getIcon("runProject"), 261 EricPixmapCache.getIcon("runProject"),
263 self.tr("Run &Project..."), 262 self.tr("Run &Project..."),
264 QKeyCombination(Qt.Modifier.SHIFT, Qt.Key.Key_F2), 263 QKeyCombination(Qt.Modifier.SHIFT, Qt.Key.Key_F2),
265 0, 264 0,
266 self, 265 self,
267 "dbg_run_project", 266 "dbg_run_project",
279 self.runProjectAct.triggered.connect(self.__runProject) 278 self.runProjectAct.triggered.connect(self.__runProject)
280 self.actions.append(self.runProjectAct) 279 self.actions.append(self.runProjectAct)
281 280
282 self.coverageAct = EricAction( 281 self.coverageAct = EricAction(
283 self.tr("Coverage run of Script"), 282 self.tr("Coverage run of Script"),
284 UI.PixmapCache.getIcon("coverageScript"), 283 EricPixmapCache.getIcon("coverageScript"),
285 self.tr("Coverage run of Script..."), 284 self.tr("Coverage run of Script..."),
286 0, 285 0,
287 0, 286 0,
288 self, 287 self,
289 "dbg_coverage_script", 288 "dbg_coverage_script",
302 self.coverageAct.triggered.connect(self.__coverageScript) 301 self.coverageAct.triggered.connect(self.__coverageScript)
303 self.actions.append(self.coverageAct) 302 self.actions.append(self.coverageAct)
304 303
305 self.coverageProjectAct = EricAction( 304 self.coverageProjectAct = EricAction(
306 self.tr("Coverage run of Project"), 305 self.tr("Coverage run of Project"),
307 UI.PixmapCache.getIcon("coverageProject"), 306 EricPixmapCache.getIcon("coverageProject"),
308 self.tr("Coverage run of Project..."), 307 self.tr("Coverage run of Project..."),
309 0, 308 0,
310 0, 309 0,
311 self, 310 self,
312 "dbg_coverage_project", 311 "dbg_coverage_project",
326 self.coverageProjectAct.triggered.connect(self.__coverageProject) 325 self.coverageProjectAct.triggered.connect(self.__coverageProject)
327 self.actions.append(self.coverageProjectAct) 326 self.actions.append(self.coverageProjectAct)
328 327
329 self.profileAct = EricAction( 328 self.profileAct = EricAction(
330 self.tr("Profile Script"), 329 self.tr("Profile Script"),
331 UI.PixmapCache.getIcon("profileScript"), 330 EricPixmapCache.getIcon("profileScript"),
332 self.tr("Profile Script..."), 331 self.tr("Profile Script..."),
333 0, 332 0,
334 0, 333 0,
335 self, 334 self,
336 "dbg_profile_script", 335 "dbg_profile_script",
346 self.profileAct.triggered.connect(self.__profileScript) 345 self.profileAct.triggered.connect(self.__profileScript)
347 self.actions.append(self.profileAct) 346 self.actions.append(self.profileAct)
348 347
349 self.profileProjectAct = EricAction( 348 self.profileProjectAct = EricAction(
350 self.tr("Profile Project"), 349 self.tr("Profile Project"),
351 UI.PixmapCache.getIcon("profileProject"), 350 EricPixmapCache.getIcon("profileProject"),
352 self.tr("Profile Project..."), 351 self.tr("Profile Project..."),
353 0, 352 0,
354 0, 353 0,
355 self, 354 self,
356 "dbg_profile_project", 355 "dbg_profile_project",
367 self.profileProjectAct.triggered.connect(self.__profileProject) 366 self.profileProjectAct.triggered.connect(self.__profileProject)
368 self.actions.append(self.profileProjectAct) 367 self.actions.append(self.profileProjectAct)
369 368
370 self.debugAct = EricAction( 369 self.debugAct = EricAction(
371 self.tr("Debug Script"), 370 self.tr("Debug Script"),
372 UI.PixmapCache.getIcon("debugScript"), 371 EricPixmapCache.getIcon("debugScript"),
373 self.tr("&Debug Script..."), 372 self.tr("&Debug Script..."),
374 Qt.Key.Key_F5, 373 Qt.Key.Key_F5,
375 0, 374 0,
376 self, 375 self,
377 "dbg_debug_script", 376 "dbg_debug_script",
389 self.debugAct.triggered.connect(self.__debugScript) 388 self.debugAct.triggered.connect(self.__debugScript)
390 self.actions.append(self.debugAct) 389 self.actions.append(self.debugAct)
391 390
392 self.debugProjectAct = EricAction( 391 self.debugProjectAct = EricAction(
393 self.tr("Debug Project"), 392 self.tr("Debug Project"),
394 UI.PixmapCache.getIcon("debugProject"), 393 EricPixmapCache.getIcon("debugProject"),
395 self.tr("Debug &Project..."), 394 self.tr("Debug &Project..."),
396 QKeyCombination(Qt.Modifier.SHIFT, Qt.Key.Key_F5), 395 QKeyCombination(Qt.Modifier.SHIFT, Qt.Key.Key_F5),
397 0, 396 0,
398 self, 397 self,
399 "dbg_debug_project", 398 "dbg_debug_project",
411 self.debugProjectAct.triggered.connect(self.__debugProject) 410 self.debugProjectAct.triggered.connect(self.__debugProject)
412 self.actions.append(self.debugProjectAct) 411 self.actions.append(self.debugProjectAct)
413 412
414 self.restartAct = EricAction( 413 self.restartAct = EricAction(
415 self.tr("Restart"), 414 self.tr("Restart"),
416 UI.PixmapCache.getIcon("debugRestart"), 415 EricPixmapCache.getIcon("debugRestart"),
417 self.tr("Restart"), 416 self.tr("Restart"),
418 Qt.Key.Key_F4, 417 Qt.Key.Key_F4,
419 0, 418 0,
420 self, 419 self,
421 "dbg_restart_script", 420 "dbg_restart_script",
433 self.restartAct.triggered.connect(self.__doRestart) 432 self.restartAct.triggered.connect(self.__doRestart)
434 self.actions.append(self.restartAct) 433 self.actions.append(self.restartAct)
435 434
436 self.stopAct = EricAction( 435 self.stopAct = EricAction(
437 self.tr("Stop"), 436 self.tr("Stop"),
438 UI.PixmapCache.getIcon("stopScript"), 437 EricPixmapCache.getIcon("stopScript"),
439 self.tr("Stop"), 438 self.tr("Stop"),
440 QKeyCombination(Qt.Modifier.SHIFT, Qt.Key.Key_F10), 439 QKeyCombination(Qt.Modifier.SHIFT, Qt.Key.Key_F10),
441 0, 440 0,
442 self, 441 self,
443 "dbg_stop_script", 442 "dbg_stop_script",
454 453
455 self.debugActGrp = createActionGroup(self) 454 self.debugActGrp = createActionGroup(self)
456 455
457 act = EricAction( 456 act = EricAction(
458 self.tr("Continue"), 457 self.tr("Continue"),
459 UI.PixmapCache.getIcon("continue"), 458 EricPixmapCache.getIcon("continue"),
460 self.tr("&Continue"), 459 self.tr("&Continue"),
461 Qt.Key.Key_F6, 460 Qt.Key.Key_F6,
462 0, 461 0,
463 self.debugActGrp, 462 self.debugActGrp,
464 "dbg_continue", 463 "dbg_continue",
475 act.triggered.connect(self.__continue) 474 act.triggered.connect(self.__continue)
476 self.actions.append(act) 475 self.actions.append(act)
477 476
478 act = EricAction( 477 act = EricAction(
479 self.tr("Continue to Cursor"), 478 self.tr("Continue to Cursor"),
480 UI.PixmapCache.getIcon("continueToCursor"), 479 EricPixmapCache.getIcon("continueToCursor"),
481 self.tr("Continue &To Cursor"), 480 self.tr("Continue &To Cursor"),
482 QKeyCombination(Qt.Modifier.SHIFT, Qt.Key.Key_F6), 481 QKeyCombination(Qt.Modifier.SHIFT, Qt.Key.Key_F6),
483 0, 482 0,
484 self.debugActGrp, 483 self.debugActGrp,
485 "dbg_continue_to_cursor", 484 "dbg_continue_to_cursor",
500 act.triggered.connect(self.__runToCursor) 499 act.triggered.connect(self.__runToCursor)
501 self.actions.append(act) 500 self.actions.append(act)
502 501
503 act = EricAction( 502 act = EricAction(
504 self.tr("Continue Until"), 503 self.tr("Continue Until"),
505 UI.PixmapCache.getIcon("continueUntil"), 504 EricPixmapCache.getIcon("continueUntil"),
506 self.tr("Continue &Until"), 505 self.tr("Continue &Until"),
507 QKeyCombination(Qt.Modifier.CTRL, Qt.Key.Key_F6), 506 QKeyCombination(Qt.Modifier.CTRL, Qt.Key.Key_F6),
508 0, 507 0,
509 self.debugActGrp, 508 self.debugActGrp,
510 "dbg_continue_until", 509 "dbg_continue_until",
526 act.triggered.connect(self.__runUntil) 525 act.triggered.connect(self.__runUntil)
527 self.actions.append(act) 526 self.actions.append(act)
528 527
529 act = EricAction( 528 act = EricAction(
530 self.tr("Move Instruction Pointer to Cursor"), 529 self.tr("Move Instruction Pointer to Cursor"),
531 UI.PixmapCache.getIcon("moveInstructionPointer"), 530 EricPixmapCache.getIcon("moveInstructionPointer"),
532 self.tr("&Jump To Cursor"), 531 self.tr("&Jump To Cursor"),
533 Qt.Key.Key_F12, 532 Qt.Key.Key_F12,
534 0, 533 0,
535 self.debugActGrp, 534 self.debugActGrp,
536 "dbg_jump_to_cursor", 535 "dbg_jump_to_cursor",
555 act.triggered.connect(self.__moveInstructionPointer) 554 act.triggered.connect(self.__moveInstructionPointer)
556 self.actions.append(act) 555 self.actions.append(act)
557 556
558 act = EricAction( 557 act = EricAction(
559 self.tr("Single Step"), 558 self.tr("Single Step"),
560 UI.PixmapCache.getIcon("step"), 559 EricPixmapCache.getIcon("step"),
561 self.tr("Sin&gle Step"), 560 self.tr("Sin&gle Step"),
562 Qt.Key.Key_F7, 561 Qt.Key.Key_F7,
563 0, 562 0,
564 self.debugActGrp, 563 self.debugActGrp,
565 "dbg_single_step", 564 "dbg_single_step",
577 act.triggered.connect(self.__step) 576 act.triggered.connect(self.__step)
578 self.actions.append(act) 577 self.actions.append(act)
579 578
580 act = EricAction( 579 act = EricAction(
581 self.tr("Step Over"), 580 self.tr("Step Over"),
582 UI.PixmapCache.getIcon("stepOver"), 581 EricPixmapCache.getIcon("stepOver"),
583 self.tr("Step &Over"), 582 self.tr("Step &Over"),
584 Qt.Key.Key_F8, 583 Qt.Key.Key_F8,
585 0, 584 0,
586 self.debugActGrp, 585 self.debugActGrp,
587 "dbg_step_over", 586 "dbg_step_over",
605 act.triggered.connect(self.__stepOver) 604 act.triggered.connect(self.__stepOver)
606 self.actions.append(act) 605 self.actions.append(act)
607 606
608 act = EricAction( 607 act = EricAction(
609 self.tr("Step Out"), 608 self.tr("Step Out"),
610 UI.PixmapCache.getIcon("stepOut"), 609 EricPixmapCache.getIcon("stepOut"),
611 self.tr("Step Ou&t"), 610 self.tr("Step Ou&t"),
612 Qt.Key.Key_F9, 611 Qt.Key.Key_F9,
613 0, 612 0,
614 self.debugActGrp, 613 self.debugActGrp,
615 "dbg_step_out", 614 "dbg_step_out",
632 act.triggered.connect(self.__stepOut) 631 act.triggered.connect(self.__stepOut)
633 self.actions.append(act) 632 self.actions.append(act)
634 633
635 act = EricAction( 634 act = EricAction(
636 self.tr("Stop"), 635 self.tr("Stop"),
637 UI.PixmapCache.getIcon("stepQuit"), 636 EricPixmapCache.getIcon("stepQuit"),
638 self.tr("&Stop"), 637 self.tr("&Stop"),
639 Qt.Key.Key_F10, 638 Qt.Key.Key_F10,
640 0, 639 0,
641 self.debugActGrp, 640 self.debugActGrp,
642 "dbg_stop", 641 "dbg_stop",
712 711
713 self.dbgSetBpActGrp = createActionGroup(self) 712 self.dbgSetBpActGrp = createActionGroup(self)
714 713
715 self.dbgToggleBpAct = EricAction( 714 self.dbgToggleBpAct = EricAction(
716 self.tr("Toggle Breakpoint"), 715 self.tr("Toggle Breakpoint"),
717 UI.PixmapCache.getIcon("breakpointToggle"), 716 EricPixmapCache.getIcon("breakpointToggle"),
718 self.tr("Toggle Breakpoint"), 717 self.tr("Toggle Breakpoint"),
719 QKeySequence(self.tr("Shift+F11", "Debug|Toggle Breakpoint")), 718 QKeySequence(self.tr("Shift+F11", "Debug|Toggle Breakpoint")),
720 0, 719 0,
721 self.dbgSetBpActGrp, 720 self.dbgSetBpActGrp,
722 "dbg_toggle_breakpoint", 721 "dbg_toggle_breakpoint",
732 self.dbgToggleBpAct.triggered.connect(self.__toggleBreakpoint) 731 self.dbgToggleBpAct.triggered.connect(self.__toggleBreakpoint)
733 self.actions.append(self.dbgToggleBpAct) 732 self.actions.append(self.dbgToggleBpAct)
734 733
735 self.dbgEditBpAct = EricAction( 734 self.dbgEditBpAct = EricAction(
736 self.tr("Edit Breakpoint"), 735 self.tr("Edit Breakpoint"),
737 UI.PixmapCache.getIcon("cBreakpointToggle"), 736 EricPixmapCache.getIcon("cBreakpointToggle"),
738 self.tr("Edit Breakpoint..."), 737 self.tr("Edit Breakpoint..."),
739 QKeySequence(self.tr("Shift+F12", "Debug|Edit Breakpoint")), 738 QKeySequence(self.tr("Shift+F12", "Debug|Edit Breakpoint")),
740 0, 739 0,
741 self.dbgSetBpActGrp, 740 self.dbgSetBpActGrp,
742 "dbg_edit_breakpoint", 741 "dbg_edit_breakpoint",
752 self.dbgEditBpAct.triggered.connect(self.__editBreakpoint) 751 self.dbgEditBpAct.triggered.connect(self.__editBreakpoint)
753 self.actions.append(self.dbgEditBpAct) 752 self.actions.append(self.dbgEditBpAct)
754 753
755 self.dbgNextBpAct = EricAction( 754 self.dbgNextBpAct = EricAction(
756 self.tr("Next Breakpoint"), 755 self.tr("Next Breakpoint"),
757 UI.PixmapCache.getIcon("breakpointNext"), 756 EricPixmapCache.getIcon("breakpointNext"),
758 self.tr("Next Breakpoint"), 757 self.tr("Next Breakpoint"),
759 QKeySequence(self.tr("Ctrl+Shift+PgDown", "Debug|Next Breakpoint")), 758 QKeySequence(self.tr("Ctrl+Shift+PgDown", "Debug|Next Breakpoint")),
760 0, 759 0,
761 self.dbgSetBpActGrp, 760 self.dbgSetBpActGrp,
762 "dbg_next_breakpoint", 761 "dbg_next_breakpoint",
771 self.dbgNextBpAct.triggered.connect(self.__nextBreakpoint) 770 self.dbgNextBpAct.triggered.connect(self.__nextBreakpoint)
772 self.actions.append(self.dbgNextBpAct) 771 self.actions.append(self.dbgNextBpAct)
773 772
774 self.dbgPrevBpAct = EricAction( 773 self.dbgPrevBpAct = EricAction(
775 self.tr("Previous Breakpoint"), 774 self.tr("Previous Breakpoint"),
776 UI.PixmapCache.getIcon("breakpointPrevious"), 775 EricPixmapCache.getIcon("breakpointPrevious"),
777 self.tr("Previous Breakpoint"), 776 self.tr("Previous Breakpoint"),
778 QKeySequence(self.tr("Ctrl+Shift+PgUp", "Debug|Previous Breakpoint")), 777 QKeySequence(self.tr("Ctrl+Shift+PgUp", "Debug|Previous Breakpoint")),
779 0, 778 0,
780 self.dbgSetBpActGrp, 779 self.dbgSetBpActGrp,
781 "dbg_previous_breakpoint", 780 "dbg_previous_breakpoint",
866 @param toolbarManager reference to a toolbar manager object 865 @param toolbarManager reference to a toolbar manager object
867 (EricToolBarManager) 866 (EricToolBarManager)
868 @return the generated toolbars (list of QToolBar) 867 @return the generated toolbars (list of QToolBar)
869 """ 868 """
870 starttb = QToolBar(self.tr("Start"), self.ui) 869 starttb = QToolBar(self.tr("Start"), self.ui)
871 starttb.setIconSize(UI.Config.ToolBarIconSize) 870 starttb.setIconSize(Config.ToolBarIconSize)
872 starttb.setObjectName("StartToolbar") 871 starttb.setObjectName("StartToolbar")
873 starttb.setToolTip(self.tr("Start")) 872 starttb.setToolTip(self.tr("Start"))
874 873
875 starttb.addAction(self.restartAct) 874 starttb.addAction(self.restartAct)
876 starttb.addAction(self.stopAct) 875 starttb.addAction(self.stopAct)
880 starttb.addSeparator() 879 starttb.addSeparator()
881 starttb.addAction(self.debugAct) 880 starttb.addAction(self.debugAct)
882 starttb.addAction(self.debugProjectAct) 881 starttb.addAction(self.debugProjectAct)
883 882
884 debugtb = QToolBar(self.tr("Debug"), self.ui) 883 debugtb = QToolBar(self.tr("Debug"), self.ui)
885 debugtb.setIconSize(UI.Config.ToolBarIconSize) 884 debugtb.setIconSize(Config.ToolBarIconSize)
886 debugtb.setObjectName("DebugToolbar") 885 debugtb.setObjectName("DebugToolbar")
887 debugtb.setToolTip(self.tr("Debug")) 886 debugtb.setToolTip(self.tr("Debug"))
888 887
889 debugtb.addActions(self.debugActGrp.actions()) 888 debugtb.addActions(self.debugActGrp.actions())
890 debugtb.addSeparator() 889 debugtb.addSeparator()
1356 kind = NotificationTypes.WARNING 1355 kind = NotificationTypes.WARNING
1357 else: 1356 else:
1358 timeout = None 1357 timeout = None
1359 kind = NotificationTypes.INFORMATION 1358 kind = NotificationTypes.INFORMATION
1360 self.ui.showNotification( 1359 self.ui.showNotification(
1361 UI.PixmapCache.getPixmap("debug48"), 1360 EricPixmapCache.getPixmap("debug48"),
1362 self.tr("Program terminated"), 1361 self.tr("Program terminated"),
1363 msg, 1362 msg,
1364 kind=kind, 1363 kind=kind,
1365 timeout=timeout, 1364 timeout=timeout,
1366 ) 1365 )

eric ide

mercurial