12 |
12 |
13 from PyQt6.QtCore import pyqtSignal |
13 from PyQt6.QtCore import pyqtSignal |
14 from PyQt6.QtWidgets import QDialog, QInputDialog, QMenu |
14 from PyQt6.QtWidgets import QDialog, QInputDialog, QMenu |
15 |
15 |
16 from EricWidgets import EricMessageBox |
16 from EricWidgets import EricMessageBox |
|
17 from EricWidgets.EricApplication import ericApp |
17 |
18 |
18 from UI.BrowserModel import ( |
19 from UI.BrowserModel import ( |
19 BrowserFileItem, BrowserClassItem, BrowserMethodItem, |
20 BrowserFileItem, BrowserClassItem, BrowserMethodItem, |
20 BrowserClassAttributeItem, BrowserImportItem |
21 BrowserClassAttributeItem, BrowserImportItem |
21 ) |
22 ) |
137 self.graphicsMenu.addAction( |
138 self.graphicsMenu.addAction( |
138 UI.PixmapCache.getIcon("open"), |
139 UI.PixmapCache.getIcon("open"), |
139 self.tr("Load Diagram..."), self.__loadDiagram) |
140 self.tr("Load Diagram..."), self.__loadDiagram) |
140 self.graphicsMenu.aboutToShow.connect(self.__showContextMenuGraphics) |
141 self.graphicsMenu.aboutToShow.connect(self.__showContextMenuGraphics) |
141 |
142 |
|
143 self.__startMenu = QMenu(self.tr("Start"), self) |
|
144 self.__startMenu.addAction( |
|
145 UI.PixmapCache.getIcon("runScript"), |
|
146 self.tr('Run Script...'), |
|
147 self.__contextMenuRunScript) |
|
148 self.__startMenu.addAction( |
|
149 UI.PixmapCache.getIcon("debugScript"), |
|
150 self.tr('Debug Script...'), |
|
151 self.__contextMenuDebugScript) |
|
152 self.__startMenu.addAction( |
|
153 UI.PixmapCache.getIcon("profileScript"), |
|
154 self.tr('Profile Script...'), |
|
155 self.__contextMenuProfileScript) |
|
156 self.__startMenu.addAction( |
|
157 UI.PixmapCache.getIcon("coverageScript"), |
|
158 self.tr('Coverage run of Script...'), |
|
159 self.__contextMenuCoverageScript) |
|
160 |
142 self.unittestAction = self.sourceMenu.addAction( |
161 self.unittestAction = self.sourceMenu.addAction( |
143 self.tr('Run unittest...'), self.handleUnittest) |
162 self.tr('Run unittest...'), self.handleUnittest) |
144 self.sourceMenu.addSeparator() |
163 self.sourceMenu.addSeparator() |
145 act = self.sourceMenu.addAction( |
164 act = self.sourceMenu.addAction( |
146 self.tr('Rename file'), self._renameFile) |
165 self.tr('Rename file'), self._renameFile) |
162 act = self.sourceMenu.addMenu(self.graphicsMenu) |
181 act = self.sourceMenu.addMenu(self.graphicsMenu) |
163 self.sourceMenu.addSeparator() |
182 self.sourceMenu.addSeparator() |
164 self.sourceMenu.addMenu(self.checksMenu) |
183 self.sourceMenu.addMenu(self.checksMenu) |
165 self.sourceMenu.addSeparator() |
184 self.sourceMenu.addSeparator() |
166 self.sourceMenuActions["Show"] = self.sourceMenu.addMenu(self.menuShow) |
185 self.sourceMenuActions["Show"] = self.sourceMenu.addMenu(self.menuShow) |
|
186 self.sourceMenu.addSeparator() |
|
187 self.__startAct = self.sourceMenu.addMenu(self.__startMenu) |
167 self.sourceMenu.addSeparator() |
188 self.sourceMenu.addSeparator() |
168 self.sourceMenu.addAction( |
189 self.sourceMenu.addAction( |
169 self.tr('Copy Path to Clipboard'), self._copyToClipboard) |
190 self.tr('Copy Path to Clipboard'), self._copyToClipboard) |
170 self.sourceMenu.addSeparator() |
191 self.sourceMenu.addSeparator() |
171 self.sourceMenu.addAction( |
192 self.sourceMenu.addAction( |
675 """ |
696 """ |
676 Private slot called by the sourceMenu aboutToShow signal. |
697 Private slot called by the sourceMenu aboutToShow signal. |
677 """ |
698 """ |
678 ProjectBaseBrowser._showContextMenu(self, self.sourceMenu) |
699 ProjectBaseBrowser._showContextMenu(self, self.sourceMenu) |
679 |
700 |
|
701 itm = self.model().item(self.currentIndex()) |
|
702 if itm: |
|
703 try: |
|
704 self.__startAct.setEnabled(itm.isPython3File()) |
|
705 except AttributeError: |
|
706 self.__startAct.setEnabled(False) |
|
707 else: |
|
708 self.__startAct.setEnabled(False) |
|
709 |
680 self.showMenu.emit("Main", self.sourceMenu) |
710 self.showMenu.emit("Main", self.sourceMenu) |
681 |
711 |
682 def __showContextMenuMulti(self): |
712 def __showContextMenuMulti(self): |
683 """ |
713 """ |
684 Private slot called by the multiMenu aboutToShow signal. |
714 Private slot called by the multiMenu aboutToShow signal. |
1152 loadedDiagram = UMLDialog( |
1182 loadedDiagram = UMLDialog( |
1153 UMLDialogType.NO_DIAGRAM, self.project, parent=self) |
1183 UMLDialogType.NO_DIAGRAM, self.project, parent=self) |
1154 if loadedDiagram.load(): |
1184 if loadedDiagram.load(): |
1155 self.loadedDiagram = loadedDiagram |
1185 self.loadedDiagram = loadedDiagram |
1156 self.loadedDiagram.show(fromFile=True) |
1186 self.loadedDiagram.show(fromFile=True) |
|
1187 |
|
1188 ########################################################################### |
|
1189 ## Methods for the Start submenu |
|
1190 ########################################################################### |
|
1191 |
|
1192 def __contextMenuRunScript(self): |
|
1193 """ |
|
1194 Private method to run the editor script. |
|
1195 """ |
|
1196 fn = self.model().item(self.currentIndex()).fileName() |
|
1197 ericApp().getObject("DebugUI").doRun(False, script=fn) |
|
1198 |
|
1199 def __contextMenuDebugScript(self): |
|
1200 """ |
|
1201 Private method to debug the editor script. |
|
1202 """ |
|
1203 fn = self.model().item(self.currentIndex()).fileName() |
|
1204 ericApp().getObject("DebugUI").doDebug(False, script=fn) |
|
1205 |
|
1206 def __contextMenuProfileScript(self): |
|
1207 """ |
|
1208 Private method to profile the editor script. |
|
1209 """ |
|
1210 fn = self.model().item(self.currentIndex()).fileName() |
|
1211 ericApp().getObject("DebugUI").doProfile(False, script=fn) |
|
1212 |
|
1213 def __contextMenuCoverageScript(self): |
|
1214 """ |
|
1215 Private method to run a coverage test of the editor script. |
|
1216 """ |
|
1217 fn = self.model().item(self.currentIndex()).fileName() |
|
1218 ericApp().getObject("DebugUI").doCoverage(False, script=fn) |