Changes to speed up the start-up phase by creating some dialog on demand.

Wed, 14 Dec 2011 19:57:54 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 14 Dec 2011 19:57:54 +0100
changeset 1490
ed6f2208297d
parent 1488
de290ce82a75
child 1491
985c5abc8226

Changes to speed up the start-up phase by creating some dialog on demand.

APIs/Python3/eric5.api file | annotate | diff | comparison | revisions
Documentation/Help/source.qch file | annotate | diff | comparison | revisions
Documentation/Help/source.qhp file | annotate | diff | comparison | revisions
Documentation/Source/eric5.UI.UserInterface.html file | annotate | diff | comparison | revisions
UI/Browser.py file | annotate | diff | comparison | revisions
UI/UserInterface.py file | annotate | diff | comparison | revisions
ViewManager/ViewManager.py file | annotate | diff | comparison | revisions
--- a/APIs/Python3/eric5.api	Sat Dec 10 18:01:16 2011 +0100
+++ b/APIs/Python3/eric5.api	Wed Dec 14 19:57:54 2011 +0100
@@ -6574,9 +6574,12 @@
 eric5.UI.UserInterface.UserInterface.setDebugProfile?4(save=True)
 eric5.UI.UserInterface.UserInterface.showAvailableVersionsInfo?4()
 eric5.UI.UserInterface.UserInterface.showEvent?4(evt)
+eric5.UI.UserInterface.UserInterface.showFindFileByNameDialog?4()
+eric5.UI.UserInterface.UserInterface.showFindFilesDialog?4(txt="", searchDir="")
 eric5.UI.UserInterface.UserInterface.showLogTab?4(tabname)
 eric5.UI.UserInterface.UserInterface.showMenu?7
 eric5.UI.UserInterface.UserInterface.showPreferences?4(pageName=None)
+eric5.UI.UserInterface.UserInterface.showReplaceFilesDialog?4(txt="", searchDir="")
 eric5.UI.UserInterface.UserInterface.unregisterToolbar?4(name)
 eric5.UI.UserInterface.UserInterface.versionIsNewer?4(required, snapshot=None)
 eric5.UI.UserInterface.UserInterface?1(app, locale, splash, plugin, noOpenAtStartup, restartArguments)
Binary file Documentation/Help/source.qch has changed
--- a/Documentation/Help/source.qhp	Sat Dec 10 18:01:16 2011 +0100
+++ b/Documentation/Help/source.qhp	Wed Dec 14 19:57:54 2011 +0100
@@ -4237,6 +4237,7 @@
       <keyword name="UserInterface.__createLayout" id="UserInterface.__createLayout" ref="eric5.UI.UserInterface.html#UserInterface.__createLayout" />
       <keyword name="UserInterface.__createSidebarsLayout" id="UserInterface.__createSidebarsLayout" ref="eric5.UI.UserInterface.html#UserInterface.__createSidebarsLayout" />
       <keyword name="UserInterface.__createToolboxesLayout" id="UserInterface.__createToolboxesLayout" ref="eric5.UI.UserInterface.html#UserInterface.__createToolboxesLayout" />
+      <keyword name="UserInterface.__createUnitTestDialog" id="UserInterface.__createUnitTestDialog" ref="eric5.UI.UserInterface.html#UserInterface.__createUnitTestDialog" />
       <keyword name="UserInterface.__customViewer" id="UserInterface.__customViewer" ref="eric5.UI.UserInterface.html#UserInterface.__customViewer" />
       <keyword name="UserInterface.__debuggingStarted" id="UserInterface.__debuggingStarted" ref="eric5.UI.UserInterface.html#UserInterface.__debuggingStarted" />
       <keyword name="UserInterface.__deinstallPlugin" id="UserInterface.__deinstallPlugin" ref="eric5.UI.UserInterface.html#UserInterface.__deinstallPlugin" />
@@ -4385,8 +4386,11 @@
       <keyword name="UserInterface.setDebugProfile" id="UserInterface.setDebugProfile" ref="eric5.UI.UserInterface.html#UserInterface.setDebugProfile" />
       <keyword name="UserInterface.showAvailableVersionsInfo" id="UserInterface.showAvailableVersionsInfo" ref="eric5.UI.UserInterface.html#UserInterface.showAvailableVersionsInfo" />
       <keyword name="UserInterface.showEvent" id="UserInterface.showEvent" ref="eric5.UI.UserInterface.html#UserInterface.showEvent" />
