aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiguel Costa <miguel.costa@qt.io>2022-01-13 18:51:29 +0100
committerMiguel Costa <miguel.costa@qt.io>2022-01-19 11:34:10 +0000
commit8ee79b3bca7493281a26c1991ab49c7a7f41f8f5 (patch)
tree7118bedb0e5159c98a30f10fc2c1898ce6941eea
parentcbb58e226c27bcb3fbe7b8f0fdc8d4774fdf4088 (diff)
Show no-Qt-version message on the VS info bar
When starting VS, the extension will check if there are Qt versions registered. If not, a notification is displayed on the VS info bar, with a link to the Qt Versions options page. Fixes: QTVSADDINBUG-953 Change-Id: I92e275e4b8fe7d7443af64a7d733e8020782daab Reviewed-by: Karsten Heimrich <karsten.heimrich@qt.io> Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
-rw-r--r--QtVsTools.Package/Options/QtVersionsPage.cs3
-rw-r--r--QtVsTools.Package/Package/DteEventsHandler.cs17
-rw-r--r--QtVsTools.Package/Package/InfoBarMessages.cs64
-rw-r--r--QtVsTools.Package/QtVsTools.Package.csproj1
-rw-r--r--QtVsTools.Package/QtVsToolsPackage.cs6
5 files changed, 91 insertions, 0 deletions
diff --git a/QtVsTools.Package/Options/QtVersionsPage.cs b/QtVsTools.Package/Options/QtVersionsPage.cs
index db3d1d6f..e282369d 100644
--- a/QtVsTools.Package/Options/QtVersionsPage.cs
+++ b/QtVsTools.Package/Options/QtVersionsPage.cs
@@ -122,6 +122,9 @@ namespace QtVsTools.Options
Messages.Print(
exception.Message + "\r\n\r\nStacktrace:\r\n" + exception.StackTrace);
}
+
+ if (InfoBarMessages.NoQtVersion.IsOpen && VersionManager.GetVersions()?.Any() == true)
+ InfoBarMessages.NoQtVersion.Close();
}
protected override void OnApply(PageApplyEventArgs e)
diff --git a/QtVsTools.Package/Package/DteEventsHandler.cs b/QtVsTools.Package/Package/DteEventsHandler.cs
index 9bbc49ae..b8b833d6 100644
--- a/QtVsTools.Package/Package/DteEventsHandler.cs
+++ b/QtVsTools.Package/Package/DteEventsHandler.cs
@@ -56,6 +56,7 @@ namespace QtVsTools
private CommandEvents debugStartEvents;
private CommandEvents debugStartWithoutDebuggingEvents;
private CommandEvents f1HelpEvents;
+ private WindowEvents windowEvents;
private int dispId_VCFileConfiguration_ExcludedFromBuild;
private int dispId_VCCLCompilerTool_UsePrecompiledHeader;
private int dispId_VCCLCompilerTool_PrecompiledHeaderThrough;
@@ -85,6 +86,9 @@ namespace QtVsTools
solutionEvents.Opened += SolutionEvents_Opened;
solutionEvents.AfterClosing += SolutionEvents_AfterClosing;
+ windowEvents = events.WindowEvents;
+ windowEvents.WindowActivated += WindowEvents_WindowActivated;
+
var debugCommandsGUID = "{5EFC7975-14BC-11CF-9B2B-00AA00573819}";
debugStartEvents = events.get_CommandEvents(debugCommandsGUID, 295);
debugStartEvents.BeforeExecute += debugStartEvents_BeforeExecute;
@@ -105,6 +109,16 @@ namespace QtVsTools
InitializeVCProjects();
}
+ private void WindowEvents_WindowActivated(Window gotFocus, Window lostFocus)
+ {
+ ThreadHelper.ThrowIfNotOnUIThread();
+ if (dte.MainWindow?.Visible == true) {
+ windowEvents.WindowActivated -= WindowEvents_WindowActivated;
+ windowEvents = null;
+ QtVsToolsPackage.Instance.VsMainWindowActivated();
+ }
+ }
+
private void F1HelpEvents_BeforeExecute(
string Guid, int ID, object CustomIn, object CustomOut, ref bool CancelDefault)
{
@@ -176,6 +190,9 @@ namespace QtVsTools
if (vcProjectEngineEvents != null)
vcProjectEngineEvents.ItemPropertyChange -= OnVCProjectEngineItemPropertyChange;
+
+ if (windowEvents != null)
+ windowEvents.WindowActivated -= WindowEvents_WindowActivated;
}
public void OnBuildProjConfigBegin(string projectName, string projectConfig, string platform, string solutionConfig)
diff --git a/QtVsTools.Package/Package/InfoBarMessages.cs b/QtVsTools.Package/Package/InfoBarMessages.cs
new file mode 100644
index 00000000..b1042200
--- /dev/null
+++ b/QtVsTools.Package/Package/InfoBarMessages.cs
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2022 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt VS Tools.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+using System;
+using Microsoft.VisualStudio.Imaging;
+
+namespace QtVsTools
+{
+ using static VisualStudio.InfoBar;
+
+ internal static class InfoBarMessages
+ {
+ static IMessage _NoQtVersion = null;
+ public static IMessage NoQtVersion => _NoQtVersion ?? (
+ _NoQtVersion = new Message
+ {
+ Icon = KnownMonikers.StatusInformation,
+ Text = new TextSpan[]
+ {
+ new TextSpan { Bold = true, Text = "Qt Visual Studio Tools" },
+ new TextSpacer(2),
+ "\u2014", // Em dash
+ new TextSpacer(2),
+ "You must select a Qt version to use for development."
+ },
+ Hyperlinks = new Hyperlink[]
+ {
+ new Hyperlink
+ {
+ Text = "Select Qt version...",
+ CloseInfoBar = false,
+ OnClicked = () =>
+ QtVsToolsPackage.Instance.ShowOptionPage(typeof(Options.QtVersionsPage))
+ }
+ }
+ }
+ );
+ }
+}
diff --git a/QtVsTools.Package/QtVsTools.Package.csproj b/QtVsTools.Package/QtVsTools.Package.csproj
index 20247c84..c99d4be4 100644
--- a/QtVsTools.Package/QtVsTools.Package.csproj
+++ b/QtVsTools.Package/QtVsTools.Package.csproj
@@ -452,6 +452,7 @@
<Compile Include="Package\Translation.cs" />
<Compile Include="Package\TranslationItem.cs" />
<Compile Include="VisualStudio\InfoBar.cs" />
+ <Compile Include="Package\InfoBarMessages.cs" />
<Compile Include="VisualStudio\VsShell.cs" />
<Compile Include="Common\VsToolsDialogWindow.cs" />
<Content Include="..\Changelog">
diff --git a/QtVsTools.Package/QtVsToolsPackage.cs b/QtVsTools.Package/QtVsToolsPackage.cs
index 2b8d9d06..5fec3978 100644
--- a/QtVsTools.Package/QtVsToolsPackage.cs
+++ b/QtVsTools.Package/QtVsToolsPackage.cs
@@ -326,6 +326,12 @@ namespace QtVsTools
eventHandler.SolutionEvents_Opened();
}
+ public void VsMainWindowActivated()
+ {
+ if (QtVersionManager.The().GetVersions()?.Length == 0)
+ InfoBarMessages.NoQtVersion.Show();
+ }
+
protected override int QueryClose(out bool canClose)
{
if (eventHandler != null) {