Rename and organize config values

This commit is contained in:
whimsical-c4lic0 2026-02-17 22:23:43 -06:00
parent ac1c814633
commit 56b951ace0
4 changed files with 104 additions and 93 deletions

View File

@ -105,8 +105,11 @@ public class Config : IFileNameFormatConfig
[ToggleableConfig] public bool DisableTextSanitization { get; set; }
public string? PaidPostFileNameFormat { get; set; } = "";
public string? PostFileNameFormat { get; set; } = "";
public string? PaidMessageFileNameFormat { get; set; } = "";
public string? MessageFileNameFormat { get; set; } = "";
public IFileNameFormatConfig GetCreatorFileNameFormatConfig(string username)

View File

@ -48,6 +48,18 @@ public partial class ConfigFieldViewModel : ViewModelBase
["dark"] = "Dark"
};
private static readonly Dictionary<string, string> s_displayNameOverridesByProperty =
new(StringComparer.Ordinal)
{
[nameof(Config.PostFileNameFormat)] = "Free Post File Name Format",
[nameof(Config.MessageFileNameFormat)] = "Free Message File Name Format",
[nameof(Config.DownloadVideoResolution)] = "Video Resolution",
[nameof(Config.IgnoredUsersListName)] = "Ignored Users List",
[nameof(Config.RenameExistingFilesWhenCustomFormatIsSelected)] =
"Rename Existing Files with Custom Formats",
[nameof(Config.DownloadPath)] = "Download Folder"
};
public ConfigFieldViewModel(
PropertyInfo propertyInfo,
object? initialValue,
@ -56,7 +68,7 @@ public partial class ConfigFieldViewModel : ViewModelBase
{
PropertyInfo = propertyInfo;
PropertyName = propertyInfo.Name;
DisplayName = ToDisplayName(propertyInfo.Name);
DisplayName = GetDisplayName(propertyInfo.Name);
PropertyType = propertyInfo.PropertyType;
HelpText = helpText?.Trim() ?? string.Empty;
@ -86,7 +98,8 @@ public partial class ConfigFieldViewModel : ViewModelBase
}
SelectedFileNameVariable = AvailableFileNameVariables.FirstOrDefault();
string availableVariables = string.Join(", ", AvailableFileNameVariables.Select(variable => $"{{{variable}}}"));
string availableVariables =
string.Join(", ", AvailableFileNameVariables.Select(variable => $"{{{variable}}}"));
string fileNameHelpText =
$"Available variables: {availableVariables}. Include {{mediaId}} or {{filename}} to avoid collisions.";
HelpText = string.IsNullOrWhiteSpace(HelpText)
@ -165,13 +178,11 @@ public partial class ConfigFieldViewModel : ViewModelBase
private string _actualTextValue = string.Empty;
[ObservableProperty]
private string _textValue = string.Empty;
[ObservableProperty] private string _textValue = string.Empty;
private bool _isNormalizingFileNameFormatInput;
[ObservableProperty]
[NotifyCanExecuteChangedFor(nameof(InsertSelectedFileNameVariableCommand))]
[ObservableProperty] [NotifyCanExecuteChangedFor(nameof(InsertSelectedFileNameVariableCommand))]
private string? _selectedFileNameVariable;
private bool IsPathField =>
@ -180,16 +191,13 @@ public partial class ConfigFieldViewModel : ViewModelBase
[ObservableProperty] private ConfigSelectOptionViewModel? _selectedIgnoredUsersListOption;
[ObservableProperty]
[NotifyPropertyChangedFor(nameof(HasHelpText))]
[ObservableProperty] [NotifyPropertyChangedFor(nameof(HasHelpText))]
private string _helpText = string.Empty;
[ObservableProperty]
[NotifyPropertyChangedFor(nameof(HasUnknownFileNameVariables))]
[ObservableProperty] [NotifyPropertyChangedFor(nameof(HasUnknownFileNameVariables))]
private string _unknownFileNameVariablesMessage = string.Empty;
[ObservableProperty]
[NotifyPropertyChangedFor(nameof(HasError))]
[ObservableProperty] [NotifyPropertyChangedFor(nameof(HasError))]
private string _errorMessage = string.Empty;
public bool HasError => !string.IsNullOrWhiteSpace(ErrorMessage);
@ -232,7 +240,7 @@ public partial class ConfigFieldViewModel : ViewModelBase
if (PropertyType == typeof(string))
{
// Use actual value for path fields when privacy mode is enabled
string textToUse = (Program.HidePrivateInfo && IsPathField) ? _actualTextValue : TextValue;
string textToUse = Program.HidePrivateInfo && IsPathField ? _actualTextValue : TextValue;
value = textToUse.Trim();
return true;
}
@ -311,15 +319,9 @@ public partial class ConfigFieldViewModel : ViewModelBase
return false;
}
public void ClearError()
{
ErrorMessage = string.Empty;
}
public void ClearError() => ErrorMessage = string.Empty;
public void SetError(string message)
{
ErrorMessage = message;
}
public void SetError(string message) => ErrorMessage = message;
public void SetIgnoredUsersListOptions(IEnumerable<string> listNames)
{
@ -428,6 +430,7 @@ public partial class ConfigFieldViewModel : ViewModelBase
{
EnumValue = EnumOptions.FirstOrDefault();
}
return;
}
@ -548,4 +551,9 @@ public partial class ConfigFieldViewModel : ViewModelBase
? $" {character}"
: character.ToString()));
}
private static string GetDisplayName(string propertyName) =>
s_displayNameOverridesByProperty.TryGetValue(propertyName, out string? displayName)
? displayName
: ToDisplayName(propertyName);
}

