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/QtItemContextMenu.cs |   41 +++++++++++++++++------------------------
 1 files changed, 17 insertions(+), 24 deletions(-)

diff --git a/QtVsTools.Package/Package/QtItemContextMenu.cs b/QtVsTools.Package/Package/QtItemContextMenu.cs
index 19bc389..ce4f888 100644
--- a/QtVsTools.Package/Package/QtItemContextMenu.cs
+++ b/QtVsTools.Package/Package/QtItemContextMenu.cs
@@ -26,15 +26,16 @@
 **
 ****************************************************************************/
 
-using EnvDTE;
-using Microsoft.VisualStudio.Shell;
-using QtVsTools.Core;
-using QtVsTools.VisualStudio;
 using System;
 using System.ComponentModel.Design;
+using Microsoft.VisualStudio.Shell;
+using EnvDTE;
 
 namespace QtVsTools
 {
+    using Core;
+    using VisualStudio;
+
     /// <summary>
     /// Command handler
     /// </summary>
@@ -43,30 +44,24 @@
         /// <summary>
         /// Command menu group (command set GUID).
         /// </summary>
-        public static readonly Guid ItemContextMenuGuid = new Guid("9f67a0bd-ee0a-47e3-b656-5efb12e3c770");
+        private static readonly Guid ItemContextMenuGuid = new Guid("9f67a0bd-ee0a-47e3-b656-5efb12e3c770");
 
         /// <summary>
         /// Gets the instance of the command.
         /// </summary>
-        public static QtItemContextMenu Instance
+        private static QtItemContextMenu 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 QtItemContextMenu(package);
+            Instance = new QtItemContextMenu();
         }
-
-        /// <summary>
-        /// VS Package that provides this command, not null.
-        /// </summary>
-        private readonly Package m_package;
 
         /// <summary>
         /// Command ID.
@@ -78,14 +73,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 QtItemContextMenu(Package package)
+        private QtItemContextMenu()
         {
-            if (package == null)
-                throw new ArgumentNullException("package");
-
-            m_package = package;
-
             var commandService = VsServiceProvider
                 .GetService<IMenuCommandService, OleMenuCommandService>();
             if (commandService == null)
@@ -104,6 +93,8 @@
 
         private void execHandler(object sender, EventArgs e)
         {
+            ThreadHelper.ThrowIfNotOnUIThread();
+
             var command = sender as OleMenuCommand;
             if (command == null)
                 return;
@@ -120,6 +111,8 @@
 
         private void beforeQueryStatus(object sender, EventArgs e)
         {
+            ThreadHelper.ThrowIfNotOnUIThread();
+
             var command = sender as OleMenuCommand;
             if (command == null)
                 return;
@@ -128,7 +121,7 @@
             command.Visible = false;
 
             var prj = HelperFunctions.GetSelectedProject(QtVsToolsPackage.Instance.Dte);
-            if (!HelperFunctions.IsQtProject(prj) || QtVsToolsPackage.Instance.Dte.SelectedItems.Count <= 0)
+            if (!HelperFunctions.IsVsToolsProject(prj) || QtVsToolsPackage.Instance.Dte.SelectedItems.Count <= 0)
                 return;
 
             foreach (SelectedItem si in QtVsToolsPackage.Instance.Dte.SelectedItems) {
@@ -136,7 +129,7 @@
                     return; // Don't display commands if one of the selected files is not a .ts file.
             }
 
-            command.Enabled = true;
+            command.Enabled = Translation.ToolsAvailable(prj);
             command.Visible = true;
         }
     }

--
Gitblit v1.9.1