diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 08bbc04c55..e55d081c91 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -1,6 +1,5 @@ name: "🕷️ Bug report" description: Report errors or unexpected behavior -type: Bug labels: - Issue-Bug - Needs-Triage @@ -8,7 +7,8 @@ body: - type: markdown attributes: value: Please make sure to [search for existing issues](https://github.com/microsoft/PowerToys/issues) before filing a new one! -- type: input +- id: version + type: input attributes: label: Microsoft PowerToys version placeholder: X.XX.X @@ -16,7 +16,8 @@ body: validations: required: true -- type: dropdown +- id: installed + type: dropdown attributes: label: Installation method description: How / Where was PowerToys installed from? @@ -33,14 +34,6 @@ body: validations: required: true -- type: dropdown - attributes: - label: Running as admin - description: Are you running PowerToys as Admin? - options: - - "Yes" - - "No" - - type: dropdown attributes: label: Area(s) with issue? @@ -67,7 +60,7 @@ body: - Keyboard Manager - Mouse Utilities - Mouse Without Borders - - New+ + - New+ - Peek - PowerRename - PowerToys Run @@ -106,6 +99,19 @@ body: validations: required: false +- id: additionalInfo + type: textarea + attributes: + label: Additional Information + placeholder: | + OS version + .Net version + System Language + User or System Installation + Running as admin + validations: + required: false + - type: textarea attributes: label: Other Software @@ -116,3 +122,4 @@ body: My Cool Application v0.3 (include a code snippet if it would help!) validations: required: false + diff --git a/src/settings-ui/Settings.UI/SettingsXAML/Views/GeneralPage.xaml b/src/settings-ui/Settings.UI/SettingsXAML/Views/GeneralPage.xaml index fcd06e8292..079a634e97 100644 --- a/src/settings-ui/Settings.UI/SettingsXAML/Views/GeneralPage.xaml +++ b/src/settings-ui/Settings.UI/SettingsXAML/Views/GeneralPage.xaml @@ -458,7 +458,7 @@ - + diff --git a/src/settings-ui/Settings.UI/SettingsXAML/Views/GeneralPage.xaml.cs b/src/settings-ui/Settings.UI/SettingsXAML/Views/GeneralPage.xaml.cs index a7b0bcf5dc..b40a021252 100644 --- a/src/settings-ui/Settings.UI/SettingsXAML/Views/GeneralPage.xaml.cs +++ b/src/settings-ui/Settings.UI/SettingsXAML/Views/GeneralPage.xaml.cs @@ -84,6 +84,8 @@ namespace Microsoft.PowerToys.Settings.UI.Views DataContext = ViewModel; + ViewModel.InitializeReportBugLink(); + doRefreshBackupRestoreStatus(100); } diff --git a/src/settings-ui/Settings.UI/ViewModels/GeneralViewModel.cs b/src/settings-ui/Settings.UI/ViewModels/GeneralViewModel.cs index 3669681bb7..c535ffa579 100644 --- a/src/settings-ui/Settings.UI/ViewModels/GeneralViewModel.cs +++ b/src/settings-ui/Settings.UI/ViewModels/GeneralViewModel.cs @@ -9,6 +9,7 @@ using System.Diagnostics; using System.Globalization; using System.IO; using System.IO.Abstractions; +using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Text.Json; @@ -25,11 +26,19 @@ using Microsoft.PowerToys.Settings.UI.Library.Utilities; using Microsoft.PowerToys.Settings.UI.Library.ViewModels.Commands; using Microsoft.PowerToys.Settings.UI.SerializationContext; using Microsoft.PowerToys.Telemetry; +using Microsoft.Win32; +using Windows.System.Profile; namespace Microsoft.PowerToys.Settings.UI.ViewModels { public partial class GeneralViewModel : Observable { + public enum InstallScope + { + PerMachine = 0, + PerUser, + } + private GeneralSettings GeneralSettingsConfig { get; set; } private UpdatingSettings UpdatingSettingsConfig { get; set; } @@ -72,6 +81,8 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels private SettingsBackupAndRestoreUtils settingsBackupAndRestoreUtils = SettingsBackupAndRestoreUtils.Instance; + private const string InstallScopeRegKey = @"Software\Classes\powertoys\"; + public GeneralViewModel(ISettingsRepository settingsRepository, string runAsAdminText, string runAsUserText, bool isElevated, bool isAdmin, Func ipcMSGCallBackFunc, Func ipcMSGRestartAsAdminMSGCallBackFunc, Func ipcMSGCheckForUpdatesCallBackFunc, string configFileSubfolder = "", Action dispatcherAction = null, Action hideBackupAndRestoreMessageAreaAction = null, Action doBackupAndRestoreDryRun = null, Func> pickSingleFolderDialog = null, Windows.ApplicationModel.Resources.ResourceLoader resourceLoader = null) { CheckForUpdatesEventHandler = new ButtonClickCommand(CheckForUpdatesClick); @@ -256,6 +267,73 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels private int _initLanguagesIndex; private bool _languageChanged; + private string reportBugLink; + + // Gets or sets a value indicating whether run powertoys on start-up. + public string ReportBugLink + { + get => reportBugLink; + set + { + reportBugLink = value; + OnPropertyChanged(nameof(ReportBugLink)); + } + } + + public void InitializeReportBugLink() + { + var version = GetPowerToysVersion(); + + string isElevatedString = "PowerToys is running " + (IsElevated ? "as admin (elevated)" : "as user (non-elevated)"); + + string installScope = GetCurrentInstallScope() == InstallScope.PerMachine ? "per machine (system)" : "per user"; + + var info = $"OS Version: {GetOSVersion()} \n.NET Version: {GetDotNetVersion()}\n{isElevatedString}\nInstall scope: {installScope}\nOperating System Language: {CultureInfo.InstalledUICulture.DisplayName}\nSystem locale: {CultureInfo.InstalledUICulture.Name}"; + + var gitHubURL = "https://github.com/microsoft/PowerToys/issues/new?template=bug_report.yml&labels=Issue-Bug%2CTriage-Needed" + + "&version=" + version + "&additionalInfo=" + System.Web.HttpUtility.UrlEncode(info); + + ReportBugLink = gitHubURL; + } + + private string GetPowerToysVersion() + { + return Helper.GetProductVersion().TrimStart('v'); + } + + private string GetOSVersion() + { + return Environment.OSVersion.VersionString; + } + + public static string GetDotNetVersion() + { + return $".NET {Environment.Version}"; + } + + public static InstallScope GetCurrentInstallScope() + { + // Check HKLM first + if (Registry.LocalMachine.OpenSubKey(InstallScopeRegKey) != null) + { + return InstallScope.PerMachine; + } + + // If not found, check HKCU + var userKey = Registry.CurrentUser.OpenSubKey(InstallScopeRegKey); + if (userKey != null) + { + var installScope = userKey.GetValue("InstallScope") as string; + userKey.Close(); + if (!string.IsNullOrEmpty(installScope) && installScope.Contains("perUser")) + { + return InstallScope.PerUser; + } + } + + return InstallScope.PerMachine; // Default if no specific registry key found + } + // Gets or sets a value indicating whether run powertoys on start-up. public bool Startup {