Fixed an issue with handling the focus and (de-)activation of actions as it changes.

Sun, 28 Feb 2010 13:58:38 +0000

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 28 Feb 2010 13:58:38 +0000
changeset 128
13e96bd0f5a5
parent 127
003f568ac4a0
child 129
3bc474738bf3

Fixed an issue with handling the focus and (de-)activation of actions as it changes.

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
Documentation/Source/eric5.ViewManager.ViewManager.html file | annotate | diff | comparison | revisions
QScintilla/Editor.py file | annotate | diff | comparison | revisions
QScintilla/Shell.py file | annotate | diff | comparison | revisions
QScintilla/Terminal.py file | annotate | diff | comparison | revisions
UI/UserInterface.py file | annotate | diff | comparison | revisions
ViewManager/ViewManager.py file | annotate | diff | comparison | revisions
eric5.py file | annotate | diff | comparison | revisions
--- a/APIs/Python3/eric5.api	Sun Feb 28 10:36:13 2010 +0000
+++ b/APIs/Python3/eric5.api	Sun Feb 28 13:58:38 2010 +0000
@@ -5068,7 +5068,7 @@
 eric5.UI.UserInterface.UserInterface.showPreferences?4(pageName = None)
 eric5.UI.UserInterface.UserInterface.unregisterToolbar?4(name)
 eric5.UI.UserInterface.UserInterface.versionIsNewer?4(required, snapshot = None)
-eric5.UI.UserInterface.UserInterface?1(locale, splash, plugin, noOpenAtStartup, restartArguments)
+eric5.UI.UserInterface.UserInterface?1(app, locale, splash, plugin, noOpenAtStartup, restartArguments)
 eric5.Utilities.AutoSaver.AutoSaver.AUTOSAVE_IN?7
 eric5.Utilities.AutoSaver.AutoSaver.MAXWAIT?7
 eric5.Utilities.AutoSaver.AutoSaver.changeOccurred?4()
@@ -5508,6 +5508,7 @@
 eric5.ViewManager.ViewManager.ViewManager.addSplit?4()
 eric5.ViewManager.ViewManager.ViewManager.addToExtrasMenu?4(menu)
 eric5.ViewManager.ViewManager.ViewManager.addToRecentList?4(fn)
+eric5.ViewManager.ViewManager.ViewManager.appFocusChanged?4(old, now)
 eric5.ViewManager.ViewManager.ViewManager.canCascade?4()
 eric5.ViewManager.ViewManager.ViewManager.canSplit?4()
 eric5.ViewManager.ViewManager.ViewManager.canTile?4()
Binary file Documentation/Help/source.qch has changed
--- a/Documentation/Help/source.qhp	Sun Feb 28 10:36:13 2010 +0000
+++ b/Documentation/Help/source.qhp	Sun Feb 28 13:58:38 2010 +0000
@@ -3293,6 +3293,7 @@
       <keyword name="ViewManager.addSplit" id="ViewManager.addSplit" ref="eric5.ViewManager.ViewManager.html#ViewManager.addSplit" />
       <keyword name="ViewManager.addToExtrasMenu" id="ViewManager.addToExtrasMenu" ref="eric5.ViewManager.ViewManager.html#ViewManager.addToExtrasMenu" />
       <keyword name="ViewManager.addToRecentList" id="ViewManager.addToRecentList" ref="eric5.ViewManager.ViewManager.html#ViewManager.addToRecentList" />
+      <keyword name="ViewManager.appFocusChanged" id="ViewManager.appFocusChanged" ref="eric5.ViewManager.ViewManager.html#ViewManager.appFocusChanged" />
       <keyword name="ViewManager.canCascade" id="ViewManager.canCascade" ref="eric5.ViewManager.ViewManager.html#ViewManager.canCascade" />
       <keyword name="ViewManager.canSplit" id="ViewManager.canSplit" ref="eric5.ViewManager.ViewManager.html#ViewManager.canSplit" />
       <keyword name="ViewManager.canTile" id="ViewManager.canTile" ref="eric5.ViewManager.ViewManager.html#ViewManager.canTile" />
--- a/Documentation/Source/eric5.UI.UserInterface.html	Sun Feb 28 10:36:13 2010 +0000
+++ b/Documentation/Source/eric5.UI.UserInterface.html	Sun Feb 28 13:58:38 2010 +0000
@@ -691,11 +691,14 @@
 </table>
 <a NAME="UserInterface.__init__" ID="UserInterface.__init__"></a>
 <h4>UserInterface (Constructor)</h4>
-<b>UserInterface</b>(<i>locale, splash, plugin, noOpenAtStartup, restartArguments</i>)
+<b>UserInterface</b>(<i>app, locale, splash, plugin, noOpenAtStartup, restartArguments</i>)
 <p>
         Constructor
 </p><dl>
-<dt><i>locale</i></dt>
+<dt><i>app</i></dt>
+<dd>
+reference to the application object (E5Application)
+</dd><dt><i>locale</i></dt>
 <dd>
 locale to be used by the UI (string)
 </dd><dt><i>splash</i></dt>
--- a/Documentation/Source/eric5.ViewManager.ViewManager.html	Sun Feb 28 10:36:13 2010 +0000
+++ b/Documentation/Source/eric5.ViewManager.ViewManager.html	Sun Feb 28 13:58:38 2010 +0000
@@ -533,6 +533,9 @@
 <td><a href="#ViewManager.addToRecentList">addToRecentList</a></td>
 <td>Public slot to add a filename to the list of recently opened files.</td>
 </tr><tr>
