From ca47896204482bf4a6979e3838bf7f09f61cebeb Mon Sep 17 00:00:00 2001 From: giy <giy@omp-system.ru> Date: Fri, 02 Sep 2022 14:16:56 +0300 Subject: [PATCH] Обновление до версии 2.9.0 --- QtVsTools.Package/Package/QtSolutionContextMenu.cs | 107 +++++++++++++++++++---------------------------------- 1 files changed, 39 insertions(+), 68 deletions(-) diff --git a/QtVsTools.Package/Package/QtSolutionContextMenu.cs b/QtVsTools.Package/Package/QtSolutionContextMenu.cs index d680fe7..67f2a8c 100644 --- a/QtVsTools.Package/Package/QtSolutionContextMenu.cs +++ b/QtVsTools.Package/Package/QtSolutionContextMenu.cs @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2022 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt VS Tools. @@ -26,17 +26,15 @@ ** ****************************************************************************/ -using EnvDTE80; -using Microsoft.VisualStudio.Shell; -using QtVsTools.Core; -using QtVsTools.VisualStudio; using System; using System.ComponentModel.Design; -using System.Windows.Forms; +using Microsoft.VisualStudio.Shell; namespace QtVsTools { + using Core; using QtMsBuild; + using VisualStudio; /// <summary> /// Command handler @@ -46,30 +44,24 @@ /// <summary> /// Command menu group (command set GUID). /// </summary> - public static readonly Guid SolutionContextMenuGuid = new Guid("6dcda34f-4d22-4d6a-a176-5507069c5a3e"); + private static readonly Guid SolutionContextMenuGuid = new Guid("6dcda34f-4d22-4d6a-a176-5507069c5a3e"); /// <summary> /// Gets the instance of the command. /// </summary> - public static QtSolutionContextMenu Instance + private static QtSolutionContextMenu Instance { get; - private set; + set; } /// <summary> /// Initializes the singleton instance of the command. /// </summary> - /// <param name="package">Owner package, not null.</param> - public static void Initialize(Package package) + public static void Initialize() { - Instance = new QtSolutionContextMenu(package); + Instance = new QtSolutionContextMenu(); } - - /// <summary> - /// VS Package that provides this command, not null. - /// </summary> - private readonly Package m_package; /// <summary> /// Command ID. @@ -87,14 +79,8 @@ /// Initializes a new instance of the <see cref="QtMainMenu"/> class. /// Adds our command handlers for menu (commands must exist in the command table file) /// </summary> - /// <param name="package">Owner package, not null.</param> - private QtSolutionContextMenu(Package package) + private QtSolutionContextMenu() { - if (package == null) - throw new ArgumentNullException("package"); - - m_package = package; - var commandService = VsServiceProvider .GetService<IMenuCommandService, OleMenuCommandService>(); if (commandService == null) @@ -113,66 +99,51 @@ var command = sender as OleMenuCommand; if (command == null) return; - command.Enabled = command.Visible = true; + + switch (command.CommandID.ID) { + case (int)CommandId.ChangeSolutionQtVersionId: + var projects = HelperFunctions.ProjectsInSolution(QtVsToolsPackage.Instance.Dte); + foreach (var project in projects) { + if (!HelperFunctions.IsVsToolsProject(project) + && HelperFunctions.IsQtProject(project)) { + command.Enabled = command.Visible = true; + return; + } + } + command.Enabled = command.Visible = false; + break; + default: + command.Enabled = command.Visible = true; + break; + } } private void execHandler(object sender, EventArgs e) { + ThreadHelper.ThrowIfNotOnUIThread(); + var command = sender as OleMenuCommand; if (command == null) return; var dte = QtVsToolsPackage.Instance.Dte; - switch (command.CommandID.ID) { - case (int)CommandId.lUpdateOnSolutionId: + switch ((CommandId)command.CommandID.ID) { + case CommandId.lUpdateOnSolutionId: Translation.RunlUpdate(QtVsToolsPackage.Instance.Dte.Solution); break; - case (int)CommandId.lReleaseOnSolutionId: + case CommandId.lReleaseOnSolutionId: Translation.RunlRelease(QtVsToolsPackage.Instance.Dte.Solution); break; - case (int)CommandId.ChangeSolutionQtVersionId: - string newQtVersion = null; - using (var formChangeQtVersion = new FormChangeQtVersion()) { - formChangeQtVersion.UpdateContent(ChangeFor.Solution); - if (formChangeQtVersion.ShowDialog() != DialogResult.OK) - return; - newQtVersion = formChangeQtVersion.GetSelectedQtVersion(); - } - if (newQtVersion == null) - return; - - string currentPlatform = null; - try { - var config2 = QtVsToolsPackage.Instance.Dte.Solution.SolutionBuild - .ActiveConfiguration as SolutionConfiguration2; - currentPlatform = config2.PlatformName; - } catch { } - if (string.IsNullOrEmpty(currentPlatform)) - return; - - foreach (var project in HelperFunctions.ProjectsInSolution(dte)) { - if (HelperFunctions.IsQtProject(project)) { - var OldQtVersion = QtVersionManager.The().GetProjectQtVersion(project, - currentPlatform); - if (OldQtVersion == null) - OldQtVersion = QtVersionManager.The().GetDefaultVersion(); - - var created = false; - var qtProject = QtProject.Create(project); - if (qtProject.PromptChangeQtVersion(OldQtVersion, newQtVersion)) - qtProject.ChangeQtVersion(OldQtVersion, newQtVersion, ref created); - } - } - QtVersionManager.The().SaveSolutionQtVersion(dte.Solution, newQtVersion); + case CommandId.ChangeSolutionQtVersionId: + Legacy.QtMenu.ShowFormChangeSolutionQtVersion(); break; - case (int)CommandId.SolutionConvertToQtMsBuild: { - QtMsBuildConverter.SolutionToQtMsBuild(); - } + case CommandId.SolutionConvertToQtMsBuild: + QtMsBuildConverter.SolutionToQtMsBuild(); break; - case (int)CommandId.SolutionEnableProjectTracking: { + case CommandId.SolutionEnableProjectTracking: { foreach (var project in HelperFunctions.ProjectsInSolution(dte)) { - if (HelperFunctions.IsQtProject(project)) - QtProjectTracker.Get(project); + if (HelperFunctions.IsVsToolsProject(project)) + QtProjectTracker.Get(project, project.FullName); } } break; -- Gitblit v1.9.1