private static void AddIncludePaths(Project project, ProFileOption option, string includePaths) { if (QtProject.GetFormatVersion(project) >= Resources.qtMinFormatVersion_ClProperties) { return; } if (includePaths == null) { return; } var versionManager = QtVersionManager.The(); var qtDir = versionManager.GetInstallPath(project); if (qtDir == null) { qtDir = Environment.GetEnvironmentVariable("QTDIR"); } if (qtDir == null) { qtDir = ""; } qtDir = HelperFunctions.NormalizeRelativeFilePath(qtDir); foreach (var s in includePaths.Split(';', ',')) { var d = HelperFunctions.NormalizeRelativeFilePath(s); if (!d.StartsWith("$(qtdir)\\include", StringComparison.OrdinalIgnoreCase) && !d.StartsWith(qtDir + "\\include", StringComparison.OrdinalIgnoreCase) && !d.EndsWith("win32-msvc2005", StringComparison.OrdinalIgnoreCase)) { var vcConfig = project.ConfigurationManager.ActiveConfiguration.Object as VCConfiguration; if (vcConfig != null) { HelperFunctions.ExpandString(ref d, vcConfig); } if (HelperFunctions.IsAbsoluteFilePath(d)) { d = HelperFunctions.GetRelativePath(project.FullName, d); } if (!HelperFunctions.IsAbsoluteFilePath(d)) { option.List.Add(HelperFunctions.ChangePathFormat(d)); } } } }
void debugStartEvents_BeforeExecute(string Guid, int ID, object CustomIn, object CustomOut, ref bool CancelDefault) { ThreadHelper.ThrowIfNotOnUIThread(); var debugger = dte.Debugger; if (debugger != null && debugger.CurrentMode != dbgDebugMode.dbgDesignMode) { return; } var selectedProject = HelperFunctions.GetSelectedQtProject(dte); if (selectedProject != null) { if (QtProject.GetFormatVersion(selectedProject) >= Resources.qtMinFormatVersion_Settings) { return; } var qtProject = QtProject.Create(selectedProject); if (qtProject != null) { qtProject.SetQtEnvironment(); var qtVersion = qtProject.GetQtVersion(); var versionInfo = QtVersionManager.The().GetVersionInfo(qtVersion); if (!string.IsNullOrEmpty(versionInfo.Namespace())) { QtVsToolsPackage.Instance.CopyNatvisFiles(versionInfo.Namespace()); } } } }
public bool SaveProjectQtVersion(EnvDTE.Project project, string version, string platform) { if (!IsVersionAvailable(version) && version != "$(DefaultQtVersion)") { return(false); } if (QtProject.GetFormatVersion(project) >= Resources.qtMinFormatVersion_Settings) { var vcPro = project.Object as VCProject; if (vcPro == null) { return(false); } #if VS2017 || VS2019 foreach (VCConfiguration3 config in (IVCCollection)vcPro.Configurations) { config.SetPropertyValue(Resources.projLabelQtSettings, true, "QtInstall", version); } #endif return(true); } var key = "Qt5Version " + platform; if (!project.Globals.get_VariableExists(key) || project.Globals[key].ToString() != version) { project.Globals[key] = version; } if (!project.Globals.get_VariablePersists(key)) { project.Globals.set_VariablePersists(key, true); } return(true); }
private static void AddLibraries(Project project, ProFileOption option, string paths, string deps) { if (QtProject.GetFormatVersion(project) < Resources.qtMinFormatVersion_ClProperties) { return; } var versionManager = QtVersionManager.The(); var qtDir = versionManager.GetInstallPath(project); if (qtDir == null) { qtDir = Environment.GetEnvironmentVariable("QTDIR"); } if (qtDir == null) { qtDir = ""; } qtDir = HelperFunctions.NormalizeRelativeFilePath(qtDir); ThreadHelper.ThrowIfNotOnUIThread(); if (paths != null) { foreach (var s in paths.Split(';', ',')) { var d = HelperFunctions.NormalizeRelativeFilePath(s); if (!d.StartsWith("$(qtdir)\\lib", StringComparison.OrdinalIgnoreCase) && !d.StartsWith(qtDir + "\\lib", StringComparison.OrdinalIgnoreCase)) { if (HelperFunctions.IsAbsoluteFilePath(d)) { d = HelperFunctions.GetRelativePath(project.FullName, d); } if (!HelperFunctions.IsAbsoluteFilePath(d)) { option.List.Add("-L\"" + HelperFunctions.ChangePathFormat(d) + "\""); } } } } if (deps != null) { foreach (var d in deps.Split(' ')) { if (d.Length > 0 && !d.StartsWith("$(qtdir)\\lib", StringComparison.OrdinalIgnoreCase) && !d.StartsWith(qtDir + "\\lib", StringComparison.OrdinalIgnoreCase) && !d.StartsWith("qt", StringComparison.OrdinalIgnoreCase) && !d.StartsWith(".\\qt", StringComparison.OrdinalIgnoreCase) && d != ".") { option.List.Add("-l" + HelperFunctions.ChangePathFormat(d).Replace(".lib", "")); } } } }
public void OnBuildProjConfigBegin(string projectName, string projectConfig, string platform, string solutionConfig) { if (currentBuildAction != vsBuildAction.vsBuildActionBuild && currentBuildAction != vsBuildAction.vsBuildActionRebuildAll) { return; // Don't do anything, if we're not building. } Project project = null; foreach (var p in HelperFunctions.ProjectsInSolution(dte)) { if (p.UniqueName == projectName) { project = p; break; } } if (project == null || !HelperFunctions.IsQtProject(project)) { return; } if (QtProject.GetFormatVersion(project) >= Resources.qtMinFormatVersion_Settings) { return; } var qtpro = QtProject.Create(project); var versionManager = QtVersionManager.The(); var qtVersion = versionManager.GetProjectQtVersion(project, platform); if (qtVersion == null) { Messages.DisplayCriticalErrorMessage(SR.GetString("ProjectQtVersionNotFoundError", projectName, projectConfig, platform)); dte.ExecuteCommand("Build.Cancel", ""); return; } if (!QtVSIPSettings.GetDisableAutoMocStepsUpdate()) { if (qtpro.ConfigurationRowNamesChanged) { qtpro.UpdateMocSteps(QtVSIPSettings.GetMocDirectory(project)); } } // Solution config is given to function to get QTDIR property // set correctly also during batch build qtpro.SetQtEnvironment(qtVersion, solutionConfig, true); if (QtVSIPSettings.GetLUpdateOnBuild(project)) { Translation.RunlUpdate(project); } }
void debugStartWithoutDebuggingEvents_BeforeExecute(string Guid, int ID, object CustomIn, object CustomOut, ref bool CancelDefault) { var selectedProject = HelperFunctions.GetSelectedQtProject(dte); if (selectedProject != null) { if (QtProject.GetFormatVersion(selectedProject) >= Resources.qtMinFormatVersion_Settings) { return; } var qtProject = QtProject.Create(selectedProject); if (qtProject != null) { qtProject.SetQtEnvironment(); } } }
public string GetProjectQtVersion(EnvDTE.Project project, string platform) { ThreadHelper.ThrowIfNotOnUIThread(); if (QtProject.GetFormatVersion(project) >= Resources.qtMinFormatVersion_Settings) { return(GetProjectQtVersion(project)); } var key = "Qt5Version " + platform; if (!project.Globals.get_VariablePersists(key)) { return(null); } var version = (string)project.Globals[key]; ExpandEnvironmentVariablesInQtVersion(ref version); return(VerifyIfQtVersionExists(version) ? version : null); }
public string GetProjectQtVersion(EnvDTE.Project project, EnvDTE.Configuration config) { ThreadHelper.ThrowIfNotOnUIThread(); if (QtProject.GetFormatVersion(project) >= Resources.qtMinFormatVersion_Settings) { return(QtProject.GetPropertyValue(project, config, "QtInstall")); } var key = "Qt5Version " + config.PlatformName; if (!project.Globals.get_VariablePersists(key)) { return(null); } var version = (string)project.Globals[key]; ExpandEnvironmentVariablesInQtVersion(ref version); return(VerifyIfQtVersionExists(version) ? version : null); }
private void execHandler(object sender, EventArgs e) { var command = sender as OleMenuCommand; if (command == null) { return; } switch ((CommandId)command.CommandID.ID) { case CommandId.LaunchDesignerId: DefaultEditorsHandler.Instance.StartEditor(DefaultEditor.Kind.Ui); break; case CommandId.LaunchLinguistId: DefaultEditorsHandler.Instance.StartEditor(DefaultEditor.Kind.Ts); break; case CommandId.OpenProFileId: ExtLoader.ImportProFile(); break; case CommandId.ImportPriFileId: ExtLoader.ImportPriFile(HelperFunctions.GetSelectedQtProject(Vsix.Instance.Dte)); break; case CommandId.ExportPriFileId: ExtLoader.ExportPriFile(); break; case CommandId.ExportProFileId: ExtLoader.ExportProFile(); break; case CommandId.CreateNewTsFileId: Translation.CreateNewTranslationFile(HelperFunctions.GetSelectedQtProject(Vsix .Instance.Dte)); break; case CommandId.ConvertToQtId: case CommandId.ConvertToQmakeId: { var caption = SR.GetString("ConvertTitle"); var text = SR.GetString("ConvertConfirmation"); if (MessageBox.Show(text, caption, MessageBoxButtons.YesNo) == DialogResult.Yes) { HelperFunctions.ToggleProjectKind(HelperFunctions.GetSelectedProject(Vsix .Instance.Dte)); } } break; case CommandId.ConvertToQtMsBuild: { QtMsBuildConverter.SolutionToQtMsBuild(); } break; case CommandId.QtProjectSettingsId: { var pro = HelperFunctions.GetSelectedQtProject(Vsix.Instance.Dte); int projectVersion = QtProject.GetFormatVersion(pro); if (projectVersion >= Resources.qtMinFormatVersion_Settings) { Vsix.Instance.Dte.ExecuteCommand("Project.Properties"); } else if (pro != null) { using (var formProjectQtSettings = new FormProjectQtSettings()) { formProjectQtSettings.SetProject(pro); formProjectQtSettings.StartPosition = FormStartPosition.CenterParent; var ww = new MainWinWrapper(Vsix.Instance.Dte); formProjectQtSettings.ShowDialog(ww); } } else { MessageBox.Show(SR.GetString("NoProjectOpened")); } } break; case CommandId.ChangeProjectQtVersionId: { var pro = HelperFunctions.GetSelectedQtProject(Vsix.Instance.Dte); if (HelperFunctions.IsQMakeProject(pro)) { using (var formChangeQtVersion = new FormChangeQtVersion()) { formChangeQtVersion.UpdateContent(ChangeFor.Project); var ww = new MainWinWrapper(Vsix.Instance.Dte); if (formChangeQtVersion.ShowDialog(ww) == DialogResult.OK) { var qtVersion = formChangeQtVersion.GetSelectedQtVersion(); HelperFunctions.SetDebuggingEnvironment(pro, "PATH=" + QtVersionManager .The().GetInstallPath(qtVersion) + @"\bin;$(PATH)", true); } } } } break; case CommandId.QtOptionsId: { using (var formQtVersions = new FormVSQtSettings()) { formQtVersions.LoadSettings(); formQtVersions.StartPosition = FormStartPosition.CenterParent; var ww = new MainWinWrapper(Vsix.Instance.Dte); if (formQtVersions.ShowDialog(ww) == DialogResult.OK) { formQtVersions.SaveSettings(); } } } break; } }
private void OnVCProjectEngineItemPropertyChange(object item, object tool, int dispid) { var vcFileCfg = item as VCFileConfiguration; if (vcFileCfg == null) { // A global or project specific property has changed. var vcCfg = item as VCConfiguration; if (vcCfg == null) { return; } var vcPrj = vcCfg.project as VCProject; if (vcPrj == null) { return; } if (!HelperFunctions.IsQtProject(vcPrj)) { return; } // Ignore property events when using shared compiler properties if (QtProject.GetFormatVersion(vcPrj) >= Resources.qtMinFormatVersion_ClProperties) { return; } if (dispid == dispId_VCCLCompilerTool_UsePrecompiledHeader || dispid == dispId_VCCLCompilerTool_PrecompiledHeaderThrough || dispid == dispId_VCCLCompilerTool_AdditionalIncludeDirectories || dispid == dispId_VCCLCompilerTool_PreprocessorDefinitions) { var qtPrj = QtProject.Create(vcPrj); if (qtPrj.IsQtMsBuildEnabled() && dispid == dispId_VCCLCompilerTool_AdditionalIncludeDirectories) { qtPrj.RefreshQtMocIncludePath(); } else if (qtPrj.IsQtMsBuildEnabled() && dispid == dispId_VCCLCompilerTool_PreprocessorDefinitions) { qtPrj.RefreshQtMocDefine(); } else { qtPrj.RefreshMocSteps(); } } } else { // A file specific property has changed. var vcFile = vcFileCfg.File as VCFile; if (vcFile == null) { return; } var vcPrj = vcFile.project as VCProject; if (vcPrj == null) { return; } if (!HelperFunctions.IsQtProject(vcPrj)) { return; } // Ignore property events when using shared compiler properties if (QtProject.GetFormatVersion(vcPrj) >= Resources.qtMinFormatVersion_ClProperties) { return; } if (dispid == dispId_VCFileConfiguration_ExcludedFromBuild) { var qtPrj = QtProject.Create(vcPrj); qtPrj.OnExcludedFromBuildChanged(vcFile, vcFileCfg); } else if (dispid == dispId_VCCLCompilerTool_UsePrecompiledHeader || dispid == dispId_VCCLCompilerTool_PrecompiledHeaderThrough || dispid == dispId_VCCLCompilerTool_AdditionalIncludeDirectories || dispid == dispId_VCCLCompilerTool_PreprocessorDefinitions) { var qtPrj = QtProject.Create(vcPrj); qtPrj.RefreshMocStep(vcFile); } } }
private void beforeQueryStatus(object sender, EventArgs e) { var command = sender as OleMenuCommand; if (command == null) { return; } var project = HelperFunctions.GetSelectedProject(QtVsToolsPackage.Instance.Dte); var isQtProject = HelperFunctions.IsQtProject(project); var isQMakeProject = HelperFunctions.IsQMakeProject(project); var isQtMsBuildEnabled = QtProject.IsQtMsBuildEnabled(project); if (!isQtProject && !isQMakeProject) { command.Enabled = command.Visible = false; return; } switch ((CommandId)command.CommandID.ID) { // TODO: Fix these functionality and re-enable the menu items case CommandId.ConvertToQtProjectId: case CommandId.ConvertToQmakeProjectId: { command.Visible = false; } break; case CommandId.ImportPriFileProjectId: case CommandId.ExportPriFileProjectId: case CommandId.ExportProFileProjectId: command.Visible = true; command.Enabled = HelperFunctions.IsQtProject(HelperFunctions .GetSelectedProject(QtVsToolsPackage.Instance.Dte)); break; case CommandId.lUpdateOnProjectId: case CommandId.lReleaseOnProjectId: command.Visible = true; command.Enabled = Translation.ToolsAvailable(project); break; //case CommandId.ConvertToQmakeProjectId: case CommandId.QtProjectSettingsProjectId: { var status = vsCommandStatus.vsCommandStatusSupported; if (project != null) { if (isQtProject) { status |= vsCommandStatus.vsCommandStatusEnabled; } else if (isQMakeProject) { status |= vsCommandStatus.vsCommandStatusInvisible; } } command.Enabled = ((status & vsCommandStatus.vsCommandStatusEnabled) != 0); command.Visible = ((status & vsCommandStatus.vsCommandStatusInvisible) == 0); } break; //case CommandId.ConvertToQtProjectId: case CommandId.ChangeProjectQtVersionProjectId: { var status = vsCommandStatus.vsCommandStatusSupported; if ((project == null) || isQtProject) { status |= vsCommandStatus.vsCommandStatusInvisible; } else if (isQMakeProject) { status |= vsCommandStatus.vsCommandStatusEnabled; } else { status |= vsCommandStatus.vsCommandStatusInvisible; } command.Enabled = ((status & vsCommandStatus.vsCommandStatusEnabled) != 0); command.Visible = ((status & vsCommandStatus.vsCommandStatusInvisible) == 0); } break; case CommandId.ProjectConvertToQtMsBuild: { if (project == null || (!isQtProject && !isQMakeProject)) { command.Visible = false; command.Enabled = false; } else if (isQtMsBuildEnabled) { command.Visible = true; command.Enabled = false; } else { command.Visible = true; command.Enabled = true; } } break; case CommandId.ProjectRefreshIntelliSense: { command.Visible = command.Enabled = isQtMsBuildEnabled; } break; } if (project != null && isQtProject) { int projectVersion = QtProject.GetFormatVersion(project); switch ((CommandId)command.CommandID.ID) { case CommandId.ChangeProjectQtVersionProjectId: if (projectVersion >= Resources.qtMinFormatVersion_Settings) { command.Visible = command.Enabled = false; } break; case CommandId.ProjectConvertToQtMsBuild: if (projectVersion >= Resources.qtProjectFormatVersion) { command.Visible = command.Enabled = false; } else { command.Visible = command.Enabled = true; if (isQtMsBuildEnabled) { command.Text = "Upgrade to latest Qt project format version"; } } break; } } }
private void execHandler(object sender, EventArgs e) { ThreadHelper.ThrowIfNotOnUIThread(); var command = sender as OleMenuCommand; if (command == null) { return; } switch ((CommandId)command.CommandID.ID) { case CommandId.ImportPriFileProjectId: ExtLoader.ImportPriFile(HelperFunctions.GetSelectedQtProject(QtVsToolsPackage.Instance.Dte)); break; case CommandId.ExportPriFileProjectId: ExtLoader.ExportPriFile(); break; case CommandId.ExportProFileProjectId: ExtLoader.ExportProFile(); break; case CommandId.lUpdateOnProjectId: Translation.RunlUpdate(HelperFunctions.GetSelectedQtProject(QtVsToolsPackage.Instance.Dte)); break; case CommandId.lReleaseOnProjectId: Translation.RunlRelease(HelperFunctions.GetSelectedQtProject(QtVsToolsPackage.Instance.Dte)); break; case CommandId.ConvertToQtProjectId: case CommandId.ConvertToQmakeProjectId: { var caption = SR.GetString("ConvertTitle"); var text = SR.GetString("ConvertConfirmation"); if (MessageBox.Show(text, caption, MessageBoxButtons.YesNo) == DialogResult.Yes) { HelperFunctions.ToggleProjectKind(HelperFunctions.GetSelectedProject(QtVsToolsPackage .Instance.Dte)); } } break; case CommandId.QtProjectSettingsProjectId: { var pro = HelperFunctions.GetSelectedQtProject(QtVsToolsPackage.Instance.Dte); int projectVersion = QtProject.GetFormatVersion(pro); if (projectVersion >= Resources.qtMinFormatVersion_Settings) { QtVsToolsPackage.Instance.Dte.ExecuteCommand("Project.Properties"); } else if (pro != null) { using (var formProjectQtSettings = new FormProjectQtSettings()) { formProjectQtSettings.SetProject(pro); formProjectQtSettings.StartPosition = FormStartPosition.CenterParent; var ww = new MainWinWrapper(QtVsToolsPackage.Instance.Dte); formProjectQtSettings.ShowDialog(ww); } } else { MessageBox.Show(SR.GetString("NoProjectOpened")); } } break; case CommandId.ChangeProjectQtVersionProjectId: { var pro = HelperFunctions.GetSelectedQtProject(QtVsToolsPackage.Instance.Dte); if (HelperFunctions.IsQMakeProject(pro)) { using (var formChangeQtVersion = new FormChangeQtVersion()) { formChangeQtVersion.UpdateContent(ChangeFor.Project); var ww = new MainWinWrapper(QtVsToolsPackage.Instance.Dte); if (formChangeQtVersion.ShowDialog(ww) == DialogResult.OK) { var qtVersion = formChangeQtVersion.GetSelectedQtVersion(); HelperFunctions.SetDebuggingEnvironment(pro, "PATH=" + QtVersionManager .The().GetInstallPath(qtVersion) + @"\bin;$(PATH)", true); } } } } break; case CommandId.ProjectConvertToQtMsBuild: { QtMsBuildConverter.ProjectToQtMsBuild( HelperFunctions.GetSelectedProject(QtVsToolsPackage.Instance.Dte)); } break; case CommandId.ProjectRefreshIntelliSense: { var selectedProject = HelperFunctions.GetSelectedProject(QtVsToolsPackage.Instance.Dte); var tracker = QtProjectTracker.Get(selectedProject, selectedProject.FullName); QtProjectIntellisense.Refresh(tracker.Project); } break; } }
private void execHandler(object sender, EventArgs e) { ThreadHelper.ThrowIfNotOnUIThread(); var command = sender as OleMenuCommand; if (command == null) { return; } switch ((CommandId)command.CommandID.ID) { case CommandId.ViewQtHelpId: VsShellUtilities.OpenSystemBrowser("https://www.qt.io/developers"); break; case CommandId.LaunchDesignerId: QtVsToolsPackage.Instance.QtDesigner.Start(hideWindow: false); break; case CommandId.LaunchLinguistId: QtVsToolsPackage.Instance.QtLinguist.Start(hideWindow: false); break; case CommandId.OpenProFileId: ExtLoader.ImportProFile(); break; case CommandId.ImportPriFileId: ExtLoader.ImportPriFile(HelperFunctions.GetSelectedQtProject(QtVsToolsPackage.Instance.Dte)); break; case CommandId.ExportPriFileId: ExtLoader.ExportPriFile(); break; case CommandId.ExportProFileId: ExtLoader.ExportProFile(); break; case CommandId.ConvertToQtId: case CommandId.ConvertToQmakeId: { var caption = SR.GetString("ConvertTitle"); var text = SR.GetString("ConvertConfirmation"); if (MessageBox.Show(text, caption, MessageBoxButtons.YesNo) == DialogResult.Yes) { HelperFunctions.ToggleProjectKind(HelperFunctions.GetSelectedProject(QtVsToolsPackage .Instance.Dte)); } } break; case CommandId.ConvertToQtMsBuild: { QtMsBuildConverter.SolutionToQtMsBuild(); } break; case CommandId.QtProjectSettingsId: { var pro = HelperFunctions.GetSelectedQtProject(QtVsToolsPackage.Instance.Dte); int projectVersion = QtProject.GetFormatVersion(pro); if (projectVersion >= Resources.qtMinFormatVersion_Settings) { QtVsToolsPackage.Instance.Dte.ExecuteCommand("Project.Properties"); } else if (pro != null) { using (var formProjectQtSettings = new FormProjectQtSettings()) { formProjectQtSettings.SetProject(pro); formProjectQtSettings.StartPosition = FormStartPosition.CenterParent; var ww = new MainWinWrapper(QtVsToolsPackage.Instance.Dte); formProjectQtSettings.ShowDialog(ww); } } else { MessageBox.Show(SR.GetString("NoProjectOpened")); } } break; case CommandId.ChangeProjectQtVersionId: { var pro = HelperFunctions.GetSelectedQtProject(QtVsToolsPackage.Instance.Dte); if (HelperFunctions.IsQMakeProject(pro)) { using (var formChangeQtVersion = new FormChangeQtVersion()) { formChangeQtVersion.UpdateContent(ChangeFor.Project); var ww = new MainWinWrapper(QtVsToolsPackage.Instance.Dte); if (formChangeQtVersion.ShowDialog(ww) == DialogResult.OK) { var qtVersion = formChangeQtVersion.GetSelectedQtVersion(); HelperFunctions.SetDebuggingEnvironment(pro, "PATH=" + QtVersionManager .The().GetInstallPath(qtVersion) + @"\bin;$(PATH)", true); } } } } break; case CommandId.QtOptionsId: QtVsToolsPackage.Instance.ShowOptionPage(typeof(Options.QtOptionsPage)); break; case CommandId.QtVersionsId: QtVsToolsPackage.Instance.ShowOptionPage(typeof(Options.QtVersionsPage)); break; } }