public static bool SolutionToQtMsBuild() { var solution = Vsix.Instance.Dte.Solution; if (solution == null) { return(ErrorMessage(string.Format(SR.GetString("ErrorConvertingProject"), ""))); } List <EnvDTE.Project> projects = new List <EnvDTE.Project>(); var allProjects = solution.Projects; if (allProjects.Count == 0) { return(WarningMessage(SR.GetString("NoProjectsToConvert"))); } foreach (EnvDTE.Project project in allProjects) { if ((HelperFunctions.IsQtProject(project) || HelperFunctions.IsQMakeProject(project)) && !QtProject.IsQtMsBuildEnabled(project)) { projects.Add(project); } } if (projects.Count == 0) { return(WarningMessage(SR.GetString("NoProjectsToConvert"))); } if (MessageBox.Show( SR.GetString("ConvertAllConfirmation"), SR.GetString("ConvertTitle"), MessageBoxButtons.YesNo) != DialogResult.Yes) { return(WarningMessage(SR.GetString("CancelConvertingProject"))); } if (projects.Where(project => project.IsDirty).Any()) { if (MessageBox.Show( SR.GetString("ConvertSaveConfirmation"), SR.GetString("ConvertTitle"), MessageBoxButtons.YesNo) != DialogResult.Yes) { return(WarningMessage(SR.GetString("CancelConvertingProject"))); } } foreach (var project in projects) { if (!ProjectToQtMsBuild(project, false)) { return(false); } } return(true); }
public static bool SolutionToQtMsBuild() { var solution = Vsix.Instance.Dte.Solution; if (solution == null) { return(ErrorMessage(string.Format(SR.GetString("ErrorConvertingProject"), ""))); } List <EnvDTE.Project> projects = new List <EnvDTE.Project>(); var allProjects = solution.Projects; if (allProjects.Count == 0) { return(WarningMessage(SR.GetString("NoProjectsToConvert"))); } foreach (EnvDTE.Project project in allProjects) { if ((HelperFunctions.IsQtProject(project) || HelperFunctions.IsQMakeProject(project)) && !QtProject.IsQtMsBuildEnabled(project)) { projects.Add(project); } } if (projects.Count == 0) { return(WarningMessage(SR.GetString("NoProjectsToConvert"))); } if (MessageBox.Show( SR.GetString("ConvertAllConfirmation"), SR.GetString("ConvertTitle"), MessageBoxButtons.YesNo) != DialogResult.Yes) { return(WarningMessage(SR.GetString("CancelConvertingProject"))); } if (projects.Where(project => project.IsDirty).Any()) { if (MessageBox.Show( SR.GetString("ConvertSaveConfirmation"), SR.GetString("ConvertTitle"), MessageBoxButtons.YesNo) != DialogResult.Yes) { return(WarningMessage(SR.GetString("CancelConvertingProject"))); } } var projectPaths = projects.Select(x => x.FullName).ToList(); string solutionPath = solution.FileName; solution.Close(true); var waitDialog = WaitDialog.StartWithProgress( SR.GetString("Resources_QtVsTools"), SR.GetString("ConvertWait"), null, null, 0, true, projectPaths.Count, 0); int projCount = 0; bool canceled = false; foreach (var projectPath in projectPaths) { if (waitDialog != null) { waitDialog.Update(string.Format(SR.GetString("ConvertProgress"), projCount + 1, projectPaths.Count, Path.GetFileNameWithoutExtension(projectPath)), null, null, projCount, projectPaths.Count, false); if (waitDialog.Canceled) { break; } } if (!ConvertProject(projectPath)) { if (waitDialog != null) { waitDialog.Stop(); } Vsix.Instance.Dte.Solution.Open(solutionPath); return(ErrorMessage(string.Format(SR.GetString("ErrorConvertingProject"), Path.GetFileName(projectPath)))); } ++projCount; } if (waitDialog != null) { waitDialog.Stop(); } Vsix.Instance.Dte.Solution.Open(solutionPath); if (canceled && projCount < projectPaths.Count) { MessageBox.Show(string.Format(SR.GetString("ConvertCanceled"), projectPaths.Count - projCount), SR.GetString("Resources_QtVsTools"), MessageBoxButtons.OK, MessageBoxIcon.Warning); } return(true); }
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 beforeQueryStatus(object sender, EventArgs e) { var command = sender as OleMenuCommand; if (command == null) { return; } switch ((CommandId)command.CommandID.ID) { case CommandId.ImportPriFileProjectId: case CommandId.ExportPriFileProjectId: case CommandId.ExportProFileProjectId: case CommandId.CreateNewTsFileProjectId: case CommandId.lUpdateOnProjectId: case CommandId.lReleaseOnProjectId: command.Visible = true; command.Enabled = HelperFunctions.IsQtProject(HelperFunctions .GetSelectedProject(Vsix.Instance.Dte)); break; case CommandId.ConvertToQmakeProjectId: case CommandId.QtProjectSettingsProjectId: case CommandId.ProjectAddNewQtClassProjectId: { var status = vsCommandStatus.vsCommandStatusSupported; var project = HelperFunctions.GetSelectedProject(Vsix.Instance.Dte); if (project != null) { if (HelperFunctions.IsQtProject(project)) { status |= vsCommandStatus.vsCommandStatusEnabled; } else if (HelperFunctions.IsQMakeProject(project)) { 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; var project = HelperFunctions.GetSelectedProject(Vsix.Instance.Dte); if ((project == null) || HelperFunctions.IsQtProject(project)) { status |= vsCommandStatus.vsCommandStatusInvisible; } else if (HelperFunctions.IsQMakeProject(project)) { status |= vsCommandStatus.vsCommandStatusEnabled; } else { status |= vsCommandStatus.vsCommandStatusInvisible; } command.Enabled = ((status & vsCommandStatus.vsCommandStatusEnabled) != 0); command.Visible = ((status & vsCommandStatus.vsCommandStatusInvisible) == 0); } break; case CommandId.ProjectConvertToQtMsBuild: { var project = HelperFunctions.GetSelectedProject(Vsix.Instance.Dte); if (project == null || (!HelperFunctions.IsQtProject(project) && !HelperFunctions.IsQMakeProject(project))) { command.Visible = false; command.Enabled = false; } else if (QtProject.IsQtMsBuildEnabled(project)) { command.Visible = true; command.Enabled = false; } else { command.Visible = true; command.Enabled = true; } } break; } }