src/eric7/UI/UserInterface.py

branch
eric7
changeset 9482
a2bc06a54d9d
parent 9473
3f23dbf37dbe
child 9488
44d723e53988
diff -r 0b936ff1bbb9 -r a2bc06a54d9d src/eric7/UI/UserInterface.py
--- a/src/eric7/UI/UserInterface.py	Sun Nov 06 11:22:39 2022 +0100
+++ b/src/eric7/UI/UserInterface.py	Mon Nov 07 17:19:58 2022 +0100
@@ -18,6 +18,7 @@
 import shutil
 import sys
 
+from PyQt6 import sip
 from PyQt6.Qsci import QSCINTILLA_VERSION_STR
 from PyQt6.QtCore import (
     PYQT_VERSION_STR,
@@ -53,7 +54,10 @@
     QWidget,
 )
 
-from eric7 import Globals, Preferences, Utilities
+from eric7 import Globals, Preferences, Testing, Utilities
+from eric7.CondaInterface.Conda import Conda
+from eric7.Debugger.DebugServer import DebugServer
+from eric7.Debugger.DebugUI import DebugUI
 from eric7.EricGui import EricPixmapCache
 from eric7.EricGui.EricAction import EricAction, createActionGroup
 from eric7.EricNetwork.EricNetworkIcon import EricNetworkIcon
@@ -68,9 +72,21 @@
 from eric7.EricWidgets.EricSingleApplication import EricSingleApplicationServer
 from eric7.EricWidgets.EricToolBarManager import EricToolBarManager
 from eric7.EricWidgets.EricZoomWidget import EricZoomWidget
+from eric7.EricXML.SessionReader import SessionReader
+from eric7.EricXML.TasksReader import TasksReader
 from eric7.Globals import getConfig
+from eric7.MultiProject.MultiProject import MultiProject
+from eric7.PipInterface.Pip import Pip
+from eric7.PluginManager.PluginManager import PluginManager
+from eric7.PluginManager.PluginRepositoryDialog import PluginRepositoryDownloadCleanup
+from eric7.Preferences import Shortcuts
+from eric7.Project.Project import Project
+from eric7.QScintilla.SpellChecker import SpellChecker
 from eric7.Sessions.SessionFile import SessionFile
 from eric7.Tasks.TasksFile import TasksFile
+from eric7.Testing.TestingWidget import clearSavedHistories
+from eric7.Utilities.BackgroundService import BackgroundService
+from eric7.VirtualEnv.VirtualenvManager import VirtualenvManager
 
 from . import Config
 from .Info import BugAddress, FeatureAddress, Program, Version, VersionOnly
@@ -281,56 +297,40 @@
 
         # Generate the conda interface
         logging.debug("Creating Conda Interface...")
-        from eric7.CondaInterface.Conda import Conda
-
         self.condaInterface = Conda(self)
         ericApp().registerObject("Conda", self.condaInterface)
 
         # Generate the pip interface
         logging.debug("Creating Pip Interface...")
-        from eric7.PipInterface.Pip import Pip
-
         self.pipInterface = Pip(self)
         ericApp().registerObject("Pip", self.pipInterface)
 
         # Generate the virtual environment manager
         logging.debug("Creating Virtual Environments Manager...")
-        from eric7.VirtualEnv.VirtualenvManager import VirtualenvManager
-
         self.virtualenvManager = VirtualenvManager(self)
         # register it early because it is needed very soon
         ericApp().registerObject("VirtualEnvManager", self.virtualenvManager)
 
         # Generate an empty project object and multi project object
         logging.debug("Creating Project Manager...")
-        from eric7.Project.Project import Project
-
         self.project = Project(self)
         ericApp().registerObject("Project", self.project)
 
-        from eric7.MultiProject.MultiProject import MultiProject
-
         logging.debug("Creating Multi-Project Manager...")
         self.multiProject = MultiProject(self.project, self)
 
         # Generate the debug server object
         logging.debug("Creating Debug Server...")
-        from eric7.Debugger.DebugServer import DebugServer
-
         self.__debugServer = DebugServer(
             self.__originalPathString, project=self.project, parent=self
         )
 
         # Create the background service object
