| 92 | |
| 93 | |
| 94 | class CommandLineEdit(LineEdit): |
| 95 | def __init__(self, parent=None): |
| 96 | super().__init__(parent) |
| 97 | self.upT = 0 |
| 98 | self.userCommandHistory = [] |
| 99 | self.installEventFilter(self) |
| 100 | |
| 101 | def eventFilter(self, a0: QObject, a1: QEvent) -> bool: |
| 102 | if a1.type() == QEvent.KeyPress: |
| 103 | if a1.key() == Qt.Key_Up: |
| 104 | if len(self.userCommandHistory) and self.upT > -len(self.userCommandHistory): |
| 105 | self.upT -= 1 |
| 106 | lastCommand = self.userCommandHistory[self.upT] |
| 107 | self.setText(lastCommand) |
| 108 | return True |
| 109 | elif a1.key() == Qt.Key_Down: |
| 110 | if len(self.userCommandHistory) and self.upT < 0: |
| 111 | self.upT += 1 |
| 112 | nextCommand = self.userCommandHistory[self.upT] |
| 113 | self.setText(nextCommand) |
| 114 | return True |
| 115 | if len(self.userCommandHistory) and self.upT == 0: |
| 116 | self.setText("") |
| 117 | return True |
| 118 | return super().eventFilter(a0, a1) |
| 119 | |
| 120 | |
| 121 | def _normalize_base_url(url: str) -> str: |