|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2017 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing a stand alone shell window. |
|
8 """ |
|
9 |
|
10 from __future__ import unicode_literals |
|
11 |
|
12 import sys |
|
13 import os |
|
14 |
|
15 from PyQt5.QtCore import Qt, QCoreApplication, QPoint, QSize, QSignalMapper, \ |
|
16 QProcess |
|
17 from PyQt5.QtGui import QKeySequence |
|
18 from PyQt5.QtWidgets import QWidget, QVBoxLayout, QApplication, QAction, \ |
|
19 QWhatsThis, QDialog |
|
20 from PyQt5.Qsci import QsciScintilla |
|
21 |
|
22 from E5Gui.E5MainWindow import E5MainWindow |
|
23 from E5Gui.E5Action import E5Action, createActionGroup |
|
24 from E5Gui.E5Application import e5App |
|
25 from E5Gui.E5ZoomWidget import E5ZoomWidget |
|
26 from E5Gui import E5MessageBox |
|
27 |
|
28 import UI.Config |
|
29 import UI.PixmapCache |
|
30 import Preferences |
|
31 |
|
32 from Globals import isMacPlatform |
|
33 |
|
34 from .Shell import Shell |
|
35 from .APIsManager import APIsManager |
|
36 |
|
37 from Debugger.DebugServer import DebugServer |
|
38 from UI.SearchWidget import SearchWidget |
|
39 |
|
40 from eric6config import getConfig |
|
41 |
|
42 |
|
43 class ShellWindow(E5MainWindow): |
|
44 """ |
|
45 Class implementing a stand alone shell window. |
|
46 """ |
|
47 def __init__(self, parent=None, name=None): |
|
48 """ |
|
49 Constructor |
|
50 |
|
51 @param parent reference to the parent widget |
|
52 @type QWidget |
|
53 @param name object name of the window |
|
54 @type str |
|
55 """ |
|
56 super(ShellWindow, self).__init__(parent) |
|
57 if name is not None: |
|
58 self.setObjectName(name) |
|
59 self.setWindowIcon(UI.PixmapCache.getIcon("shell.png")) |
|
60 |
|
61 self.setStyle(Preferences.getUI("Style"), |
|
62 Preferences.getUI("StyleSheet")) |
|
63 |
|
64 # initialize the APIs manager |
|
65 self.__apisManager = APIsManager(parent=self) |
|
66 |
|
67 # initialize the debug server and shell widgets |
|
68 self.__debugServer = DebugServer(preventPassiveDebugging=True) |
|
69 self.__shell = Shell(self.__debugServer, self, True, self) |
|
70 self.__searchWidget = SearchWidget(self.__shell, self, showLine=True) |
|
71 |
|
72 centralWidget = QWidget() |
|
73 layout = QVBoxLayout() |
|
74 layout.setContentsMargins(1, 1, 1, 1) |
|
75 layout.addWidget(self.__shell) |
|
76 layout.addWidget(self.__searchWidget) |
|
77 centralWidget.setLayout(layout) |
|
78 self.setCentralWidget(centralWidget) |
|
79 self.__searchWidget.hide() |
|
80 |
|
81 self.__searchWidget.searchNext.connect(self.__shell.searchNext) |
|
82 self.__searchWidget.searchPrevious.connect(self.__shell.searchPrev) |
|
83 self.__shell.searchStringFound.connect( |
|
84 self.__searchWidget.searchStringFound) |
|
85 |
|
86 self.__shell.zoomValueChanged.connect(self.__zoomValueChanged) |
|
87 |
|
88 self.__createActions() |
|
89 self.__createMenus() |
|
90 self.__createToolBars() |
|
91 self.__createStatusBar() |
|
92 |
|
93 self.__readSettings() |
|
94 |
|
95 # now start the debug client |
|
96 self.__debugServer.startClient(False) |
|
97 |
|
98 # set the keyboard input interval |
|
99 interval = Preferences.getUI("KeyboardInputInterval") |
|
100 if interval > 0: |
|
101 QApplication.setKeyboardInputInterval(interval) |
|
102 |
|
103 def closeEvent(self, event): |
|
104 """ |
|
105 Protected method to handle the close event. |
|
106 |
|
107 @param event close event |
|
108 @type QCloseEvent |
|
109 """ |
|
110 self.__writeSettings() |
|
111 self.__debugServer.shutdownServer() |
|
112 self.__shell.closeShell() |
|
113 Preferences.syncPreferences() |
|
114 |
|
115 event.accept() |
|
116 |
|
117 ################################################################## |
|
118 ## Below are API handling methods |
|
119 ################################################################## |
|
120 |
|
121 def getAPIsManager(self): |
|
122 """ |
|
123 Public method to get a reference to the APIs manager. |
|
124 |
|
125 @return the APIs manager object (eric6.QScintilla.APIsManager) |
|
126 """ |
|
127 return self.__apisManager |
|
128 |
|
129 ################################################################## |
|
130 ## Below are action related methods |
|
131 ################################################################## |
|
132 |
|
133 def __readShortcut(self, act, category): |
|
134 """ |
|
135 Private function to read a single keyboard shortcut from the settings. |
|
136 |
|
137 @param act reference to the action object |
|
138 @type E5Action |
|
139 @param category category the action belongs to |
|
140 @type str |
|
141 """ |
|
142 if act.objectName(): |
|
143 accel = Preferences.Prefs.settings.value( |
|
144 "Shortcuts/{0}/{1}/Accel".format(category, act.objectName())) |
|
145 if accel is not None: |
|
146 act.setShortcut(QKeySequence(accel)) |
|
147 accel = Preferences.Prefs.settings.value( |
|
148 "Shortcuts/{0}/{1}/AltAccel".format( |
|
149 category, act.objectName())) |
|
150 if accel is not None: |
|
151 act.setAlternateShortcut(QKeySequence(accel), removeEmpty=True) |
|
152 |
|
153 def __createActions(self): |
|
154 """ |
|
155 Private method to create the actions. |
|
156 """ |
|
157 self.fileActions = [] |
|
158 self.editActions = [] |
|
159 self.searchActions = [] |
|
160 self.viewActions = [] |
|
161 self.helpActions = [] |
|
162 |
|
163 self.viewActGrp = createActionGroup(self) |
|
164 |
|
165 self.__createFileActions() |
|
166 self.__createEditActions() |
|
167 self.__createSearchActions() |
|
168 self.__createViewActions() |
|
169 self.__createHelpActions() |
|
170 self.__createHistoryActions() |
|
171 |
|
172 # read the keyboard shortcuts and make them identical to the main |
|
173 # eric6 shortcuts |
|
174 for act in self.helpActions: |
|
175 self.__readShortcut(act, "General") |
|
176 for act in self.editActions: |
|
177 self.__readShortcut(act, "Edit") |
|
178 for act in self.fileActions: |
|
179 self.__readShortcut(act, "View") |
|
180 for act in self.searchActions: |
|
181 self.__readShortcut(act, "Search") |
|
182 |
|
183 def __createFileActions(self): |
|
184 """ |
|
185 Private method defining the user interface actions for the file |
|
186 commands. |
|
187 """ |
|
188 self.exitAct = E5Action( |
|
189 self.tr('Quit'), |
|
190 UI.PixmapCache.getIcon("exit.png"), |
|
191 self.tr('&Quit'), |
|
192 QKeySequence(self.tr("Ctrl+Q", "File|Quit")), |
|
193 0, self, 'quit') |
|
194 self.exitAct.setStatusTip(self.tr('Quit the Shell')) |
|
195 self.exitAct.setWhatsThis(self.tr( |
|
196 """<b>Quit the Shell</b>""" |
|
197 """<p>This quits the Shell window.</p>""" |
|
198 )) |
|
199 self.exitAct.triggered.connect(self.quit) |
|
200 self.exitAct.setMenuRole(QAction.QuitRole) |
|
201 self.fileActions.append(self.exitAct) |
|
202 |
|
203 self.newWindowAct = E5Action( |
|
204 self.tr('New Window'), |
|
205 UI.PixmapCache.getIcon("newWindow.png"), |
|
206 self.tr('New &Window'), |
|
207 QKeySequence(self.tr("Ctrl+Shift+N", "File|New Window")), |
|
208 0, self, 'new_window') |
|
209 self.newWindowAct.setStatusTip(self.tr( |
|
210 'Open a new Shell window')) |
|
211 self.newWindowAct.setWhatsThis(self.tr( |
|
212 """<b>New Window</b>""" |
|
213 """<p>This opens a new instance of the Shell window.</p>""" |
|
214 )) |
|
215 self.newWindowAct.triggered.connect(self.__newWindow) |
|
216 self.fileActions.append(self.newWindowAct) |
|
217 |
|
218 self.restartAct = E5Action( |
|
219 self.tr('Restart'), |
|
220 UI.PixmapCache.getIcon("restart.png"), |
|
221 self.tr('Restart'), |
|
222 0, 0, self, 'shell_restart') |
|
223 self.restartAct.setStatusTip(self.tr( |
|
224 'Restart the shell')) |
|
225 self.restartAct.setWhatsThis(self.tr( |
|
226 """<b>Restart</b>""" |
|
227 """<p>Restart the shell for the currently selected language.</p>""" |
|
228 )) |
|
229 self.restartAct.triggered.connect(self.__doRestart) |
|
230 self.fileActions.append(self.restartAct) |
|
231 |
|
232 self.clearRestartAct = E5Action( |
|
233 self.tr('Restart and Clear'), |
|
234 UI.PixmapCache.getIcon("restartDelete.png"), |
|
235 self.tr('Restart and Clear'), |
|
236 Qt.Key_F4, 0, self, 'shell_clear_restart') |
|
237 self.clearRestartAct.setStatusTip(self.tr( |
|
238 'Clear the window and restart the shell')) |
|
239 self.clearRestartAct.setWhatsThis(self.tr( |
|
240 """<b>Restart and Clear</b>""" |
|
241 """<p>Clear the shell window and restart the shell for the""" |
|
242 """ currently selected language.</p>""" |
|
243 )) |
|
244 self.clearRestartAct.triggered.connect(self.__doClearRestart) |
|
245 self.fileActions.append(self.clearRestartAct) |
|
246 |
|
247 def __createEditActions(self): |
|
248 """ |
|
249 Private method defining the user interface actions for the edit |
|
250 commands. |
|
251 """ |
|
252 self.editActGrp = createActionGroup(self) |
|
253 self.copyActGrp = createActionGroup(self.editActGrp) |
|
254 |
|
255 self.cutAct = E5Action( |
|
256 QCoreApplication.translate('ViewManager', 'Cut'), |
|
257 UI.PixmapCache.getIcon("editCut.png"), |
|
258 QCoreApplication.translate('ViewManager', 'Cu&t'), |
|
259 QKeySequence(QCoreApplication.translate( |
|
260 'ViewManager', "Ctrl+X", "Edit|Cut")), |
|
261 QKeySequence(QCoreApplication.translate( |
|
262 'ViewManager', "Shift+Del", "Edit|Cut")), |
|
263 self.copyActGrp, 'vm_edit_cut') |
|
264 self.cutAct.setStatusTip(QCoreApplication.translate( |
|
265 'ViewManager', 'Cut the selection')) |
|
266 self.cutAct.setWhatsThis(QCoreApplication.translate( |
|
267 'ViewManager', |
|
268 """<b>Cut</b>""" |
|
269 """<p>Cut the selected text of the current editor to the""" |
|
270 """ clipboard.</p>""" |
|
271 )) |
|
272 self.cutAct.triggered.connect(self.__shell.cut) |
|
273 self.editActions.append(self.cutAct) |
|
274 |
|
275 self.copyAct = E5Action( |
|
276 QCoreApplication.translate('ViewManager', 'Copy'), |
|
277 UI.PixmapCache.getIcon("editCopy.png"), |
|
278 QCoreApplication.translate('ViewManager', '&Copy'), |
|
279 QKeySequence(QCoreApplication.translate( |
|
280 'ViewManager', "Ctrl+C", "Edit|Copy")), |
|
281 QKeySequence(QCoreApplication.translate( |
|
282 'ViewManager', "Ctrl+Ins", "Edit|Copy")), |
|
283 self.copyActGrp, 'vm_edit_copy') |
|
284 self.copyAct.setStatusTip(QCoreApplication.translate( |
|
285 'ViewManager', 'Copy the selection')) |
|
286 self.copyAct.setWhatsThis(QCoreApplication.translate( |
|
287 'ViewManager', |
|
288 """<b>Copy</b>""" |
|
289 """<p>Copy the selected text of the current editor to the""" |
|
290 """ clipboard.</p>""" |
|
291 )) |
|
292 self.copyAct.triggered.connect(self.__shell.copy) |
|
293 self.editActions.append(self.copyAct) |
|
294 |
|
295 self.pasteAct = E5Action( |
|
296 QCoreApplication.translate('ViewManager', 'Paste'), |
|
297 UI.PixmapCache.getIcon("editPaste.png"), |
|
298 QCoreApplication.translate('ViewManager', '&Paste'), |
|
299 QKeySequence(QCoreApplication.translate( |
|
300 'ViewManager', "Ctrl+V", "Edit|Paste")), |
|
301 QKeySequence(QCoreApplication.translate( |
|
302 'ViewManager', "Shift+Ins", "Edit|Paste")), |
|
303 self.copyActGrp, 'vm_edit_paste') |
|
304 self.pasteAct.setStatusTip(QCoreApplication.translate( |
|
305 'ViewManager', 'Paste the last cut/copied text')) |
|
306 self.pasteAct.setWhatsThis(QCoreApplication.translate( |
|
307 'ViewManager', |
|
308 """<b>Paste</b>""" |
|
309 """<p>Paste the last cut/copied text from the clipboard to""" |
|
310 """ the current editor.</p>""" |
|
311 )) |
|
312 self.pasteAct.triggered.connect(self.__shell.paste) |
|
313 self.editActions.append(self.pasteAct) |
|
314 |
|
315 self.clearAct = E5Action( |
|
316 QCoreApplication.translate('ViewManager', 'Clear'), |
|
317 UI.PixmapCache.getIcon("editDelete.png"), |
|
318 QCoreApplication.translate('ViewManager', 'Clear'), |
|
319 QKeySequence(QCoreApplication.translate( |
|
320 'ViewManager', "Alt+Shift+C", "Edit|Clear")), |
|
321 0, |
|
322 self.copyActGrp, 'vm_edit_clear') |
|
323 self.clearAct.setStatusTip(QCoreApplication.translate( |
|
324 'ViewManager', 'Clear all text')) |
|
325 self.clearAct.setWhatsThis(QCoreApplication.translate( |
|
326 'ViewManager', |
|
327 """<b>Clear</b>""" |
|
328 """<p>Delete all text of the current editor.</p>""" |
|
329 )) |
|
330 self.clearAct.triggered.connect(self.__shell.clear) |
|
331 self.editActions.append(self.clearAct) |
|
332 |
|
333 self.cutAct.setEnabled(False) |
|
334 self.copyAct.setEnabled(False) |
|
335 self.__shell.copyAvailable.connect(self.cutAct.setEnabled) |
|
336 self.__shell.copyAvailable.connect(self.copyAct.setEnabled) |
|
337 |
|
338 #################################################################### |
|
339 ## Below follow the actions for QScintilla standard commands. |
|
340 #################################################################### |
|
341 |
|
342 self.esm = QSignalMapper(self) |
|
343 self.esm.mapped[int].connect(self.__shell.editorCommand) |
|
344 |
|
345 self.editorActGrp = createActionGroup(self) |
|
346 |
|
347 act = E5Action( |
|
348 QCoreApplication.translate('ViewManager', 'Delete current line'), |
|
349 QCoreApplication.translate('ViewManager', 'Delete current line'), |
|
350 QKeySequence(QCoreApplication.translate( |
|
351 'ViewManager', 'Ctrl+Shift+L')), |
|
352 0, |
|
353 self.editorActGrp, 'vm_edit_delete_current_line') |
|
354 self.esm.setMapping(act, QsciScintilla.SCI_LINEDELETE) |
|
355 act.triggered.connect(self.esm.map) |
|
356 self.editActions.append(act) |
|
357 |
|
358 act = E5Action( |
|
359 QCoreApplication.translate('ViewManager', 'Indent one level'), |
|
360 QCoreApplication.translate('ViewManager', 'Indent one level'), |
|
361 QKeySequence(QCoreApplication.translate('ViewManager', 'Tab')), 0, |
|
362 self.editorActGrp, 'vm_edit_indent_one_level') |
|
363 self.esm.setMapping(act, QsciScintilla.SCI_TAB) |
|
364 act.triggered.connect(self.esm.map) |
|
365 self.editActions.append(act) |
|
366 |
|
367 act = E5Action( |
|
368 QCoreApplication.translate('ViewManager', 'Insert new line'), |
|
369 QCoreApplication.translate('ViewManager', 'Insert new line'), |
|
370 QKeySequence(QCoreApplication.translate('ViewManager', 'Return')), |
|
371 QKeySequence(QCoreApplication.translate('ViewManager', 'Enter')), |
|
372 self.editorActGrp, 'vm_edit_insert_line') |
|
373 self.esm.setMapping(act, QsciScintilla.SCI_NEWLINE) |
|
374 act.triggered.connect(self.esm.map) |
|
375 self.editActions.append(act) |
|
376 |
|
377 act = E5Action( |
|
378 QCoreApplication.translate('ViewManager', |
|
379 'Delete previous character'), |
|
380 QCoreApplication.translate('ViewManager', |
|
381 'Delete previous character'), |
|
382 QKeySequence(QCoreApplication.translate('ViewManager', |
|
383 'Backspace')), |
|
384 0, self.editorActGrp, 'vm_edit_delete_previous_char') |
|
385 if isMacPlatform(): |
|
386 act.setAlternateShortcut(QKeySequence( |
|
387 QCoreApplication.translate('ViewManager', 'Meta+H'))) |
|
388 else: |
|
389 act.setAlternateShortcut(QKeySequence( |
|
390 QCoreApplication.translate('ViewManager', 'Shift+Backspace'))) |
|
391 self.esm.setMapping(act, QsciScintilla.SCI_DELETEBACK) |
|
392 act.triggered.connect(self.esm.map) |
|
393 self.editActions.append(act) |
|
394 |
|
395 act = E5Action( |
|
396 QCoreApplication.translate('ViewManager', |
|
397 'Delete current character'), |
|
398 QCoreApplication.translate('ViewManager', |
|
399 'Delete current character'), |
|
400 QKeySequence(QCoreApplication.translate('ViewManager', 'Del')), |
|
401 0, self.editorActGrp, 'vm_edit_delete_current_char') |
|
402 if isMacPlatform(): |
|
403 act.setAlternateShortcut(QKeySequence( |
|
404 QCoreApplication.translate('ViewManager', 'Meta+D'))) |
|
405 self.esm.setMapping(act, QsciScintilla.SCI_CLEAR) |
|
406 act.triggered.connect(self.esm.map) |
|
407 self.editActions.append(act) |
|
408 |
|
409 act = E5Action( |
|
410 QCoreApplication.translate('ViewManager', 'Delete word to left'), |
|
411 QCoreApplication.translate('ViewManager', 'Delete word to left'), |
|
412 QKeySequence(QCoreApplication.translate( |
|
413 'ViewManager', 'Ctrl+Backspace')), |
|
414 0, |
|
415 self.editorActGrp, 'vm_edit_delete_word_left') |
|
416 self.esm.setMapping(act, QsciScintilla.SCI_DELWORDLEFT) |
|
417 act.triggered.connect(self.esm.map) |
|
418 self.editActions.append(act) |
|
419 |
|
420 act = E5Action( |
|
421 QCoreApplication.translate('ViewManager', 'Delete word to right'), |
|
422 QCoreApplication.translate('ViewManager', 'Delete word to right'), |
|
423 QKeySequence(QCoreApplication.translate('ViewManager', |
|
424 'Ctrl+Del')), |
|
425 0, self.editorActGrp, 'vm_edit_delete_word_right') |
|
426 self.esm.setMapping(act, QsciScintilla.SCI_DELWORDRIGHT) |
|
427 act.triggered.connect(self.esm.map) |
|
428 self.editActions.append(act) |
|
429 |
|
430 act = E5Action( |
|
431 QCoreApplication.translate('ViewManager', 'Delete line to left'), |
|
432 QCoreApplication.translate('ViewManager', 'Delete line to left'), |
|
433 QKeySequence(QCoreApplication.translate( |
|
434 'ViewManager', 'Ctrl+Shift+Backspace')), |
|
435 0, |
|
436 self.editorActGrp, 'vm_edit_delete_line_left') |
|
437 self.esm.setMapping(act, QsciScintilla.SCI_DELLINELEFT) |
|
438 act.triggered.connect(self.esm.map) |
|
439 self.editActions.append(act) |
|
440 |
|
441 act = E5Action( |
|
442 QCoreApplication.translate('ViewManager', 'Delete line to right'), |
|
443 QCoreApplication.translate('ViewManager', 'Delete line to right'), |
|
444 0, 0, |
|
445 self.editorActGrp, 'vm_edit_delete_line_right') |
|
446 if isMacPlatform(): |
|
447 act.setShortcut(QKeySequence( |
|
448 QCoreApplication.translate('ViewManager', 'Meta+K'))) |
|
449 else: |
|
450 act.setShortcut(QKeySequence( |
|
451 QCoreApplication.translate('ViewManager', 'Ctrl+Shift+Del'))) |
|
452 self.esm.setMapping(act, QsciScintilla.SCI_DELLINERIGHT) |
|
453 act.triggered.connect(self.esm.map) |
|
454 self.editActions.append(act) |
|
455 |
|
456 act = E5Action( |
|
457 QCoreApplication.translate('ViewManager', |
|
458 'Move left one character'), |
|
459 QCoreApplication.translate('ViewManager', |
|
460 'Move left one character'), |
|
461 QKeySequence(QCoreApplication.translate('ViewManager', 'Left')), 0, |
|
462 self.editorActGrp, 'vm_edit_move_left_char') |
|
463 self.esm.setMapping(act, QsciScintilla.SCI_CHARLEFT) |
|
464 if isMacPlatform(): |
|
465 act.setAlternateShortcut(QKeySequence( |
|
466 QCoreApplication.translate('ViewManager', 'Meta+B'))) |
|
467 act.triggered.connect(self.esm.map) |
|
468 self.editActions.append(act) |
|
469 |
|
470 act = E5Action( |
|
471 QCoreApplication.translate('ViewManager', |
|
472 'Move right one character'), |
|
473 QCoreApplication.translate('ViewManager', |
|
474 'Move right one character'), |
|
475 QKeySequence(QCoreApplication.translate('ViewManager', 'Right')), |
|
476 0, self.editorActGrp, 'vm_edit_move_right_char') |
|
477 if isMacPlatform(): |
|
478 act.setAlternateShortcut(QKeySequence( |
|
479 QCoreApplication.translate('ViewManager', 'Meta+F'))) |
|
480 self.esm.setMapping(act, QsciScintilla.SCI_CHARRIGHT) |
|
481 act.triggered.connect(self.esm.map) |
|
482 self.editActions.append(act) |
|
483 |
|
484 act = E5Action( |
|
485 QCoreApplication.translate('ViewManager', 'Move left one word'), |
|
486 QCoreApplication.translate('ViewManager', 'Move left one word'), |
|
487 0, 0, |
|
488 self.editorActGrp, 'vm_edit_move_left_word') |
|
489 if isMacPlatform(): |
|
490 act.setShortcut(QKeySequence( |
|
491 QCoreApplication.translate('ViewManager', 'Alt+Left'))) |
|
492 else: |
|
493 act.setShortcut(QKeySequence( |
|
494 QCoreApplication.translate('ViewManager', 'Ctrl+Left'))) |
|
495 self.esm.setMapping(act, QsciScintilla.SCI_WORDLEFT) |
|
496 act.triggered.connect(self.esm.map) |
|
497 self.editActions.append(act) |
|
498 |
|
499 act = E5Action( |
|
500 QCoreApplication.translate('ViewManager', 'Move right one word'), |
|
501 QCoreApplication.translate('ViewManager', 'Move right one word'), |
|
502 0, 0, |
|
503 self.editorActGrp, 'vm_edit_move_right_word') |
|
504 if not isMacPlatform(): |
|
505 act.setShortcut(QKeySequence( |
|
506 QCoreApplication.translate('ViewManager', 'Ctrl+Right'))) |
|
507 self.esm.setMapping(act, QsciScintilla.SCI_WORDRIGHT) |
|
508 act.triggered.connect(self.esm.map) |
|
509 self.editActions.append(act) |
|
510 |
|
511 act = E5Action( |
|
512 QCoreApplication.translate( |
|
513 'ViewManager', |
|
514 'Move to first visible character in document line'), |
|
515 QCoreApplication.translate( |
|
516 'ViewManager', |
|
517 'Move to first visible character in document line'), |
|
518 0, 0, |
|
519 self.editorActGrp, 'vm_edit_move_first_visible_char') |
|
520 if not isMacPlatform(): |
|
521 act.setShortcut(QKeySequence( |
|
522 QCoreApplication.translate('ViewManager', 'Home'))) |
|
523 self.esm.setMapping(act, QsciScintilla.SCI_VCHOME) |
|
524 act.triggered.connect(self.esm.map) |
|
525 self.editActions.append(act) |
|
526 |
|
527 act = E5Action( |
|
528 QCoreApplication.translate( |
|
529 'ViewManager', 'Move to end of document line'), |
|
530 QCoreApplication.translate( |
|
531 'ViewManager', 'Move to end of document line'), |
|
532 0, 0, |
|
533 self.editorActGrp, 'vm_edit_move_end_line') |
|
534 if isMacPlatform(): |
|
535 act.setShortcut(QKeySequence( |
|
536 QCoreApplication.translate('ViewManager', 'Meta+E'))) |
|
537 else: |
|
538 act.setShortcut(QKeySequence( |
|
539 QCoreApplication.translate('ViewManager', 'End'))) |
|
540 self.esm.setMapping(act, QsciScintilla.SCI_LINEEND) |
|
541 act.triggered.connect(self.esm.map) |
|
542 self.editActions.append(act) |
|
543 |
|
544 act = E5Action( |
|
545 QCoreApplication.translate('ViewManager', 'Move up one line'), |
|
546 QCoreApplication.translate('ViewManager', 'Move up one line'), |
|
547 QKeySequence(QCoreApplication.translate('ViewManager', 'Up')), 0, |
|
548 self.editorActGrp, 'vm_edit_move_up_line') |
|
549 if isMacPlatform(): |
|
550 act.setAlternateShortcut(QKeySequence( |
|
551 QCoreApplication.translate('ViewManager', 'Meta+P'))) |
|
552 self.esm.setMapping(act, QsciScintilla.SCI_LINEUP) |
|
553 act.triggered.connect(self.esm.map) |
|
554 self.editActions.append(act) |
|
555 |
|
556 act = E5Action( |
|
557 QCoreApplication.translate('ViewManager', 'Move down one line'), |
|
558 QCoreApplication.translate('ViewManager', 'Move down one line'), |
|
559 QKeySequence(QCoreApplication.translate('ViewManager', 'Down')), 0, |
|
560 self.editorActGrp, 'vm_edit_move_down_line') |
|
561 if isMacPlatform(): |
|
562 act.setAlternateShortcut(QKeySequence( |
|
563 QCoreApplication.translate('ViewManager', 'Meta+N'))) |
|
564 self.esm.setMapping(act, QsciScintilla.SCI_LINEDOWN) |
|
565 act.triggered.connect(self.esm.map) |
|
566 self.editActions.append(act) |
|
567 |
|
568 act = E5Action( |
|
569 self.tr('Move forward one history entry'), |
|
570 self.tr('Move forward one history entry'), |
|
571 QKeySequence(QCoreApplication.translate('ViewManager', |
|
572 'Ctrl+Down')), |
|
573 0, self.editorActGrp, 'vm_edit_scroll_down_line') |
|
574 self.esm.setMapping(act, QsciScintilla.SCI_LINESCROLLDOWN) |
|
575 act.triggered.connect(self.esm.map) |
|
576 self.editActions.append(act) |
|
577 |
|
578 act = E5Action( |
|
579 self.tr('Move back one history entry'), |
|
580 self.tr('Move back one history entry'), |
|
581 QKeySequence(QCoreApplication.translate('ViewManager', 'Ctrl+Up')), |
|
582 0, self.editorActGrp, 'vm_edit_scroll_up_line') |
|
583 self.esm.setMapping(act, QsciScintilla.SCI_LINESCROLLUP) |
|
584 act.triggered.connect(self.esm.map) |
|
585 self.editActions.append(act) |
|
586 |
|
587 act = E5Action( |
|
588 QCoreApplication.translate('ViewManager', 'Move up one page'), |
|
589 QCoreApplication.translate('ViewManager', 'Move up one page'), |
|
590 QKeySequence(QCoreApplication.translate('ViewManager', 'PgUp')), 0, |
|
591 self.editorActGrp, 'vm_edit_move_up_page') |
|
592 self.esm.setMapping(act, QsciScintilla.SCI_PAGEUP) |
|
593 act.triggered.connect(self.esm.map) |
|
594 self.editActions.append(act) |
|
595 |
|
596 act = E5Action( |
|
597 QCoreApplication.translate('ViewManager', 'Move down one page'), |
|
598 QCoreApplication.translate('ViewManager', 'Move down one page'), |
|
599 QKeySequence(QCoreApplication.translate('ViewManager', 'PgDown')), |
|
600 0, self.editorActGrp, 'vm_edit_move_down_page') |
|
601 if isMacPlatform(): |
|
602 act.setAlternateShortcut(QKeySequence( |
|
603 QCoreApplication.translate('ViewManager', 'Meta+V'))) |
|
604 self.esm.setMapping(act, QsciScintilla.SCI_PAGEDOWN) |
|
605 act.triggered.connect(self.esm.map) |
|
606 self.editActions.append(act) |
|
607 |
|
608 act = E5Action( |
|
609 QCoreApplication.translate('ViewManager', 'Escape'), |
|
610 QCoreApplication.translate('ViewManager', 'Escape'), |
|
611 QKeySequence(QCoreApplication.translate('ViewManager', 'Esc')), 0, |
|
612 self.editorActGrp, 'vm_edit_escape') |
|
613 self.esm.setMapping(act, QsciScintilla.SCI_CANCEL) |
|
614 act.triggered.connect(self.esm.map) |
|
615 self.editActions.append(act) |
|
616 |
|
617 act = E5Action( |
|
618 QCoreApplication.translate( |
|
619 'ViewManager', 'Extend selection left one character'), |
|
620 QCoreApplication.translate( |
|
621 'ViewManager', 'Extend selection left one character'), |
|
622 QKeySequence(QCoreApplication.translate('ViewManager', |
|
623 'Shift+Left')), |
|
624 0, self.editorActGrp, 'vm_edit_extend_selection_left_char') |
|
625 if isMacPlatform(): |
|
626 act.setAlternateShortcut(QKeySequence( |
|
627 QCoreApplication.translate('ViewManager', 'Meta+Shift+B'))) |
|
628 self.esm.setMapping(act, QsciScintilla.SCI_CHARLEFTEXTEND) |
|
629 act.triggered.connect(self.esm.map) |
|
630 self.editActions.append(act) |
|
631 |
|
632 act = E5Action( |
|
633 QCoreApplication.translate( |
|
634 'ViewManager', 'Extend selection right one character'), |
|
635 QCoreApplication.translate( |
|
636 'ViewManager', 'Extend selection right one character'), |
|
637 QKeySequence(QCoreApplication.translate('ViewManager', |
|
638 'Shift+Right')), |
|
639 0, self.editorActGrp, 'vm_edit_extend_selection_right_char') |
|
640 if isMacPlatform(): |
|
641 act.setAlternateShortcut(QKeySequence( |
|
642 QCoreApplication.translate('ViewManager', 'Meta+Shift+F'))) |
|
643 self.esm.setMapping(act, QsciScintilla.SCI_CHARRIGHTEXTEND) |
|
644 act.triggered.connect(self.esm.map) |
|
645 self.editActions.append(act) |
|
646 |
|
647 act = E5Action( |
|
648 QCoreApplication.translate( |
|
649 'ViewManager', 'Extend selection left one word'), |
|
650 QCoreApplication.translate( |
|
651 'ViewManager', 'Extend selection left one word'), |
|
652 0, 0, |
|
653 self.editorActGrp, 'vm_edit_extend_selection_left_word') |
|
654 if isMacPlatform(): |
|
655 act.setShortcut(QKeySequence( |
|
656 QCoreApplication.translate('ViewManager', 'Alt+Shift+Left'))) |
|
657 else: |
|
658 act.setShortcut(QKeySequence( |
|
659 QCoreApplication.translate('ViewManager', 'Ctrl+Shift+Left'))) |
|
660 self.esm.setMapping(act, QsciScintilla.SCI_WORDLEFTEXTEND) |
|
661 act.triggered.connect(self.esm.map) |
|
662 self.editActions.append(act) |
|
663 |
|
664 act = E5Action( |
|
665 QCoreApplication.translate( |
|
666 'ViewManager', 'Extend selection right one word'), |
|
667 QCoreApplication.translate( |
|
668 'ViewManager', 'Extend selection right one word'), |
|
669 0, 0, |
|
670 self.editorActGrp, 'vm_edit_extend_selection_right_word') |
|
671 if isMacPlatform(): |
|
672 act.setShortcut(QKeySequence( |
|
673 QCoreApplication.translate('ViewManager', 'Alt+Shift+Right'))) |
|
674 else: |
|
675 act.setShortcut(QKeySequence( |
|
676 QCoreApplication.translate('ViewManager', 'Ctrl+Shift+Right'))) |
|
677 self.esm.setMapping(act, QsciScintilla.SCI_WORDRIGHTEXTEND) |
|
678 act.triggered.connect(self.esm.map) |
|
679 self.editActions.append(act) |
|
680 |
|
681 act = E5Action( |
|
682 QCoreApplication.translate( |
|
683 'ViewManager', |
|
684 'Extend selection to first visible character in document' |
|
685 ' line'), |
|
686 QCoreApplication.translate( |
|
687 'ViewManager', |
|
688 'Extend selection to first visible character in document' |
|
689 ' line'), |
|
690 0, 0, |
|
691 self.editorActGrp, 'vm_edit_extend_selection_first_visible_char') |
|
692 if not isMacPlatform(): |
|
693 act.setShortcut(QKeySequence( |
|
694 QCoreApplication.translate('ViewManager', 'Shift+Home'))) |
|
695 self.esm.setMapping(act, QsciScintilla.SCI_VCHOMEEXTEND) |
|
696 act.triggered.connect(self.esm.map) |
|
697 self.editActions.append(act) |
|
698 |
|
699 act = E5Action( |
|
700 QCoreApplication.translate( |
|
701 'ViewManager', 'Extend selection to end of document line'), |
|
702 QCoreApplication.translate( |
|
703 'ViewManager', 'Extend selection to end of document line'), |
|
704 0, 0, |
|
705 self.editorActGrp, 'vm_edit_extend_selection_end_line') |
|
706 if isMacPlatform(): |
|
707 act.setShortcut(QKeySequence( |
|
708 QCoreApplication.translate('ViewManager', 'Meta+Shift+E'))) |
|
709 else: |
|
710 act.setShortcut(QKeySequence( |
|
711 QCoreApplication.translate('ViewManager', 'Shift+End'))) |
|
712 self.esm.setMapping(act, QsciScintilla.SCI_LINEENDEXTEND) |
|
713 act.triggered.connect(self.esm.map) |
|
714 self.editActions.append(act) |
|
715 |
|
716 def __createSearchActions(self): |
|
717 """ |
|
718 Private method defining the user interface actions for the search |
|
719 commands. |
|
720 """ |
|
721 self.searchActGrp = createActionGroup(self) |
|
722 |
|
723 self.searchAct = E5Action( |
|
724 QCoreApplication.translate('ViewManager', 'Search'), |
|
725 UI.PixmapCache.getIcon("find.png"), |
|
726 QCoreApplication.translate('ViewManager', '&Search...'), |
|
727 QKeySequence(QCoreApplication.translate( |
|
728 'ViewManager', "Ctrl+F", "Search|Search")), |
|
729 0, |
|
730 self, 'vm_search') |
|
731 self.searchAct.setStatusTip(QCoreApplication.translate( |
|
732 'ViewManager', 'Search for a text')) |
|
733 self.searchAct.setWhatsThis(QCoreApplication.translate( |
|
734 'ViewManager', |
|
735 """<b>Search</b>""" |
|
736 """<p>Search for some text in the current editor. A""" |
|
737 """ dialog is shown to enter the searchtext and options""" |
|
738 """ for the search.</p>""" |
|
739 )) |
|
740 self.searchAct.triggered.connect(self.__showFind) |
|
741 self.searchActions.append(self.searchAct) |
|
742 |
|
743 self.searchNextAct = E5Action( |
|
744 QCoreApplication.translate( |
|
745 'ViewManager', 'Search next'), |
|
746 UI.PixmapCache.getIcon("findNext.png"), |
|
747 QCoreApplication.translate('ViewManager', 'Search &next'), |
|
748 QKeySequence(QCoreApplication.translate( |
|
749 'ViewManager', "F3", "Search|Search next")), |
|
750 0, |
|
751 self, 'vm_search_next') |
|
752 self.searchNextAct.setStatusTip(QCoreApplication.translate( |
|
753 'ViewManager', 'Search next occurrence of text')) |
|
754 self.searchNextAct.setWhatsThis(QCoreApplication.translate( |
|
755 'ViewManager', |
|
756 """<b>Search next</b>""" |
|
757 """<p>Search the next occurrence of some text in the current""" |
|
758 """ editor. The previously entered searchtext and options are""" |
|
759 """ reused.</p>""" |
|
760 )) |
|
761 self.searchNextAct.triggered.connect( |
|
762 self.__searchWidget.on_findNextButton_clicked) |
|
763 self.searchActions.append(self.searchNextAct) |
|
764 |
|
765 self.searchPrevAct = E5Action( |
|
766 QCoreApplication.translate('ViewManager', 'Search previous'), |
|
767 UI.PixmapCache.getIcon("findPrev.png"), |
|
768 QCoreApplication.translate('ViewManager', 'Search &previous'), |
|
769 QKeySequence(QCoreApplication.translate( |
|
770 'ViewManager', "Shift+F3", "Search|Search previous")), |
|
771 0, |
|
772 self, 'vm_search_previous') |
|
773 self.searchPrevAct.setStatusTip(QCoreApplication.translate( |
|
774 'ViewManager', 'Search previous occurrence of text')) |
|
775 self.searchPrevAct.setWhatsThis(QCoreApplication.translate( |
|
776 'ViewManager', |
|
777 """<b>Search previous</b>""" |
|
778 """<p>Search the previous occurrence of some text in the current""" |
|
779 """ editor. The previously entered searchtext and options are""" |
|
780 """ reused.</p>""" |
|
781 )) |
|
782 self.searchPrevAct.triggered.connect( |
|
783 self.__searchWidget.on_findPrevButton_clicked) |
|
784 self.searchActions.append(self.searchPrevAct) |
|
785 |
|
786 def __createViewActions(self): |
|
787 """ |
|
788 Private method defining the user interface actions for the view |
|
789 commands. |
|
790 """ |
|
791 self.viewActGrp = createActionGroup(self) |
|
792 |
|
793 self.zoomInAct = E5Action( |
|
794 QCoreApplication.translate('ViewManager', 'Zoom in'), |
|
795 UI.PixmapCache.getIcon("zoomIn.png"), |
|
796 QCoreApplication.translate('ViewManager', 'Zoom &in'), |
|
797 QKeySequence(QCoreApplication.translate( |
|
798 'ViewManager', "Ctrl++", "View|Zoom in")), |
|
799 QKeySequence(QCoreApplication.translate( |
|
800 'ViewManager', "Zoom In", "View|Zoom in")), |
|
801 self.viewActGrp, 'vm_view_zoom_in') |
|
802 self.zoomInAct.setStatusTip(QCoreApplication.translate( |
|
803 'ViewManager', 'Zoom in on the text')) |
|
804 self.zoomInAct.setWhatsThis(QCoreApplication.translate( |
|
805 'ViewManager', |
|
806 """<b>Zoom in</b>""" |
|
807 """<p>Zoom in on the text. This makes the text bigger.</p>""" |
|
808 )) |
|
809 self.zoomInAct.triggered.connect(self.__zoomIn) |
|
810 self.viewActions.append(self.zoomInAct) |
|
811 |
|
812 self.zoomOutAct = E5Action( |
|
813 QCoreApplication.translate('ViewManager', 'Zoom out'), |
|
814 UI.PixmapCache.getIcon("zoomOut.png"), |
|
815 QCoreApplication.translate('ViewManager', 'Zoom &out'), |
|
816 QKeySequence(QCoreApplication.translate( |
|
817 'ViewManager', "Ctrl+-", "View|Zoom out")), |
|
818 QKeySequence(QCoreApplication.translate( |
|
819 'ViewManager', "Zoom Out", "View|Zoom out")), |
|
820 self.viewActGrp, 'vm_view_zoom_out') |
|
821 self.zoomOutAct.setStatusTip(QCoreApplication.translate( |
|
822 'ViewManager', 'Zoom out on the text')) |
|
823 self.zoomOutAct.setWhatsThis(QCoreApplication.translate( |
|
824 'ViewManager', |
|
825 """<b>Zoom out</b>""" |
|
826 """<p>Zoom out on the text. This makes the text smaller.</p>""" |
|
827 )) |
|
828 self.zoomOutAct.triggered.connect(self.__zoomOut) |
|
829 self.viewActions.append(self.zoomOutAct) |
|
830 |
|
831 self.zoomResetAct = E5Action( |
|
832 QCoreApplication.translate('ViewManager', 'Zoom reset'), |
|
833 UI.PixmapCache.getIcon("zoomReset.png"), |
|
834 QCoreApplication.translate('ViewManager', 'Zoom &reset'), |
|
835 QKeySequence(QCoreApplication.translate( |
|
836 'ViewManager', "Ctrl+0", "View|Zoom reset")), |
|
837 0, |
|
838 self.viewActGrp, 'vm_view_zoom_reset') |
|
839 self.zoomResetAct.setStatusTip(QCoreApplication.translate( |
|
840 'ViewManager', 'Reset the zoom of the text')) |
|
841 self.zoomResetAct.setWhatsThis(QCoreApplication.translate( |
|
842 'ViewManager', |
|
843 """<b>Zoom reset</b>""" |
|
844 """<p>Reset the zoom of the text. """ |
|
845 """This sets the zoom factor to 100%.</p>""" |
|
846 )) |
|
847 self.zoomResetAct.triggered.connect(self.__zoomReset) |
|
848 self.viewActions.append(self.zoomResetAct) |
|
849 |
|
850 self.zoomToAct = E5Action( |
|
851 QCoreApplication.translate('ViewManager', 'Zoom'), |
|
852 UI.PixmapCache.getIcon("zoomTo.png"), |
|
853 QCoreApplication.translate('ViewManager', '&Zoom'), |
|
854 QKeySequence(QCoreApplication.translate( |
|
855 'ViewManager', "Ctrl+#", "View|Zoom")), |
|
856 0, |
|
857 self.viewActGrp, 'vm_view_zoom') |
|
858 self.zoomToAct.setStatusTip(QCoreApplication.translate( |
|
859 'ViewManager', 'Zoom the text')) |
|
860 self.zoomToAct.setWhatsThis(QCoreApplication.translate( |
|
861 'ViewManager', |
|
862 """<b>Zoom</b>""" |
|
863 """<p>Zoom the text. This opens a dialog where the""" |
|
864 """ desired size can be entered.</p>""" |
|
865 )) |
|
866 self.zoomToAct.triggered.connect(self.__zoom) |
|
867 self.viewActions.append(self.zoomToAct) |
|
868 |
|
869 def __createHistoryActions(self): |
|
870 """ |
|
871 Private method defining the user interface actions for the history |
|
872 commands. |
|
873 """ |
|
874 self.showHistoryAct = E5Action( |
|
875 self.tr('Show History'), |
|
876 UI.PixmapCache.getIcon("history.png"), |
|
877 self.tr('&Show History...'), |
|
878 0, 0, |
|
879 self, 'shell_show_history') |
|
880 self.showHistoryAct.setStatusTip(self.tr( |
|
881 "Show the shell history in a dialog")) |
|
882 self.showHistoryAct.triggered.connect(self.__shell.showHistory) |
|
883 |
|
884 self.clearHistoryAct = E5Action( |
|
885 self.tr('Clear History'), |
|
886 UI.PixmapCache.getIcon("historyClear.png"), |
|
887 self.tr('&Clear History...'), |
|
888 0, 0, |
|
889 self, 'shell_clear_history') |
|
890 self.clearHistoryAct.setStatusTip(self.tr( |
|
891 "Clear the shell history")) |
|
892 self.clearHistoryAct.triggered.connect(self.__shell.clearHistory) |
|
893 |
|
894 self.selectHistoryAct = E5Action( |
|
895 self.tr('Select History Entry'), |
|
896 self.tr('Select History &Entry'), |
|
897 0, 0, |
|
898 self, 'shell_select_history') |
|
899 self.selectHistoryAct.setStatusTip(self.tr( |
|
900 "Select an entry of the shell history")) |
|
901 self.selectHistoryAct.triggered.connect(self.__shell.selectHistory) |
|
902 |
|
903 def __createHelpActions(self): |
|
904 """ |
|
905 Private method to create the Help actions. |
|
906 """ |
|
907 self.aboutAct = E5Action( |
|
908 self.tr('About'), |
|
909 self.tr('&About'), |
|
910 0, 0, self, 'about_eric') |
|
911 self.aboutAct.setStatusTip(self.tr( |
|
912 'Display information about this software')) |
|
913 self.aboutAct.setWhatsThis(self.tr( |
|
914 """<b>About</b>""" |
|
915 """<p>Display some information about this software.</p>""")) |
|
916 self.aboutAct.triggered.connect(self.__about) |
|
917 self.helpActions.append(self.aboutAct) |
|
918 |
|
919 self.aboutQtAct = E5Action( |
|
920 self.tr('About Qt'), |
|
921 self.tr('About &Qt'), |
|
922 0, 0, self, 'about_qt') |
|
923 self.aboutQtAct.setStatusTip( |
|
924 self.tr('Display information about the Qt toolkit')) |
|
925 self.aboutQtAct.setWhatsThis(self.tr( |
|
926 """<b>About Qt</b>""" |
|
927 """<p>Display some information about the Qt toolkit.</p>""" |
|
928 )) |
|
929 self.aboutQtAct.triggered.connect(self.__aboutQt) |
|
930 self.helpActions.append(self.aboutQtAct) |
|
931 |
|
932 self.whatsThisAct = E5Action( |
|
933 self.tr('What\'s This?'), |
|
934 UI.PixmapCache.getIcon("whatsThis.png"), |
|
935 self.tr('&What\'s This?'), |
|
936 QKeySequence(self.tr("Shift+F1", "Help|What's This?'")), |
|
937 0, self, 'help_help_whats_this') |
|
938 self.whatsThisAct.setStatusTip(self.tr('Context sensitive help')) |
|
939 self.whatsThisAct.setWhatsThis(self.tr( |
|
940 """<b>Display context sensitive help</b>""" |
|
941 """<p>In What's This? mode, the mouse cursor shows an arrow""" |
|
942 """ with a question mark, and you can click on the interface""" |
|
943 """ elements to get a short description of what they do and""" |
|
944 """ how to use them. In dialogs, this feature can be""" |
|
945 """ accessed using the context help button in the titlebar.""" |
|
946 """</p>""" |
|
947 )) |
|
948 self.whatsThisAct.triggered.connect(self.__whatsThis) |
|
949 self.helpActions.append(self.whatsThisAct) |
|
950 |
|
951 def __showFind(self): |
|
952 """ |
|
953 Private method to display the search widget. |
|
954 """ |
|
955 txt = self.__shell.selectedText() |
|
956 self.__searchWidget.showFind(txt) |
|
957 |
|
958 def activeWindow(self): |
|
959 """ |
|
960 Public method to get a reference to the active shell. |
|
961 |
|
962 @return reference to the shell widget |
|
963 @rtype Shell |
|
964 """ |
|
965 return self.__shell |
|
966 |
|
967 def __readSettings(self): |
|
968 """ |
|
969 Private method to read the settings remembered last time. |
|
970 """ |
|
971 settings = Preferences.Prefs.settings |
|
972 pos = settings.value("ShellWindow/Position", QPoint(0, 0)) |
|
973 size = settings.value("ShellWindow/Size", QSize(800, 600)) |
|
974 self.resize(size) |
|
975 self.move(pos) |
|
976 |
|
977 def __writeSettings(self): |
|
978 """ |
|
979 Private method to write the settings for reuse. |
|
980 """ |
|
981 settings = Preferences.Prefs.settings |
|
982 settings.setValue("ShellWindow/Position", self.pos()) |
|
983 settings.setValue("ShellWindow/Size", self.size()) |
|
984 |
|
985 def quit(self): |
|
986 """ |
|
987 Public method to quit the application. |
|
988 """ |
|
989 e5App().closeAllWindows() |
|
990 |
|
991 def __doRestart(self): |
|
992 """ |
|
993 Private slot to handle the 'restart' menu entry. |
|
994 """ |
|
995 self.__debugServer.startClient(False) |
|
996 |
|
997 def __doClearRestart(self): |
|
998 """ |
|
999 Private slot to handle the 'restart and clear' menu entry. |
|
1000 """ |
|
1001 self.__doRestart() |
|
1002 self.__shell.clear() |
|
1003 |
|
1004 def __newWindow(self): |
|
1005 """ |
|
1006 Private slot to start a new instance of eric6. |
|
1007 """ |
|
1008 program = sys.executable |
|
1009 eric6 = os.path.join(getConfig("ericDir"), "eric6_shell.py") |
|
1010 args = [eric6] |
|
1011 QProcess.startDetached(program, args) |
|
1012 |
|
1013 ################################################################## |
|
1014 ## Below are the action methods for the view menu |
|
1015 ################################################################## |
|
1016 |
|
1017 def __zoomIn(self): |
|
1018 """ |
|
1019 Private method to handle the zoom in action. |
|
1020 """ |
|
1021 self.__shell.zoomIn() |
|
1022 self.__sbZoom.setValue(self.__shell.getZoom()) |
|
1023 |
|
1024 def __zoomOut(self): |
|
1025 """ |
|
1026 Private method to handle the zoom out action. |
|
1027 """ |
|
1028 self.__shell.zoomOut() |
|
1029 self.__sbZoom.setValue(self.__shell.getZoom()) |
|
1030 |
|
1031 def __zoomReset(self): |
|
1032 """ |
|
1033 Private method to reset the zoom factor. |
|
1034 """ |
|
1035 self.__shell.zoomTo(0) |
|
1036 self.__sbZoom.setValue(self.__shell.getZoom()) |
|
1037 |
|
1038 def __zoom(self): |
|
1039 """ |
|
1040 Private method to handle the zoom action. |
|
1041 """ |
|
1042 from QScintilla.ZoomDialog import ZoomDialog |
|
1043 dlg = ZoomDialog(self.__shell.getZoom(), self, None, True) |
|
1044 if dlg.exec_() == QDialog.Accepted: |
|
1045 value = dlg.getZoomSize() |
|
1046 self.__zoomTo(value) |
|
1047 |
|
1048 def __zoomTo(self, value): |
|
1049 """ |
|
1050 Private slot to zoom to a given value. |
|
1051 |
|
1052 @param value zoom value to be set |
|
1053 @type int |
|
1054 """ |
|
1055 self.__shell.zoomTo(value) |
|
1056 self.__sbZoom.setValue(self.__shell.getZoom()) |
|
1057 |
|
1058 def __zoomValueChanged(self, value): |
|
1059 """ |
|
1060 Private slot to handle changes of the zoom value. |
|
1061 |
|
1062 @param value new zoom value |
|
1063 @type int |
|
1064 """ |
|
1065 self.__sbZoom.setValue(value) |
|
1066 |
|
1067 ################################################################## |
|
1068 ## Below are the action methods for the help menu |
|
1069 ################################################################## |
|
1070 |
|
1071 def __about(self): |
|
1072 """ |
|
1073 Private slot to show a little About message. |
|
1074 """ |
|
1075 E5MessageBox.about( |
|
1076 self, |
|
1077 self.tr("About eric6 Shell Window"), |
|
1078 self.tr( |
|
1079 "The eric6 Shell is a standalone shell window." |
|
1080 " It uses the same backend as the debugger of" |
|
1081 " the full IDE, but is executed independently.")) |
|
1082 |
|
1083 def __aboutQt(self): |
|
1084 """ |
|
1085 Private slot to handle the About Qt dialog. |
|
1086 """ |
|
1087 E5MessageBox.aboutQt(self, "eric6 Shell Window") |
|
1088 |
|
1089 def __whatsThis(self): |
|
1090 """ |
|
1091 Private slot called in to enter Whats This mode. |
|
1092 """ |
|
1093 QWhatsThis.enterWhatsThisMode() |
|
1094 |
|
1095 ################################################################## |
|
1096 ## Below are the main menu handling methods |
|
1097 ################################################################## |
|
1098 |
|
1099 def __createMenus(self): |
|
1100 """ |
|
1101 Private method to create the menus of the menu bar. |
|
1102 """ |
|
1103 self.__fileMenu = self.menuBar().addMenu(self.tr("&File")) |
|
1104 self.__fileMenu.setTearOffEnabled(True) |
|
1105 self.__fileMenu.addAction(self.newWindowAct) |
|
1106 self.__fileMenu.addSeparator() |
|
1107 self.__fileMenu.addAction(self.restartAct) |
|
1108 self.__fileMenu.addAction(self.clearRestartAct) |
|
1109 self.__fileMenu.addSeparator() |
|
1110 self.__fileMenu.addAction(self.exitAct) |
|
1111 |
|
1112 self.__editMenu = self.menuBar().addMenu(self.tr("&Edit")) |
|
1113 self.__editMenu.setTearOffEnabled(True) |
|
1114 self.__editMenu.addAction(self.cutAct) |
|
1115 self.__editMenu.addAction(self.copyAct) |
|
1116 self.__editMenu.addAction(self.pasteAct) |
|
1117 self.__editMenu.addAction(self.clearAct) |
|
1118 self.__editMenu.addSeparator() |
|
1119 self.__editMenu.addAction(self.searchAct) |
|
1120 self.__editMenu.addAction(self.searchNextAct) |
|
1121 self.__editMenu.addAction(self.searchPrevAct) |
|
1122 |
|
1123 self.__viewMenu = self.menuBar().addMenu(self.tr("&View")) |
|
1124 self.__viewMenu.setTearOffEnabled(True) |
|
1125 self.__viewMenu.addAction(self.zoomInAct) |
|
1126 self.__viewMenu.addAction(self.zoomOutAct) |
|
1127 self.__viewMenu.addAction(self.zoomResetAct) |
|
1128 self.__viewMenu.addAction(self.zoomToAct) |
|
1129 |
|
1130 self.__historyMenu = self.menuBar().addMenu(self.tr("Histor&y")) |
|
1131 self.__historyMenu.setTearOffEnabled(True) |
|
1132 self.__historyMenu.addAction(self.selectHistoryAct) |
|
1133 self.__historyMenu.addAction(self.showHistoryAct) |
|
1134 self.__historyMenu.addAction(self.clearHistoryAct) |
|
1135 |
|
1136 self.__startMenu = self.menuBar().addMenu(self.tr("&Start")) |
|
1137 self.__startMenu.aboutToShow.connect(self.__showLanguageMenu) |
|
1138 self.__startMenu.triggered.connect(self.__startShell) |
|
1139 |
|
1140 self.menuBar().addSeparator() |
|
1141 |
|
1142 self.__helpMenu = self.menuBar().addMenu(self.tr("&Help")) |
|
1143 self.__helpMenu.setTearOffEnabled(True) |
|
1144 self.__helpMenu.addAction(self.aboutAct) |
|
1145 self.__helpMenu.addAction(self.aboutQtAct) |
|
1146 self.__helpMenu.addSeparator() |
|
1147 self.__helpMenu.addAction(self.whatsThisAct) |
|
1148 |
|
1149 def __showLanguageMenu(self): |
|
1150 """ |
|
1151 Private slot to prepare the language menu. |
|
1152 """ |
|
1153 self.__startMenu.clear() |
|
1154 clientLanguages = self.__debugServer.getSupportedLanguages( |
|
1155 shellOnly=True) |
|
1156 for language in sorted(clientLanguages): |
|
1157 act = self.__startMenu.addAction(language) |
|
1158 act.setData(language) |
|
1159 |
|
1160 def __startShell(self, action): |
|
1161 """ |
|
1162 Private slot to start a shell according to the action triggered. |
|
1163 |
|
1164 @param action menu action that was triggered (QAction) |
|
1165 """ |
|
1166 language = action.data() |
|
1167 self.__debugServer.startClient(False, language) |
|
1168 |
|
1169 ################################################################## |
|
1170 ## Below are the toolbar handling methods |
|
1171 ################################################################## |
|
1172 |
|
1173 def __createToolBars(self): |
|
1174 """ |
|
1175 Private method to create the various toolbars. |
|
1176 """ |
|
1177 filetb = self.addToolBar(self.tr("File")) |
|
1178 filetb.setIconSize(UI.Config.ToolBarIconSize) |
|
1179 filetb.addAction(self.newWindowAct) |
|
1180 filetb.addSeparator() |
|
1181 filetb.addAction(self.restartAct) |
|
1182 filetb.addAction(self.clearRestartAct) |
|
1183 filetb.addSeparator() |
|
1184 filetb.addAction(self.exitAct) |
|
1185 |
|
1186 edittb = self.addToolBar(self.tr("Edit")) |
|
1187 edittb.setIconSize(UI.Config.ToolBarIconSize) |
|
1188 edittb.addAction(self.cutAct) |
|
1189 edittb.addAction(self.copyAct) |
|
1190 edittb.addAction(self.pasteAct) |
|
1191 edittb.addAction(self.clearAct) |
|
1192 |
|
1193 findtb = self.addToolBar(self.tr("Find")) |
|
1194 findtb.setIconSize(UI.Config.ToolBarIconSize) |
|
1195 findtb.addAction(self.searchAct) |
|
1196 findtb.addAction(self.searchNextAct) |
|
1197 findtb.addAction(self.searchPrevAct) |
|
1198 |
|
1199 viewtb = self.addToolBar(self.tr("View")) |
|
1200 viewtb.setIconSize(UI.Config.ToolBarIconSize) |
|
1201 viewtb.addAction(self.zoomInAct) |
|
1202 viewtb.addAction(self.zoomOutAct) |
|
1203 viewtb.addAction(self.zoomResetAct) |
|
1204 viewtb.addAction(self.zoomToAct) |
|
1205 |
|
1206 historytb = self.addToolBar(self.tr("History")) |
|
1207 historytb.setIconSize(UI.Config.ToolBarIconSize) |
|
1208 historytb.addAction(self.showHistoryAct) |
|
1209 historytb.addAction(self.clearHistoryAct) |
|
1210 |
|
1211 helptb = self.addToolBar(self.tr("Help")) |
|
1212 helptb.setIconSize(UI.Config.ToolBarIconSize) |
|
1213 helptb.addAction(self.whatsThisAct) |
|
1214 |
|
1215 ################################################################## |
|
1216 ## Below are the status bar handling methods |
|
1217 ################################################################## |
|
1218 |
|
1219 def __createStatusBar(self): |
|
1220 """ |
|
1221 Private slot to set up the status bar. |
|
1222 """ |
|
1223 self.__statusBar = self.statusBar() |
|
1224 self.__statusBar.setSizeGripEnabled(True) |
|
1225 |
|
1226 self.__sbZoom = E5ZoomWidget( |
|
1227 UI.PixmapCache.getPixmap("zoomOut.png"), |
|
1228 UI.PixmapCache.getPixmap("zoomIn.png"), |
|
1229 UI.PixmapCache.getPixmap("zoomReset.png"), |
|
1230 self.__statusBar) |
|
1231 self.__statusBar.addPermanentWidget(self.__sbZoom) |
|
1232 self.__sbZoom.setWhatsThis(self.tr( |
|
1233 """<p>This part of the status bar allows zooming the shell.</p>""" |
|
1234 )) |
|
1235 |
|
1236 self.__sbZoom.valueChanged.connect(self.__zoomTo) |
|
1237 self.__sbZoom.setValue(0) |