-        from eric7.Utilities.BackgroundService import BackgroundService
-
         self.backgroundService = BackgroundService(self)
 
         splash.showMessage(self.tr("Initializing Plugin Manager..."))
 
         # Initialize the Plugin Manager (Plugins are initialized later
-        from eric7.PluginManager.PluginManager import PluginManager
-
         self.pluginManager = PluginManager(
             self, self.__disabledPlugins, develPlugin=plugin
         )
@@ -342,14 +342,14 @@
         self.__webBrowserSAName = QUuid.createUuid().toString()[1:-1]
 
         # set spellchecker defaults
-        from eric7.QScintilla.SpellChecker import SpellChecker
-
         SpellChecker.setDefaultLanguage(
             Preferences.getEditor("SpellCheckingDefaultLanguage")
         )
 
         with contextlib.suppress(ImportError, AttributeError):
-            from eric7.EricWidgets.EricSpellCheckedTextEdit import SpellCheckMixin
+            from eric7.EricWidgets.EricSpellCheckedTextEdit import (  # __IGNORE_WARNING__
+                SpellCheckMixin,
+            )
 
             pwl = SpellChecker.getUserDictionaryPath(isException=False)
             pel = SpellChecker.getUserDictionaryPath(isException=True)
@@ -368,8 +368,6 @@
 
         # Generate the debugger part of the ui
         logging.debug("Creating Debugger UI...")
-        from eric7.Debugger.DebugUI import DebugUI
-
         self.debuggerUI = DebugUI(
             self, self.viewmanager, self.__debugServer, self.debugViewer, self.project
         )
@@ -746,15 +744,9 @@
         self.pluginManager.initPluginToolbars(self.toolbarManager)
         if Preferences.getPluginManager("StartupCleanup"):
             splash.showMessage(self.tr("Cleaning Plugins Download Area..."))
-            from eric7.PluginManager.PluginRepositoryDialog import (
-                PluginRepositoryDownloadCleanup,
-            )
-
             PluginRepositoryDownloadCleanup(quiet=True)
 
         # now read the keyboard shortcuts for all the actions
-        from eric7.Preferences import Shortcuts
-
         Shortcuts.readShortcuts()
 
         # restore toolbar manager state
@@ -835,66 +827,62 @@
         """
         Private method to create the various application objects.
         """
+        from eric7 import ViewManager
+        from eric7.Debugger.DebugViewer import DebugViewer
+        from eric7.JediInterface.AssistantJedi import AssistantJedi
+        from eric7.MultiProject.MultiProjectBrowser import MultiProjectBrowser
+        from eric7.PluginManager.PluginRepositoryDialog import PluginRepositoryWidget
+        from eric7.Project.ProjectBrowser import ProjectBrowser
+        from eric7.QScintilla.Shell import ShellAssembly
+        from eric7.Tasks.TaskViewer import TaskViewer
+        from eric7.VCS.StatusWidget import StatusWidget
+        from eric7.VirtualEnv.VirtualenvManagerWidgets import VirtualenvManagerWidget
+
+        from .LogView import LogViewer
+        from .Previewer import Previewer
+        from .PythonAstViewer import PythonAstViewer
+        from .PythonDisViewer import PythonDisViewer
+
         # Create the view manager depending on the configuration setting
         logging.debug("Creating Viewmanager...")
-        from eric7 import ViewManager
-
         self.viewmanager = ViewManager.factory(
             self, self, self.__debugServer, self.pluginManager
         )
 
         # Create previewer
         logging.debug("Creating Previewer...")
-        from .Previewer import Previewer
-
         self.__previewer = Previewer(self.viewmanager)
 
         # Create AST viewer
         logging.debug("Creating Python AST Viewer")
-        from .PythonAstViewer import PythonAstViewer
-
         self.__astViewer = PythonAstViewer(self.viewmanager)
 
         # Create DIS viewer
         logging.debug("Creating Python Disassembly Viewer")
-        from .PythonDisViewer import PythonDisViewer
-
         self.__disViewer = PythonDisViewer(self.viewmanager)
 
         # Create the project browser
         logging.debug("Creating Project Browser...")
-        from eric7.Project.ProjectBrowser import ProjectBrowser
-
         self.projectBrowser = ProjectBrowser(self.project)
 
         # Create the multi project browser
         logging.debug("Creating Multiproject Browser...")
