eric7/UI/UserInterface.py

branch
eric7
changeset 8614
4a3a68e51b92
parent 8610
c9cd21bcbe33
child 8618
356a2f1b04b0
diff -r 2af21036b293 -r 4a3a68e51b92 eric7/UI/UserInterface.py
--- a/eric7/UI/UserInterface.py	Fri Sep 17 19:53:54 2021 +0200
+++ b/eric7/UI/UserInterface.py	Sat Sep 18 18:51:58 2021 +0200
@@ -945,6 +945,13 @@
         from VirtualEnv.VirtualenvManagerWidgets import VirtualenvManagerWidget
         self.__virtualenvManagerWidget = VirtualenvManagerWidget(
             self.virtualenvManager, self)
+        
+        # Create the find in files widget
+        from .FindFileWidget import FindFileWidget
+        self.__findFileWidget = FindFileWidget(self.project, self)
+        self.__findFileWidget.sourceFile.connect(
+            self.viewmanager.openSourceFile)
+        self.__findFileWidget.designerFile.connect(self.__designer)
     
     def __createLayout(self):
         """
@@ -1065,6 +1072,10 @@
                               UI.PixmapCache.getIcon("debugViewer"),
                               self.tr("Debug-Viewer"))
         
+        self.rToolbox.addItem(self.__findFileWidget,
+                              UI.PixmapCache.getIcon("find"),
+                              self.tr("Find/Replace In Files"))
+        
         self.rToolbox.addItem(self.pluginRepositoryViewer,
                               UI.PixmapCache.getIcon("pluginRepository"),
                               self.tr("Plugin Repository"))
@@ -1203,10 +1214,16 @@
                 self.tr("Code Documentation Viewer"))
         
         self.rightSidebar.addTab(
-            self.debugViewer, UI.PixmapCache.getIcon("sbDebugViewer96"),
+            self.debugViewer,
+            UI.PixmapCache.getIcon("sbDebugViewer96"),
             self.tr("Debug-Viewer"))
         
         self.rightSidebar.addTab(
+            self.__findFileWidget,
+            UI.PixmapCache.getIcon("sbFind96"),
+            self.tr("Find/Replace In Files"))
+        
+        self.rightSidebar.addTab(
             self.pluginRepositoryViewer,
             UI.PixmapCache.getIcon("sbPluginRepository96"),
             self.tr("Plugin Repository"))
@@ -2210,6 +2227,24 @@
             self.activateVirtualenvManager)
         self.actions.append(self.virtualenvManagerActivateAct)
         self.addAction(self.virtualenvManagerActivateAct)
+
+        self.findFileActivateAct = EricAction(
+            self.tr("Find/Replace In Files"),
+            self.tr("Find/Replace In Files"),
+            QKeySequence(self.tr("Ctrl+Alt+Shift+F")),
+            0, self,
+            'find_file_activate')
+        self.findFileActivateAct.setStatusTip(self.tr(
+            "Switch the input focus to the Find/Replace In Files window."))
+        self.findFileActivateAct.setWhatsThis(self.tr(
+            """<b>Find/Replace In Files</b>"""
+            """<p>This switches the input focus to the Find/Replace In Files"""
+            """ window.</p>"""
+        ))
+        self.findFileActivateAct.triggered.connect(
+            self.__activateFindFileWidget)
+        self.actions.append(self.findFileActivateAct)
+        self.addAction(self.findFileActivateAct)
         
         self.whatsThisAct = EricAction(
             self.tr('What\'s This?'),
@@ -3311,6 +3346,7 @@
             self.__menus["subwindow"].addAction(
                 self.codeDocumentationViewerActivateAct)
         self.__menus["subwindow"].addAction(self.debugViewerActivateAct)
+        self.__menus["subwindow"].addAction(self.findFileActivateAct)
         self.__menus["subwindow"].addAction(
             self.pluginRepositoryViewerActivateAct)
         self.__menus["subwindow"].addAction(self.virtualenvManagerActivateAct)
@@ -6796,50 +6832,54 @@
         self.findFileNameDialog.raise_()
         self.findFileNameDialog.activateWindow()
     
-    def showFindFilesDialog(self, txt="", searchDir="", openFiles=False):
-        """
-        Public slot to show the Find In Files dialog.
-        
-        @param txt text to search for (string)
-        @param searchDir directory to search in (string)
-        @param openFiles flag indicating to operate on open files (boolean)
-        """
-        if self.findFilesDialog is None:
-            from .FindFileDialog import FindFileDialog
-            self.findFilesDialog = FindFileDialog(self.project)
-            self.findFilesDialog.sourceFile.connect(
-                self.viewmanager.openSourceFile)
-            self.findFilesDialog.designerFile.connect(self.__designer)
-        if searchDir:
-            self.findFilesDialog.setSearchDirectory(searchDir)
-        self.findFilesDialog.show(txt)
-        if openFiles:
-            self.findFilesDialog.setOpenFiles()
-        self.findFilesDialog.raise_()
-        self.findFilesDialog.activateWindow()
+    def showFindFilesWidget(self, txt="", searchDir="", openFiles=False):
+        """
+        Public slot to show the Find In Files widget.
+        
+        @param txt text to search for (defaults to "")
+        @type str (optional)
+        @param searchDir directory to search in (defaults to "")
+        @type str (optional)
+        @param openFiles flag indicating to operate on open files only
+            (defaults to False)
+        @type bool (optional)
+        """
+        self.__activateFindFileWidget()
+        self.__findFileWidget.activate(
+            replaceMode=False, txt=txt, searchDir=searchDir,
+            openFiles=openFiles)
     
-    def showReplaceFilesDialog(self, txt="", searchDir="", openFiles=False):
-        """
-        Public slot to show the Find & Replace In Files dialog.
-        
-        @param txt text to search for (string)
-        @param searchDir directory to search in (string)
-        @param openFiles flag indicating to operate on open files (boolean)
-        """
-        if self.replaceFilesDialog is None:
-            from .FindFileDialog import FindFileDialog
-            self.replaceFilesDialog = FindFileDialog(
-                self.project, replaceMode=True)
-            self.replaceFilesDialog.sourceFile.connect(
-                self.viewmanager.openSourceFile)
-            self.replaceFilesDialog.designerFile.connect(self.__designer)
-        if searchDir:
-            self.replaceFilesDialog.setSearchDirectory(searchDir)
-        self.replaceFilesDialog.show(txt)
-        if openFiles:
-            self.replaceFilesDialog.setOpenFiles()
-        self.replaceFilesDialog.raise_()
-        self.replaceFilesDialog.activateWindow()
+    def showReplaceFilesWidget(self, txt="", searchDir="", openFiles=False):
+        """
+        Public slot to show the Find In Files widget in replace mode.
+        
+        @param txt text to search for (defaults to "")
+        @type str (optional)
+        @param searchDir directory to search in (defaults to "")
+        @type str (optional)
+        @param openFiles flag indicating to operate on open files only
+            (defaults to False)
+        @type bool (optional)
+        """
+        self.__activateFindFileWidget()
+        self.__findFileWidget.activate(
+            replaceMode=True, txt=txt, searchDir=searchDir,
+            openFiles=openFiles)
+    
+    def __activateFindFileWidget(self):
+        """
+        Private method to activate the Find In Files widget.
+        """
+        if self.__layoutType == "Toolboxes":
+            self.rToolboxDock.show()
+            self.rToolbox.setCurrentWidget(self.__findFileWidget)
+        elif self.__layoutType == "Sidebars":
+            self.rightSidebar.show()
+            self.rightSidebar.setCurrentWidget(self.__findFileWidget)
+        self.__findFileWidget.setFocus(
+            Qt.FocusReason.ActiveWindowFocusReason)
+        
+        self.__findFileWidget.activate()
     
     ##########################################################
     ## Below are slots to handle StdOut and StdErr

eric ide

mercurial