Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 3 commits
  • 2 files changed
  • 2 comments
  • 1 contributor
166  src/helpers/actions.py
... ...
@@ -1,166 +0,0 @@
1  
-# ricodebug - A GDB frontend which focuses on visually supported
2  
-# debugging using data structure graphs and SystemC features.
3  
-#
4  
-# Copyright (C) 2011  The ricodebug project team at the
5  
-# Upper Austrian University Of Applied Sciences Hagenberg,
6  
-# Department Embedded Systems Design
7  
-#
8  
-# This file is part of ricodebug.
9  
-#
10  
-# ricodebug is free software: you can redistribute it and/or modify
11  
-# it under the terms of the GNU General Public License as published by
12  
-# the Free Software Foundation, either version 3 of the License, or
13  
-# (at your option) any later version.
14  
-#
15  
-# This program is distributed in the hope that it will be useful,
16  
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
17  
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  
-# GNU General Public License for more details.
19  
-#
20  
-# You should have received a copy of the GNU General Public License
21  
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
22  
-#
23  
-# For further information see <http://syscdbg.hagenberg.servus.at/>.
24  
-
25  
-from PyQt4 import QtCore, QtGui
26  
-from PyQt4.QtCore import SIGNAL, QObject
27  
-
28  
-"""
29  
-general information:
30  
- * to add a action write a enum-Key-word into list below class declaration 
31  
-   and raise range in both, range after list AND range for 
32  
-   self.actions = rang(N) dont forget "\" if line is ending
33  
- * then create the action using createAction function in initActions 
34  
-   from Actions class:
35  
-    ...
36  
-    def initActions(self):
37  
-        # your action name
38  
-        self.createActions(<params for your action as string>)
39  
-    ...
40  
- * connect your actions via connectAction or connectActionEx or your own Implementation
41  
-"""
42  
-
43  
-
44  
-class ActionEx(QtGui.QAction):
45  
-    def __init__(self, parameter, parent=None):
46  
-        QtGui.QAction.__init__(self, parent)
47  
-        self.parameter = parameter
48  
-        QObject.connect(self, SIGNAL("triggered()"), self.commit)
49  
-        self.parent = parent
50  
-
51  
-    def commit(self):
52  
-        print "---------------------------- commit ActionEx success."
53  
-        if self.parameter == None:
54  
-            print "------------------------ ActionEx: set paramter first!"
55  
-        else:
56  
-            print "------------------------ parameter ok."
57  
-            self.emit(QtCore.SIGNAL("triggered(PyQt_PyObject)"), self.parameter)
58  
-
59  
-
60  
-class Actions(QtCore.QObject):
61  
-    NumActions = 20
62  
-    Open, Exit, SaveFile, \
63  
-    Run, Continue, ReverseContinue, Interrupt, Next, ReverseNext, \
64  
-    Step, ReverseStep, Finish, RunToCursor, \
65  
-    ToggleBreak, ToggleTrace, AddTraceVar, DelTraveVar, \
66  
-    AddWatch, AddVarToDataGraph, DelWatch = range(NumActions)
67  
-
68  
-    def __init__(self, parent=None):
69  
-        QtCore.QObject.__init__(self, parent)
70  
-        self.actions = [None for _ in range(self.NumActions)]
71  
-        self.initGlobalActions()
72  
-
73  
-    def add(self, enum, action):
74  
-        """dont use this function outside of class!!!"""
75  
-        self.actions[enum] = action
76  
-
77  
-    def createAction(self, icon, text, shortcut, statustip, enum, parameter=None):
78  
-        """dont use this function outside of class!!!"""
79  
-        if parameter is None:
80  
-            newAction = QtGui.QAction(QtGui.QIcon(icon), text, self)
81  
-        else:
82  
-            newAction = ActionEx(parameter)
83  
-
84  
-        if shortcut is not None:
85  
-            newAction.setShortcut(shortcut)
86  
-
87  
-        newAction.setStatusTip(statustip)
88  
-        self.add(enum, newAction)
89  
-
90  
-    def initGlobalActions(self):
91  
-
92  
-        ###############################################
93  
-        ## file/program control
94  
-        ###############################################
95  
-        #open
96  
-        self.createAction(":/icons/images/open.png", "Open", "Ctrl+O", \
97  
-                "Open executable file", self.Open)
98  
-        #exit
99  
-        self.createAction(":/icons/images/exit.png", "Exit", "Ctrl+Q", \
100  
-                "Close Program", self.Exit)
101  
-        #save source file
102  
-        self.createAction(":/icons/images/save.png", "Save File", "Ctrl+S", \
103  
-                "Save source file", self.SaveFile)
104  
-
105  
-        ###############################################
106  
-        ## file control
107  
-        ###############################################
108  
-        #run
109  
-        self.createAction(":/icons/images/run.png", "Run", "F5", \
110  
-                "Run current executable", self.Run)
111  
-        #continue
112  
-        self.createAction(":/icons/images/continue.png", "Continue", "F6", \
113  
-                "Continue current executable", self.Continue)
114  
-        #interrupt
115  
-        self.createAction(":/icons/images/interrupt.png", "Interrupt", "F4", \
116  
-                "Interrupt current executable", self.Interrupt)
117  
-        #next
118  
-        self.createAction(":/icons/images/next.png", "Next", "F10", \
119  
-                "Execute next line", self.Next)
120  
-        #previous
121  
-        self.createAction(":/icons/images/rnext.png", "Reverse Next", None, \
122  
-                "Execute previous line", self.ReverseNext)
123  
-        #step
124  
-        self.createAction(":/icons/images/step.png", "Step", "F11", \
125  
-                "Next Step", self.Step)
126  
-        #reverse step
127  
-        self.createAction(":/icons/images/rstep.png", "Reverse Step", None, \
128  
-                "Previous Step", self.ReverseStep)
129  
-        #finish
130  
-        self.createAction(":/icons/images/finish.png", "Finish", None, \
131  
-                "Finish executable", self.Finish)
132  
-        #run to cursor
133  
-        self.createAction(":/icons/images/until.png", "Run to Cursor", None, \
134  
-                "Run executable to cursor position", self.RunToCursor)
135  
-
136  
-        ###############################################
137  
-        ## watch/break/trace points
138  
-        ###############################################
139  
-        #toggle breakpoint
140  
-        self.createAction(":/icons/images/bp.png", "Toggle Breakpoint", \
141  
-                "Ctrl+b", "Toggle breakpoint in current line", self.ToggleBreak)
142  
-        #add tracepoint
143  
-        self.createAction(":/icons/images/tp.png", "Toggle Tracepoint", \
144  
-                "Ctrl+t", "Toggle tracepoint in current line", self.ToggleTrace)
145  
-        #AddTraceVar
146  
-        self.createAction(":/icons/images/tp_var_plus.png", \
147  
-                "Add var to Tracepoint", "+", \
148  
-                "Add selected variable to tracepoint", self.AddTraceVar)
149  
-        #DelTraceVar
150  
-        self.createAction(":/icons/images/tp_var_minus.png", \
151  
-                "Del var from Tracepoint", "-", \
152  
-                "Remove selected variable from tracepoint", self.DelTraveVar)
153  
-        #AddWatch
154  
-        self.createAction(":/icons/images/watch_plus.png", "Add var to Watch",\
155  
-                "+", "Add selected variable to watchview-window", self.AddWatch)
156  
-        #AddToDataGraph
157  
-        self.createAction(":/icons/images/watch_plus.png", \
158  
-                "Add var to DataGraph", "+", \
159  
-                "Add selected variable to datagraph-window", \
160  
-                self.AddVarToDataGraph)
161  
-        #DelWatch
162  
-        self.createAction(":/icons/images/watch_minus.png", \
163  
-                "Del var from Watch", "+", \
164  
-                "Remove selected variable from watchview-window", self.DelWatch)
165  
-
166  
-
171  src/views/mainwindow.py
@@ -22,15 +22,93 @@
22 22
 #
