aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiguel Costa <miguel.costa@qt.io>2021-02-11 19:33:54 +0100
committerMiguel Costa <miguel.costa@qt.io>2021-03-03 09:21:54 +0000
commitfff087334743b7977d2443c4d95883801d0fb14c (patch)
tree32d187513485ceb61244f84897640113bf0be7d1
parent096a7ecfa2043c080ede605c01970aba74a7221a (diff)
Rework online help
Made several changes to the Qt online help feature: * Preference of help source (online vs. offline) is now configured in the Qt options page. * Moved the "View Qt Help" menu item on the VS top-level Help menu into the add-in menu; selecting this option will open a browser and navigate to qt.io; the menu item text will now make this explicit. * Fixed a bug where, if searching in the online help produced more than one result, no page would be shown Task-number: QTVSADDINBUG-698 Task-number: QTVSADDINBUG-851 Change-Id: I230674332a9ed3bb6bbb735c9f996edbe46d1648 Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
-rw-r--r--src/qtvstools.core/QtVSIPSettings.cs1
-rw-r--r--src/qtvstools/Options/QtOptionsPage.cs15
-rw-r--r--src/qtvstools/QtHelp.cs (renamed from src/qtvstools/QtHelpMenu.cs)83
-rw-r--r--src/qtvstools/QtMainMenu.cs7
-rw-r--r--src/qtvstools/QtMenus.vsct_TT81
-rw-r--r--src/qtvstools/QtVsTools.csproj2
-rw-r--r--src/qtvstools/Vsix.cs2
7 files changed, 61 insertions, 130 deletions
diff --git a/src/qtvstools.core/QtVSIPSettings.cs b/src/qtvstools.core/QtVSIPSettings.cs
index ea856b5e..25a09f42 100644
--- a/src/qtvstools.core/QtVSIPSettings.cs
+++ b/src/qtvstools.core/QtVSIPSettings.cs
@@ -41,6 +41,7 @@ namespace QtVsTools.Core
int QmlDebuggerTimeout { get; }
bool RefreshIntelliSenseOnBuild { get; }
bool RefreshIntelliSenseOnUiFile { get; }
+ bool HelpPreferenceOnline { get; }
}
public static class QtVSIPSettings
diff --git a/src/qtvstools/Options/QtOptionsPage.cs b/src/qtvstools/Options/QtOptionsPage.cs
index 9c9e852a..b263cb70 100644
--- a/src/qtvstools/Options/QtOptionsPage.cs
+++ b/src/qtvstools/Options/QtOptionsPage.cs
@@ -58,6 +58,11 @@ namespace QtVsTools.Options
[String("IntelliSense_OnUiFile")] OnUiFile
}
+ public enum Help
+ {
+ [String("Help_Preference")] Preference
+ }
+
public enum Timeout : uint { Disabled = 0 }
class TimeoutConverter : EnumConverter
@@ -122,6 +127,12 @@ namespace QtVsTools.Options
[DisplayName("Refresh after changes to UI file")]
public bool RefreshIntelliSenseOnUiFile { get; set; }
+ [Category("Help")]
+ [DisplayName("Preferred source")]
+ public QtHelp.SourcePreference HelpPreference { get; set; }
+ bool IQtVsToolsOptions.HelpPreferenceOnline
+ => (HelpPreference == QtHelp.SourcePreference.Online);
+
public override void ResetSettings()
{
QtMsBuildPath = "";
@@ -129,6 +140,7 @@ namespace QtVsTools.Options
QmlDebuggerTimeout = (Timeout)60000;
RefreshIntelliSenseOnBuild = true;
RefreshIntelliSenseOnUiFile = true;
+ HelpPreference = QtHelp.SourcePreference.Online;
}
public override void LoadSettingsFromStorage()
@@ -149,6 +161,8 @@ namespace QtVsTools.Options
RefreshIntelliSenseOnBuild = (iSenseOnBuild != 0);
if (key.GetValue(IntelliSense.OnUiFile.Cast<string>()) is int iSenseOnUiFile)
RefreshIntelliSenseOnUiFile = (iSenseOnUiFile != 0);
+ if (key.GetValue(Help.Preference.Cast<string>()) is string preference)
+ HelpPreference = EnumExt.Cast(preference, QtHelp.SourcePreference.Online);
}
} catch (Exception exception) {
Messages.Print(
@@ -177,6 +191,7 @@ namespace QtVsTools.Options
RefreshIntelliSenseOnBuild ? 1 : 0);
key.SetValue(IntelliSense.OnUiFile.Cast<string>(),
RefreshIntelliSenseOnUiFile ? 1 : 0);
+ key.SetValue(Help.Preference.Cast<string>(), HelpPreference.Cast<string>());
}
} catch (Exception exception) {
Messages.Print(
diff --git a/src/qtvstools/QtHelpMenu.cs b/src/qtvstools/QtHelp.cs
index 19ad458d..d7be9115 100644
--- a/src/qtvstools/QtHelpMenu.cs
+++ b/src/qtvstools/QtHelp.cs
@@ -43,9 +43,11 @@ using System.Linq;
namespace QtVsTools
{
- internal sealed class QtHelpMenu
+ public class QtHelp
{
- public static QtHelpMenu Instance
+ public enum SourcePreference { Online, Offline }
+
+ public static QtHelp Instance
{
get;
private set;
@@ -53,18 +55,15 @@ namespace QtVsTools
public static void Initialize(Package package)
{
- Instance = new QtHelpMenu(package);
+ Instance = new QtHelp(package);
}
- const int F1QtHelpId = 0x0100;
- const int ViewQtHelpId = 0x0101;
- const int OnlineDocumentationId = 0x0102;
- const int OfflineDocumentationId = 0x0103;
+ const int F1QtHelpId = 0x0502;
readonly Package package;
- static readonly Guid HelpMenuGroupGuid = new Guid("fc6244f9-ec84-4370-a59c-b009b2eafd1b");
+ public static readonly Guid MainMenuGuid = new Guid("58f83fff-d39d-4c66-810b-2702e1f04e73");
- QtHelpMenu(Package pkg)
+ QtHelp(Package pkg)
{
if (pkg == null)
throw new ArgumentNullException("package");
@@ -75,21 +74,8 @@ namespace QtVsTools
if (commandService == null)
return;
- var menuCommandID = new CommandID(HelpMenuGroupGuid, F1QtHelpId);
+ var menuCommandID = new CommandID(MainMenuGuid, F1QtHelpId);
commandService.AddCommand(new MenuCommand(F1QtHelpCallback, menuCommandID));
-
- menuCommandID = new CommandID(HelpMenuGroupGuid, ViewQtHelpId);
- commandService.AddCommand(new MenuCommand(ViewQtHelpCallback, menuCommandID));
-
- var command = new OleMenuCommand(ExecHandler, new CommandID(HelpMenuGroupGuid,
- OfflineDocumentationId));
- command.BeforeQueryStatus += BeforeQueryStatus;
- commandService.AddCommand(command);
-
- command = new OleMenuCommand(ExecHandler, new CommandID(HelpMenuGroupGuid,
- OnlineDocumentationId));
- command.BeforeQueryStatus += BeforeQueryStatus;
- commandService.AddCommand(command);
}
IServiceProvider ServiceProvider
@@ -141,11 +127,6 @@ namespace QtVsTools
return string.Empty;
}
- void ViewQtHelpCallback(object sender, EventArgs args)
- {
- VsShellUtilities.OpenSystemBrowser("https://www.qt.io/developers");
- }
-
async void F1QtHelpCallback(object sender, EventArgs args)
{
try {
@@ -200,9 +181,7 @@ namespace QtVsTools
return;
var settingsManager = VsShellSettings.Manager;
- var store = settingsManager.GetReadOnlySettingsStore(SettingsScope.UserSettings);
- var offline =
- store.GetBoolean(Statics.HelpPreferencePath, Statics.HelpPreferenceKey, true);
+ var offline = Vsix.Instance.Options.HelpPreference == SourcePreference.Offline;
var linksForKeyword = string.Format("SELECT d.Title, f.Name, e.Name, "
+ "d.Name, a.Anchor FROM IndexTable a, FileNameTable d, FolderTable e, "
@@ -274,8 +253,8 @@ namespace QtVsTools
string.Empty, OLEMSGICON.OLEMSGICON_INFO, OLEMSGBUTTON.OLEMSGBUTTON_OK,
OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
} else {
- if (uri.StartsWith("file:///", StringComparison.Ordinal)
- && !File.Exists(uri.Substring("file:///".Length))) {
+ var helpUri = new Uri(uri.Replace('\\', '/'));
+ if (helpUri.IsFile && !File.Exists(helpUri.LocalPath)) {
VsShellUtilities.ShowMessageBox(Instance.ServiceProvider,
"Your search - " + keyword + " - did match a document, but it could "
+ "not be found on disk. To use the online help, select: "
@@ -286,41 +265,9 @@ namespace QtVsTools
VsShellUtilities.OpenSystemBrowser(HelperFunctions.ChangePathFormat(uri));
}
}
- } catch { }
- }
-
- void ExecHandler(object sender, EventArgs e)
- {
- var command = sender as OleMenuCommand;
- if (command == null)
- return;
-
- var settingsManager = VsShellSettings.Manager;
- var store = settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings);
- store.CreateCollection(Statics.HelpPreferencePath);
-
- var value = command.CommandID.ID == OfflineDocumentationId;
- store.SetBoolean(Statics.HelpPreferencePath, Statics.HelpPreferenceKey, value);
- }
-
- void BeforeQueryStatus(object sender, EventArgs e)
- {
- var command = sender as OleMenuCommand;
- if (command == null)
- return;
-
- var settingsManager = VsShellSettings.Manager;
- var store = settingsManager.GetReadOnlySettingsStore(SettingsScope.UserSettings);
-
- switch (command.CommandID.ID) {
- case OnlineDocumentationId:
- command.Checked = !store.GetBoolean(Statics.HelpPreferencePath,
- Statics.HelpPreferenceKey, false);
- break;
- case OfflineDocumentationId:
- command.Checked = store.GetBoolean(Statics.HelpPreferencePath,
- Statics.HelpPreferenceKey, true);
- break;
+ } catch (Exception e) {
+ Messages.Print(
+ e.Message + "\r\n\r\nStacktrace:\r\n" + e.StackTrace);
}
}
}
diff --git a/src/qtvstools/QtMainMenu.cs b/src/qtvstools/QtMainMenu.cs
index d2bfb3ef..a5114024 100644
--- a/src/qtvstools/QtMainMenu.cs
+++ b/src/qtvstools/QtMainMenu.cs
@@ -70,6 +70,7 @@ namespace QtVsTools
private enum CommandId
{
QtVersionId = 0x0500,
+ ViewQtHelpId = 0x0501,
LaunchDesignerId = 0x0100,
LaunchLinguistId = 0x0101,
OpenProFileId = 0x0102,
@@ -131,6 +132,9 @@ namespace QtVsTools
return;
switch ((CommandId) command.CommandID.ID) {
+ case CommandId.ViewQtHelpId:
+ VsShellUtilities.OpenSystemBrowser("https://www.qt.io/developers");
+ break;
case CommandId.LaunchDesignerId:
Vsix.Instance.QtDesigner.Start(hideWindow: false);
break;
@@ -219,6 +223,9 @@ namespace QtVsTools
return;
switch ((CommandId) command.CommandID.ID) {
+ case CommandId.ViewQtHelpId:
+ command.Visible = command.Enabled = true;
+ break;
case CommandId.QtVersionId:
command.Text = "Qt Visual Studio Tools version " + Version.USER_VERSION;
command.Visible = true;
diff --git a/src/qtvstools/QtMenus.vsct_TT b/src/qtvstools/QtMenus.vsct_TT
index 90624f6c..8c213922 100644
--- a/src/qtvstools/QtMenus.vsct_TT
+++ b/src/qtvstools/QtMenus.vsct_TT
@@ -81,13 +81,6 @@
</Strings>
</Menu>
- <Menu guid="HelpMenuGroupGuid" id="HelpMenuSubMenuId" priority="0x0700" type="Menu">
- <Parent guid="HelpMenuGroupGuid" id="HelpMenuGroupId" />
- <Strings>
- <ButtonText>Set Qt Help Preference</ButtonText>
- </Strings>
- </Menu>
-
<Menu guid="ProjectContextMenuGuid" id="QtSubMenu" priority="0x0100" type="Menu">
<Parent guid="ProjectContextMenuGuid" id="QtSubMenuGroup" />
<Strings>
@@ -163,14 +156,6 @@
<Parent guid="guidSHLMainMenu" id="IDM_VS_CTXT_ITEMNODE" />
</Group>
- <Group guid="HelpMenuGroupGuid" id="HelpMenuGroupId" priority="0x0600">
- <Parent guid="guidSHLMainMenu" id="IDM_VS_MENU_HELP"/>
- </Group>
-
- <Group guid="HelpMenuGroupGuid" id="HelpMenuSubGroupId" priority="0x0600">
- <Parent guid="HelpMenuGroupGuid" id="HelpMenuSubMenuId"/>
- </Group>
-
</Groups>
<!--
@@ -205,6 +190,24 @@
</Strings>
</Button>
+ <Button guid="MainMenuGuid" id="ViewQtHelpId" priority="0x0100" type="Button">
+ <Parent guid="MainMenuGuid" id="VersionMenuGroup" />
+ <Icon guid="MenuImages" id="QtLogoBitmap" />
+ <CommandFlag>DynamicVisibility</CommandFlag>
+ <CommandFlag>DefaultInvisible</CommandFlag>
+ <Strings>
+ <ButtonText>qt.io</ButtonText>
+ </Strings>
+ </Button>
+
+ <Button guid="MainMenuGuid" id="F1QtHelpId" priority="0x0100" type="Button">
+ <Parent guid="MainMenuGuid" id="VersionMenuGroup" />
+ <CommandFlag>DefaultInvisible</CommandFlag>
+ <Strings>
+ <ButtonText>F1 Qt Help</ButtonText>
+ </Strings>
+ </Button>
+
<Button guid="MainMenuGuid" id="LaunchDesignerId" priority="0x0100" type="Button">
<Parent guid="MainMenuGuid" id="LaunchMenuGroup" />
<Icon guid="MenuImages" id="LaunchDesignerBitmap" />
@@ -540,38 +543,6 @@
<!-- Endregion Item context menu buttons -->
- <Button guid="HelpMenuGroupGuid" id="F1QtHelpId" priority="0x0100" type="Button">
- <Parent guid="HelpMenuGroupGuid" id="HelpMenuGroupId" />
- <CommandFlag>DefaultInvisible</CommandFlag>
- <Strings>
- <ButtonText>F1 Qt Help</ButtonText>
- </Strings>
- </Button>
-
- <Button guid="HelpMenuGroupGuid" id="ViewQtHelpId" priority="0x0100" type="Button">
- <Parent guid="HelpMenuGroupGuid" id="HelpMenuGroupId" />
- <Icon guid="MenuImages" id="QtLogoBitmap" />
- <Strings>
- <ButtonText>View Qt Help</ButtonText>
- </Strings>
- </Button>
-
- <Button guid="HelpMenuGroupGuid" id="OnlineDocumentationId" priority="0x0100" type="Button">
- <Parent guid="HelpMenuGroupGuid" id="HelpMenuSubGroupId" />
- <CommandFlag>DefaultDisabled</CommandFlag>
- <Strings>
- <ButtonText>Use Online Documentation</ButtonText>
- </Strings>
- </Button>
-
- <Button guid="HelpMenuGroupGuid" id="OfflineDocumentationId" priority="0x0100" type="Button">
- <Parent guid="HelpMenuGroupGuid" id="HelpMenuSubGroupId" />
- <CommandFlag>DefaultDisabled</CommandFlag>
- <Strings>
- <ButtonText>Use Offline Documentation</ButtonText>
- </Strings>
- </Button>
-
</Buttons>
<!-- The bitmaps section is used to define the bitmaps that are used for the commands. -->
@@ -603,6 +574,8 @@
<IDSymbol name="VersionMenuGroup" value="0x5021" />
<IDSymbol name="QtVersionId" value="0x0500" />
+ <IDSymbol name="ViewQtHelpId" value="0x0501" />
+ <IDSymbol name="F1QtHelpId" value="0x0502" />
<IDSymbol name="LaunchMenuGroup" value="0x1021" />
<IDSymbol name="LaunchDesignerId" value="0x0100" />
@@ -685,18 +658,6 @@
</GuidSymbol>
- <GuidSymbol name="HelpMenuGroupGuid" value="{fc6244f9-ec84-4370-a59c-b009b2eafd1b}">
-
- <IDSymbol name="HelpMenuGroupId" value="0x1040" />
- <IDSymbol name="HelpMenuSubMenuId" value="0x1050" />
- <IDSymbol name="HelpMenuSubGroupId" value="0x1060" />
- <IDSymbol name="F1QtHelpId" value="0x0100" />
- <IDSymbol name="ViewQtHelpId" value="0x0101" />
- <IDSymbol name="OnlineDocumentationId" value="0x0102" />
- <IDSymbol name="OfflineDocumentationId" value="0x0103" />
-
- </GuidSymbol>
-
<GuidSymbol name="MenuImages" value="{d7cf9f1c-0f37-4609-8eb3-72589dc5a5ec}" >
<IDSymbol name="LaunchDesignerBitmap" value="1" />
<IDSymbol name="LaunchLinguistBitmap" value="2" />
@@ -725,6 +686,6 @@
</VisibilityConstraints>
<KeyBindings>
- <KeyBinding guid="HelpMenuGroupGuid" id="F1QtHelpId" key1="VK_F1" mod1="ALT" editor="guidVSStd97" />
+ <KeyBinding guid="MainMenuGuid" id="F1QtHelpId" key1="VK_F1" mod1="ALT" editor="guidVSStd97" />
</KeyBindings>
</CommandTable>
diff --git a/src/qtvstools/QtVsTools.csproj b/src/qtvstools/QtVsTools.csproj
index ddcc1368..a2d22095 100644
--- a/src/qtvstools/QtVsTools.csproj
+++ b/src/qtvstools/QtVsTools.csproj
@@ -155,7 +155,7 @@
<Compile Include="QtHelpLinkChooser.xaml.cs">
<DependentUpon>QtHelpLinkChooser.xaml</DependentUpon>
</Compile>
- <Compile Include="QtHelpMenu.cs" />
+ <Compile Include="QtHelp.cs" />
<Compile Include="QtItemContextMenu.cs" />
<Compile Include="QtMainMenu.cs" />
<Compile Include="QtMsBuildConverter.cs" />
diff --git a/src/qtvstools/Vsix.cs b/src/qtvstools/Vsix.cs
index 10f5c8e9..768ad305 100644
--- a/src/qtvstools/Vsix.cs
+++ b/src/qtvstools/Vsix.cs
@@ -207,7 +207,7 @@ namespace QtVsTools
RegisterEditorFactory(QtDesigner = new Editors.QtDesigner());
RegisterEditorFactory(QtLinguist = new Editors.QtLinguist());
RegisterEditorFactory(QtResourceEditor = new Editors.QtResourceEditor());
- QtHelpMenu.Initialize(this);
+ QtHelp.Initialize(this);
if (!string.IsNullOrEmpty(VsShell.InstallRootDir))
HelperFunctions.VCPath = Path.Combine(VsShell.InstallRootDir, "VC");