-        from eric7.MultiProject.MultiProjectBrowser import MultiProjectBrowser
-
         self.multiProjectBrowser = MultiProjectBrowser(self.multiProject, self.project)
 
         # Create the task viewer part of the user interface
         logging.debug("Creating Task Viewer...")
-        from eric7.Tasks.TaskViewer import TaskViewer
-
         self.taskViewer = TaskViewer(None, self.project)
 
         # Create the log viewer part of the user interface
         logging.debug("Creating Log Viewer...")
-        from .LogView import LogViewer
-
         self.logViewer = LogViewer(self)
 
         # Create the debug viewer
         logging.debug("Creating Debug Viewer...")
-        from eric7.Debugger.DebugViewer import DebugViewer
-
         self.debugViewer = DebugViewer(self.__debugServer)
 
         # Create the shell
         logging.debug("Creating Shell...")
-        from eric7.QScintilla.Shell import ShellAssembly
-
         self.shellAssembly = ShellAssembly(
             self.__debugServer, self.viewmanager, self.project, True
         )
@@ -903,7 +891,9 @@
         if Preferences.getUI("ShowTemplateViewer"):
             # Create the template viewer part of the user interface
             logging.debug("Creating Template Viewer...")
-            from eric7.Templates.TemplateViewer import TemplateViewer
+            from eric7.Templates.TemplateViewer import (  # __IGNORE_WARNING_I101__
+                TemplateViewer,
+            )
 
             self.templateViewer = TemplateViewer(None, self.viewmanager)
         else:
@@ -913,7 +903,7 @@
         if Preferences.getUI("ShowFileBrowser"):
             # Create the file browser
             logging.debug("Creating File Browser...")
-            from .Browser import Browser
+            from .Browser import Browser  # __IGNORE_WARNING_I101__
 
             self.browser = Browser()
         else:
@@ -923,7 +913,7 @@
         if Preferences.getUI("ShowSymbolsViewer"):
             # Create the symbols viewer
             logging.debug("Creating Symbols Viewer...")
-            from .SymbolsWidget import SymbolsWidget
+            from .SymbolsWidget import SymbolsWidget  # __IGNORE_WARNING_I101__
 
             self.symbolsViewer = SymbolsWidget()
         else:
@@ -933,7 +923,9 @@
         if Preferences.getUI("ShowCodeDocumentationViewer"):
             # Create the code documentation viewer
             logging.debug("Creating Code Documentation Viewer...")
-            from .CodeDocumentationViewer import CodeDocumentationViewer
+            from .CodeDocumentationViewer import (  # __IGNORE_WARNING_I101__
+                CodeDocumentationViewer,
+            )
 
             self.codeDocumentationViewer = CodeDocumentationViewer(self)
         else:
@@ -943,7 +935,9 @@
         if Preferences.getUI("ShowPyPIPackageManager"):
             # Create the PyPI package manager
             logging.debug("Creating PyPI Package Manager...")
-            from eric7.PipInterface.PipPackagesWidget import PipPackagesWidget
+            from eric7.PipInterface.PipPackagesWidget import (  # __IGNORE_WARNING__
+                PipPackagesWidget,
+            )
 
             self.pipWidget = PipPackagesWidget(self.pipInterface)
         else:
@@ -953,7 +947,9 @@
         if Preferences.getUI("ShowCondaPackageManager"):
             # Create the conda package manager
             logging.debug("Creating Conda Package Manager...")
-            from eric7.CondaInterface.CondaPackagesWidget import CondaPackagesWidget
+            from eric7.CondaInterface.CondaPackagesWidget import (  # __IGNORE_WARNING__
+                CondaPackagesWidget,
+            )
 
             self.condaWidget = CondaPackagesWidget(self.condaInterface)
         else:
@@ -963,7 +959,9 @@
         if Preferences.getUI("ShowCooperation"):
             # Create the chat part of the user interface
             logging.debug("Creating Chat Widget...")
-            from eric7.Cooperation.ChatWidget import ChatWidget
+            from eric7.Cooperation.ChatWidget import (  # __IGNORE_WARNING_I101__
+                ChatWidget,
+            )
 
             self.cooperation = ChatWidget(self)
         else:
@@ -973,7 +971,7 @@
         if Preferences.getUI("ShowIrc"):
             # Create the IRC part of the user interface
             logging.debug("Creating IRC Widget...")