View File

@ -43,15 +43,15 @@ public partial class MainWindowViewModel(
private static readonly (string DisplayName, string PropertyName)[] s_mediaSourceOptions =
[
("Avatar/Header Photo", nameof(Config.DownloadAvatarHeaderPhoto)),
("Posts", nameof(Config.DownloadPosts)),
("Free Posts", nameof(Config.DownloadPosts)),
("Paid Posts", nameof(Config.DownloadPaidPosts)),
("Free Messages", nameof(Config.DownloadMessages)),
("Paid Messages", nameof(Config.DownloadPaidMessages)),
("Archived", nameof(Config.DownloadArchived)),
("Streams", nameof(Config.DownloadStreams)),
("Stories", nameof(Config.DownloadStories)),
("Highlights", nameof(Config.DownloadHighlights)),
("Messages", nameof(Config.DownloadMessages)),
("Paid Messages", nameof(Config.DownloadPaidMessages))
("Avatar/Header Photo", nameof(Config.DownloadAvatarHeaderPhoto))
];
private static readonly Dictionary<string, string> s_configHelpTextByProperty = new(StringComparer.Ordinal)
@ -1247,10 +1247,10 @@ public partial class MainWindowViewModel(
return propertyName switch
{
nameof(Config.RenameExistingFilesWhenCustomFormatIsSelected) => 0,
nameof(Config.PaidPostFileNameFormat) => 1,
nameof(Config.PostFileNameFormat) => 2,
nameof(Config.PaidMessageFileNameFormat) => 3,
nameof(Config.MessageFileNameFormat) => 4,
nameof(Config.PostFileNameFormat) => 1,
nameof(Config.PaidPostFileNameFormat) => 2,
nameof(Config.MessageFileNameFormat) => 3,
nameof(Config.PaidMessageFileNameFormat) => 4,
nameof(Config.CreatorConfigs) => 5,
_ => 100
};

View File

@ -48,7 +48,7 @@
<Grid RowDefinitions="Auto,Auto,*">
<Menu Grid.Row="0">
<MenuItem Header="_File">
<MenuItem Header="_Refresh Users" Command="{Binding RefreshUsersCommand}" />
<MenuItem Header="_Refresh" Command="{Binding RefreshUsersCommand}" />
<MenuItem Header="_Logout"
IsVisible="{Binding IsAuthenticated}"
Command="{Binding LogoutCommand}" />
@ -530,14 +530,14 @@
ToolTip.Tip="{Binding FolderStructureHelpText}" />
</Grid>
<StackPanel Grid.Column="1" Spacing="6">
<CheckBox Content="Paid Posts"
IsChecked="{Binding FolderPerPaidPostField.BoolValue, FallbackValue=False}" />
<CheckBox Content="Free Posts"
IsChecked="{Binding FolderPerPostField.BoolValue, FallbackValue=False}" />
<CheckBox Content="Paid Messages"
IsChecked="{Binding FolderPerPaidMessageField.BoolValue, FallbackValue=False}" />
<CheckBox Content="Paid Posts"
IsChecked="{Binding FolderPerPaidPostField.BoolValue, FallbackValue=False}" />
<CheckBox Content="Free Messages"
IsChecked="{Binding FolderPerMessageField.BoolValue, FallbackValue=False}" />
<CheckBox Content="Paid Messages"
IsChecked="{Binding FolderPerPaidMessageField.BoolValue, FallbackValue=False}" />
</StackPanel>
</Grid>
<ItemsControl ItemsSource="{Binding Fields}">
@ -1005,6 +1005,47 @@
Foreground="{DynamicResource TextSecondaryBrush}"
Text="File Name Formats (leave blank to use global defaults)" />
<StackPanel Spacing="8">
<TextBlock FontWeight="SemiBold" Foreground="{DynamicResource TextPrimaryBrush}"
Text="Free Post File Name Format" />
<Grid ClipToBounds="True">
<TextBox x:Name="PostFileNameFormatTextBox"
Classes="fileNameOverlayInput"
Text="{Binding PostFileNameFormat}"
Watermark="Optional: override global post format"
Padding="8,6"
CaretBrush="{DynamicResource TextPrimaryBrush}" />
<controls:FileNameFormatOverlayTextBlock IsHitTestVisible="False"
Margin="{Binding #PostFileNameFormatTextBox.Padding}"
VerticalAlignment="Center"
Segments="{Binding PostSegments}"
SourceTextBox="{Binding #PostFileNameFormatTextBox}"
FontFamily="{Binding #PostFileNameFormatTextBox.FontFamily}"
FontSize="{Binding #PostFileNameFormatTextBox.FontSize}"
FontWeight="{Binding #PostFileNameFormatTextBox.FontWeight}"
FontStyle="{Binding #PostFileNameFormatTextBox.FontStyle}" />
</Grid>
<Grid ColumnDefinitions="*,Auto">
<ComboBox Grid.Column="0"
HorizontalAlignment="Stretch"
ItemsSource="{Binding PostVariables}"
SelectedItem="{Binding SelectedPostVariable}" />
<Button Grid.Column="1"
Margin="8,0,0,0"
Classes="secondary"
Content="Insert"
Command="{Binding InsertPostVariableCommand}" />
</Grid>
<TextBlock IsVisible="{Binding HasUnknownPostVariables}"
Foreground="{DynamicResource ErrorTextBrush}"
Text="{Binding UnknownPostVariablesMessage}"
TextWrapping="Wrap" />
<TextBlock IsVisible="{Binding HasPostFileNameFormatError}"
Foreground="{DynamicResource ErrorTextBrush}"
Text="{Binding PostFileNameFormatError}"
TextWrapping="Wrap" />
</StackPanel>
<StackPanel Spacing="8">
<TextBlock FontWeight="SemiBold" Foreground="{DynamicResource TextPrimaryBrush}"
Text="Paid Post File Name Format" />
@ -1048,42 +1089,42 @@
<StackPanel Spacing="8">
<TextBlock FontWeight="SemiBold" Foreground="{DynamicResource TextPrimaryBrush}"
Text="Post File Name Format" />
Text="Free Message File Name Format" />
<Grid ClipToBounds="True">
<TextBox x:Name="PostFileNameFormatTextBox"
<TextBox x:Name="MessageFileNameFormatTextBox"
Classes="fileNameOverlayInput"
Text="{Binding PostFileNameFormat}"
Watermark="Optional: override global post format"
Text="{Binding MessageFileNameFormat}"
Watermark="Optional: override global message format"
Padding="8,6"
CaretBrush="{DynamicResource TextPrimaryBrush}" />
<controls:FileNameFormatOverlayTextBlock IsHitTestVisible="False"
Margin="{Binding #PostFileNameFormatTextBox.Padding}"
Margin="{Binding #MessageFileNameFormatTextBox.Padding}"
VerticalAlignment="Center"
Segments="{Binding PostSegments}"
SourceTextBox="{Binding #PostFileNameFormatTextBox}"
FontFamily="{Binding #PostFileNameFormatTextBox.FontFamily}"
FontSize="{Binding #PostFileNameFormatTextBox.FontSize}"
FontWeight="{Binding #PostFileNameFormatTextBox.FontWeight}"
FontStyle="{Binding #PostFileNameFormatTextBox.FontStyle}" />
Segments="{Binding MessageSegments}"
SourceTextBox="{Binding #MessageFileNameFormatTextBox}"
FontFamily="{Binding #MessageFileNameFormatTextBox.FontFamily}"
FontSize="{Binding #MessageFileNameFormatTextBox.FontSize}"
FontWeight="{Binding #MessageFileNameFormatTextBox.FontWeight}"
FontStyle="{Binding #MessageFileNameFormatTextBox.FontStyle}" />
</Grid>
<Grid ColumnDefinitions="*,Auto">
<ComboBox Grid.Column="0"
HorizontalAlignment="Stretch"
ItemsSource="{Binding PostVariables}"
SelectedItem="{Binding SelectedPostVariable}" />
ItemsSource="{Binding MessageVariables}"
SelectedItem="{Binding SelectedMessageVariable}" />
<Button Grid.Column="1"
Margin="8,0,0,0"
Classes="secondary"
Content="Insert"
Command="{Binding InsertPostVariableCommand}" />
Command="{Binding InsertMessageVariableCommand}" />
</Grid>
<TextBlock IsVisible="{Binding HasUnknownPostVariables}"
<TextBlock IsVisible="{Binding HasUnknownMessageVariables}"
Foreground="{DynamicResource ErrorTextBrush}"
Text="{Binding UnknownPostVariablesMessage}"
Text="{Binding UnknownMessageVariablesMessage}"
TextWrapping="Wrap" />
<TextBlock IsVisible="{Binding HasPostFileNameFormatError}"
<TextBlock IsVisible="{Binding HasMessageFileNameFormatError}"
Foreground="{DynamicResource ErrorTextBrush}"
Text="{Binding PostFileNameFormatError}"
Text="{Binding MessageFileNameFormatError}"
TextWrapping="Wrap" />
</StackPanel>
@ -1128,47 +1169,6 @@
TextWrapping="Wrap" />
</StackPanel>
<StackPanel Spacing="8">
<TextBlock FontWeight="SemiBold" Foreground="{DynamicResource TextPrimaryBrush}"
Text="Message File Name Format" />
<Grid ClipToBounds="True">
<TextBox x:Name="MessageFileNameFormatTextBox"
Classes="fileNameOverlayInput"
Text="{Binding MessageFileNameFormat}"
Watermark="Optional: override global message format"
Padding="8,6"
CaretBrush="{DynamicResource TextPrimaryBrush}" />
<controls:FileNameFormatOverlayTextBlock IsHitTestVisible="False"
Margin="{Binding #MessageFileNameFormatTextBox.Padding}"
VerticalAlignment="Center"
Segments="{Binding MessageSegments}"
SourceTextBox="{Binding #MessageFileNameFormatTextBox}"
FontFamily="{Binding #MessageFileNameFormatTextBox.FontFamily}"
FontSize="{Binding #MessageFileNameFormatTextBox.FontSize}"
FontWeight="{Binding #MessageFileNameFormatTextBox.FontWeight}"
FontStyle="{Binding #MessageFileNameFormatTextBox.FontStyle}" />
</Grid>
<Grid ColumnDefinitions="*,Auto">
<ComboBox Grid.Column="0"
HorizontalAlignment="Stretch"
ItemsSource="{Binding MessageVariables}"
SelectedItem="{Binding SelectedMessageVariable}" />
<Button Grid.Column="1"
Margin="8,0,0,0"
Classes="secondary"
Content="Insert"
Command="{Binding InsertMessageVariableCommand}" />
</Grid>
<TextBlock IsVisible="{Binding HasUnknownMessageVariables}"
Foreground="{DynamicResource ErrorTextBrush}"
Text="{Binding UnknownMessageVariablesMessage}"
TextWrapping="Wrap" />
<TextBlock IsVisible="{Binding HasMessageFileNameFormatError}"
Foreground="{DynamicResource ErrorTextBrush}"
Text="{Binding MessageFileNameFormatError}"
TextWrapping="Wrap" />
</StackPanel>
<StackPanel Orientation="Horizontal" Spacing="10" HorizontalAlignment="Right">
<Button Content="Cancel"
Classes="secondary"