Added capability to configure use of an external "Find Files" dialog. external_find

Fri, 29 Apr 2022 17:49:47 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Fri, 29 Apr 2022 17:49:47 +0200
branch
external_find
changeset 9039
3c8aa997bad8
parent 9038
90bcfdd63d47
child 9040
b96a7dcfd839
child 9041
4f598360a94a

Added capability to configure use of an external "Find Files" dialog.

docs/changelog file | annotate | diff | comparison | revisions
eric7/PipInterface/PipPackagesWidget.py file | annotate | diff | comparison | revisions
eric7/UI/FindFileWidget.py file | annotate | diff | comparison | revisions
eric7/UI/FindLocationWidget.py file | annotate | diff | comparison | revisions
eric7/UI/UserInterface.py file | annotate | diff | comparison | revisions
--- a/docs/changelog	Fri Apr 29 15:40:17 2022 +0200
+++ b/docs/changelog	Fri Apr 29 17:49:47 2022 +0200
@@ -2,6 +2,9 @@
 ----------
 Version 22.5:
 - bug fixes
+- General
+  -- added configuration options to disable the embedded "Find/Replace In
+     Files" and "Find File" tools and use dialog based variants instead
 - Mercurial Interface
   -- added capability to enter a revset expression when defining a revision
     to operate on
--- a/eric7/PipInterface/PipPackagesWidget.py	Fri Apr 29 15:40:17 2022 +0200
+++ b/eric7/PipInterface/PipPackagesWidget.py	Fri Apr 29 17:49:47 2022 +0200
@@ -1820,7 +1820,6 @@
         Private slot to show a dialog with the licenses of the selected
         environment.
         """
-        # TODO: not yet implemented
         from .PipLicensesDialog import PipLicensesDialog
         
         environment = self.environmentsComboBox.currentText()
--- a/eric7/UI/FindFileWidget.py	Fri Apr 29 15:40:17 2022 +0200
+++ b/eric7/UI/FindFileWidget.py	Fri Apr 29 17:49:47 2022 +0200
@@ -962,7 +962,7 @@
         self.setLayout(self.__layout)
         self.resize(600, 800)
         
-       # connect the widgets
+        # connect the widgets
         self.__findWidget.sourceFile.connect(self.sourceFile)
         self.__findWidget.designerFile.connect(self.designerFile)
         self.__findWidget.linguistFile.connect(self.linguistFile)
--- a/eric7/UI/FindLocationWidget.py	Fri Apr 29 15:40:17 2022 +0200
+++ b/eric7/UI/FindLocationWidget.py	Fri Apr 29 17:49:47 2022 +0200
@@ -13,7 +13,8 @@
 from PyQt6.QtCore import pyqtSignal, pyqtSlot, Qt, QUrl
 from PyQt6.QtGui import QDesktopServices, QImageReader
 from PyQt6.QtWidgets import (
-    QWidget, QHeaderView, QApplication, QTreeWidgetItem
+    QWidget, QHeaderView, QApplication, QTreeWidgetItem, QDialog,
+    QDialogButtonBox, QVBoxLayout
 )
 
 from EricWidgets.EricPathPicker import EricPathPickerModes
@@ -68,23 +69,28 @@
         self.fileList.headerItem().setText(self.fileList.columnCount(), "")
         
         self.stopButton.setEnabled(False)
+        self.stopButton.setIcon(UI.PixmapCache.getIcon("stopLoading"))
+        self.stopButton.setAutoDefault(False)
         self.stopButton.clicked.connect(self.__stopSearch)
-        self.stopButton.setIcon(UI.PixmapCache.getIcon("stopLoading"))
         
+        self.findButton.setIcon(UI.PixmapCache.getIcon("find"))
+        self.findButton.setAutoDefault(False)
         self.findButton.clicked.connect(self.__searchFile)
-        self.findButton.setIcon(UI.PixmapCache.getIcon("find"))
         
         self.clearButton.setEnabled(False)
+        self.clearButton.setIcon(UI.PixmapCache.getIcon("clear"))
+        self.clearButton.setAutoDefault(False)
         self.clearButton.clicked.connect(self.__clearResults)
-        self.clearButton.setIcon(UI.PixmapCache.getIcon("clear"))
         
         self.openButton.setEnabled(False)
         self.openButton.setIcon(UI.PixmapCache.getIcon("open"))
+        self.openButton.setAutoDefault(False)
         self.openButton.clicked.connect(self.__openFile)
         
         self.__project = project
         self.__project.projectOpened.connect(self.__projectOpened)
         self.__project.projectClosed.connect(self.__projectClosed)
+        
         self.extsepLabel.setText(os.extsep)
         
         self.__shouldStop = False
@@ -290,7 +296,83 @@
     @pyqtSlot()
     def activate(self):
         """
