src/eric7/Project/Project.py

branch
eric7-maintenance
changeset 11019
27cd57e98461
parent 10892
409d010d7cae
parent 11006
a671918232f3
child 11063
bb05d1db9286
--- a/src/eric7/Project/Project.py	Thu Oct 03 17:06:51 2024 +0200
+++ b/src/eric7/Project/Project.py	Thu Oct 31 10:54:33 2024 +0100
@@ -1382,7 +1382,7 @@
             fn1, _ext = os.path.splitext(os.path.basename(self.pfile))
             fn = os.path.join(self.getProjectManagementDir(), f"{fn1}{indicator}.esj")
 
-        self.__sessionFile.writeFile(fn)
+        self.__sessionFile.writeFile(fn, withServer=False)
 
     def __deleteSession(self):
         """
@@ -1646,7 +1646,9 @@
         from .DebuggerPropertiesDialog import DebuggerPropertiesDialog
 
         dlg = DebuggerPropertiesDialog(
-            self, isRemote=FileSystemUtilities.isRemoteFileName(self.ppath)
+            self,
+            isRemote=FileSystemUtilities.isRemoteFileName(self.ppath),
+            parent=self.ui,
         )
         if dlg.exec() == QDialog.DialogCode.Accepted:
             dlg.storeData()
@@ -1776,7 +1778,7 @@
             )
             return
 
-        dlg = AddLanguageDialog(self.parent())
+        dlg = AddLanguageDialog(parent=self.parent())
         if dlg.exec() == QDialog.DialogCode.Accepted:
             lang = dlg.getSelectedLanguage()
             if self.__pdata["PROJECTTYPE"] in [
@@ -2039,7 +2041,9 @@
         if not startdir:
             startdir = self.ppath
 
-        dlg = AddFileDialog(self, self.parent(), fileTypeFilter, startdir=startdir)
+        dlg = AddFileDialog(
+            self, parent=self.parent(), fileTypeFilter=fileTypeFilter, startdir=startdir
+        )
         if dlg.exec() == QDialog.DialogCode.Accepted:
             fnames, target, isSource = dlg.getData()
             if target != "":
@@ -2279,7 +2283,9 @@
         if not startdir:
             startdir = self.ppath
 
-        dlg = AddDirectoryDialog(self, fileTypeFilter, self.parent(), startdir=startdir)
+        dlg = AddDirectoryDialog(
+            self, fileTypeFilter, parent=self.parent(), startdir=startdir
+        )
         if dlg.exec() == QDialog.DialogCode.Accepted:
             filetype, source, target, recursive = dlg.getData()
             if target == "":
@@ -2753,7 +2759,7 @@
 
         isRemote = self.__remoteServer.isServerConnected()
 
-        dlg = PropertiesDialog(self, new=True, isRemote=isRemote)
+        dlg = PropertiesDialog(self, new=True, isRemote=isRemote, parent=self.ui)
         if dlg.exec() == QDialog.DialogCode.Accepted:
             self.closeProject()
 
@@ -3093,7 +3099,9 @@
                                 else:
                                     vcores = False
                                 if vcores:
-                                    codlg = VcsCommandOptionsDialog(self.vcs)
+                                    codlg = VcsCommandOptionsDialog(
+                                        self.vcs, parent=self.ui
+                                    )
                                     if codlg.exec() == QDialog.DialogCode.Accepted:
                                         self.vcs.vcsSetOptions(codlg.getOptions())
                                 # add project file to repository
@@ -3149,7 +3157,7 @@
                     self.__pdata["VCS"] = "None"
                 self.vcs = self.initVCS()
                 if self.vcs is not None:
-                    vcsdlg = self.vcs.vcsOptionsDialog(self, self.name)
+                    vcsdlg = self.vcs.vcsOptionsDialog(self, self.name, parent=self.ui)
                     if vcsdlg.exec() == QDialog.DialogCode.Accepted:
                         vcsDataDict = vcsdlg.getData()
                     else:
@@ -3170,7 +3178,7 @@
                     else:
                         vcores = False
                     if vcores:
-                        codlg = VcsCommandOptionsDialog(self.vcs)
+                        codlg = VcsCommandOptionsDialog(self.vcs, parent=self.ui)
                         if codlg.exec() == QDialog.DialogCode.Accepted:
                             self.vcs.vcsSetOptions(codlg.getOptions())
 
@@ -3400,7 +3408,7 @@
         from .PropertiesDialog import PropertiesDialog
 
         isRemote = FileSystemUtilities.isRemoteFileName(self.ppath)
-        dlg = PropertiesDialog(self, new=False, isRemote=isRemote)
+        dlg = PropertiesDialog(self, new=False, isRemote=isRemote, parent=self.ui)
         if dlg.exec() == QDialog.DialogCode.Accepted:
             fileTypesDict = copy.copy(self.__pdata["FILETYPES"])
             dlg.storeData()
@@ -3519,7 +3527,7 @@
         vcsSystem = self.__pdata["VCS"] or None
         vcsSystemOverride = self.pudata["VCSOVERRIDE"] or None
 
-        dlg = UserPropertiesDialog(self)
+        dlg = UserPropertiesDialog(self, parent=self.ui)
         if dlg.exec() == QDialog.DialogCode.Accepted:
             dlg.storeData()
 
@@ -3557,7 +3565,9 @@
         """
         from .FiletypeAssociationDialog import FiletypeAssociationDialog
 
-        dlg = FiletypeAssociationDialog(self, self.getProjectData(dataKey="FILETYPES"))
+        dlg = FiletypeAssociationDialog(
+            self, self.getProjectData(dataKey="FILETYPES"), parent=self.ui
+        )
         if dlg.exec() == QDialog.DialogCode.Accepted:
             fileTypes = dlg.getData()
             self.setProjectData(fileTypes, dataKey="FILETYPES")
