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/QtProjectContextMenu.cs |  128 ++++++++----------------------------------
 1 files changed, 26 insertions(+), 102 deletions(-)

diff --git a/QtVsTools.Package/Package/QtProjectContextMenu.cs b/QtVsTools.Package/Package/QtProjectContextMenu.cs
index 2706ef5..3b08b13 100644
--- a/QtVsTools.Package/Package/QtProjectContextMenu.cs
+++ b/QtVsTools.Package/Package/QtProjectContextMenu.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,20 +26,17 @@
 **
 ****************************************************************************/
 
-using EnvDTE;
-using Microsoft.VisualStudio;
-using Microsoft.VisualStudio.Shell;
-using Microsoft.VisualStudio.Shell.Interop;
-using Microsoft.VisualStudio.VCProjectEngine;
-using QtVsTools.Core;
-using QtVsTools.VisualStudio;
 using System;
 using System.ComponentModel.Design;
 using System.Windows.Forms;
+using Microsoft.VisualStudio.Shell;
+using EnvDTE;
 
 namespace QtVsTools
 {
+    using Core;
     using QtMsBuild;
+    using VisualStudio;
 
     /// <summary>
     /// Command handler
@@ -49,24 +46,23 @@
         /// <summary>
         /// Command menu group (command set GUID).
         /// </summary>
-        public static readonly Guid ProjectContextMenuGuid = new Guid("5732faa9-6074-4e07-b035-2816e809f50e");
+        private static readonly Guid ProjectContextMenuGuid = new Guid("5732faa9-6074-4e07-b035-2816e809f50e");
 
         /// <summary>
         /// Gets the instance of the command.
         /// </summary>
-        public static QtProjectContextMenu Instance
+        private static QtProjectContextMenu 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 QtProjectContextMenu(package);
+            Instance = new QtProjectContextMenu();
         }
 
         /// <summary>
@@ -77,35 +73,20 @@
             ImportPriFileProjectId = 0x0114,
             ExportPriFileProjectId = 0x0115,
             ExportProFileProjectId = 0x0116,
-            CreateNewTsFileProjectId = 0x0117,
             lUpdateOnProjectId = 0x0118,
             lReleaseOnProjectId = 0x0119,
             ProjectConvertToQtMsBuild = 0x0130,
             ProjectRefreshIntelliSense = 0x0131,
-            ConvertToQtProjectId = 0x0120,
-            ConvertToQmakeProjectId = 0x0121,
             QtProjectSettingsProjectId = 0x0122,
-            ChangeProjectQtVersionProjectId = 0x0123,
-            ProjectAddNewQtClassProjectId = 0x200
+            ChangeProjectQtVersionProjectId = 0x0123
         }
-
-        /// <summary>
-        /// VS Package that provides this command, not null.
-        /// </summary>
-        private readonly Package m_package;
 
         /// <summary>
         /// 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 QtProjectContextMenu(Package package)
+        private QtProjectContextMenu()
         {
-            if (package == null)
-                throw new ArgumentNullException("package");
-
-            m_package = package;
-
             var commandService = VsServiceProvider
                 .GetService<IMenuCommandService, OleMenuCommandService>();
             if (commandService == null)
@@ -121,6 +102,8 @@
 
         private void execHandler(object sender, EventArgs e)
         {
+            ThreadHelper.ThrowIfNotOnUIThread();
+
             var command = sender as OleMenuCommand;
             if (command == null)
                 return;
@@ -135,25 +118,11 @@
             case CommandId.ExportProFileProjectId:
                 ExtLoader.ExportProFile();
                 break;
-            case CommandId.CreateNewTsFileProjectId:
-                Translation.CreateNewTranslationFile(HelperFunctions.GetSelectedQtProject(QtVsToolsPackage
-                    .Instance.Dte));
-                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);
@@ -161,31 +130,14 @@
                     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);
-                        }
+                        Legacy.QtMenu.ShowFormProjectQtSettings(pro);
                     } 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);
-                            }
-                        }
-                    }
-                }
+            case CommandId.ChangeProjectQtVersionProjectId:
+                Legacy.QtMenu.ShowFormChangeProjectQtVersion();
                 break;
             case CommandId.ProjectConvertToQtMsBuild: {
                     QtMsBuildConverter.ProjectToQtMsBuild(
@@ -194,29 +146,8 @@
                 break;
             case CommandId.ProjectRefreshIntelliSense: {
                     var selectedProject = HelperFunctions.GetSelectedProject(QtVsToolsPackage.Instance.Dte);
-                    var tracker = QtProjectTracker.Get(selectedProject);
+                    var tracker = QtProjectTracker.Get(selectedProject, selectedProject.FullName);
                     QtProjectIntellisense.Refresh(tracker.Project);
-                }
-                break;
-            case CommandId.ProjectAddNewQtClassProjectId: {
-                    try {
-                        var project = HelperFunctions.GetSelectedProject(QtVsToolsPackage.Instance.Dte);
-                        if (!HelperFunctions.IsQtProject(project))
-                            return;
-
-                        var vcProject = project.Object as VCProject;
-                        if (vcProject == null)
-                            return;
-
-                        var loop = true;
-                        do {
-                            var classWizard = new Wizards.ClassWizard.AddClassWizard();
-                            loop = classWizard.Run(QtVsToolsPackage.Instance.Dte, vcProject.Name,
-                                vcProject.ProjectDirectory) == Wizards.WizardResult.Exception;
-                        } while (loop);
-                    } catch {
-                        // Deliberately ignore any kind of exception but close the dialog.
-                    }
                 }
                 break;
             }
@@ -229,8 +160,8 @@
                 return;
 
             var project = HelperFunctions.GetSelectedProject(QtVsToolsPackage.Instance.Dte);
-            var isQtProject = HelperFunctions.IsQtProject(project);
-            var isQMakeProject = HelperFunctions.IsQMakeProject(project);
+            var isQtProject = HelperFunctions.IsVsToolsProject(project);
+            var isQMakeProject = HelperFunctions.IsQtProject(project);
             var isQtMsBuildEnabled = QtProject.IsQtMsBuildEnabled(project);
 
             if (!isQtProject && !isQMakeProject) {
@@ -239,25 +170,19 @@
             }
 
             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:
-            case CommandId.CreateNewTsFileProjectId:
+                command.Visible = true;
+                command.Enabled = HelperFunctions.IsVsToolsProject(HelperFunctions
+                    .GetSelectedProject(QtVsToolsPackage.Instance.Dte));
+                break;
             case CommandId.lUpdateOnProjectId:
             case CommandId.lReleaseOnProjectId:
                 command.Visible = true;
-                command.Enabled = HelperFunctions.IsQtProject(HelperFunctions
-                    .GetSelectedProject(QtVsToolsPackage.Instance.Dte));
+                command.Enabled = Translation.ToolsAvailable(project);
                 break;
-            //case CommandId.ConvertToQmakeProjectId:
-            case CommandId.QtProjectSettingsProjectId:
-            case CommandId.ProjectAddNewQtClassProjectId: {
+            case CommandId.QtProjectSettingsProjectId: {
                     var status = vsCommandStatus.vsCommandStatusSupported;
                     if (project != null) {
                         if (isQtProject)
@@ -269,7 +194,6 @@
                     command.Visible = ((status & vsCommandStatus.vsCommandStatusInvisible) == 0);
                 }
                 break;
-            //case CommandId.ConvertToQtProjectId:
             case CommandId.ChangeProjectQtVersionProjectId: {
                     var status = vsCommandStatus.vsCommandStatusSupported;
                     if ((project == null) || isQtProject)

--
Gitblit v1.9.1