src/eric7/Project/Project.py

branch
eric7
changeset 11006
a671918232f3
parent 10969
705b71b3fde6
child 11019
27cd57e98461
child 11024
b9048ec9b87f
equal deleted inserted replaced
11005:b918c6c2736b 11006:a671918232f3
1644 Private slot to display the debugger properties dialog. 1644 Private slot to display the debugger properties dialog.
1645 """ 1645 """
1646 from .DebuggerPropertiesDialog import DebuggerPropertiesDialog 1646 from .DebuggerPropertiesDialog import DebuggerPropertiesDialog
1647 1647
1648 dlg = DebuggerPropertiesDialog( 1648 dlg = DebuggerPropertiesDialog(
1649 self, isRemote=FileSystemUtilities.isRemoteFileName(self.ppath) 1649 self,
1650 isRemote=FileSystemUtilities.isRemoteFileName(self.ppath),
1651 parent=self.ui,
1650 ) 1652 )
1651 if dlg.exec() == QDialog.DialogCode.Accepted: 1653 if dlg.exec() == QDialog.DialogCode.Accepted:
1652 dlg.storeData() 1654 dlg.storeData()
1653 1655
1654 def getDebugProperty(self, key): 1656 def getDebugProperty(self, key):
1774 self.tr("Add Language"), 1776 self.tr("Add Language"),
1775 self.tr("You have to specify a translation pattern first."), 1777 self.tr("You have to specify a translation pattern first."),
1776 ) 1778 )
1777 return 1779 return
1778 1780
1779 dlg = AddLanguageDialog(self.parent()) 1781 dlg = AddLanguageDialog(parent=self.parent())
1780 if dlg.exec() == QDialog.DialogCode.Accepted: 1782 if dlg.exec() == QDialog.DialogCode.Accepted:
1781 lang = dlg.getSelectedLanguage() 1783 lang = dlg.getSelectedLanguage()
1782 if self.__pdata["PROJECTTYPE"] in [ 1784 if self.__pdata["PROJECTTYPE"] in [
1783 "PyQt5", 1785 "PyQt5",
1784 "PyQt5C", 1786 "PyQt5C",
2037 from .AddFileDialog import AddFileDialog 2039 from .AddFileDialog import AddFileDialog
2038 2040
2039 if not startdir: 2041 if not startdir:
2040 startdir = self.ppath 2042 startdir = self.ppath
2041 2043
2042 dlg = AddFileDialog(self, self.parent(), fileTypeFilter, startdir=startdir) 2044 dlg = AddFileDialog(
2045 self, parent=self.parent(), fileTypeFilter=fileTypeFilter, startdir=startdir
2046 )
2043 if dlg.exec() == QDialog.DialogCode.Accepted: 2047 if dlg.exec() == QDialog.DialogCode.Accepted:
2044 fnames, target, isSource = dlg.getData() 2048 fnames, target, isSource = dlg.getData()
2045 if target != "": 2049 if target != "":
2046 isRemote = FileSystemUtilities.isRemoteFileName(target) 2050 isRemote = FileSystemUtilities.isRemoteFileName(target)
2047 for fn in fnames: 2051 for fn in fnames:
2277 from .AddDirectoryDialog import AddDirectoryDialog 2281 from .AddDirectoryDialog import AddDirectoryDialog
2278 2282
2279 if not startdir: 2283 if not startdir:
2280 startdir = self.ppath 2284 startdir = self.ppath
2281 2285
2282 dlg = AddDirectoryDialog(self, fileTypeFilter, self.parent(), startdir=startdir) 2286 dlg = AddDirectoryDialog(
2287 self, fileTypeFilter, parent=self.parent(), startdir=startdir
2288 )
2283 if dlg.exec() == QDialog.DialogCode.Accepted: 2289 if dlg.exec() == QDialog.DialogCode.Accepted:
2284 filetype, source, target, recursive = dlg.getData() 2290 filetype, source, target, recursive = dlg.getData()
2285 if target == "": 2291 if target == "":
2286 EricMessageBox.critical( 2292 EricMessageBox.critical(
2287 self.ui, 2293 self.ui,
2751 if not self.checkDirty(): 2757 if not self.checkDirty():
2752 return 2758 return
2753 2759
2754 isRemote = self.__remoteServer.isServerConnected() 2760 isRemote = self.__remoteServer.isServerConnected()
2755 2761
2756 dlg = PropertiesDialog(self, new=True, isRemote=isRemote) 2762 dlg = PropertiesDialog(self, new=True, isRemote=isRemote, parent=self.ui)
2757 if dlg.exec() == QDialog.DialogCode.Accepted: 2763 if dlg.exec() == QDialog.DialogCode.Accepted:
2758 self.closeProject() 2764 self.closeProject()
2759 2765
2760 # reset the auto save flag 2766 # reset the auto save flag
2761 autoSaveProject = Preferences.getProject("AutoSaveProject") 2767 autoSaveProject = Preferences.getProject("AutoSaveProject")
3091 ), 3097 ),
3092 ) 3098 )
3093 else: 3099 else:
3094 vcores = False 3100 vcores = False
3095 if vcores: 3101 if vcores:
3096 codlg = VcsCommandOptionsDialog(self.vcs) 3102 codlg = VcsCommandOptionsDialog(
3103 self.vcs, parent=self.ui
3104 )
3097 if codlg.exec() == QDialog.DialogCode.Accepted: 3105 if codlg.exec() == QDialog.DialogCode.Accepted:
3098 self.vcs.vcsSetOptions(codlg.getOptions()) 3106 self.vcs.vcsSetOptions(codlg.getOptions())
3099 # add project file to repository 3107 # add project file to repository
3100 if res == 0: 3108 if res == 0:
3101 apres = EricMessageBox.yesNo( 3109 apres = EricMessageBox.yesNo(
3147 self.__pdata["VCS"] = "None" 3155 self.__pdata["VCS"] = "None"
3148 else: 3156 else:
3149 self.__pdata["VCS"] = "None" 3157 self.__pdata["VCS"] = "None"
3150 self.vcs = self.initVCS() 3158 self.vcs = self.initVCS()
3151 if self.vcs is not None: 3159 if self.vcs is not None:
3152 vcsdlg = self.vcs.vcsOptionsDialog(self, self.name) 3160 vcsdlg = self.vcs.vcsOptionsDialog(self, self.name, parent=self.ui)
3153 if vcsdlg.exec() == QDialog.DialogCode.Accepted: 3161 if vcsdlg.exec() == QDialog.DialogCode.Accepted:
3154 vcsDataDict = vcsdlg.getData() 3162 vcsDataDict = vcsdlg.getData()
3155 else: 3163 else:
3156 self.__pdata["VCS"] = "None" 3164 self.__pdata["VCS"] = "None"
3157 self.vcs = self.initVCS() 3165 self.vcs = self.initVCS()
3168 ), 3176 ),
3169 ) 3177 )
3170 else: 3178 else:
3171 vcores = False 3179 vcores = False
3172 if vcores: 3180 if vcores:
3173 codlg = VcsCommandOptionsDialog(self.vcs) 3181 codlg = VcsCommandOptionsDialog(self.vcs, parent=self.ui)
3174 if codlg.exec() == QDialog.DialogCode.Accepted: 3182 if codlg.exec() == QDialog.DialogCode.Accepted:
3175 self.vcs.vcsSetOptions(codlg.getOptions()) 3183 self.vcs.vcsSetOptions(codlg.getOptions())
3176 3184
3177 # create the project in the VCS 3185 # create the project in the VCS
3178 self.vcs.vcsSetDataFromDict(vcsDataDict) 3186 self.vcs.vcsSetDataFromDict(vcsDataDict)
3398 Private slot to display the properties dialog. 3406 Private slot to display the properties dialog.
3399 """ 3407 """
3400 from .PropertiesDialog import PropertiesDialog 3408 from .PropertiesDialog import PropertiesDialog
3401 3409
3402 isRemote = FileSystemUtilities.isRemoteFileName(self.ppath) 3410 isRemote = FileSystemUtilities.isRemoteFileName(self.ppath)
3403 dlg = PropertiesDialog(self, new=False, isRemote=isRemote) 3411 dlg = PropertiesDialog(self, new=False, isRemote=isRemote, parent=self.ui)
3404 if dlg.exec() == QDialog.DialogCode.Accepted: 3412 if dlg.exec() == QDialog.DialogCode.Accepted:
3405 fileTypesDict = copy.copy(self.__pdata["FILETYPES"]) 3413 fileTypesDict = copy.copy(self.__pdata["FILETYPES"])
3406 dlg.storeData() 3414 dlg.storeData()
3407 self.setDirty(True) 3415 self.setDirty(True)
3408 if self.__pdata["MAINSCRIPT"]: 3416 if self.__pdata["MAINSCRIPT"]:
3517 from .UserPropertiesDialog import UserPropertiesDialog 3525 from .UserPropertiesDialog import UserPropertiesDialog
3518 3526
3519 vcsSystem = self.__pdata["VCS"] or None 3527 vcsSystem = self.__pdata["VCS"] or None
3520 vcsSystemOverride = self.pudata["VCSOVERRIDE"] or None 3528 vcsSystemOverride = self.pudata["VCSOVERRIDE"] or None
3521 3529
3522 dlg = UserPropertiesDialog(self) 3530 dlg = UserPropertiesDialog(self, parent=self.ui)
3523 if dlg.exec() == QDialog.DialogCode.Accepted: 3531 if dlg.exec() == QDialog.DialogCode.Accepted:
3524 dlg.storeData() 3532 dlg.storeData()
3525 3533
3526 if ( 3534 if (
3527 (self.__pdata["VCS"] and self.__pdata["VCS"] != vcsSystem) 3535 (self.__pdata["VCS"] and self.__pdata["VCS"] != vcsSystem)
3555 """ 3563 """
3556 Private slot to display the filetype association dialog. 3564 Private slot to display the filetype association dialog.
3557 """ 3565 """
3558 from .FiletypeAssociationDialog import FiletypeAssociationDialog 3566 from .FiletypeAssociationDialog import FiletypeAssociationDialog
3559 3567
3560 dlg = FiletypeAssociationDialog(self, self.getProjectData(dataKey="FILETYPES")) 3568 dlg = FiletypeAssociationDialog(
3569 self, self.getProjectData(dataKey="FILETYPES"), parent=self.ui
3570 )
3561 if dlg.exec() == QDialog.DialogCode.Accepted: 3571 if dlg.exec() == QDialog.DialogCode.Accepted:
3562 fileTypes = dlg.getData() 3572 fileTypes = dlg.getData()
3563 self.setProjectData(fileTypes, dataKey="FILETYPES") 3573 self.setProjectData(fileTypes, dataKey="FILETYPES")
3564 self.setDirty(True) 3574 self.setDirty(True)
3565 self.__reorganizeFiles() 3575 self.__reorganizeFiles()
3585 """ 3595 """
3586 Private slot to display the lexer association dialog. 3596 Private slot to display the lexer association dialog.
3587 """ 3597 """
3588 from .LexerAssociationDialog import LexerAssociationDialog 3598 from .LexerAssociationDialog import LexerAssociationDialog
3589 3599
3590 dlg = LexerAssociationDialog(self) 3600 dlg = LexerAssociationDialog(self, parent=self.ui)
3591 if dlg.exec() == QDialog.DialogCode.Accepted: 3601 if dlg.exec() == QDialog.DialogCode.Accepted:
3592 dlg.transferData() 3602 dlg.transferData()
3593 self.setDirty(True) 3603 self.setDirty(True)
3594 self.lexerAssociationsChanged.emit() 3604 self.lexerAssociationsChanged.emit()
3595 3605
7035 dlg = EricListSelectionDialog( 7045 dlg = EricListSelectionDialog(
7036 sorted(pkglists), 7046 sorted(pkglists),
7037 title=self.tr("Create Plugin Archive"), 7047 title=self.tr("Create Plugin Archive"),
7038 message=self.tr("Select package lists:"), 7048 message=self.tr("Select package lists:"),
7039 checkBoxSelection=True, 7049 checkBoxSelection=True,
7050 parent=self.ui,
7040 ) 7051 )
7041 if dlg.exec() == QDialog.DialogCode.Accepted: 7052 if dlg.exec() == QDialog.DialogCode.Accepted:
7042 selectedLists = [ 7053 selectedLists = [
7043 os.path.join(self.ppath, s) for s in dlg.getSelection() 7054 os.path.join(self.ppath, s) for s in dlg.getSelection()
7044 ] 7055 ]
7625 """ 7636 """
7626 Private slot to create a SBOM file of the project dependencies. 7637 Private slot to create a SBOM file of the project dependencies.
7627 """ 7638 """
7628 from eric7 import CycloneDXInterface 7639 from eric7 import CycloneDXInterface
7629 7640
7630 CycloneDXInterface.createCycloneDXFile("<project>") 7641 CycloneDXInterface.createCycloneDXFile("<project>", parent=self.ui)
7631 7642
7632 ######################################################################### 7643 #########################################################################
7633 ## Below are methods implementing the 'Code Formatting' support 7644 ## Below are methods implementing the 'Code Formatting' support
7634 ######################################################################### 7645 #########################################################################
7635 7646
7659 BlackConfigurationDialog, 7670 BlackConfigurationDialog,
7660 ) 7671 )
7661 from eric7.CodeFormatting.BlackFormattingDialog import BlackFormattingDialog 7672 from eric7.CodeFormatting.BlackFormattingDialog import BlackFormattingDialog
7662 7673
7663 if ericApp().getObject("ViewManager").checkAllDirty(): 7674 if ericApp().getObject("ViewManager").checkAllDirty():
7664 dlg = BlackConfigurationDialog(withProject=True) 7675 dlg = BlackConfigurationDialog(withProject=True, parent=self.ui)
7665 if dlg.exec() == QDialog.DialogCode.Accepted: 7676 if dlg.exec() == QDialog.DialogCode.Accepted:
7666 config = dlg.getConfiguration(saveToProject=True) 7677 config = dlg.getConfiguration(saveToProject=True)
7667 7678
7668 formattingDialog = BlackFormattingDialog( 7679 formattingDialog = BlackFormattingDialog(
7669 config, 7680 config,
7670 self.getProjectFiles("SOURCES", normalized=True), 7681 self.getProjectFiles("SOURCES", normalized=True),
7671 project=self, 7682 project=self,
7672 action=action, 7683 action=action,
7684 parent=self.ui,
7673 ) 7685 )
7674 formattingDialog.exec() 7686 formattingDialog.exec()
7675 7687
7676 @pyqtSlot() 7688 @pyqtSlot()
7677 def __configureBlack(self): 7689 def __configureBlack(self):
7681 """ 7693 """
7682 from eric7.CodeFormatting.BlackConfigurationDialog import ( 7694 from eric7.CodeFormatting.BlackConfigurationDialog import (
7683 BlackConfigurationDialog, 7695 BlackConfigurationDialog,
7684 ) 7696 )
7685 7697
7686 dlg = BlackConfigurationDialog(withProject=True, onlyProject=True) 7698 dlg = BlackConfigurationDialog(
7699 withProject=True, onlyProject=True, parent=self.ui
7700 )
7687 if dlg.exec() == QDialog.DialogCode.Accepted: 7701 if dlg.exec() == QDialog.DialogCode.Accepted:
7688 dlg.getConfiguration(saveToProject=True) 7702 dlg.getConfiguration(saveToProject=True)
7689 # The data is saved to the project as a side effect. 7703 # The data is saved to the project as a side effect.
7690 7704
7691 def __performImportSortingWithIsort(self, action): 7705 def __performImportSortingWithIsort(self, action):
7709 IsortConfigurationDialog, 7723 IsortConfigurationDialog,
7710 ) 7724 )
7711 from eric7.CodeFormatting.IsortFormattingDialog import IsortFormattingDialog 7725 from eric7.CodeFormatting.IsortFormattingDialog import IsortFormattingDialog
7712 7726
7713 if ericApp().getObject("ViewManager").checkAllDirty(): 7727 if ericApp().getObject("ViewManager").checkAllDirty():
7714 dlg = IsortConfigurationDialog(withProject=True) 7728 dlg = IsortConfigurationDialog(withProject=True, parent=self.ui)
7715 if dlg.exec() == QDialog.DialogCode.Accepted: 7729 if dlg.exec() == QDialog.DialogCode.Accepted:
7716 config = dlg.getConfiguration(saveToProject=True) 7730 config = dlg.getConfiguration(saveToProject=True)
7717 7731
7718 isortDialog = IsortFormattingDialog( 7732 isortDialog = IsortFormattingDialog(
7719 config, 7733 config,
7720 self.getProjectFiles("SOURCES", normalized=True), 7734 self.getProjectFiles("SOURCES", normalized=True),
7721 project=self, 7735 project=self,
7722 action=action, 7736 action=action,
7737 parent=self.ui,
7723 ) 7738 )
7724 isortDialog.exec() 7739 isortDialog.exec()
7725 7740
7726 @pyqtSlot() 7741 @pyqtSlot()
7727 def __configureIsort(self): 7742 def __configureIsort(self):
7731 """ 7746 """
7732 from eric7.CodeFormatting.IsortConfigurationDialog import ( 7747 from eric7.CodeFormatting.IsortConfigurationDialog import (
7733 IsortConfigurationDialog, 7748 IsortConfigurationDialog,
7734 ) 7749 )
7735 7750
7736 dlg = IsortConfigurationDialog(withProject=True, onlyProject=True) 7751 dlg = IsortConfigurationDialog(
7752 withProject=True, onlyProject=True, parent=self.ui
7753 )
7737 if dlg.exec() == QDialog.DialogCode.Accepted: 7754 if dlg.exec() == QDialog.DialogCode.Accepted:
7738 dlg.getConfiguration(saveToProject=True) 7755 dlg.getConfiguration(saveToProject=True)
7739 # The data is saved to the project as a side effect. 7756 # The data is saved to the project as a side effect.
7740 7757
7741 ######################################################################### 7758 #########################################################################
7820 ) 7837 )
7821 7838
7822 environmentPath = self.__findEmbeddedEnvironment() 7839 environmentPath = self.__findEmbeddedEnvironment()
7823 if force or upgrade or not environmentPath: 7840 if force or upgrade or not environmentPath:
7824 dlg = ProjectVenvCreationParametersDialog( 7841 dlg = ProjectVenvCreationParametersDialog(
7825 withSystemSitePackages=self.__venvConfiguration["system_site_packages"] 7842 withSystemSitePackages=self.__venvConfiguration["system_site_packages"],
7843 parent=self.ui,
7826 ) 7844 )
7827 if dlg.exec() != QDialog.DialogCode.Accepted: 7845 if dlg.exec() != QDialog.DialogCode.Accepted:
7828 # user canceled the environment creation 7846 # user canceled the environment creation
7829 self.__setEmbeddedEnvironmentProjectConfig(False) 7847 self.__setEmbeddedEnvironmentProjectConfig(False)
7830 return 7848 return
7847 if os.path.exists(os.path.join(self.getProjectPath(), ".venv")): 7865 if os.path.exists(os.path.join(self.getProjectPath(), ".venv")):
7848 args.append("--clear") 7866 args.append("--clear")
7849 if withSystemSitePackages: 7867 if withSystemSitePackages:
7850 args.append("--system-site-packages") 7868 args.append("--system-site-packages")
7851 args.append(configuration["targetDirectory"]) 7869 args.append(configuration["targetDirectory"])
7852 dia = VirtualenvExecDialog(configuration, None) 7870 dia = VirtualenvExecDialog(configuration, None, parent=self.ui)
7853 dia.show() 7871 dia.show()
7854 dia.start(args) 7872 dia.start(args)
7855 dia.exec() 7873 dia.exec()
7856 7874
7857 self.__venvConfiguration["system_site_packages"] = withSystemSitePackages 7875 self.__venvConfiguration["system_site_packages"] = withSystemSitePackages
7892 dlg = ProjectVenvConfigurationDialog( 7910 dlg = ProjectVenvConfigurationDialog(
7893 self.__venvConfiguration["name"], 7911 self.__venvConfiguration["name"],
7894 environmentPath, 7912 environmentPath,
7895 self.__venvConfiguration["interpreter"], 7913 self.__venvConfiguration["interpreter"],
7896 self.__venvConfiguration["exec_path"], 7914 self.__venvConfiguration["exec_path"],
7915 parent=self.ui,
7897 ) 7916 )
7898 if dlg.exec() == QDialog.DialogCode.Accepted: 7917 if dlg.exec() == QDialog.DialogCode.Accepted:
7899 ( 7918 (
7900 self.__venvConfiguration["interpreter"], 7919 self.__venvConfiguration["interpreter"],
7901 self.__venvConfiguration["exec_path"], 7920 self.__venvConfiguration["exec_path"],

eric ide

mercurial