23 23
 # For further information see <http://syscdbg.hagenberg.servus.at/>.
24 24
 
25  
-from PyQt4.QtGui import QMainWindow, QFileDialog, QLabel, QDockWidget, QPixmap
  25
+from PyQt4.QtGui import QMainWindow, QFileDialog, QLabel, QDockWidget, QPixmap,\
  26
+        QAction, QIcon
26 27
 from PyQt4.QtCore import SIGNAL, QObject, Qt
27 28
 from ui_mainwindow import Ui_MainWindow
28 29
 from helpers.distributedobjects import DistributedObjects
29 30
 from helpers.recentfilehandler import OpenRecentFileAction, RecentFileHandler
30  
-from helpers.actions import Actions
31 31
 from helpers.pluginloader import PluginLoader
32 32
 from controllers.quickwatch import QuickWatch
33 33
 
  34
+class Actions(QObject):
  35
+    Open = Exit = SaveFile = Run = Continue = ReverseContinue = Interrupt = Next = \
  36
+        ReverseNext = Step = ReverseStep = Finish = RunToCursor = ToggleBreak = \
  37
+        ToggleTrace = AddTraceVar = DelTraveVar = AddWatch = AddVarToDataGraph = \
  38
+        DelWatch = None
  39
+
  40
+    def __init__(self, parent):
  41