+      <keyword name="UserInterface.showFindFileByNameDialog" id="UserInterface.showFindFileByNameDialog" ref="eric5.UI.UserInterface.html#UserInterface.showFindFileByNameDialog" />
+      <keyword name="UserInterface.showFindFilesDialog" id="UserInterface.showFindFilesDialog" ref="eric5.UI.UserInterface.html#UserInterface.showFindFilesDialog" />
       <keyword name="UserInterface.showLogTab" id="UserInterface.showLogTab" ref="eric5.UI.UserInterface.html#UserInterface.showLogTab" />
       <keyword name="UserInterface.showPreferences" id="UserInterface.showPreferences" ref="eric5.UI.UserInterface.html#UserInterface.showPreferences" />
+      <keyword name="UserInterface.showReplaceFilesDialog" id="UserInterface.showReplaceFilesDialog" ref="eric5.UI.UserInterface.html#UserInterface.showReplaceFilesDialog" />
       <keyword name="UserInterface.unregisterToolbar" id="UserInterface.unregisterToolbar" ref="eric5.UI.UserInterface.html#UserInterface.unregisterToolbar" />
       <keyword name="UserInterface.versionIsNewer" id="UserInterface.versionIsNewer" ref="eric5.UI.UserInterface.html#UserInterface.versionIsNewer" />
       <keyword name="DiffDialog (Module)" id="DiffDialog (Module)" ref="eric5.UI.DiffDialog.html" />
--- a/Documentation/Source/eric5.UI.UserInterface.html	Sat Dec 10 18:01:16 2011 +0100
+++ b/Documentation/Source/eric5.UI.UserInterface.html	Wed Dec 14 19:57:54 2011 +0100
@@ -278,6 +278,9 @@
 <td><a href="#UserInterface.__createToolboxesLayout">__createToolboxesLayout</a></td>
 <td>Private method to create the Toolboxes layout.</td>
 </tr><tr>
+<td><a href="#UserInterface.__createUnitTestDialog">__createUnitTestDialog</a></td>
+<td>Private slot to generate the unit test dialog on demand.</td>
+</tr><tr>
 <td><a href="#UserInterface.__customViewer">__customViewer</a></td>
 <td>Private slot to start a custom viewer.</td>
 </tr><tr>
@@ -722,12 +725,21 @@
 <td><a href="#UserInterface.showEvent">showEvent</a></td>
 <td>Protected method to handle the show event.</td>
 </tr><tr>
+<td><a href="#UserInterface.showFindFileByNameDialog">showFindFileByNameDialog</a></td>
+<td>Public slot to show the Find File by Name dialog.</td>
+</tr><tr>
+<td><a href="#UserInterface.showFindFilesDialog">showFindFilesDialog</a></td>
+<td>Public slot to show the Find In Files dialog.</td>
+</tr><tr>
 <td><a href="#UserInterface.showLogTab">showLogTab</a></td>
 <td>Public method to show a particular Log-Viewer tab.</td>
 </tr><tr>
 <td><a href="#UserInterface.showPreferences">showPreferences</a></td>
 <td>Public slot to set the preferences.</td>
 </tr><tr>
+<td><a href="#UserInterface.showReplaceFilesDialog">showReplaceFilesDialog</a></td>
+<td>Public slot to show the Find & Replace In Files dialog.</td>
+</tr><tr>
 <td><a href="#UserInterface.unregisterToolbar">unregisterToolbar</a></td>
 <td>Public method to unregister a toolbar.</td>
 </tr><tr>
@@ -1007,7 +1019,12 @@
 <dd>
 reference to the debug server object
 </dd>