-        Public slot to enable/disable the project checkbox.
+        Public slot to activate this widget.
         """
         self.fileNameEdit.selectAll()
         self.fileNameEdit.setFocus()
+
+
+class FindLocationDialog(QDialog):
+    """
+    Class implementing a dialog to search for files.
+    
+    The occurrences found are displayed in a QTreeWidget showing the
+    filename and the pathname. The file will be opened upon a double click
+    onto the respective entry of the list or by pressing the open button.
+    
+    @signal sourceFile(str) emitted to open a file in the editor
+    @signal designerFile(str) emitted to open a Qt-Designer file
+    @signal linguistFile(str) emitted to open a Qt-Linguist (*.ts) file
+    @signal trpreview([str]) emitted to preview Qt-Linguist (*.qm) files
+    @signal pixmapFile(str) emitted to open a pixmap file
+    @signal svgFile(str) emitted to open a SVG file
+    @signal umlFile(str) emitted to open an eric UML file
+    """
+    sourceFile = pyqtSignal(str)
+    designerFile = pyqtSignal(str)
+    linguistFile = pyqtSignal(str)
+    trpreview = pyqtSignal(list)
+    pixmapFile = pyqtSignal(str)
+    svgFile = pyqtSignal(str)
+    umlFile = pyqtSignal(str)
+    
+    def __init__(self, project, parent=None):
+        """
+        Constructor
+        
+        @param project reference to the project object
+        @type Project
+        @param parent parent widget of this dialog (defaults to None)
+        @type QWidget (optional)
+        """
+        super().__init__(parent)
+        self.setWindowFlags(Qt.WindowType.Window)
+        
+        self.__layout = QVBoxLayout()
+        
+        self.__findWidget = FindLocationWidget(project, self)
+        self.__layout.addWidget(self.__findWidget)
+        
+        self.__buttonBox = QDialogButtonBox(
+            QDialogButtonBox.StandardButton.Close,
+            Qt.Orientation.Horizontal,
+            self
+        )
+        self.__buttonBox.button(
+            QDialogButtonBox.StandardButton.Close).setAutoDefault(False)
+        self.__layout.addWidget(self.__buttonBox)
+        
+        self.setLayout(self.__layout)
+        self.resize(600, 800)
+        
+        # connect the widgets
+        self.__findWidget.sourceFile.connect(self.sourceFile)
+        self.__findWidget.designerFile.connect(self.designerFile)
+        self.__findWidget.linguistFile.connect(self.linguistFile)
+        self.__findWidget.trpreview.connect(self.trpreview)
+        self.__findWidget.pixmapFile.connect(self.pixmapFile)
+        self.__findWidget.svgFile.connect(self.svgFile)
+        self.__findWidget.umlFile.connect(self.umlFile)
+        
+        self.__buttonBox.accepted.connect(self.accept)
+        self.__buttonBox.rejected.connect(self.reject)
+    
+    def activate(self):
+        """
+        Public method to activate the dialog.
+        """
+        self.__findWidget.activate()
+        
+        self.raise_()
+        self.activateWindow()
+        self.show()
--- a/eric7/UI/UserInterface.py	Fri Apr 29 15:40:17 2022 +0200
+++ b/eric7/UI/UserInterface.py	Fri Apr 29 17:49:47 2022 +0200
@@ -944,7 +944,7 @@
         self.__virtualenvManagerWidget = VirtualenvManagerWidget(
             self.virtualenvManager, self)
         
-        self.__FindFileDialog = None
+        self.__findFileDialog = None
         self.__replaceFileDialog = None
         if Preferences.getUI("ShowFindFileWidget"):
             # Create the find in files widget
@@ -961,18 +961,21 @@
         else:
             self.__findFileWidget = None
         
-        # TODO: add separate dialog variant
-        # Create the find location (file) widget
-        from .FindLocationWidget import FindLocationWidget
-        self.__findLocationWidget = FindLocationWidget(self.project, self)
-        self.__findLocationWidget.sourceFile.connect(
-            self.viewmanager.openSourceFile)
-        self.__findLocationWidget.designerFile.connect(self.__designer)
-        self.__findLocationWidget.linguistFile.connect(self.__linguist)
-        self.__findLocationWidget.trpreview.connect(self.__TRPreviewer)
-        self.__findLocationWidget.pixmapFile.connect(self.__showPixmap)
-        self.__findLocationWidget.svgFile.connect(self.__showSvg)
-        self.__findLocationWidget.umlFile.connect(self.__showUml)
+        self.__findLocationDialog = None
+        if Preferences.getUI("ShowFindLocationWidget"):
+            # Create the find location (file) widget
+            from .FindLocationWidget import FindLocationWidget
+            self.__findLocationWidget = FindLocationWidget(self.project, self)
+            self.__findLocationWidget.sourceFile.connect(
+                self.viewmanager.openSourceFile)
+            self.__findLocationWidget.designerFile.connect(self.__designer)
+            self.__findLocationWidget.linguistFile.connect(self.__linguist)
+            self.__findLocationWidget.trpreview.connect(self.__TRPreviewer)
+            self.__findLocationWidget.pixmapFile.connect(self.__showPixmap)
+            self.__findLocationWidget.svgFile.connect(self.__showSvg)
+            self.__findLocationWidget.umlFile.connect(self.__showUml)
+        else:
+            self.__findLocationWidget = None
         
         # Create the VCS Status widget
         from VCS.StatusWidget import StatusWidget
@@ -1095,9 +1098,10 @@
                                   UI.PixmapCache.getIcon("find"),
                                   self.tr("Find/Replace In Files"))
         
-        self.lToolbox.addItem(self.__findLocationWidget,
-                              UI.PixmapCache.getIcon("findLocation"),
-                              self.tr("Find File"))
+        if self.__findLocationWidget:
+            self.lToolbox.addItem(self.__findLocationWidget,
+                                  UI.PixmapCache.getIcon("findLocation"),
+                                  self.tr("Find File"))
         
         self.lToolbox.addItem(self.__vcsStatusWidget,
                               UI.PixmapCache.getIcon("tbVcsStatus"),
@@ -1246,10 +1250,11 @@
                 UI.PixmapCache.getIcon("sbFind96"),
                 self.tr("Find/Replace In Files"))
         
-        self.leftSidebar.addTab(
-            self.__findLocationWidget,
-            UI.PixmapCache.getIcon("sbFindLocation96"),
-            self.tr("Find File"))
+        if self.__findLocationWidget:
+            self.leftSidebar.addTab(
+                self.__findLocationWidget,
+                UI.PixmapCache.getIcon("sbFindLocation96"),
+                self.tr("Find File"))
         
         self.leftSidebar.addTab(
             self.__vcsStatusWidget,
@@ -2339,24 +2344,25 @@
                 self.__activateFindFileWidget)
             self.actions.append(self.findFileActivateAct)
             self.addAction(self.findFileActivateAct)
-
-        self.findLocationActivateAct = EricAction(
-            self.tr("Find File"),
-            self.tr("Find File"),
-            QKeySequence(self.tr("Ctrl+Alt+Shift+L")),
-            0, self,
-            'find_location_activate')
-        self.findLocationActivateAct.setStatusTip(self.tr(
-            "Switch the input focus to the Find File window."))
-        self.findLocationActivateAct.setWhatsThis(self.tr(
-            """<b>Find File</b>"""
-            """<p>This switches the input focus to the Find File window."""
-            """</p>"""
-        ))
-        self.findLocationActivateAct.triggered.connect(
-            self.__activateFindLocationWidget)
-        self.actions.append(self.findLocationActivateAct)
-        self.addAction(self.findLocationActivateAct)
+        
+        if self.__findLocationWidget is not None:
+            self.findLocationActivateAct = EricAction(
+                self.tr("Find File"),
+                self.tr("Find File"),
+                QKeySequence(self.tr("Ctrl+Alt+Shift+L")),
+                0, self,
+                'find_location_activate')
+            self.findLocationActivateAct.setStatusTip(self.tr(
+                "Switch the input focus to the Find File window."))
+            self.findLocationActivateAct.setWhatsThis(self.tr(
+                """<b>Find File</b>"""
+                """<p>This switches the input focus to the Find File window."""
+                """</p>"""
+            ))
+            self.findLocationActivateAct.triggered.connect(
+                self.__activateFindLocationWidget)
+            self.actions.append(self.findLocationActivateAct)
+            self.addAction(self.findLocationActivateAct)
 
         self.vcsStatusListActivateAct = EricAction(
             self.tr("VCS Status List"),
@@ -3477,7 +3483,8 @@
         self.__menus["subwindow"].addAction(self.pbActivateAct)
         if self.__findFileWidget is not None:
             self.__menus["subwindow"].addAction(self.findFileActivateAct)
-        self.__menus["subwindow"].addAction(self.findLocationActivateAct)
+        if self.__findLocationWidget is not None:
+            self.__menus["subwindow"].addAction(self.findLocationActivateAct)
         self.__menus["subwindow"].addAction(self.vcsStatusListActivateAct)
         if not self.rightSidebar:
             self.__menus["subwindow"].addAction(self.debugViewerActivateAct)
@@ -7179,18 +7186,18 @@
                 openFiles=openFiles)
         else:
             # external dialog
-            if self.__FindFileDialog is None:
+            if self.__findFileDialog is None:
                 from .FindFileWidget import FindFileDialog
-                self.__FindFileDialog = FindFileDialog(self.project)
-                self.__FindFileDialog.sourceFile.connect(
+                self.__findFileDialog = FindFileDialog(self.project, self)
+                self.__findFileDialog.sourceFile.connect(
                     self.viewmanager.openSourceFile)
-                self.__FindFileDialog.designerFile.connect(self.__designer)
-                self.__FindFileDialog.linguistFile.connect(self.__linguist)
-                self.__FindFileDialog.trpreview.connect(self.__TRPreviewer)
-                self.__FindFileDialog.pixmapFile.connect(self.__showPixmap)
-                self.__FindFileDialog.svgFile.connect(self.__showSvg)
-                self.__FindFileDialog.umlFile.connect(self.__showUml)
-            self.__FindFileDialog.activate(
+                self.__findFileDialog.designerFile.connect(self.__designer)
+                self.__findFileDialog.linguistFile.connect(self.__linguist)
+                self.__findFileDialog.trpreview.connect(self.__TRPreviewer)
+                self.__findFileDialog.pixmapFile.connect(self.__showPixmap)
+                self.__findFileDialog.svgFile.connect(self.__showSvg)
+                self.__findFileDialog.umlFile.connect(self.__showUml)
+            self.__findFileDialog.activate(
                 replaceMode=False, txt=txt, searchDir=searchDir,
                 openFiles=openFiles)
     
@@ -7207,6 +7214,7 @@
         @type bool (optional)
         """
         if Preferences.getUI("ShowFindFileWidget"):
