8 """ |
8 """ |
9 |
9 |
10 import contextlib |
10 import contextlib |
11 import os |
11 import os |
12 |
12 |
13 from PyQt6.QtCore import pyqtSlot, Qt |
13 from PyQt6.QtCore import pyqtSlot, Qt, QEvent |
14 from PyQt6.QtWidgets import ( |
14 from PyQt6.QtWidgets import ( |
15 QWidget, QVBoxLayout, QHBoxLayout, QLabel, QSizePolicy, QListView, |
15 QWidget, QVBoxLayout, QHBoxLayout, QLabel, QSizePolicy, QListView, |
16 QListWidget, QListWidgetItem, QToolButton, QAbstractItemView, QMenu, |
16 QListWidget, QListWidgetItem, QToolButton, QAbstractItemView, QMenu, |
17 QGroupBox, QDialog |
17 QGroupBox, QDialog |
18 ) |
18 ) |
123 self.__quickCommitEdit = EricSpellCheckedTextEdit(self) |
123 self.__quickCommitEdit = EricSpellCheckedTextEdit(self) |
124 self.__quickCommitEdit.setSizePolicy( |
124 self.__quickCommitEdit.setSizePolicy( |
125 QSizePolicy.Policy.Expanding, |
125 QSizePolicy.Policy.Expanding, |
126 QSizePolicy.Policy.Preferred) |
126 QSizePolicy.Policy.Preferred) |
127 self.__quickCommitEdit.setMaximumHeight(100) |
127 self.__quickCommitEdit.setMaximumHeight(100) |
|
128 self.__quickCommitEdit.setTabChangesFocus(True) |
|
129 self.__quickCommitEdit.installEventFilter(self) |
128 self.__quickCommitEdit.textChanged.connect( |
130 self.__quickCommitEdit.textChanged.connect( |
129 self.__quickCommitEditTextChanged) |
131 self.__quickCommitEditTextChanged) |
130 self.__quickCommitLayout.addWidget(self.__quickCommitEdit) |
132 self.__quickCommitLayout.addWidget(self.__quickCommitEdit) |
131 |
133 |
132 self.__quickCommitLayout2 = QHBoxLayout() |
134 self.__quickCommitLayout2 = QHBoxLayout() |
927 """ |
929 """ |
928 Private slot to react upon changes of the quick commit text. |
930 Private slot to react upon changes of the quick commit text. |
929 """ |
931 """ |
930 self.__quickCommitButton.setEnabled(bool( |
932 self.__quickCommitButton.setEnabled(bool( |
931 self.__quickCommitEdit.toPlainText())) |
933 self.__quickCommitEdit.toPlainText())) |
|
934 |
|
935 def eventFilter(self, obj, evt): |
|
936 """ |
|
937 Public method to process some events for the Commit edit. |
|
938 |
|
939 @param obj reference to the object the event was meant for |
|
940 @type QObject |
|
941 @param evt reference to the event object |
|
942 @type QEvent |
|
943 @return flag to indicate that the event was handled |
|
944 @rtype bool |
|
945 """ |
|
946 if ( |
|
947 obj is self.__quickCommitEdit and |
|
948 evt.type() == QEvent.Type.KeyPress and |
|
949 evt.key() in (Qt.Key.Key_Return, Qt.Key.Key_Enter) and |
|
950 evt.modifiers() == Qt.KeyboardModifier.ControlModifier |
|
951 ): |
|
952 # Ctrl-Enter or Ctrl-Return => commit |
|
953 self.__quickCommitButton.animateClick() |
|
954 return True |
|
955 else: |
|
956 # standard event processing |
|
957 return super().eventFilter(obj, evt) |