-</dl><a NAME="UserInterface.__customViewer" ID="UserInterface.__customViewer"></a>
+</dl><a NAME="UserInterface.__createUnitTestDialog" ID="UserInterface.__createUnitTestDialog"></a>
+<h4>UserInterface.__createUnitTestDialog</h4>
+<b>__createUnitTestDialog</b>(<i></i>)
+<p>
+        Private slot to generate the unit test dialog on demand.
+</p><a NAME="UserInterface.__customViewer" ID="UserInterface.__customViewer"></a>
 <h4>UserInterface.__customViewer</h4>
 <b>__customViewer</b>(<i>home=None</i>)
 <p>
@@ -2161,6 +2178,24 @@
 <dd>
 reference to the show event (QShowEvent)
 </dd>
+</dl><a NAME="UserInterface.showFindFileByNameDialog" ID="UserInterface.showFindFileByNameDialog"></a>
+<h4>UserInterface.showFindFileByNameDialog</h4>
+<b>showFindFileByNameDialog</b>(<i></i>)
+<p>
+        Public slot to show the Find File by Name dialog.
+</p><a NAME="UserInterface.showFindFilesDialog" ID="UserInterface.showFindFilesDialog"></a>
+<h4>UserInterface.showFindFilesDialog</h4>
+<b>showFindFilesDialog</b>(<i>txt="", searchDir=""</i>)
+<p>
+        Public slot to show the Find In Files dialog.
+</p><dl>
+<dt><i>txt=</i></dt>
+<dd>
+text to search for (string)
+</dd><dt><i>searchDir=</i></dt>
+<dd>
+directory to search in (string)
+</dd>
 </dl><a NAME="UserInterface.showLogTab" ID="UserInterface.showLogTab"></a>
 <h4>UserInterface.showLogTab</h4>
 <b>showLogTab</b>(<i>tabname</i>)
@@ -2181,6 +2216,19 @@
 <dd>
 name of the configuration page to show (string)
 </dd>
+</dl><a NAME="UserInterface.showReplaceFilesDialog" ID="UserInterface.showReplaceFilesDialog"></a>
+<h4>UserInterface.showReplaceFilesDialog</h4>
+<b>showReplaceFilesDialog</b>(<i>txt="", searchDir=""</i>)
+<p>
+        Public slot to show the Find & Replace In Files dialog.
+</p><dl>
+<dt><i>txt=</i></dt>
+<dd>
+text to search for (string)
+</dd><dt><i>searchDir=</i></dt>
+<dd>
+directory to search in (string)
+</dd>
 </dl><a NAME="UserInterface.unregisterToolbar" ID="UserInterface.unregisterToolbar"></a>
 <h4>UserInterface.unregisterToolbar</h4>
 <b>unregisterToolbar</b>(<i>name</i>)
--- a/UI/Browser.py	Sat Dec 10 18:01:16 2011 +0100
+++ b/UI/Browser.py	Wed Dec 14 19:57:54 2011 +0100
@@ -496,11 +496,7 @@
         index = self.currentIndex()
         searchDir = self.model().item(index).dirName()
         
-        findFilesDialog = e5App().getObject("FindFilesDialog")
-        findFilesDialog.setSearchDirectory(searchDir)
-        findFilesDialog.show()
-        findFilesDialog.raise_()
-        findFilesDialog.activateWindow()
+        e5App().getObject("UserInterface").showFindFilesDialog(searchDir=searchDir)
         
     def __replaceInDirectory(self):
         """
@@ -509,11 +505,7 @@
         index = self.currentIndex()
         searchDir = self.model().item(index).dirName()
         
-        replaceFilesDialog = e5App().getObject("ReplaceFilesDialog")
-        replaceFilesDialog.setSearchDirectory(searchDir)
-        replaceFilesDialog.show()
-        replaceFilesDialog.raise_()
-        replaceFilesDialog.activateWindow()
+        e5App().getObject("UserInterface").showReplaceFilesDialog(searchDir=searchDir)
         
     def handleProgramChange(self, fn):
         """
--- a/UI/UserInterface.py	Sat Dec 10 18:01:16 2011 +0100
+++ b/UI/UserInterface.py	Wed Dec 14 19:57:54 2011 +0100
@@ -275,13 +275,15 @@
         self.stdout = Redirector(False)
         self.stderr = Redirector(True)
         