+        QObject.__init__(self, parent)
  42
+        self.parent = parent
  43
+        ###############################################
  44
+        ## file/program control
  45
+        ###############################################
  46
+        Actions.Open = self.createAction(":/icons/images/open.png", "Open", "Ctrl+O", \
  47
+                "Open executable file", self.Open)
  48
+        Actions.Exit = self.createAction(":/icons/images/exit.png", "Exit", "Ctrl+Q", \
  49
+                "Close Program", self.Exit)
  50
+        Actions.SaveFile = self.createAction(":/icons/images/save.png", "Save File", "Ctrl+S", \
  51
+                "Save source file", self.SaveFile)
  52
+
  53
+        ###############################################
  54
+        ## file control
  55
+        ###############################################
  56
+        Actions.Run = self.createAction(":/icons/images/run.png", "Run", "F5", \
  57
+                "Run current executable")
  58
+        Actions.Continue = self.createAction(":/icons/images/continue.png", "Continue", "F6", \
  59
+                "Continue current executable")
  60
+        Actions.Interrupt = self.createAction(":/icons/images/interrupt.png", "Interrupt", "F4", \
  61
+                "Interrupt current executable")
  62
+        Actions.Next = self.createAction(":/icons/images/next.png", "Next", "F10", \
  63
+                "Execute next line")
  64
+        Actions.ReverseNext = self.createAction(":/icons/images/rnext.png", "Reverse Next", None, \
  65
+                "Execute previous line")
  66
+        Actions.Step = self.createAction(":/icons/images/step.png", "Step", "F11", \
  67
+                "Next Step")
  68
+        Actions.ReverseStep = self.createAction(":/icons/images/rstep.png", "Reverse Step", None, \
  69
+                "Previous Step", self.ReverseStep)
  70
+        Actions.Finish = self.createAction(":/icons/images/finish.png", "Finish", None, \
  71
+                "Finish executable")
  72
+        Actions.RunToCursor = self.createAction(":/icons/images/until.png", "Run to Cursor", None, \
  73
+                "Run executable to cursor position")
  74
+
  75
+        ###############################################
  76
+        ## watch/break/trace points
  77
+        ###############################################
  78
+        Actions.ToggleBreak = self.createAction(":/icons/images/bp.png", "Toggle Breakpoint", \
  79
+                "Ctrl+b", "Toggle breakpoint in current line")
  80
+        Actions.ToggleTrace = self.createAction(":/icons/images/tp.png", "Toggle Tracepoint", \
  81
+                "Ctrl+t", "Toggle tracepoint in current line")
  82
+        Actions.AddTraceVar = self.createAction(":/icons/images/tp_var_plus.png", \
  83
+                "Add var to Tracepoint", "+", \
  84
+                "Add selected variable to tracepoint")
  85
+        Actions.DelTraceVar = self.createAction(":/icons/images/tp_var_minus.png", \
  86
+                "Del var from Tracepoint", "-", \
  87
+                "Remove selected variable from tracepoint")
  88
+        Actions.AddWatch = self.createAction(":/icons/images/watch_plus.png", "Add var to Watch",\
  89
+                "+", "Add selected variable to watchview-window")
  90
+        Actions.AddVarToDataGraph = self.createAction(":/icons/images/watch_plus.png", \
  91
+                "Add var to DataGraph", "+", \
  92
+                "Add selected variable to datagraph-window",)
  93
+        Actions.DelWatch = self.createAction(":/icons/images/watch_minus.png", \
  94
+                "Del var from Watch", "+", \
  95
+                "Remove selected variable from watchview-window")
  96
+
  97
+    def createAction(self, icon, text, shortcut, statustip, parameter=None):
  98
+        """dont use this function outside of class!!!"""
  99
+        if parameter is None:
  100
+            newAction = QAction(QIcon(icon), text, self.parent)
  101
