Added a double click instant selection to the Eric List Selection Dialog. eric7

Tue, 05 Oct 2021 19:47:03 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Tue, 05 Oct 2021 19:47:03 +0200
branch
eric7
changeset 8670
12e7fbf2445a
parent 8669
c26ecdb00a8b
child 8671
8857942747cb

Added a double click instant selection to the Eric List Selection Dialog.

eric7/EricWidgets/EricListSelectionDialog.py file | annotate | diff | comparison | revisions
eric7/VCS/StatusWidget.py file | annotate | diff | comparison | revisions
--- a/eric7/EricWidgets/EricListSelectionDialog.py	Tue Oct 05 19:36:02 2021 +0200
+++ b/eric7/EricWidgets/EricListSelectionDialog.py	Tue Oct 05 19:47:03 2021 +0200
@@ -22,7 +22,8 @@
     def __init__(self, entries,
                  selectionMode=QAbstractItemView.SelectionMode
                  .ExtendedSelection,
-                 title="", message="", checkBoxSelection=False, parent=None):
+                 title="", message="", checkBoxSelection=False,
+                 doubleClickOk=False, parent=None):
         """
         Constructor
         
@@ -37,6 +38,9 @@
         @param checkBoxSelection flag indicating to select items via their
             checkbox
         @type bool
+        @param doubleClickOk flag indicating to accept the dialog upon a
+            double click of an item (single selection only)
+        @type bool
         @param parent reference to the parent widget
         @type QWidget
         """
@@ -92,6 +96,21 @@
                 QDialogButtonBox.StandardButton.Ok).setEnabled(
                 self.__checkCount > 0)
     
+    @pyqtSlot(QListWidgetItem)
+    def on_selectionList_itemDoubleClicked(self, item):
+        """
+        Private slot handling double clicking an item.
+        
+        @param item double clicked item
+        @type QListWidgetItem
+        """
+        if (
+            not self.__isCheckBoxSelection and
+            self.selectionList.selectionMode() ==
+            QAbstractItemView.SelectionMode.SingleSelection
+        ):
+            self.accept()
+    
     def getSelection(self):
         """
         Public method to retrieve the selected items.
--- a/eric7/VCS/StatusWidget.py	Tue Oct 05 19:36:02 2021 +0200
+++ b/eric7/VCS/StatusWidget.py	Tue Oct 05 19:47:03 2021 +0200
@@ -872,6 +872,7 @@
                 selectionMode=QAbstractItemView.SelectionMode.SingleSelection,
                 title=self.tr("Quick Commit"),
                 message=self.tr("Select your commit message:"),
+                doubleClickOk=True,
                 parent=self
             )
             if dlg.exec() == QDialog.DialogCode.Accepted:

eric ide

mercurial