@@ -3587,7 +3597,7 @@
         """
         from .LexerAssociationDialog import LexerAssociationDialog
 
-        dlg = LexerAssociationDialog(self)
+        dlg = LexerAssociationDialog(self, parent=self.ui)
         if dlg.exec() == QDialog.DialogCode.Accepted:
             dlg.transferData()
             self.setDirty(True)
@@ -3821,10 +3831,7 @@
                 if restoreSession:
                     # open the main script
                     if self.__pdata["MAINSCRIPT"]:
-                        if not os.path.isabs(self.__pdata["MAINSCRIPT"]):
-                            ms = os.path.join(self.ppath, self.__pdata["MAINSCRIPT"])
-                        else:
-                            ms = self.__pdata["MAINSCRIPT"]
+                        ms = self.getAbsolutePath(self.__pdata["MAINSCRIPT"])
                         self.sourceFile.emit(ms)
 
                     # open a project session file being quiet about errors
@@ -7040,6 +7047,7 @@
                 title=self.tr("Create Plugin Archive"),
                 message=self.tr("Select package lists:"),
                 checkBoxSelection=True,
+                parent=self.ui,
             )
             if dlg.exec() == QDialog.DialogCode.Accepted:
                 selectedLists = [
@@ -7630,7 +7638,7 @@
         """
         from eric7 import CycloneDXInterface
 
-        CycloneDXInterface.createCycloneDXFile("<project>")
+        CycloneDXInterface.createCycloneDXFile("<project>", parent=self.ui)
 
     #########################################################################
     ## Below are methods implementing the 'Code Formatting' support
@@ -7664,7 +7672,7 @@
         from eric7.CodeFormatting.BlackFormattingDialog import BlackFormattingDialog
 
         if ericApp().getObject("ViewManager").checkAllDirty():
-            dlg = BlackConfigurationDialog(withProject=True)
+            dlg = BlackConfigurationDialog(withProject=True, parent=self.ui)
             if dlg.exec() == QDialog.DialogCode.Accepted:
                 config = dlg.getConfiguration(saveToProject=True)
 
@@ -7673,6 +7681,7 @@
                     self.getProjectFiles("SOURCES", normalized=True),
                     project=self,
                     action=action,
+                    parent=self.ui,
                 )
                 formattingDialog.exec()
 
@@ -7686,7 +7695,9 @@
             BlackConfigurationDialog,
         )
 
-        dlg = BlackConfigurationDialog(withProject=True, onlyProject=True)
+        dlg = BlackConfigurationDialog(
+            withProject=True, onlyProject=True, parent=self.ui
+        )
         if dlg.exec() == QDialog.DialogCode.Accepted:
             dlg.getConfiguration(saveToProject=True)
             # The data is saved to the project as a side effect.
@@ -7714,7 +7725,7 @@
         from eric7.CodeFormatting.IsortFormattingDialog import IsortFormattingDialog
 
         if ericApp().getObject("ViewManager").checkAllDirty():
-            dlg = IsortConfigurationDialog(withProject=True)
+            dlg = IsortConfigurationDialog(withProject=True, parent=self.ui)
             if dlg.exec() == QDialog.DialogCode.Accepted:
                 config = dlg.getConfiguration(saveToProject=True)
 
@@ -7723,6 +7734,7 @@
                     self.getProjectFiles("SOURCES", normalized=True),
                     project=self,
                     action=action,
+                    parent=self.ui,
                 )
                 isortDialog.exec()
 
@@ -7736,7 +7748,9 @@
             IsortConfigurationDialog,
         )
 
-        dlg = IsortConfigurationDialog(withProject=True, onlyProject=True)
+        dlg = IsortConfigurationDialog(
+            withProject=True, onlyProject=True, parent=self.ui
+        )
         if dlg.exec() == QDialog.DialogCode.Accepted:
             dlg.getConfiguration(saveToProject=True)
             # The data is saved to the project as a side effect.
@@ -7825,7 +7839,8 @@
         environmentPath = self.__findEmbeddedEnvironment()
         if force or upgrade or not environmentPath:
             dlg = ProjectVenvCreationParametersDialog(
-                withSystemSitePackages=self.__venvConfiguration["system_site_packages"]
+                withSystemSitePackages=self.__venvConfiguration["system_site_packages"],
+                parent=self.ui,
             )
             if dlg.exec() != QDialog.DialogCode.Accepted:
                 # user canceled the environment creation
@@ -7852,7 +7867,7 @@
             if withSystemSitePackages:
                 args.append("--system-site-packages")
             args.append(configuration["targetDirectory"])
-            dia = VirtualenvExecDialog(configuration, None)
+            dia = VirtualenvExecDialog(configuration, None, parent=self.ui)
             dia.show()
             dia.start(args)
             dia.exec()
@@ -7897,6 +7912,7 @@
             environmentPath,
             self.__venvConfiguration["interpreter"],
             self.__venvConfiguration["exec_path"],
+            parent=self.ui,
         )
         if dlg.exec() == QDialog.DialogCode.Accepted:
             (
@@ -8009,6 +8025,14 @@
             self.closeProject(noSave=True)
 
     @pyqtSlot()
+    def remoteConnectionAboutToDisconnect(self):
+        """
+        Public slot to handle the imminent disconnect from an 'eric-ide' server.
+        """
+        if FileSystemUtilities.isRemoteFileName(self.ppath):
+            self.closeProject()
+
+    @pyqtSlot()
     def __openRemoteProject(self):
         """
         Private slot to open a project of an 'eric-ide' server.

eric ide

mercurial