| | |
| | | ****************************************************************************/
|
| | |
|
| | | using System;
|
| | | using System.ComponentModel.Design;
|
| | | using System.Diagnostics;
|
| | | using System.Diagnostics.CodeAnalysis;
|
| | | using System.Globalization;
|
| | | using System.IO;
|
| | | using System.Linq;
|
| | | using System.Net.Http;
|
| | | using System.Runtime.InteropServices;
|
| | | using System.Threading;
|
| | | using System.Threading.Tasks;
|
| | | using Task = System.Threading.Tasks.Task;
|
| | | using System.Windows.Forms;
|
| | | using Microsoft.VisualStudio;
|
| | | using Microsoft.VisualStudio.OLE.Interop;
|
| | | using Microsoft.VisualStudio.Settings;
|
| | | using Microsoft.VisualStudio.Shell;
|
| | | using Microsoft.VisualStudio.Shell.Interop;
|
| | |
| | | using Microsoft.Win32;
|
| | | using EnvDTE;
|
| | |
|
| | | using Task = System.Threading.Tasks.Task;
|
| | |
|
| | | namespace QtVsTools
|
| | | {
|
| | | using Core;
|
| | | using QtMsBuild;
|
| | | using SyntaxAnalysis;
|
| | | using static SyntaxAnalysis.RegExpr;
|
| | | using VisualStudio;
|
| | |
|
| | | using static SyntaxAnalysis.RegExpr;
|
| | |
|
| | | [Guid(QtVsToolsPackage.PackageGuidString)]
|
| | | [InstalledProductRegistration("#110", "#112", Version.PRODUCT_VERSION, IconResourceID = 400)]
|
| | |
| | | "Qt", "Versions", 0, 0, true, Sort = 1)]
|
| | |
|
| | | // Legacy options page
|
| | | [ProvideOptionPage(typeof(Options.QtLegacyOptionsPage),
|
| | | [ProvideOptionPage(typeof(Legacy.QtOptionsPage),
|
| | | "Qt", "Legacy Project Format", 0, 0, true, Sort = 2)]
|
| | |
|
| | | public sealed class QtVsToolsPackage : AsyncPackage, IVsServiceProvider, IProjectTracker
|
| | |
| | | public string PkgInstallPath { get; private set; }
|
| | | public Options.QtOptionsPage Options
|
| | | => GetDialogPage(typeof(Options.QtOptionsPage)) as Options.QtOptionsPage;
|
| | | public Options.QtLegacyOptionsPage LegacyOptions
|
| | | => GetDialogPage(typeof(Options.QtLegacyOptionsPage)) as Options.QtLegacyOptionsPage;
|
| | | public Legacy.QtOptionsPage LegacyOptions
|
| | | => GetDialogPage(typeof(Legacy.QtOptionsPage)) as Legacy.QtOptionsPage;
|
| | | public Editors.QtDesigner QtDesigner { get; private set; }
|
| | | public Editors.QtLinguist QtLinguist { get; private set; }
|
| | | public Editors.QtResourceEditor QtResourceEditor { get; private set; }
|
| | | private Editors.QtResourceEditor QtResourceEditor { get; set; }
|
| | |
|
| | | static EventWaitHandle initDone = new EventWaitHandle(false, EventResetMode.ManualReset);
|
| | | static readonly EventWaitHandle initDone = new EventWaitHandle(false, EventResetMode.ManualReset);
|
| | |
|
| | | static QtVsToolsPackage instance = null;
|
| | | public static QtVsToolsPackage Instance
|
| | |
| | | var timeInitBegin = initTimer.Elapsed;
|
| | | VsServiceProvider.Instance = instance = this;
|
| | | QtProject.ProjectTracker = this;
|
| | | Messages.JoinableTaskFactory = JoinableTaskFactory;
|
| | |
|
| | | // determine the package installation directory
|
| | | var uri = new Uri(System.Reflection.Assembly
|
| | |
| | | await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);
|
| | | var timeUiThreadBegin = initTimer.Elapsed;
|
| | |
|
| | | if ((Dte = VsServiceProvider.GetService<DTE>()) == null)
|
| | | if ((Dte = await VsServiceProvider.GetServiceAsync<DTE>()) == null)
|
| | | throw new Exception("Unable to get service: DTE");
|
| | |
|
| | | QtVSIPSettings.Options = Options;
|
| | |
| | | eventHandler = new DteEventsHandler(Dte);
|
| | |
|
| | | Qml.Debug.Launcher.Initialize();
|
| | | QtMainMenu.Initialize(this);
|
| | | QtSolutionContextMenu.Initialize(this);
|
| | | QtProjectContextMenu.Initialize(this);
|
| | | QtItemContextMenu.Initialize(this);
|
| | | QtMainMenu.Initialize();
|
| | | QtSolutionContextMenu.Initialize();
|
| | | QtProjectContextMenu.Initialize();
|
| | | QtItemContextMenu.Initialize();
|
| | | RegisterEditorFactory(QtDesigner = new Editors.QtDesigner());
|
| | | RegisterEditorFactory(QtLinguist = new Editors.QtLinguist());
|
| | | RegisterEditorFactory(QtResourceEditor = new Editors.QtResourceEditor());
|
| | | QtHelp.Initialize(this);
|
| | | QtHelp.Initialize();
|
| | |
|
| | | if (!string.IsNullOrEmpty(VsShell.InstallRootDir))
|
| | | HelperFunctions.VCPath = Path.Combine(VsShell.InstallRootDir, "VC");
|
| | |
| | | var timeUiThreadEnd = initTimer.Elapsed;
|
| | |
|
| | | var vm = QtVersionManager.The(initDone);
|
| | | var error = string.Empty;
|
| | | if (vm.HasInvalidVersions(out error))
|
| | | if (vm.HasInvalidVersions(out string error, out bool defaultInvalid)) {
|
| | | if (defaultInvalid)
|
| | | vm.SetLatestQtVersionAsDefault();
|
| | | Messages.Print(error);
|
| | | }
|
| | |
|
| | | ///////////
|
| | | // Install Qt/MSBuild files from package folder to standard location
|
| | |
| | | ================================================================",
|
| | | urlDownloadQtIo, devRelease));
|
| | | }
|
| | | } catch (Exception e) {
|
| | | Messages.Print(
|
| | | e.Message + "\r\n\r\nStacktrace:\r\n" + e.StackTrace);
|
| | | } catch (Exception exception) {
|
| | | exception.Log();
|
| | | } finally {
|
| | | initDone.Set();
|
| | | initTimer.Stop();
|
| | |
| | | eventHandler.SolutionEvents_Opened();
|
| | | }
|
| | |
|
| | | bool TestVersionInstalled()
|
| | | {
|
| | | bool newVersion = false;
|
| | | string versionFile = Path.Combine(PkgInstallPath, "lastversion.txt");
|
| | | if (File.Exists(versionFile)) {
|
| | | string lastVersion = File.ReadAllText(versionFile);
|
| | | newVersion = (lastVersion!= Version.PRODUCT_VERSION);
|
| | | } else {
|
| | | newVersion = true;
|
| | | }
|
| | | if (newVersion)
|
| | | File.WriteAllText(versionFile, Version.PRODUCT_VERSION);
|
| | | return newVersion;
|
| | | }
|
| | |
|
| | | public void VsMainWindowActivated()
|
| | | {
|
| | | if (QtVersionManager.The().GetVersions()?.Length == 0)
|
| | | Notifications.NoQtVersion.Show();
|
| | | if (Options.NotifyInstalled && TestVersionInstalled())
|
| | | Notifications.NotifyInstall.Show();
|
| | | }
|
| | |
|
| | | protected override int QueryClose(out bool canClose)
|
| | | {
|
| | | if (eventHandler != null) {
|
| | | ThreadHelper.ThrowIfNotOnUIThread();
|
| | |
|
| | | if (eventHandler != null)
|
| | | eventHandler.Disconnect();
|
| | | }
|
| | | return base.QueryClose(out canClose);
|
| | | }
|
| | |
|
| | |
| | |
|
| | | File.WriteAllText(Path.Combine(visualizersPath, natvisFile),
|
| | | natvis, System.Text.Encoding.UTF8);
|
| | | } catch (Exception e) {
|
| | | Messages.Print(
|
| | | e.Message + "\r\n\r\nStacktrace:\r\n" + e.StackTrace);
|
| | | } catch (Exception exception) {
|
| | | exception.Log();
|
| | | }
|
| | | }
|
| | |
|
| | | public string GetNatvisPath()
|
| | | {
|
| | | ThreadHelper.ThrowIfNotOnUIThread();
|
| | |
|
| | | try {
|
| | | using (var vsRootKey = Registry.CurrentUser.OpenSubKey(Dte.RegistryRoot)) {
|
| | | if (vsRootKey.GetValue("VisualStudioLocation") is string vsLocation)
|
| | |
| | |
|
| | | void IProjectTracker.AddProject(Project project)
|
| | | {
|
| | | ThreadHelper.ThrowIfNotOnUIThread();
|
| | | QtProjectTracker.Add(project);
|
| | | }
|
| | |
|