diff --git a/nvidiaProfileInspector/Common/Helper/UserSettings.cs b/nvidiaProfileInspector/Common/Helper/UserSettings.cs index 4e915e1..15b0a56 100644 --- a/nvidiaProfileInspector/Common/Helper/UserSettings.cs +++ b/nvidiaProfileInspector/Common/Helper/UserSettings.cs @@ -81,6 +81,9 @@ namespace nvidiaProfileInspector.Common.Helper // enabled as setting sources. public bool AllowMetaFromInactiveSources { get; set; } = true; + // Prefix the setting id to the setting name in the list. Off by default. + public bool ShowSettingIdInName { get; set; } = false; + private static string GetSettingsFilename() { var fiPortalbleSettings = new FileInfo("settings.xml"); diff --git a/nvidiaProfileInspector/UI/ViewModels/MainViewModel.cs b/nvidiaProfileInspector/UI/ViewModels/MainViewModel.cs index 560c9d6..a6bf66f 100644 --- a/nvidiaProfileInspector/UI/ViewModels/MainViewModel.cs +++ b/nvidiaProfileInspector/UI/ViewModels/MainViewModel.cs @@ -72,6 +72,7 @@ namespace nvidiaProfileInspector.UI.ViewModels private bool _addPredefinedAppListToCommon; private bool _addRawValueToCommon; private bool _allowMetaFromInactiveSources = true; + private bool _showSettingIdInName; private bool _isFilterMenuOpen; private DateTime _filterMenuClosedAt = DateTime.MinValue; private bool _isInitializing; @@ -287,6 +288,24 @@ namespace nvidiaProfileInspector.UI.ViewModels set { if (SetProperty(ref _allowMetaFromInactiveSources, value, nameof(AllowMetaFromInactiveSources))) OnSourceFilterChanged(); } } + // Setting-source sub-option: prefix the setting id to the name. Display only - just + // recomputes the cached DisplayName, no profile reload (keeps scroll perf intact). + public bool ShowSettingIdInName + { + get => _showSettingIdInName; + set + { + if (SetProperty(ref _showSettingIdInName, value, nameof(ShowSettingIdInName))) + { + if (_isInitializing) + return; + + ApplySettingIdInName(); + SaveFilterPreferences(); + } + } + } + // Availability flags used to disable flyout entries for sources that aren't present. public bool IsReferenceAvailable => _metaService?.HasReferenceSource ?? false; @@ -572,6 +591,7 @@ namespace nvidiaProfileInspector.UI.ViewModels public ICommand ImportProfileCommand { get; private set; } public ICommand OpenBitEditorCommand { get; private set; } public ICommand ResetValueCommand { get; private set; } + public ICommand CopySettingIdCommand { get; private set; } public ICommand CopySettingsCommand { get; private set; } public ICommand ToggleDevModeCommand { get; private set; } public ICommand NavigateToGlobalCommand { get; private set; } @@ -623,6 +643,7 @@ namespace nvidiaProfileInspector.UI.ViewModels ImportProfileCommand = new RelayCommand(ImportProfile); OpenBitEditorCommand = new RelayCommand(OpenBitEditor, () => SelectedSetting != null); ResetValueCommand = new RelayCommand(ResetValue); + CopySettingIdCommand = new RelayCommand(CopySettingId); CopySettingsCommand = new RelayCommand(CopySettingsToClipboard); ToggleDevModeCommand = new RelayCommand(ToggleDevMode); NavigateToGlobalCommand = new RelayCommand(_ => NavigateToGlobalProfile()); @@ -765,6 +786,8 @@ namespace nvidiaProfileInspector.UI.ViewModels _addPredefinedAppListToCommon = settings.AddPredefinedAppListToCommon; _addRawValueToCommon = settings.AddRawValueToCommon; _allowMetaFromInactiveSources = settings.AllowMetaFromInactiveSources; + _showSettingIdInName = settings.ShowSettingIdInName; + SettingItemViewModel.ShowSettingIdInName = _showSettingIdInName; ApplySourceFilters(); @@ -1036,6 +1059,9 @@ namespace nvidiaProfileInspector.UI.ViewModels private void RefreshCurrentProfile() { + // Make sure freshly built rows pick up the current "setting id in name" option. + SettingItemViewModel.ShowSettingIdInName = _showSettingIdInName; + // A freshly opened profile always starts collapsed to a single row. ApplicationsExpanded = false; Applications.Clear(); @@ -1662,6 +1688,30 @@ namespace nvidiaProfileInspector.UI.ViewModels ShowSnackbar("Settings copied to clipboard!", "Success"); } + // Double-click on a setting name copies its setting id to the clipboard. + private void CopySettingId(object parameter) + { + if (!(parameter is SettingItemViewModel item)) + return; + + try + { + Clipboard.SetText(item.SettingIdHex); + ShowSnackbar($"Setting ID {item.SettingIdHex} copied to clipboard.", "Success"); + } + catch + { + } + } + + // Re-applies the "setting id in name" option in place (no profile reload). + private void ApplySettingIdInName() + { + SettingItemViewModel.ShowSettingIdInName = _showSettingIdInName; + foreach (var setting in Settings) + setting.RefreshDisplayName(); + } + private void ToggleDevMode() { IsDevMode = !IsDevMode; @@ -1803,6 +1853,7 @@ namespace nvidiaProfileInspector.UI.ViewModels settings.AddPredefinedAppListToCommon = _addPredefinedAppListToCommon; settings.AddRawValueToCommon = _addRawValueToCommon; settings.AllowMetaFromInactiveSources = _allowMetaFromInactiveSources; + settings.ShowSettingIdInName = _showSettingIdInName; settings.SaveSettings(); } @@ -1825,6 +1876,7 @@ namespace nvidiaProfileInspector.UI.ViewModels _addPredefinedAppListToCommon = false; _addRawValueToCommon = false; _allowMetaFromInactiveSources = true; + _showSettingIdInName = false; OnPropertyChanged(nameof(SettingSourceCommon)); OnPropertyChanged(nameof(SettingSourceDriver)); @@ -1842,6 +1894,7 @@ namespace nvidiaProfileInspector.UI.ViewModels OnPropertyChanged(nameof(AddPredefinedAppListToCommon)); OnPropertyChanged(nameof(AddRawValueToCommon)); OnPropertyChanged(nameof(AllowMetaFromInactiveSources)); + OnPropertyChanged(nameof(ShowSettingIdInName)); ApplySourceFilters(); RefreshCurrentProfile(); diff --git a/nvidiaProfileInspector/UI/ViewModels/SettingItemViewModel.cs b/nvidiaProfileInspector/UI/ViewModels/SettingItemViewModel.cs index e3619dc..d9a8886 100644 --- a/nvidiaProfileInspector/UI/ViewModels/SettingItemViewModel.cs +++ b/nvidiaProfileInspector/UI/ViewModels/SettingItemViewModel.cs @@ -44,12 +44,27 @@ namespace nvidiaProfileInspector.UI.ViewModels _cachedGroupNameForDisplay = GroupName; } + // Set by the view model from the persisted filter option. Read only while (re)building + // the cached DisplayName, so there is no per-row cost while scrolling the list. + public static bool ShowSettingIdInName; + private void UpdateDisplayName() { - if (IsSettingHidden) - DisplayName = "[H] " + SettingText; - else - DisplayName = SettingText; + var name = IsSettingHidden ? "[H] " + SettingText : SettingText; + + // Optionally prefix the setting id, unless the name already is the hex id itself. + if (ShowSettingIdInName && !(SettingText != null && SettingText.StartsWith("0x", System.StringComparison.OrdinalIgnoreCase))) + name = SettingIdHex + " " + name; + + DisplayName = name; + } + + // Recompute the cached display name in place (used when the "show setting id" option + // toggles, avoiding a full profile reload). + public void RefreshDisplayName() + { + UpdateDisplayName(); + OnPropertyChanged(nameof(DisplayName)); } private void InvalidateValueNameItems() diff --git a/nvidiaProfileInspector/UI/Views/MainWindow.xaml b/nvidiaProfileInspector/UI/Views/MainWindow.xaml index 6d82177..e38562a 100644 --- a/nvidiaProfileInspector/UI/Views/MainWindow.xaml +++ b/nvidiaProfileInspector/UI/Views/MainWindow.xaml @@ -34,6 +34,7 @@ Fill="{DynamicResource TextSecondaryBrush}" Stretch="Uniform" /> @@ -42,6 +43,7 @@ + + + + ToolTipService.IsEnabled="{Binding DataContext.IsDevMode, RelativeSource={RelativeSource AncestorType=Window}}"> + + + +