Added code to the VCS Status widget to commit by pressing Ctrl+Enter or Ctrl+Return in the Quick Commit entry. eric7

Wed, 06 Oct 2021 18:39:50 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 06 Oct 2021 18:39:50 +0200
branch
eric7
changeset 8676
3348ac06e4bb
parent 8675
bbc674c6c3fd
child 8677
2e3d02a0f0b6

Added code to the VCS Status widget to commit by pressing Ctrl+Enter or Ctrl+Return in the Quick Commit entry.

eric7/VCS/StatusWidget.py file | annotate | diff | comparison | revisions
--- a/eric7/VCS/StatusWidget.py	Wed Oct 06 18:38:45 2021 +0200
+++ b/eric7/VCS/StatusWidget.py	Wed Oct 06 18:39:50 2021 +0200
@@ -10,7 +10,7 @@
 import contextlib
 import os
 
-from PyQt6.QtCore import pyqtSlot, Qt
+from PyQt6.QtCore import pyqtSlot, Qt, QEvent
 from PyQt6.QtWidgets import (
     QWidget, QVBoxLayout, QHBoxLayout, QLabel, QSizePolicy, QListView,
     QListWidget, QListWidgetItem, QToolButton, QAbstractItemView, QMenu,
@@ -125,6 +125,8 @@
             QSizePolicy.Policy.Expanding,
             QSizePolicy.Policy.Preferred)
         self.__quickCommitEdit.setMaximumHeight(100)
+        self.__quickCommitEdit.setTabChangesFocus(True)
+        self.__quickCommitEdit.installEventFilter(self)
         self.__quickCommitEdit.textChanged.connect(
             self.__quickCommitEditTextChanged)
         self.__quickCommitLayout.addWidget(self.__quickCommitEdit)
@@ -929,3 +931,27 @@
         """
         self.__quickCommitButton.setEnabled(bool(
             self.__quickCommitEdit.toPlainText()))
+    
+    def eventFilter(self, obj, evt):
+        """
+        Public method to process some events for the Commit edit.
+        
+        @param obj reference to the object the event was meant for
+        @type QObject
+        @param evt reference to the event object
+        @type QEvent
+        @return flag to indicate that the event was handled
+        @rtype bool
+        """
+        if (
+            obj is self.__quickCommitEdit and
+            evt.type() == QEvent.Type.KeyPress and
+            evt.key() in (Qt.Key.Key_Return, Qt.Key.Key_Enter) and
+            evt.modifiers() == Qt.KeyboardModifier.ControlModifier
+        ):
+            # Ctrl-Enter or Ctrl-Return => commit
+            self.__quickCommitButton.animateClick()
+            return True
+        else:
+            # standard event processing
+            return super().eventFilter(obj, evt)

eric ide

mercurial