+        else:
  102
+            print "Booo"
  103
+            newAction = None
  104
+
  105
+        if shortcut is not None:
  106
+            newAction.setShortcut(shortcut)
  107
+
  108
+        newAction.setStatusTip(statustip)
  109
+        return newAction
  110
+
  111
+
34 112
 
35 113
 class MainWindow(QMainWindow):
36 114
     
@@ -106,22 +184,21 @@ def setupUi(self):
106 184
         #self.scene.addItem(self.c2)
107 185
 
108 186
     def __initActions(self):
109  
-        self.act = Actions(self)
  187
+        Actions(self)
110 188
         # debug actions
111  
-        self.ui.menuDebug.addAction(self.act.actions[Actions.Run])
112  
-        self.ui.menuDebug.addAction(self.act.actions[Actions.Continue])
113  
-        self.ui.menuDebug.addAction(self.act.actions[Actions.Interrupt])
114  
-        self.ui.menuDebug.addAction(self.act.actions[Actions.Next])
115  
-        self.ui.menuDebug.addAction(self.act.actions[Actions.ReverseNext])
116  
-        self.ui.menuDebug.addAction(self.act.actions[Actions.Step])
117  
-        self.ui.menuDebug.addAction(self.act.actions[Actions.ReverseStep])
118  
-        self.ui.menuDebug.addAction(self.act.actions[Actions.Finish])
119  
-        self.ui.menuDebug.addAction(self.act.actions[Actions.RunToCursor])
  189
+        self.ui.menuDebug.addAction(Actions.Run)
  190
+        self.ui.menuDebug.addAction(Actions.Continue)
  191
+        self.ui.menuDebug.addAction(Actions.Interrupt)
  192
+        self.ui.menuDebug.addAction(Actions.Next)
  193
+        self.ui.menuDebug.addAction(Actions.ReverseNext)
  194
+        self.ui.menuDebug.addAction(Actions.Step)
  195
+        self.ui.menuDebug.addAction(Actions.ReverseStep)
  196
+        self.ui.menuDebug.addAction(Actions.Finish)
  197
+        self.ui.menuDebug.addAction(Actions.RunToCursor)
120 198
         # file actions
121  
-        self.ui.menuFile.insertAction(self.ui.actionSaveSession, \
122  
-                self.act.actions[Actions.Open])
123  
-        self.ui.menuFile.addAction(self.act.actions[Actions.SaveFile])
124  
-        self.ui.menuFile.addAction(self.act.actions[Actions.Exit])
  199
+        self.ui.menuFile.insertAction(self.ui.actionSaveSession, Actions.Open)
  200
+        self.ui.menuFile.addAction(Actions.SaveFile)
  201
+        self.ui.menuFile.addAction(Actions.Exit)
125 202
 
126 203
         # add them to menubar and also menuView to respect order
127 204
         self.ui.menubar.addAction(self.ui.menuFile.menuAction())
@@ -129,51 +206,38 @@ def __initActions(self):
129 206
         self.ui.menubar.addAction(self.ui.menuDebug.menuAction())
130 207
         self.ui.menubar.addAction(self.ui.menuHelp.menuAction())
131 208
         # now make toolbar actions
132  
-        self.ui.Main.addAction(self.act.actions[Actions.Open])
133  
-        self.ui.Main.addAction(self.act.actions[Actions.SaveFile])
  209
+        self.ui.Main.addAction(Actions.Open)
  210
+        self.ui.Main.addAction(Actions.SaveFile)
134 211
         self.ui.Main.addSeparator()
135  
-        self.ui.Main.addAction(self.act.actions[Actions.Run])
136  
-        self.ui.Main.addAction(self.act.actions[Actions.Continue])
137  
-        self.ui.Main.addAction(self.act.actions[Actions.Interrupt])
138  
-        self.ui.Main.addAction(self.act.actions[Actions.Next])
139  
-        self.ui.Main.addAction(self.act.actions[Actions.Step])
140  
-        self.ui.Main.addAction(self.act.actions[Actions.ReverseNext])
141  
-        self.ui.Main.addAction(self.act.actions[Actions.ReverseStep])
142  
-        self.ui.Main.addAction(self.act.actions[Actions.Finish])
143  
-        self.ui.Main.addAction(self.act.actions[Actions.RunToCursor])
  212
+        self.ui.Main.addAction(Actions.Run)
  213