+            # embedded tool
             self.__activateFindFileWidget()
             self.__findFileWidget.activate(
                 replaceMode=True, txt=txt, searchDir=searchDir,
@@ -7215,7 +7223,7 @@
             # external dialog
             if self.__replaceFileDialog is None:
                 from .FindFileWidget import FindFileDialog
-                self.__replaceFileDialog = FindFileDialog(self.project)
+                self.__replaceFileDialog = FindFileDialog(self.project, self)
                 self.__replaceFileDialog.sourceFile.connect(
                     self.viewmanager.openSourceFile)
                 self.__replaceFileDialog.designerFile.connect(self.__designer)
@@ -7247,8 +7255,24 @@
         """
         Public method to show the Find File widget.
         """
-        # TODO: add separate dialog variant
-        self.__activateFindLocationWidget()
+        if Preferences.getUI("ShowFindLocationWidget"):
+            # embedded tool
+            self.__activateFindLocationWidget()
+        else:
+            # external dialog
+            if self.__findLocationDialog is None:
+                from .FindLocationWidget import FindLocationDialog
+                self.__findLocationDialog = FindLocationDialog(self.project,
+                                                               self)
+                self.__findLocationDialog.sourceFile.connect(
+                    self.viewmanager.openSourceFile)
+                self.__findLocationDialog.designerFile.connect(self.__designer)
+                self.__findLocationDialog.linguistFile.connect(self.__linguist)
+                self.__findLocationDialog.trpreview.connect(self.__TRPreviewer)
+                self.__findLocationDialog.pixmapFile.connect(self.__showPixmap)
+                self.__findLocationDialog.svgFile.connect(self.__showSvg)
+                self.__findLocationDialog.umlFile.connect(self.__showUml)
+            self.__findLocationDialog.activate()
     
     def __activateFindLocationWidget(self):
         """

eric ide

mercurial