-        # Genrae the programs dialog
-        logging.debug("Creating Programs Dialog...")
-        self.programsDialog = ProgramsDialog(self)
-        
-        # Generate the shortcuts configuration dialog
-        logging.debug("Creating Shortcuts Dialog...")
-        self.shortcutsDialog = ShortcutsDialog(self, 'Shortcuts')
+        # set a few dialog members for dialogs created on demand
+        self.programsDialog = None
+        self.shortcutsDialog = None
+        self.unittestDialog = None
+        self.findFileNameDialog = None
+        self.diffDlg = None
+        self.compareDlg = None
+        self.findFilesDialog = None
+        self.replaceFilesDialog = None
         
         # now setup the connections
         splash.showMessage(self.trUtf8("Setting up connections..."))
@@ -448,30 +450,6 @@
         
         self.numbersViewer.insertNumber.connect(self.viewmanager.insertNumber)
         
-        # Generate the unittest dialog
-        self.unittestDialog = UnittestDialog(None, self.debuggerUI.debugServer, self,
-                                             fromEric=True)
-        self.unittestDialog.unittestFile.connect(self.viewmanager.setFileLine)
-        
-        # Generate the find in project files dialog
-        self.findFilesDialog = FindFileDialog(self.project)
-        self.findFilesDialog.sourceFile.connect(
-            self.viewmanager.openSourceFile)
-        self.findFilesDialog.designerFile.connect(self.__designer)
-        self.replaceFilesDialog = FindFileDialog(self.project, replaceMode=True)
-        self.replaceFilesDialog.sourceFile.connect(
-            self.viewmanager.openSourceFile)
-        self.replaceFilesDialog.designerFile.connect(self.__designer)
-        
-        # generate the find file dialog
-        self.findFileNameDialog = FindFileNameDialog(self.project)
-        self.findFileNameDialog.sourceFile.connect(self.viewmanager.openSourceFile)
-        self.findFileNameDialog.designerFile.connect(self.__designer)
-        
-        # generate the diff dialogs
-        self.diffDlg = DiffDialog()
-        self.compareDlg = CompareDialog()
-        
         # create the toolbar manager object
         self.toolbarManager = E5ToolBarManager(self, self)
         self.toolbarManager.setMainWindow(self)
@@ -497,8 +475,6 @@
         e5App().registerObject("TaskViewer", self.taskViewer)
         e5App().registerObject("TemplateViewer", self.templateViewer)
         e5App().registerObject("Shell", self.shell)
-        e5App().registerObject("FindFilesDialog", self.findFilesDialog)
-        e5App().registerObject("ReplaceFilesDialog", self.replaceFilesDialog)
         e5App().registerObject("DummyHelpViewer", self.dummyHelpViewer)
         e5App().registerObject("PluginManager", self.pluginManager)
         e5App().registerObject("ToolbarManager", self.toolbarManager)
@@ -2914,6 +2890,8 @@
         """
         aw = self.viewmanager.activeWindow()
         fn = aw and aw.getFileName() or None
+        if self.diffDlg is None:
+            self.diffDlg = DiffDialog()
         self.diffDlg.show(fn)
         
     def __compareFilesSbs(self):
@@ -2922,6 +2900,8 @@
         """
         aw = self.viewmanager.activeWindow()
         fn = aw and aw.getFileName() or None
+        if self.compareDlg is None:
+            self.compareDlg = CompareDialog()
         self.compareDlg.show(fn)
         
     def __openMiniEditor(self):
@@ -4005,10 +3985,20 @@
         if dlg.exec_() == QDialog.Accepted:
             self.toolGroups, self.currentToolGroup = dlg.getToolGroups()
         
+    def __createUnitTestDialog(self):
+        """
+        Private slot to generate the unit test dialog on demand.
+        """
+        if self.unittestDialog is None:
+            self.unittestDialog = UnittestDialog(
+                None, self.debuggerUI.debugServer, self, fromEric=True)
+            self.unittestDialog.unittestFile.connect(self.viewmanager.setFileLine)
+    
     def __unittest(self):
         """
         Private slot for displaying the unittest dialog.
         """
+        self.__createUnitTestDialog()
         self.unittestDialog.show()
         self.unittestDialog.raise_()
 
@@ -4027,6 +4017,7 @@
             else:
                 prog = fn
         