-            from eric7.Network.IRC.IrcWidget import IrcWidget
+            from eric7.Network.IRC.IrcWidget import IrcWidget  # __IGNORE_WARNING_I101__
 
             self.irc = IrcWidget(self)
         else:
@@ -983,7 +981,9 @@
         if Preferences.getUI("ShowMicroPython"):
             # Create the MicroPython part of the user interface
             logging.debug("Creating MicroPython Widget...")
-            from eric7.MicroPython.MicroPythonWidget import MicroPythonWidget
+            from eric7.MicroPython.MicroPythonWidget import (  # __IGNORE_WARNING_I101__
+                MicroPythonWidget,
+            )
 
             self.microPythonWidget = MicroPythonWidget(self)
         else:
@@ -993,7 +993,7 @@
         if Preferences.getUI("ShowNumbersViewer"):
             # Create the numbers viewer
             logging.debug("Creating Numbers Viewer...")
-            from .NumbersWidget import NumbersWidget
+            from .NumbersWidget import NumbersWidget  # __IGNORE_WARNING_I101__
 
             self.numbersViewer = NumbersWidget()
         else:
@@ -1002,13 +1002,9 @@
 
         # Create the Jedi Assistant
         logging.debug("Creating Jedi Assistant...")
-        from eric7.JediInterface.AssistantJedi import AssistantJedi
-
         self.jediAssistant = AssistantJedi(self, self.viewmanager, self.project)
 
         # Create the plug-ins repository viewer
-        from eric7.PluginManager.PluginRepositoryDialog import PluginRepositoryWidget
-
         self.pluginRepositoryViewer = PluginRepositoryWidget(
             self.pluginManager, integrated=True, parent=self
         )
@@ -1017,8 +1013,6 @@
         )
 
         # Create the virtual environments management widget
-        from eric7.VirtualEnv.VirtualenvManagerWidgets import VirtualenvManagerWidget
-
         self.__virtualenvManagerWidget = VirtualenvManagerWidget(
             self.virtualenvManager, self
         )
@@ -1027,7 +1021,7 @@
         self.__replaceFileDialog = None
         if Preferences.getUI("ShowFindFileWidget"):
             # Create the find in files widget
-            from .FindFileWidget import FindFileWidget
+            from .FindFileWidget import FindFileWidget  # __IGNORE_WARNING_I101__
 
             self.__findFileWidget = FindFileWidget(self.project, self)
             self.__findFileWidget.sourceFile.connect(self.viewmanager.openSourceFile)
@@ -1043,7 +1037,9 @@
         self.__findLocationDialog = None
         if Preferences.getUI("ShowFindLocationWidget"):
             # Create the find location (file) widget
-            from .FindLocationWidget import FindLocationWidget
+            from .FindLocationWidget import (  # __IGNORE_WARNING_I101__
+                FindLocationWidget,
+            )
 
             self.__findLocationWidget = FindLocationWidget(self.project, self)
             self.__findLocationWidget.sourceFile.connect(
@@ -1059,8 +1055,6 @@
             self.__findLocationWidget = None
 
         # Create the VCS Status widget
-        from eric7.VCS.StatusWidget import StatusWidget
-
         self.__vcsStatusWidget = StatusWidget(self.project, self.viewmanager, self)
 
         if (
@@ -1069,7 +1063,9 @@
         ):
             # Create the embedded help viewer
             logging.debug("Creating Internal Help Viewer...")
-            from eric7.HelpViewer.HelpViewerWidget import HelpViewerWidget
+            from eric7.HelpViewer.HelpViewerWidget import (  # __IGNORE_WARNING_I101__
+                HelpViewerWidget,
+            )
 
             self.__helpViewerWidget = HelpViewerWidget(self)
         else:
@@ -4359,6 +4355,8 @@
         """
         Private slot to set up the status bar.
         """
+        from eric7.VCS.StatusMonitorLed import StatusMonitorLedWidget
+
         self.__statusBar = self.statusBar()
         self.__statusBar.setSizeGripEnabled(True)
 
@@ -4440,8 +4438,6 @@
             self.sbZoom,
         )
 