+<td><a href="#ViewManager.appFocusChanged">appFocusChanged</a></td>
+<td>Public method to handle the global change of focus.</td>
+</tr><tr>
 <td><a href="#ViewManager.canCascade">canCascade</a></td>
 <td>Public method to signal if cascading of managed windows is available.</td>
 </tr><tr>
@@ -1606,6 +1609,19 @@
 <dd>
 name of the file to be added
 </dd>
+</dl><a NAME="ViewManager.appFocusChanged" ID="ViewManager.appFocusChanged"></a>
+<h4>ViewManager.appFocusChanged</h4>
+<b>appFocusChanged</b>(<i>old, now</i>)
+<p>
+        Public method to handle the global change of focus.
+</p><dl>
+<dt><i>old</i></dt>
+<dd>
+reference to the widget loosing focus (QWidget)
+</dd><dt><i>now</i></dt>
+<dd>
+reference to the widget gaining focus (QWidget)
+</dd>
 </dl><a NAME="ViewManager.canCascade" ID="ViewManager.canCascade"></a>
 <h4>ViewManager.canCascade</h4>
 <b>canCascade</b>(<i></i>)
--- a/QScintilla/Editor.py	Sun Feb 28 10:36:13 2010 +0000
+++ b/QScintilla/Editor.py	Sun Feb 28 13:58:38 2010 +0000
@@ -4765,6 +4765,7 @@
         self.vm.editorActGrp.setEnabled(True)
         self.vm.copyActGrp.setEnabled(True)
         self.vm.viewActGrp.setEnabled(True)
+        self.vm.searchActGrp.setEnabled(True)
         try:
             self.setCaretWidth(self.caretWidth)
         except AttributeError:
--- a/QScintilla/Shell.py	Sun Feb 28 10:36:13 2010 +0000
+++ b/QScintilla/Shell.py	Sun Feb 28 13:58:38 2010 +0000
@@ -1391,6 +1391,7 @@
             self.vm.editorActGrp.setEnabled(True)
             self.vm.copyActGrp.setEnabled(True)
             self.vm.viewActGrp.setEnabled(True)
+            self.vm.searchActGrp.setEnabled(False)
         except AttributeError:
             pass
         self.setCaretWidth(self.caretWidth)
--- a/QScintilla/Terminal.py	Sun Feb 28 10:36:13 2010 +0000
+++ b/QScintilla/Terminal.py	Sun Feb 28 13:58:38 2010 +0000
@@ -889,6 +889,7 @@
             self.vm.editorActGrp.setEnabled(True)
             self.vm.copyActGrp.setEnabled(True)
             self.vm.viewActGrp.setEnabled(True)
+            self.vm.searchActGrp.setEnabled(False)
         except AttributeError:
             pass
         self.setCaretWidth(self.caretWidth)
--- a/UI/UserInterface.py	Sun Feb 28 10:36:13 2010 +0000
+++ b/UI/UserInterface.py	Sun Feb 28 13:58:38 2010 +0000
@@ -169,10 +169,11 @@
     maxSbFilePathLen = 150
     maxMenuFilePathLen = 75
     
-    def __init__(self, locale, splash, plugin, noOpenAtStartup, restartArguments):
+    def __init__(self, app, locale, splash, plugin, noOpenAtStartup, restartArguments):
         """
         Constructor
         
+        @param app reference to the application object (E5Application)
         @param locale locale to be used by the UI (string)
         @param splash reference to the splashscreen (UI.SplashScreen.SplashScreen)
         @param plugin filename of a plugin to be loaded (used for plugin development)
@@ -255,6 +256,8 @@
         
         # now setup the connections
         splash.showMessage(self.trUtf8("Setting up connections..."))
+        self.connect(app, SIGNAL("focusChanged(QWidget*, QWidget*)"), 
+                     self.viewmanager.appFocusChanged)
         self.connect(self.browser, SIGNAL('sourceFile'),
                      self.viewmanager.openSourceFile)
         self.connect(self.browser, SIGNAL('designerFile'),
--- a/ViewManager/ViewManager.py	Sun Feb 28 10:36:13 2010 +0000
+++ b/ViewManager/ViewManager.py	Sun Feb 28 13:58:38 2010 +0000
@@ -29,6 +29,8 @@
 from QScintilla.SpellChecker import SpellChecker
 import QScintilla.Lexers
 import QScintilla.Exporters
+from QScintilla.Shell import Shell
+from QScintilla.Terminal import Terminal
 
 import Utilities
 
@@ -3738,6 +3740,19 @@
         self.ui.findFileNameDialog.raise_()
         self.ui.findFileNameDialog.activateWindow()
     
+    def appFocusChanged(self, old, now):
+        """
+        Public method to handle the global change of focus.
+        
+        @param old reference to the widget loosing focus (QWidget)
+        @param now reference to the widget gaining focus (QWidget)
+        """
+        if not isinstance(now, (Editor, Shell, Terminal)):
+            self.editActGrp.setEnabled(False)
+            self.copyActGrp.setEnabled(False)
+            self.viewActGrp.setEnabled(False)
+            self.searchActGrp.setEnabled(False)
+    
     ##################################################################
     ## Below are the action methods for the edit menu
     ##################################################################
--- a/eric5.py	Sun Feb 28 10:36:13 2010 +0000
+++ b/eric5.py	Sun Feb 28 13:58:38 2010 +0000
@@ -225,7 +225,7 @@
 
     splash.showMessage(QApplication.translate("eric5", "Generating Main Window..."))
     try:
-        mainWindow = UserInterface(loc, splash, pluginFile, noopen, restartArgs)
+        mainWindow = UserInterface(app, loc, splash, pluginFile, noopen, restartArgs)
         app.connect(app, SIGNAL("lastWindowClosed()"), app, SLOT("quit()"))
         mainWindow.show()
         

eric ide

mercurial