option for show settingid in settings list + changed settings list and values to monospace font

This commit is contained in:
Orbmu2k
2026-06-30 13:26:31 +02:00
parent df10d971c2
commit 7b2f73e2b4
4 changed files with 97 additions and 5 deletions

View File

@@ -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");

View File

@@ -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();

View File

@@ -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()

View File

@@ -34,6 +34,7 @@
Fill="{DynamicResource TextSecondaryBrush}"
Stretch="Uniform" />
<TextBlock
FontFamily="Consolas"
Text="{Binding ValueName, Mode=OneWay}"
TextTrimming="CharacterEllipsis"
TextWrapping="NoWrap" />
@@ -42,6 +43,7 @@
<controls:SearchableComboBox x:Key="SharedValueEditorResource"
Padding="8,4"
FontFamily="Consolas"
HorizontalAlignment="Stretch"
Foreground="{Binding State, Converter={StaticResource StateToColorConverter}, Mode=OneWay}"
behaviors:SettingValueValidationBehavior.Enabled="True"
@@ -1350,6 +1352,17 @@
Text="Name &amp; description from inactive sources"
TextWrapping="Wrap" />
</CheckBox>
<CheckBox
IsChecked="{Binding ShowSettingIdInName}"
Style="{StaticResource FilterFlyoutCheckBoxStyle}"
ToolTip="Prefix the setting id to the setting name in the list (double-click a name to copy its id).">
<TextBlock
VerticalAlignment="Center"
FontSize="11"
Foreground="{DynamicResource TextSecondaryBrush}"
Text="Add setting ID to name"
TextWrapping="Wrap" />
</CheckBox>
<Border
Height="1"
@@ -1519,6 +1532,7 @@
<Grid Grid.Row="1">
<ListBox
x:Name="SettingsListView"
FontFamily="Consolas"
behaviors:GridViewColumnResizeBehavior.EnableStarSizing="True"
behaviors:GridViewColumnResizeBehavior.HexColumnWidth="200"
behaviors:GridViewColumnResizeBehavior.SettingColumnMinWidth="320"
@@ -1663,7 +1677,14 @@
Foreground="{Binding State, Converter={StaticResource StateToSettingIconColorConverter}, Mode=OneWay}"
Text="{Binding DisplayName, Mode=OneWay}"
ToolTip="{Binding SettingIdHex, Mode=OneWay}"
ToolTipService.IsEnabled="{Binding DataContext.IsDevMode, RelativeSource={RelativeSource AncestorType=Window}}" />
ToolTipService.IsEnabled="{Binding DataContext.IsDevMode, RelativeSource={RelativeSource AncestorType=Window}}">
<TextBlock.InputBindings>
<MouseBinding
Command="{Binding DataContext.CopySettingIdCommand, RelativeSource={RelativeSource AncestorType=Window}}"
CommandParameter="{Binding}"
Gesture="LeftDoubleClick" />
</TextBlock.InputBindings>
</TextBlock>
<Grid Grid.Column="3">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />