QScintilla/ShellWindow.py

changeset 5711
50b6867ffcd3
parent 5710
b5809b948010
child 5712
f0d08bdeacf4
equal deleted inserted replaced
5710:b5809b948010 5711:50b6867ffcd3
7 Module implementing a stand alone shell window. 7 Module implementing a stand alone shell window.
8 """ 8 """
9 9
10 from __future__ import unicode_literals 10 from __future__ import unicode_literals
11 11
12 from PyQt5.QtCore import Qt, QCoreApplication, QPoint, QSize, QSignalMapper 12 import sys
13 import os
14
15 from PyQt5.QtCore import Qt, QCoreApplication, QPoint, QSize, QSignalMapper, \
16 QProcess
13 from PyQt5.QtGui import QKeySequence 17 from PyQt5.QtGui import QKeySequence
14 from PyQt5.QtWidgets import QWidget, QVBoxLayout, QApplication, QAction, \ 18 from PyQt5.QtWidgets import QWidget, QVBoxLayout, QApplication, QAction, \
15 QWhatsThis, QDialog 19 QWhatsThis, QDialog
16 from PyQt5.Qsci import QsciScintilla 20 from PyQt5.Qsci import QsciScintilla
17 21
30 from .Shell import Shell 34 from .Shell import Shell
31 from .APIsManager import APIsManager 35 from .APIsManager import APIsManager
32 36
33 from Debugger.DebugServer import DebugServer 37 from Debugger.DebugServer import DebugServer
34 from UI.SearchWidget import SearchWidget 38 from UI.SearchWidget import SearchWidget
39
40 from eric6config import getConfig
35 41
36 42
37 class ShellWindow(E5MainWindow): 43 class ShellWindow(E5MainWindow):
38 """ 44 """
39 Class implementing a stand alone shell window. 45 Class implementing a stand alone shell window.
96 102
97 def closeEvent(self, event): 103 def closeEvent(self, event):
98 """ 104 """
99 Protected method to handle the close event. 105 Protected method to handle the close event.
100 106
101 @param event close event (QCloseEvent) 107 @param event close event
108 @type QCloseEvent
102 """ 109 """
103 self.__writeSettings() 110 self.__writeSettings()
104 self.__debugServer.shutdownServer() 111 self.__debugServer.shutdownServer()
105 self.__shell.closeShell() 112 self.__shell.closeShell()
106 113
124 131
125 def __readShortcut(self, act, category): 132 def __readShortcut(self, act, category):
126 """ 133 """
127 Private function to read a single keyboard shortcut from the settings. 134 Private function to read a single keyboard shortcut from the settings.
128 135
129 @param act reference to the action object (E5Action) 136 @param act reference to the action object
130 @param category category the action belongs to (string) 137 @type E5Action
138 @param category category the action belongs to
139 @type str
131 """ 140 """
132 if act.objectName(): 141 if act.objectName():
133 accel = Preferences.Prefs.settings.value( 142 accel = Preferences.Prefs.settings.value(
134 "Shortcuts/{0}/{1}/Accel".format(category, act.objectName())) 143 "Shortcuts/{0}/{1}/Accel".format(category, act.objectName()))
135 if accel is not None: 144 if accel is not None:
179 self.tr('Quit'), 188 self.tr('Quit'),
180 UI.PixmapCache.getIcon("exit.png"), 189 UI.PixmapCache.getIcon("exit.png"),
181 self.tr('&Quit'), 190 self.tr('&Quit'),
182 QKeySequence(self.tr("Ctrl+Q", "File|Quit")), 191 QKeySequence(self.tr("Ctrl+Q", "File|Quit")),
183 0, self, 'quit') 192 0, self, 'quit')
184 self.exitAct.setStatusTip(self.tr('Quit the IDE')) 193 self.exitAct.setStatusTip(self.tr('Quit the Shell'))
185 self.exitAct.setWhatsThis(self.tr( 194 self.exitAct.setWhatsThis(self.tr(
186 """<b>Quit the Shell</b>""" 195 """<b>Quit the Shell</b>"""
187 """<p>This quits the Shell window.</p>""" 196 """<p>This quits the Shell window.</p>"""
188 )) 197 ))
189 self.exitAct.triggered.connect(self.quit) 198 self.exitAct.triggered.connect(self.quit)
190 self.exitAct.setMenuRole(QAction.QuitRole) 199 self.exitAct.setMenuRole(QAction.QuitRole)
191 self.fileActions.append(self.exitAct) 200 self.fileActions.append(self.exitAct)
192 ## 201
193 ## self.newWindowAct = E5Action( 202 self.newWindowAct = E5Action(
194 ## self.tr('New Window'), 203 self.tr('New Window'),
195 ## UI.PixmapCache.getIcon("newWindow.png"), 204 UI.PixmapCache.getIcon("newWindow.png"),
196 ## self.tr('New &Window'), 205 self.tr('New &Window'),
197 ## QKeySequence(self.tr("Ctrl+Shift+N", "File|New Window")), 206 QKeySequence(self.tr("Ctrl+Shift+N", "File|New Window")),
198 ## 0, self, 'new_window') 207 0, self, 'new_window')
199 ## self.newWindowAct.setStatusTip(self.tr( 208 self.newWindowAct.setStatusTip(self.tr(
200 ## 'Open a new eric6 instance')) 209 'Open a new Shell window'))
201 ## self.newWindowAct.setWhatsThis(self.tr( 210 self.newWindowAct.setWhatsThis(self.tr(
202 ## """<b>New Window</b>""" 211 """<b>New Window</b>"""
203 ## """<p>This opens a new instance of the eric6 IDE.</p>""" 212 """<p>This opens a new instance of the Shell window.</p>"""
204 ## )) 213 ))
205 ## self.newWindowAct.triggered.connect(self.__newWindow) 214 self.newWindowAct.triggered.connect(self.__newWindow)
206 ## self.fileActions.append(self.newWindowAct) 215 self.fileActions.append(self.newWindowAct)
207 216
208 self.restartAct = E5Action( 217 self.restartAct = E5Action(
209 self.tr('Restart'), 218 self.tr('Restart'),
210 UI.PixmapCache.getIcon("restart.png"), 219 UI.PixmapCache.getIcon("restart.png"),
211 self.tr('Restart'), 220 self.tr('Restart'),
970 Private slot to handle the 'restart and clear' menu entry. 979 Private slot to handle the 'restart and clear' menu entry.
971 """ 980 """
972 self.__doRestart() 981 self.__doRestart()
973 self.__shell.clear() 982 self.__shell.clear()
974 983
984 def __newWindow(self):
985 """
986 Private slot to start a new instance of eric6.
987 """
988 program = sys.executable
989 eric6 = os.path.join(getConfig("ericDir"), "eric6_shell.py")
990 args = [eric6]
991 QProcess.startDetached(program, args)
992
975 ################################################################## 993 ##################################################################
976 ## Below are the action methods for the view menu 994 ## Below are the action methods for the view menu
977 ################################################################## 995 ##################################################################
978 996
979 def __zoomIn(self): 997 def __zoomIn(self):
1009 1027
1010 def __zoomTo(self, value): 1028 def __zoomTo(self, value):
1011 """ 1029 """
1012 Private slot to zoom to a given value. 1030 Private slot to zoom to a given value.
1013 1031
1014 @param value zoom value to be set (integer) 1032 @param value zoom value to be set
1033 @type int
1015 """ 1034 """
1016 self.__shell.zoomTo(value) 1035 self.__shell.zoomTo(value)
1017 self.__sbZoom.setValue(self.__shell.getZoom()) 1036 self.__sbZoom.setValue(self.__shell.getZoom())
1018 1037
1019 def __zoomValueChanged(self, value): 1038 def __zoomValueChanged(self, value):
1020 """ 1039 """
1021 Private slot to handle changes of the zoom value. 1040 Private slot to handle changes of the zoom value.
1022 1041
1023 @param value new zoom value (integer) 1042 @param value new zoom value
1043 @type int
1024 """ 1044 """
1025 self.__sbZoom.setValue(value) 1045 self.__sbZoom.setValue(value)
1026 1046
1027 ################################################################## 1047 ##################################################################
1028 ## Below are the action methods for the help menu 1048 ## Below are the action methods for the help menu
1060 """ 1080 """
1061 Private method to create the menus of the menu bar. 1081 Private method to create the menus of the menu bar.
1062 """ 1082 """
1063 self.__fileMenu = self.menuBar().addMenu(self.tr("&File")) 1083 self.__fileMenu = self.menuBar().addMenu(self.tr("&File"))
1064 self.__fileMenu.setTearOffEnabled(True) 1084 self.__fileMenu.setTearOffEnabled(True)
1065 ## self.__fileMenu.addAction(self.newAct) 1085 self.__fileMenu.addAction(self.newWindowAct)
1066 ## self.__fileMenu.addSeparator() 1086 self.__fileMenu.addSeparator()
1067 self.__fileMenu.addAction(self.restartAct) 1087 self.__fileMenu.addAction(self.restartAct)
1068 self.__fileMenu.addAction(self.clearRestartAct) 1088 self.__fileMenu.addAction(self.clearRestartAct)
1069 self.__fileMenu.addSeparator() 1089 self.__fileMenu.addSeparator()
1070 self.__fileMenu.addAction(self.exitAct) 1090 self.__fileMenu.addAction(self.exitAct)
1071 1091
1134 """ 1154 """
1135 Private method to create the various toolbars. 1155 Private method to create the various toolbars.
1136 """ 1156 """
1137 filetb = self.addToolBar(self.tr("File")) 1157 filetb = self.addToolBar(self.tr("File"))
1138 filetb.setIconSize(UI.Config.ToolBarIconSize) 1158 filetb.setIconSize(UI.Config.ToolBarIconSize)
1139 ## filetb.addAction(self.newAct) 1159 filetb.addAction(self.newWindowAct)
1140 filetb.addSeparator() 1160 filetb.addSeparator()
1141 filetb.addAction(self.restartAct) 1161 filetb.addAction(self.restartAct)
1142 filetb.addAction(self.clearRestartAct) 1162 filetb.addAction(self.clearRestartAct)
1143 filetb.addSeparator() 1163 filetb.addSeparator()
1144 filetb.addAction(self.exitAct) 1164 filetb.addAction(self.exitAct)

eric ide

mercurial