eric7/Plugins/ViewManagerPlugins/Listspace/Listspace.py

branch
eric7
changeset 8532
a392af4b87e8
parent 8519
fd4722a8f782
child 8881
54e42bc2437a
equal deleted inserted replaced
8531:4ce885e452ac 8532:a392af4b87e8
13 from PyQt6.QtWidgets import ( 13 from PyQt6.QtWidgets import (
14 QStackedWidget, QSplitter, QListWidget, QListWidgetItem, QSizePolicy, 14 QStackedWidget, QSplitter, QListWidget, QListWidgetItem, QSizePolicy,
15 QMenu, QApplication 15 QMenu, QApplication
16 ) 16 )
17 17
18 from EricWidgets.EricApplication import ericApp
19
18 from ViewManager.ViewManager import ViewManager 20 from ViewManager.ViewManager import ViewManager
19 21
20 import QScintilla.Editor 22 import QScintilla.Editor
21 from QScintilla.Editor import Editor 23 from QScintilla.Editor import Editor
22 from QScintilla.EditorAssembly import EditorAssembly 24 from QScintilla.EditorAssembly import EditorAssembly
23 25
24 import UI.PixmapCache 26 import UI.PixmapCache
27 import Preferences
25 28
26 29
27 class StackedWidget(QStackedWidget): 30 class StackedWidget(QStackedWidget):
28 """ 31 """
29 Class implementing a custimized StackedWidget. 32 Class implementing a custimized StackedWidget.
252 255
253 def __initMenu(self): 256 def __initMenu(self):
254 """ 257 """
255 Private method to initialize the viewlist context menu. 258 Private method to initialize the viewlist context menu.
256 """ 259 """
260 self.__startMenu = QMenu(self.tr("Start"), self)
261 self.__startMenu.addAction(
262 UI.PixmapCache.getIcon("runScript"),
263 self.tr('Run Script...'),
264 self.__contextMenuRunScript)
265 self.__startMenu.addAction(
266 UI.PixmapCache.getIcon("debugScript"),
267 self.tr('Debug Script...'),
268 self.__contextMenuDebugScript)
269 self.__startMenu.addAction(
270 UI.PixmapCache.getIcon("profileScript"),
271 self.tr('Profile Script...'),
272 self.__contextMenuProfileScript)
273 self.__startMenu.addAction(
274 UI.PixmapCache.getIcon("coverageScript"),
275 self.tr('Coverage run of Script...'),
276 self.__contextMenuCoverageScript)
277
257 self.__menu = QMenu(self) 278 self.__menu = QMenu(self)
258 self.__menu.addAction( 279 self.__menu.addAction(
259 UI.PixmapCache.getIcon("tabClose"), 280 UI.PixmapCache.getIcon("tabClose"),
260 self.tr('Close'), self.__contextMenuClose) 281 self.tr('Close'), self.__contextMenuClose)
261 self.closeOthersMenuAct = self.__menu.addAction( 282 self.closeOthersMenuAct = self.__menu.addAction(
277 self.__menu.addSeparator() 298 self.__menu.addSeparator()
278 self.openRejectionsMenuAct = self.__menu.addAction( 299 self.openRejectionsMenuAct = self.__menu.addAction(
279 self.tr("Open 'rejection' file"), 300 self.tr("Open 'rejection' file"),
280 self.__contextMenuOpenRejections) 301 self.__contextMenuOpenRejections)
281 self.__menu.addSeparator() 302 self.__menu.addSeparator()
303 self.__startAct = self.__menu.addMenu(self.__startMenu)
304 self.__menu.addSeparator()
282 self.__menu.addAction( 305 self.__menu.addAction(
283 UI.PixmapCache.getIcon("printPreview"), 306 UI.PixmapCache.getIcon("printPreview"),
284 self.tr("Print Preview"), self.__contextMenuPrintPreviewFile) 307 self.tr("Print Preview"), self.__contextMenuPrintPreviewFile)
285 self.__menu.addAction( 308 self.__menu.addAction(
286 UI.PixmapCache.getIcon("print"), 309 UI.PixmapCache.getIcon("print"),
311 self.copyPathAct.setEnabled(bool(fileName)) 334 self.copyPathAct.setEnabled(bool(fileName))
312 if fileName: 335 if fileName:
313 rej = "{0}.rej".format(fileName) 336 rej = "{0}.rej".format(fileName)
314 self.openRejectionsMenuAct.setEnabled( 337 self.openRejectionsMenuAct.setEnabled(
315 os.path.exists(rej)) 338 os.path.exists(rej))
339
340 ext = os.path.splitext(fileName)[1]
341 self.__startAct.setEnabled(
342 ext in Preferences.getDebugger(
343 "Python3Extensions").split()
344 )
316 else: 345 else:
317 self.openRejectionsMenuAct.setEnabled(False) 346 self.openRejectionsMenuAct.setEnabled(False)
347 self.__startAct.setEnabled(False)
318 348
319 self.closeOthersMenuAct.setEnabled( 349 self.closeOthersMenuAct.setEnabled(
320 self.viewlist.count() > 1) 350 self.viewlist.count() > 1)
321 351
322 self.__menu.popup(self.viewlist.mapToGlobal(point)) 352 self.__menu.popup(self.viewlist.mapToGlobal(point))
870 if self.contextMenuEditor: 900 if self.contextMenuEditor:
871 fn = self.contextMenuEditor.getFileName() 901 fn = self.contextMenuEditor.getFileName()
872 if fn: 902 if fn:
873 cb = QApplication.clipboard() 903 cb = QApplication.clipboard()
874 cb.setText(fn) 904 cb.setText(fn)
875 905
906 def __contextMenuRunScript(self):
907 """
908 Private method to run the editor script.
909 """
910 if self.contextMenuEditor:
911 fn = self.contextMenuEditor.getFileName()
912 if fn:
913 ericApp().getObject("DebugUI").doRun(False, script=fn)
914
915 def __contextMenuDebugScript(self):
916 """
917 Private method to debug the editor script.
918 """
919 if self.contextMenuEditor:
920 fn = self.contextMenuEditor.getFileName()
921 if fn:
922 ericApp().getObject("DebugUI").doDebug(False, script=fn)
923
924 def __contextMenuProfileScript(self):
925 """
926 Private method to profile the editor script.
927 """
928 if self.contextMenuEditor:
929 fn = self.contextMenuEditor.getFileName()
930 if fn:
931 ericApp().getObject("DebugUI").doProfile(False, script=fn)
932
933 def __contextMenuCoverageScript(self):
934 """
935 Private method to run a coverage test of the editor script.
936 """
937 if self.contextMenuEditor:
938 fn = self.contextMenuEditor.getFileName()
939 if fn:
940 ericApp().getObject("DebugUI").doCoverage(False, script=fn)
941
876 def __currentChanged(self, index): 942 def __currentChanged(self, index):
877 """ 943 """
878 Private slot to handle the currentChanged signal. 944 Private slot to handle the currentChanged signal.
879 945
880 @param index index of the current editor 946 @param index index of the current editor

eric ide

mercurial