+        self.ui.Main.addAction(Actions.Continue)
  214
+        self.ui.Main.addAction(Actions.Interrupt)
  215
+        self.ui.Main.addAction(Actions.Next)
  216
+        self.ui.Main.addAction(Actions.Step)
  217
+        self.ui.Main.addAction(Actions.ReverseNext)
  218
+        self.ui.Main.addAction(Actions.ReverseStep)
  219
+        self.ui.Main.addAction(Actions.Finish)
  220
+        self.ui.Main.addAction(Actions.RunToCursor)
144 221
         self.ui.Main.addSeparator()
145  
-        self.ui.Main.addAction(self.act.actions[Actions.Exit])
  222
+        self.ui.Main.addAction(Actions.Exit)
146 223
         # connect actions
147 224
         self.__connectActions()
148 225
 
149 226
     def __connectActions(self):
150 227
         # file menu
151  
-        self.connect(self.act.actions[Actions.Open], SIGNAL('activated()'), \
152  
-                self.showOpenExecutableDialog)
153  
-        self.connect(self.act.actions[Actions.Exit], SIGNAL('activated()'), \
154  
-                self.close)
155  
-        self.connect(self.act.actions[Actions.SaveFile], SIGNAL('activated()'),\
156  
-                self.signalproxy.emitSaveCurrentFile)
157  
-
  228
+        Actions.Open.triggered.connect(self.showOpenExecutableDialog)
  229
+        Actions.Exit.triggered.connect(self.close)
  230
+        Actions.SaveFile.triggered.connect(self.signalproxy.emitSaveCurrentFile) 
158 231
         # debug menu
159  
-        self.connect(self.act.actions[Actions.Run], SIGNAL('activated()'), \
160  
-                self.debugController.run)
161  
-        self.connect(self.act.actions[Actions.Next], SIGNAL('activated()'), \
162  
-                self.debugController.next_)
163  
-        self.connect(self.act.actions[Actions.ReverseNext], \
164  
-                SIGNAL('activated()'), self.debugController.reverse_next)
165  
-        self.connect(self.act.actions[Actions.Step], SIGNAL('activated()'), \
166  
-                self.debugController.step)
167  
-        self.connect(self.act.actions[Actions.ReverseStep], \
168  
-                SIGNAL('activated()'), self.debugController.reverse_step)
169  
-        self.connect(self.act.actions[Actions.Continue], SIGNAL('activated()'),\
170  
-                self.debugController.cont)
171  
-        self.connect(self.act.actions[Actions.Interrupt], SIGNAL('activated()')\
172  
-                , self.debugController.interrupt)
173  
-        self.connect(self.act.actions[Actions.Finish], SIGNAL('activated()'), \
174  
-                self.debugController.finish)
175  
-        self.connect(self.act.actions[Actions.RunToCursor], \
176  
-                SIGNAL('activated()'), self.debugController.inferiorUntil)
  232
+        Actions.Run.triggered.connect(self.debugController.run)
  233
+        Actions.Next.triggered.connect(self.debugController.next_)
  234
+        Actions.ReverseNext.triggered.connect(self.debugController.reverse_next)
  235
+        Actions.Step.triggered.connect(self.debugController.step)
  236
+        Actions.ReverseStep.triggered.connect(self.debugController.reverse_step)
  237
+        Actions.Continue.triggered.connect(self.debugController.cont)
  238
+        Actions.Interrupt.triggered.connect(self.debugController.interrupt)
  239
+        Actions.Finish.triggered.connect(self.debugController.finish)
  240
+        Actions.RunToCursor.triggered.connect(self.debugController.inferiorUntil)
177 241
 
178 242
         QObject.connect(self.ui.actionRestoreSession, SIGNAL('activated()'), \
179 243
                 self.distributedObjects.sessionManager.showRestoreSessionDialog)
@@ -297,3 +361,4 @@ def closeEvent(self, event):
297 361
     def readSettings(self):
298 362
         self.restoreGeometry(self.settings.value("geometry").toByteArray())
299 363
         self.restoreState(self.settings.value("windowState").toByteArray())
  364
+

Showing you all comments on commits in this comparison.

Rainer Findenig

Both helpers/distributedobjects.py and views/openedfileview.py still reference actions.py, ie. with those changes the program will not run. Why merge them into the main window, anyway?

Rainer Findenig

This looks good -- it just needs to be changed all over the place ;).

Something went wrong with that request. Please try again.