+        self.__createUnitTestDialog()
         self.unittestDialog.insertProg(prog)
         self.unittestDialog.show()
         self.unittestDialog.raise_()
@@ -4050,6 +4041,7 @@
                     " current project. Aborting"))
             return
         
+        self.__createUnitTestDialog()
         self.unittestDialog.insertProg(prog)
         self.unittestDialog.show()
         self.unittestDialog.raise_()
@@ -4059,6 +4051,7 @@
         """
         Private slot to display the unittest dialog and rerun the last test.
         """
+        self.__createUnitTestDialog()
         self.unittestDialog.show()
         self.unittestDialog.raise_()
         self.unittestDialog.on_startButton_clicked()
@@ -5048,6 +5041,8 @@
         """
         Private slot to display a dialog show a list of external tools used by eric5.
         """
+        if self.programsDialog is None:
+            self.programsDialog = ProgramsDialog(self)
         self.programsDialog.show()
         
     def __configViewProfiles(self):
@@ -5076,6 +5071,8 @@
         """
         Private slot to configure the keyboard shortcuts.
         """
+        if self.shortcutsDialog is None:
+            self.shortcutsDialog = ShortcutsDialog(self, 'Shortcuts')
         self.shortcutsDialog.populate()
         self.shortcutsDialog.show()
         
@@ -5290,6 +5287,54 @@
                 self.trUtf8("<p>The session file <b>{0}</b> could not be read.</p>")\
                     .format(fn))
     
+    def showFindFileByNameDialog(self):
+        """
+        Public slot to show the Find File by Name dialog.
+        """
+        if self.findFileNameDialog is None:
+            self.findFileNameDialog = FindFileNameDialog(self.project)
+            self.findFileNameDialog.sourceFile.connect(self.viewmanager.openSourceFile)
+            self.findFileNameDialog.designerFile.connect(self.__designer)
+        self.findFileNameDialog.show()
+        self.findFileNameDialog.raise_()
+        self.findFileNameDialog.activateWindow()
+    
+    def showFindFilesDialog(self, txt="", searchDir=""):
+        """
+        Public slot to show the Find In Files dialog.
+        
+        @keyparam txt text to search for (string)
+        @keyparam searchDir directory to search in (string)
+        """
+        if self.findFilesDialog is None:
+            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)
+        self.findFilesDialog.raise_()
+        self.findFilesDialog.activateWindow()
+    
+    def showReplaceFilesDialog(self, txt="", searchDir=""):
+        """
+        Public slot to show the Find & Replace In Files dialog.
+        
+        @keyparam txt text to search for (string)
+        @keyparam searchDir directory to search in (string)
+        """
+        if self.replaceFilesDialog is None:
+            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)
+        self.replaceFilesDialog.raise_()
+        self.replaceFilesDialog.activateWindow()
+    
     ##########################################################
     ## Below are slots to handle StdOut and StdErr
     ##########################################################
--- a/ViewManager/ViewManager.py	Sat Dec 10 18:01:16 2011 +0100
+++ b/ViewManager/ViewManager.py	Wed Dec 14 19:57:54 2011 +0100
@@ -4192,9 +4192,7 @@
         """
         Private method to handle the search for file action.
         """
-        self.ui.findFileNameDialog.show()
-        self.ui.findFileNameDialog.raise_()
-        self.ui.findFileNameDialog.activateWindow()
+        self.ui.showFindFileByNameDialog()
     
     def appFocusChanged(self, old, now):
         """
@@ -4692,17 +4690,13 @@
         """
         Private method to handle the search in files action.
         """
-        self.ui.findFilesDialog.show(self.textForFind())
-        self.ui.findFilesDialog.raise_()
-        self.ui.findFilesDialog.activateWindow()
+        self.ui.showFindFilesDialog(self.textForFind())
         
     def __replaceFiles(self):
         """
         Private method to handle the replace in files action.
         """
-        self.ui.replaceFilesDialog.show(self.textForFind())
-        self.ui.replaceFilesDialog.raise_()
-        self.ui.replaceFilesDialog.activateWindow()
+        self.ui.showReplaceFilesDialog(self.textForFind())
     
     ##################################################################
     ## Below are the action methods for the view menu

eric ide

mercurial