56 |
56 |
57 self.__shell = Shell(dbs, vm, project, False, self) |
57 self.__shell = Shell(dbs, vm, project, False, self) |
58 |
58 |
59 from UI.SearchWidget import SearchWidget |
59 from UI.SearchWidget import SearchWidget |
60 self.__searchWidget = SearchWidget(self.__shell, self, horizontal) |
60 self.__searchWidget = SearchWidget(self.__shell, self, horizontal) |
61 self.__searchWidget.setSizePolicy(QSizePolicy.Fixed, |
61 self.__searchWidget.setSizePolicy(QSizePolicy.Policy.Fixed, |
62 QSizePolicy.Preferred) |
62 QSizePolicy.Policy.Preferred) |
63 self.__searchWidget.hide() |
63 self.__searchWidget.hide() |
64 |
64 |
65 if horizontal: |
65 if horizontal: |
66 self.__layout = QHBoxLayout(self) |
66 self.__layout = QHBoxLayout(self) |
67 else: |
67 else: |
372 Preferences.getShell("HistoryNavigateByCursor") |
372 Preferences.getShell("HistoryNavigateByCursor") |
373 ) |
373 ) |
374 |
374 |
375 self.__queuedText = '' |
375 self.__queuedText = '' |
376 self.__blockTextProcessing = False |
376 self.__blockTextProcessing = False |
377 self.queueText.connect(self.__concatenateText, Qt.QueuedConnection) |
377 self.queueText.connect(self.__concatenateText, |
|
378 Qt.ConnectionType.QueuedConnection) |
378 |
379 |
379 self.__project = project |
380 self.__project = project |
380 if self.__project: |
381 if self.__project: |
381 self.__project.projectOpened.connect(self.__projectOpened) |
382 self.__project.projectOpened.connect(self.__projectOpened) |
382 self.__project.projectClosed.connect(self.__projectClosed) |
383 self.__project.projectClosed.connect(self.__projectClosed) |
383 |
384 |
384 self.grabGesture(Qt.PinchGesture) |
385 self.grabGesture(Qt.GestureType.PinchGesture) |
385 |
386 |
386 def __showStartMenu(self): |
387 def __showStartMenu(self): |
387 """ |
388 """ |
388 Private slot to prepare the start submenu. |
389 Private slot to prepare the start submenu. |
389 """ |
390 """ |
477 """ |
478 """ |
478 Private method to configure the text display. |
479 Private method to configure the text display. |
479 """ |
480 """ |
480 self.setTabWidth(Preferences.getEditor("TabWidth")) |
481 self.setTabWidth(Preferences.getEditor("TabWidth")) |
481 if Preferences.getEditor("ShowWhitespace"): |
482 if Preferences.getEditor("ShowWhitespace"): |
482 self.setWhitespaceVisibility(QsciScintilla.WsVisible) |
483 self.setWhitespaceVisibility( |
|
484 QsciScintilla.WhitespaceVisibility.WsVisible) |
483 try: |
485 try: |
484 self.setWhitespaceForegroundColor( |
486 self.setWhitespaceForegroundColor( |
485 Preferences.getEditorColour("WhitespaceForeground")) |
487 Preferences.getEditorColour("WhitespaceForeground")) |
486 self.setWhitespaceBackgroundColor( |
488 self.setWhitespaceBackgroundColor( |
487 Preferences.getEditorColour("WhitespaceBackground")) |
489 Preferences.getEditorColour("WhitespaceBackground")) |
489 Preferences.getEditor("WhitespaceSize")) |
491 Preferences.getEditor("WhitespaceSize")) |
490 except AttributeError: |
492 except AttributeError: |
491 # QScintilla before 2.5 doesn't support this |
493 # QScintilla before 2.5 doesn't support this |
492 pass |
494 pass |
493 else: |
495 else: |
494 self.setWhitespaceVisibility(QsciScintilla.WsInvisible) |
496 self.setWhitespaceVisibility( |
|
497 QsciScintilla.WhitespaceVisibility.WsInvisible) |
495 self.setEolVisibility(Preferences.getEditor("ShowEOL")) |
498 self.setEolVisibility(Preferences.getEditor("ShowEOL")) |
496 if Preferences.getEditor("BraceHighlighting"): |
499 if Preferences.getEditor("BraceHighlighting"): |
497 self.setBraceMatching(QsciScintilla.SloppyBraceMatch) |
500 self.setBraceMatching(QsciScintilla.BraceMatch.SloppyBraceMatch) |
498 else: |
501 else: |
499 self.setBraceMatching(QsciScintilla.NoBraceMatch) |
502 self.setBraceMatching(QsciScintilla.BraceMatch.NoBraceMatch) |
500 self.setMatchedBraceForegroundColor( |
503 self.setMatchedBraceForegroundColor( |
501 Preferences.getEditorColour("MatchingBrace")) |
504 Preferences.getEditorColour("MatchingBrace")) |
502 self.setMatchedBraceBackgroundColor( |
505 self.setMatchedBraceBackgroundColor( |
503 Preferences.getEditorColour("MatchingBraceBack")) |
506 Preferences.getEditorColour("MatchingBraceBack")) |
504 self.setUnmatchedBraceForegroundColor( |
507 self.setUnmatchedBraceForegroundColor( |
508 if Preferences.getEditor("CustomSelectionColours"): |
511 if Preferences.getEditor("CustomSelectionColours"): |
509 self.setSelectionBackgroundColor( |
512 self.setSelectionBackgroundColor( |
510 Preferences.getEditorColour("SelectionBackground")) |
513 Preferences.getEditorColour("SelectionBackground")) |
511 else: |
514 else: |
512 self.setSelectionBackgroundColor( |
515 self.setSelectionBackgroundColor( |
513 QApplication.palette().color(QPalette.Highlight)) |
516 QApplication.palette().color(QPalette.ColorRole.Highlight)) |
514 if Preferences.getEditor("ColourizeSelText"): |
517 if Preferences.getEditor("ColourizeSelText"): |
515 self.resetSelectionForegroundColor() |
518 self.resetSelectionForegroundColor() |
516 elif Preferences.getEditor("CustomSelectionColours"): |
519 elif Preferences.getEditor("CustomSelectionColours"): |
517 self.setSelectionForegroundColor( |
520 self.setSelectionForegroundColor( |
518 Preferences.getEditorColour("SelectionForeground")) |
521 Preferences.getEditorColour("SelectionForeground")) |
519 else: |
522 else: |
520 self.setSelectionForegroundColor( |
523 self.setSelectionForegroundColor( |
521 QApplication.palette().color(QPalette.HighlightedText)) |
524 QApplication.palette().color( |
|
525 QPalette.ColorRole.HighlightedText)) |
522 self.setSelectionToEol(Preferences.getEditor("ExtendSelectionToEol")) |
526 self.setSelectionToEol(Preferences.getEditor("ExtendSelectionToEol")) |
523 self.setCaretForegroundColor( |
527 self.setCaretForegroundColor( |
524 Preferences.getEditorColour("CaretForeground")) |
528 Preferences.getEditorColour("CaretForeground")) |
525 self.setCaretLineVisible(False) |
529 self.setCaretLineVisible(False) |
526 self.caretWidth = Preferences.getEditor("CaretWidth") |
530 self.caretWidth = Preferences.getEditor("CaretWidth") |
527 self.setCaretWidth(self.caretWidth) |
531 self.setCaretWidth(self.caretWidth) |
528 if Preferences.getShell("WrapEnabled"): |
532 if Preferences.getShell("WrapEnabled"): |
529 self.setWrapMode(QsciScintilla.WrapWord) |
533 self.setWrapMode(QsciScintilla.WrapMode.WrapWord) |
530 else: |
534 else: |
531 self.setWrapMode(QsciScintilla.WrapNone) |
535 self.setWrapMode(QsciScintilla.WrapMode.WrapNone) |
532 self.useMonospaced = Preferences.getShell("UseMonospacedFont") |
536 self.useMonospaced = Preferences.getShell("UseMonospacedFont") |
533 self.__setMonospaced(self.useMonospaced) |
537 self.__setMonospaced(self.useMonospaced) |
534 |
538 |
535 self.setCursorFlashTime(QApplication.cursorFlashTime()) |
539 self.setCursorFlashTime(QApplication.cursorFlashTime()) |
536 |
540 |
584 Preferences.getEditorColour("CallTipsForeground")) |
588 Preferences.getEditorColour("CallTipsForeground")) |
585 self.setCallTipsHighlightColor( |
589 self.setCallTipsHighlightColor( |
586 Preferences.getEditorColour("CallTipsHighlight")) |
590 Preferences.getEditorColour("CallTipsHighlight")) |
587 self.setCallTipsVisible(Preferences.getEditor("CallTipsVisible")) |
591 self.setCallTipsVisible(Preferences.getEditor("CallTipsVisible")) |
588 calltipsStyle = Preferences.getEditor("CallTipsStyle") |
592 calltipsStyle = Preferences.getEditor("CallTipsStyle") |
589 if calltipsStyle == QsciScintilla.CallTipsNoContext: |
593 if calltipsStyle == QsciScintilla.CallTipsStyle.CallTipsNoContext: |
590 self.setCallTipsStyle(QsciScintilla.CallTipsNoContext) |
594 self.setCallTipsStyle( |
|
595 QsciScintilla.CallTipsStyle.CallTipsNoContext) |
591 elif ( |
596 elif ( |
592 calltipsStyle == |
597 calltipsStyle == |
593 QsciScintilla.CallTipsNoAutoCompletionContext |
598 QsciScintilla.CallTipsStyle.CallTipsNoAutoCompletionContext |
594 ): |
599 ): |
595 self.setCallTipsStyle( |
600 self.setCallTipsStyle( |
596 QsciScintilla.CallTipsNoAutoCompletionContext) |
601 QsciScintilla.CallTipsStyle |
|
602 .CallTipsNoAutoCompletionContext) |
597 else: |
603 else: |
598 self.setCallTipsStyle(QsciScintilla.CallTipsContext) |
604 self.setCallTipsStyle( |
599 else: |
605 QsciScintilla.CallTipsStyle.CallTipsContext) |
600 self.setCallTipsStyle(QsciScintilla.CallTipsNone) |
606 else: |
|
607 self.setCallTipsStyle(QsciScintilla.CallTipsStyle.CallTipsNone) |
601 |
608 |
602 def setDebuggerUI(self, ui): |
609 def setDebuggerUI(self, ui): |
603 """ |
610 """ |
604 Public method to set the debugger UI. |
611 Public method to set the debugger UI. |
605 |
612 |
784 """ |
791 """ |
785 Public slot to show the shell history dialog. |
792 Public slot to show the shell history dialog. |
786 """ |
793 """ |
787 from .ShellHistoryDialog import ShellHistoryDialog |
794 from .ShellHistoryDialog import ShellHistoryDialog |
788 dlg = ShellHistoryDialog(self.__history, self.vm, self) |
795 dlg = ShellHistoryDialog(self.__history, self.vm, self) |
789 if dlg.exec() == QDialog.Accepted: |
796 if dlg.exec() == QDialog.DialogCode.Accepted: |
790 self.__historyLists[self.clientType], idx = dlg.getHistory() |
797 self.__historyLists[self.clientType], idx = dlg.getHistory() |
791 self.__history = self.__historyLists[self.clientType] |
798 self.__history = self.__historyLists[self.clientType] |
792 self.__setHistoryIndex(index=idx) |
799 self.__setHistoryIndex(index=idx) |
793 |
800 |
794 def clearAllHistories(self): |
801 def clearAllHistories(self): |
1230 Protected method to handle the mouse press event. |
1237 Protected method to handle the mouse press event. |
1231 |
1238 |
1232 @param event the mouse press event (QMouseEvent) |
1239 @param event the mouse press event (QMouseEvent) |
1233 """ |
1240 """ |
1234 self.setFocus() |
1241 self.setFocus() |
1235 if event.button() == Qt.MidButton: |
1242 if event.button() == Qt.MouseButton.MidButton: |
1236 lines = QApplication.clipboard().text(QClipboard.Selection) |
1243 lines = QApplication.clipboard().text(QClipboard.Mode.Selection) |
1237 self.paste(lines) |
1244 self.paste(lines) |
1238 else: |
1245 else: |
1239 super(Shell, self).mousePressEvent(event) |
1246 super(Shell, self).mousePressEvent(event) |
1240 |
1247 |
1241 def wheelEvent(self, evt): |
1248 def wheelEvent(self, evt): |
1242 """ |
1249 """ |
1243 Protected method to handle wheel events. |
1250 Protected method to handle wheel events. |
1244 |
1251 |
1245 @param evt reference to the wheel event (QWheelEvent) |
1252 @param evt reference to the wheel event (QWheelEvent) |
1246 """ |
1253 """ |
1247 if evt.modifiers() & Qt.ControlModifier: |
1254 if evt.modifiers() & Qt.KeyboardModifier.ControlModifier: |
1248 delta = evt.angleDelta().y() |
1255 delta = evt.angleDelta().y() |
1249 if delta < 0: |
1256 if delta < 0: |
1250 self.zoomOut() |
1257 self.zoomOut() |
1251 elif delta > 0: |
1258 elif delta > 0: |
1252 self.zoomIn() |
1259 self.zoomIn() |
1260 Public method handling events. |
1267 Public method handling events. |
1261 |
1268 |
1262 @param evt reference to the event (QEvent) |
1269 @param evt reference to the event (QEvent) |
1263 @return flag indicating, if the event was handled (boolean) |
1270 @return flag indicating, if the event was handled (boolean) |
1264 """ |
1271 """ |
1265 if evt.type() == QEvent.Gesture: |
1272 if evt.type() == QEvent.Type.Gesture: |
1266 self.gestureEvent(evt) |
1273 self.gestureEvent(evt) |
1267 return True |
1274 return True |
1268 |
1275 |
1269 return super(Shell, self).event(evt) |
1276 return super(Shell, self).event(evt) |
1270 |
1277 |
1272 """ |
1279 """ |
1273 Protected method handling gesture events. |
1280 Protected method handling gesture events. |
1274 |
1281 |
1275 @param evt reference to the gesture event (QGestureEvent |
1282 @param evt reference to the gesture event (QGestureEvent |
1276 """ |
1283 """ |
1277 pinch = evt.gesture(Qt.PinchGesture) |
1284 pinch = evt.gesture(Qt.GestureType.PinchGesture) |
1278 if pinch: |
1285 if pinch: |
1279 if pinch.state() == Qt.GestureStarted: |
1286 if pinch.state() == Qt.GestureState.GestureStarted: |
1280 zoom = (self.getZoom() + 10) / 10.0 |
1287 zoom = (self.getZoom() + 10) / 10.0 |
1281 pinch.setTotalScaleFactor(zoom) |
1288 pinch.setTotalScaleFactor(zoom) |
1282 elif pinch.state() == Qt.GestureUpdated: |
1289 elif pinch.state() == Qt.GestureState.GestureUpdated: |
1283 zoom = int(pinch.totalScaleFactor() * 10) - 10 |
1290 zoom = int(pinch.totalScaleFactor() * 10) - 10 |
1284 if zoom <= -9: |
1291 if zoom <= -9: |
1285 zoom = -9 |
1292 zoom = -9 |
1286 pinch.setTotalScaleFactor(0.1) |
1293 pinch.setTotalScaleFactor(0.1) |
1287 elif zoom >= 20: |
1294 elif zoom >= 20: |