-        from eric7.VCS.StatusMonitorLed import StatusMonitorLedWidget
-
         self.sbVcsMonitorLed = StatusMonitorLedWidget(self.project, self.__statusBar)
         self.__statusBar.addPermanentWidget(self.sbVcsMonitorLed)
 
@@ -4599,12 +4595,8 @@
         from .VersionsDialog import VersionsDialog
 
         try:
-            try:
-                from PyQt6 import sip
-            except ImportError:
-                import sip
             sip_version_str = sip.SIP_VERSION_STR
-        except (ImportError, AttributeError):
+        except AttributeError:
             sip_version_str = "sip version not available"
 
         sizeStr = "64-Bit" if sys.maxsize > 2**32 else "32-Bit"
@@ -4626,13 +4618,13 @@
             PYQT_VERSION_STR
         )
         with contextlib.suppress(ImportError, AttributeError):
-            from PyQt6 import QtCharts
+            from PyQt6 import QtCharts  # __IGNORE_WARNING_I10__
 
             versionText += (
                 """<tr><td><b>PyQt6-Charts</b></td><td>{0}</td></tr>"""
             ).format(QtCharts.PYQT_CHART_VERSION_STR)
         with contextlib.suppress(ImportError, AttributeError):
-            from PyQt6 import QtWebEngineCore
+            from PyQt6 import QtWebEngineCore  # __IGNORE_WARNING_I10__
 
             versionText += (
                 """<tr><td><b>PyQt6-WebEngine</b></td><td>{0}</td></tr>"""
@@ -4646,7 +4638,9 @@
 
         # webengine (chromium) version
         with contextlib.suppress(ImportError):
-            from eric7.WebBrowser.Tools import WebBrowserTools
+            from eric7.WebBrowser.Tools import (  # __IGNORE_WARNING_I101__
+                WebBrowserTools,
+            )
 
             (
                 chromiumVersion,
@@ -4724,7 +4718,7 @@
                 self.showPreferences("emailPage")
                 return
 
-            from .EmailDialog import EmailDialog
+            from .EmailDialog import EmailDialog  # __IGNORE_WARNING_I101__
 
             self.dlg = EmailDialog(mode=mode)
             if attachFile is not None:
@@ -4767,11 +4761,11 @@
         Public method to check for the presence of an error log and ask the
         user, what to do with it.
         """
+        from .ErrorLogDialog import ErrorLogDialog
+
         if Preferences.getUI("CheckErrorLog"):
             logFile = os.path.join(Utilities.getConfigDir(), self.ErrorLogFileName)
             if os.path.exists(logFile):
-                from .ErrorLogDialog import ErrorLogDialog
-
                 dlg = ErrorLogDialog(logFile, False, self)
                 dlg.exec()
 
@@ -4788,10 +4782,10 @@
         """
         Private slot to show the most recent error log message.
         """
+        from .ErrorLogDialog import ErrorLogDialog
+
         logFile = os.path.join(Utilities.getConfigDir(), self.ErrorLogFileName)
         if os.path.exists(logFile):
-            from .ErrorLogDialog import ErrorLogDialog
-
             dlg = ErrorLogDialog(logFile, True, self)
             dlg.show()
 
@@ -4810,11 +4804,11 @@
         """
         Private slot to handle the Compare Files dialog.
         """
+        from .DiffDialog import DiffDialog
+
         aw = self.viewmanager.activeWindow()
         fn = aw and aw.getFileName() or None
         if self.diffDlg is None:
-            from .DiffDialog import DiffDialog
-
             self.diffDlg = DiffDialog()
         self.diffDlg.show(fn)
 
@@ -4822,11 +4816,11 @@
         """
         Private slot to handle the Compare Files dialog.
         """
+        from .CompareDialog import CompareDialog
+
         aw = self.viewmanager.activeWindow()
         fn = aw and aw.getFileName() or None
         if self.compareDlg is None:
-            from .CompareDialog import CompareDialog
-
             self.compareDlg = CompareDialog()
         self.compareDlg.show(fn)
 
@@ -5961,9 +5955,9 @@
         """
         Private slot to generate the testing dialog on demand.
         """
+        from eric7.Testing.TestingWidget import TestingWidget
+
         if self.__testingWidget is None:
-            from eric7.Testing.TestingWidget import TestingWidget
-
             self.__testingWidget = TestingWidget()
             self.__testingWidget.testFile.connect(self.viewmanager.setFileLine)
             self.__testingWidget.testRunStopped.connect(self.__testingStopped)
@@ -7158,10 +7152,10 @@
 
         @param pageName name of the configuration page to show (string)
         """
+        from eric7.Preferences.ConfigurationDialog import ConfigurationDialog
+
         if self.__configurationDialog is None:
             # only one invocation at a time is allowed
-            from eric7.Preferences.ConfigurationDialog import ConfigurationDialog
-
             self.__configurationDialog = ConfigurationDialog(
                 self,
                 "Configuration",
@@ -7237,6 +7231,8 @@
         """
         Private slot to handle a change of the preferences.
         """
+        from eric7.HexEdit.HexEditMainWindow import HexEditMainWindow
+
         self.setStyle(Preferences.getUI("Style"), Preferences.getUI("StyleSheet"))
 
         if Preferences.getUI("SingleApplicationMode"):
@@ -7273,14 +7269,14 @@
 
         self.performVersionCheck()
 
-        from eric7.QScintilla.SpellChecker import SpellChecker
-
         SpellChecker.setDefaultLanguage(
             Preferences.getEditor("SpellCheckingDefaultLanguage")
         )
 
         with contextlib.suppress(ImportError, AttributeError):
-            from eric7.EricWidgets.EricSpellCheckedTextEdit import SpellCheckMixin
+            from eric7.EricWidgets.EricSpellCheckedTextEdit import (  # __IGNORE_WARNING__
+                SpellCheckMixin,
+            )
 
             pwl = SpellChecker.getUserDictionaryPath(isException=False)
             pel = SpellChecker.getUserDictionaryPath(isException=True)
@@ -7295,8 +7291,6 @@
             QNetworkProxyFactory.setApplicationProxyFactory(self.__proxyFactory)
             QNetworkProxyFactory.setUseSystemConfiguration(False)
 
-        from eric7.HexEdit.HexEditMainWindow import HexEditMainWindow
-
         for hexEditor in HexEditMainWindow.windows:
             hexEditor.preferencesChanged()
 
@@ -7328,7 +7322,9 @@
         Preferences.convertPasswords(oldPassword, newPassword)
         variant = Globals.getWebBrowserSupport()
         if variant == "QtWebEngine":
-            from eric7.WebBrowser.Passwords.PasswordManager import PasswordManager
+            from eric7.WebBrowser.Passwords.PasswordManager import (  # __IGNORE_WARNING__
+                PasswordManager,
+            )
 
             pwManager = PasswordManager()
             pwManager.masterPasswordChanged(oldPassword, newPassword)
@@ -7345,9 +7341,9 @@
         Private slot to display a dialog show a list of external tools used
         by eric.
         """
+        from eric7.Preferences.ProgramsDialog import ProgramsDialog
+
         if self.programsDialog is None:
-            from eric7.Preferences.ProgramsDialog import ProgramsDialog
-
             self.programsDialog = ProgramsDialog(self)
         self.programsDialog.show()
 
@@ -7384,9 +7380,9 @@
         """
         Private slot to configure the keyboard shortcuts.
         """
+        from eric7.Preferences.ShortcutsDialog import ShortcutsDialog
+
         if self.shortcutsDialog is None:
-            from eric7.Preferences.ShortcutsDialog import ShortcutsDialog
-
             self.shortcutsDialog = ShortcutsDialog(self)
         self.shortcutsDialog.populate()
         self.shortcutsDialog.show()
@@ -7427,8 +7423,6 @@
         )
 
         if ok:
-            from eric7.Preferences import Shortcuts
-
             Shortcuts.exportShortcuts(str(fpath))
 
     def __importShortcuts(self):
@@ -7445,8 +7439,6 @@
         )
 
         if fn:
-            from eric7.Preferences import Shortcuts
-
             Shortcuts.importShortcuts(fn)
 
     def __showCertificatesDialog(self):
@@ -7498,8 +7490,6 @@
             if testing:
                 # clear the unit test histories
                 if self.__testingWidget is None:
-                    from eric7.Testing.TestingWidget import clearSavedHistories
-
                     clearSavedHistories()
                 else:
                     self.__testingWidget.clearRecent()
@@ -7574,14 +7564,15 @@
         """
         self.wizardsMenuAct.setEnabled(len(self.__menus["wizards"].actions()) > 0)
 
-        if fn and str(fn) != "None":
-            from eric7 import Testing
-
-            if Testing.isLanguageSupported(
+        if (
+            fn
+            and str(fn) != "None"
+            and Testing.isLanguageSupported(
                 self.viewmanager.getOpenEditor(fn).getFileType()
-            ):
-                self.testScriptAct.setEnabled(True)
-                self.__testingEditorOpen = True
+            )
+        ):
+            self.testScriptAct.setEnabled(True)
+            self.__testingEditorOpen = True
 
     def __checkActions(self, editor):
         """
@@ -7591,13 +7582,10 @@
         """
         fn = editor.getFileName() if editor else None
 
-        if fn:
-            from eric7 import Testing
-
-            if Testing.isLanguageSupported(editor.getFileType()):
-                self.testScriptAct.setEnabled(True)
-                self.__testingEditorOpen = True
-                return
+        if fn and Testing.isLanguageSupported(editor.getFileType()):
+            self.testScriptAct.setEnabled(True)
+            self.__testingEditorOpen = True
+            return
 
         self.testScriptAct.setEnabled(False)
 
@@ -7622,8 +7610,6 @@
             if os.path.exists(fn):
                 f = QFile(fn)
                 if f.open(QIODevice.OpenModeFlag.ReadOnly):
-                    from eric7.EricXML.TasksReader import TasksReader
-
                     reader = TasksReader(f, viewer=self.taskViewer)
                     reader.readXML()
                     f.close()
@@ -7692,8 +7678,6 @@
                 # old XML based format
                 f = QFile(fn)
                 if f.open(QIODevice.OpenModeFlag.ReadOnly):
-                    from eric7.EricXML.SessionReader import SessionReader
-
                     self.__readingSession = True
                     reader = SessionReader(f, True)
                     reader.readXML()
@@ -7806,9 +7790,9 @@
         """
         Public slot to show the Find File by Name dialog.
         """
+        from .FindFileNameDialog import FindFileNameDialog
+
         if self.findFileNameDialog is None:
-            from .FindFileNameDialog import FindFileNameDialog
-
             self.findFileNameDialog = FindFileNameDialog(self.project)
             self.findFileNameDialog.sourceFile.connect(self.viewmanager.openSourceFile)
             self.findFileNameDialog.designerFile.connect(self.__designer)
@@ -7828,6 +7812,8 @@
             (defaults to False)
         @type bool (optional)
         """
+        from .FindFileWidget import FindFileDialog
+
         if Preferences.getUI("ShowFindFileWidget"):
             # embedded tool
             self.__activateFindFileWidget()
@@ -7837,8 +7823,6 @@
         else:
             # external dialog
             if self.__findFileDialog is None:
-                from .FindFileWidget import FindFileDialog
-
                 self.__findFileDialog = FindFileDialog(self.project, self)
                 self.__findFileDialog.sourceFile.connect(
                     self.viewmanager.openSourceFile
@@ -7865,6 +7849,8 @@
             (defaults to False)
         @type bool (optional)
         """
+        from .FindFileWidget import FindFileDialog
+
         if Preferences.getUI("ShowFindFileWidget"):
             # embedded tool
             self.__activateFindFileWidget()
@@ -7874,8 +7860,6 @@
         else:
             # external dialog
             if self.__replaceFileDialog is None:
-                from .FindFileWidget import FindFileDialog
-
                 self.__replaceFileDialog = FindFileDialog(self.project, self)
                 self.__replaceFileDialog.sourceFile.connect(
                     self.viewmanager.openSourceFile
@@ -7908,14 +7892,14 @@
         """
         Public method to show the Find File widget.
         """
+        from .FindLocationWidget import FindLocationDialog
+
         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
@@ -8528,9 +8512,9 @@
             (None = use configured timeout, 0 = indefinitely)
         @type int
         """
+        from .NotificationWidget import NotificationWidget
+
         if self.__notification is None:
-            from .NotificationWidget import NotificationWidget
-
             self.__notification = NotificationWidget(parent=self)
         if timeout is None:
             timeout = Preferences.getUI("NotificationTimeout")

eric ide

mercurial