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/QtMainMenu.cs |  115 +++++++++++++++++----------------------------------------
 1 files changed, 34 insertions(+), 81 deletions(-)

diff --git a/QtVsTools.Package/Package/QtMainMenu.cs b/QtVsTools.Package/Package/QtMainMenu.cs
index 2c8e90d..7298333 100644
--- a/QtVsTools.Package/Package/QtMainMenu.cs
+++ b/QtVsTools.Package/Package/QtMainMenu.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,16 +26,17 @@
 **
 ****************************************************************************/
 
-using EnvDTE;
-using Microsoft.VisualStudio.Shell;
-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 VisualStudio;
+
     /// <summary>
     /// Command handler
     /// </summary>
@@ -44,24 +45,23 @@
         /// <summary>
         /// Command menu group (command set GUID).
         /// </summary>
-        public static readonly Guid MainMenuGuid = new Guid("58f83fff-d39d-4c66-810b-2702e1f04e73");
+        private static readonly Guid MainMenuGuid = new Guid("58f83fff-d39d-4c66-810b-2702e1f04e73");
 
         /// <summary>
         /// Gets the instance of the command.
         /// </summary>
-        public static QtMainMenu Instance
+        private static QtMainMenu 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 QtMainMenu(package);
+            Instance = new QtMainMenu();
         }
 
         /// <summary>
@@ -71,16 +71,14 @@
         {
             QtVersionId = 0x0500,
             ViewQtHelpId = 0x0501,
+            ViewGettingStartedId = 0x0503,
             LaunchDesignerId = 0x0100,
             LaunchLinguistId = 0x0101,
             OpenProFileId = 0x0102,
             ImportPriFileId = 0x0103,
             ExportPriFileId = 0x0104,
             ExportProFileId = 0x0105,
-            CreateNewTsFileId = 0x0107,
             ConvertToQtMsBuild = 0x0130,
-            ConvertToQtId = 0x0124,
-            ConvertToQmakeId = 0x0108,
             QtProjectSettingsId = 0x0109,
             ChangeProjectQtVersionId = 0x0126,
             QtOptionsId = 0x0110,
@@ -88,22 +86,12 @@
         }
 
         /// <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 QtMainMenu(Package package)
+        private QtMainMenu()
         {
-            if (package == null)
-                throw new ArgumentNullException("package");
-
-            m_package = package;
-
             var commandService = VsServiceProvider
                 .GetService<IMenuCommandService, OleMenuCommandService>();
             if (commandService == null)
@@ -119,6 +107,8 @@
 
         private void execHandler(object sender, EventArgs e)
         {
+            ThreadHelper.ThrowIfNotOnUIThread();
+
             var command = sender as OleMenuCommand;
             if (command == null)
                 return;
@@ -126,6 +116,9 @@
             switch ((CommandId)command.CommandID.ID) {
             case CommandId.ViewQtHelpId:
                 VsShellUtilities.OpenSystemBrowser("https://www.qt.io/developers");
+                break;
+            case CommandId.ViewGettingStartedId:
+                VsShellUtilities.OpenSystemBrowser("https://doc.qt.io/qtvstools/qtvstools-getting-started.html");
                 break;
             case CommandId.LaunchDesignerId:
                 QtVsToolsPackage.Instance.QtDesigner.Start(hideWindow: false);
@@ -145,23 +138,8 @@
             case CommandId.ExportProFileId:
                 ExtLoader.ExportProFile();
                 break;
-            case CommandId.CreateNewTsFileId:
-                Translation.CreateNewTranslationFile(HelperFunctions.GetSelectedQtProject(QtVsToolsPackage
-                    .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(QtVsToolsPackage
-                            .Instance.Dte));
-                    }
-                }
-                break;
-            case CommandId.ConvertToQtMsBuild: {
-                    QtMsBuildConverter.SolutionToQtMsBuild();
-                }
+            case CommandId.ConvertToQtMsBuild:
+                QtMsBuildConverter.SolutionToQtMsBuild();
                 break;
             case CommandId.QtProjectSettingsId: {
                     var pro = HelperFunctions.GetSelectedQtProject(QtVsToolsPackage.Instance.Dte);
@@ -169,31 +147,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.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);
-                            }
-                        }
-                    }
-                }
+            case CommandId.ChangeProjectQtVersionId:
+                Legacy.QtMenu.ShowFormChangeProjectQtVersion();
                 break;
             case CommandId.QtOptionsId:
                 QtVsToolsPackage.Instance.ShowOptionPage(typeof(Options.QtOptionsPage));
@@ -206,12 +167,17 @@
 
         private void beforeQueryStatus(object sender, EventArgs e)
         {
+            ThreadHelper.ThrowIfNotOnUIThread();
+
             var command = sender as OleMenuCommand;
             if (command == null)
                 return;
 
+            var project = HelperFunctions.GetSelectedProject(QtVsToolsPackage.Instance.Dte);
+
             switch ((CommandId)command.CommandID.ID) {
             case CommandId.ViewQtHelpId:
+            case CommandId.ViewGettingStartedId:
                 command.Visible = command.Enabled = true;
                 break;
             case CommandId.QtVersionId:
@@ -230,39 +196,26 @@
             case CommandId.ImportPriFileId:
             case CommandId.ExportPriFileId:
             case CommandId.ExportProFileId:
-            case CommandId.CreateNewTsFileId: {
-                    command.Visible = true;
-                    command.Enabled = HelperFunctions.IsQtProject(HelperFunctions
-                        .GetSelectedProject(QtVsToolsPackage.Instance.Dte));
-                }
+                command.Visible = true;
+                command.Enabled = HelperFunctions.IsVsToolsProject(project);
                 break;
-            // TODO: Fix these functionality and re-enable the menu items
-            case CommandId.ConvertToQtId:
-            case CommandId.ConvertToQmakeId: {
-                    command.Visible = false;
-                }
-                break;
-            //case CommandId.ConvertToQmakeId:
             case CommandId.QtProjectSettingsId: {
                     var status = vsCommandStatus.vsCommandStatusSupported;
-                    var project = HelperFunctions.GetSelectedProject(QtVsToolsPackage.Instance.Dte);
                     if (project != null) {
-                        if (HelperFunctions.IsQtProject(project))
+                        if (HelperFunctions.IsVsToolsProject(project))
                             status |= vsCommandStatus.vsCommandStatusEnabled;
-                        else if (HelperFunctions.IsQMakeProject(project))
+                        else if (HelperFunctions.IsQtProject(project))
                             status |= vsCommandStatus.vsCommandStatusInvisible;
                     }
                     command.Enabled = ((status & vsCommandStatus.vsCommandStatusEnabled) != 0);
                     command.Visible = ((status & vsCommandStatus.vsCommandStatusInvisible) == 0);
                 }
                 break;
-            //case CommandId.ConvertToQtId:
             case CommandId.ChangeProjectQtVersionId: {
                     var status = vsCommandStatus.vsCommandStatusSupported;
-                    var project = HelperFunctions.GetSelectedProject(QtVsToolsPackage.Instance.Dte);
-                    if ((project == null) || HelperFunctions.IsQtProject(project))
+                    if ((project == null) || HelperFunctions.IsVsToolsProject(project))
                         status |= vsCommandStatus.vsCommandStatusInvisible;
-                    else if (HelperFunctions.IsQMakeProject(project))
+                    else if (HelperFunctions.IsQtProject(project))
                         status |= vsCommandStatus.vsCommandStatusEnabled;
                     else
                         status |= vsCommandStatus.vsCommandStatusInvisible;

--
Gitblit v1.9.1