From fd050ee2e723f57302b1f2fa502dfa36835ed7c7 Mon Sep 17 00:00:00 2001 From: jernejp21 Date: Sat, 18 Apr 2026 06:30:45 +0200 Subject: [PATCH 1/3] feature: Multi User Profile #911 In Preference menu, added tab fro creating multiple user profiles. --- src/Models/UserProfile.cs | 43 ++++++++++++ src/Resources/Locales/en_US.axaml | 5 ++ src/ViewModels/Preferences.cs | 6 ++ src/Views/Preferences.axaml | 112 ++++++++++++++++++++++++++++++ src/Views/Preferences.axaml.cs | 52 ++++++++++++++ 5 files changed, 218 insertions(+) create mode 100644 src/Models/UserProfile.cs diff --git a/src/Models/UserProfile.cs b/src/Models/UserProfile.cs new file mode 100644 index 000000000..ee232216a --- /dev/null +++ b/src/Models/UserProfile.cs @@ -0,0 +1,43 @@ +using Avalonia.Collections; +using CommunityToolkit.Mvvm.ComponentModel; + +namespace SourceGit.Models +{ + + + public record UserProfileTargetFile(string File, Commit Revision); + + + public class UserProfile : ObservableObject + { + public string ProfileName + { + get => _profileName; + set => SetProperty(ref _profileName, value); + } + + public string UserName + { + get => _userName; + set => SetProperty(ref _userName, value); + } + + public string Email + { + get => _email; + set => SetProperty(ref _email, value); + } + + public string Key + { + get => _key; + set => SetProperty(ref _key, value); + } + + + private string _profileName = string.Empty; + private string _userName = string.Empty; + private string _email = string.Empty; + private string _key = string.Empty; + } +} diff --git a/src/Resources/Locales/en_US.axaml b/src/Resources/Locales/en_US.axaml index a14c66a16..95a0c523e 100644 --- a/src/Resources/Locales/en_US.axaml +++ b/src/Resources/Locales/en_US.axaml @@ -266,6 +266,11 @@ HTTP proxy used by this repository User Name User name for this repository + USER PROFILE + User Profile + User Name + Email Address + User Signing Key Edit Custom Action Controls Checked Value: When checked, this value will be used in command-line arguments diff --git a/src/ViewModels/Preferences.cs b/src/ViewModels/Preferences.cs index 04ffbeb9d..d4be961f3 100644 --- a/src/ViewModels/Preferences.cs +++ b/src/ViewModels/Preferences.cs @@ -493,6 +493,12 @@ public AvaloniaList CustomActions set; } = []; + public AvaloniaList UserProfiles + { + get; + set; + } = []; + public AvaloniaList OpenAIServices { get; diff --git a/src/Views/Preferences.axaml b/src/Views/Preferences.axaml index 3b2ee062b..337ae0ca3 100644 --- a/src/Views/Preferences.axaml +++ b/src/Views/Preferences.axaml @@ -428,6 +428,118 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Views/Preferences.axaml.cs b/src/Views/Preferences.axaml.cs index 28cdf901c..aab84ff1a 100644 --- a/src/Views/Preferences.axaml.cs +++ b/src/Views/Preferences.axaml.cs @@ -113,6 +113,15 @@ public Models.CustomAction SelectedCustomAction set => SetValue(SelectedCustomActionProperty, value); } + public static readonly StyledProperty SelectedUserProfileProperty = + AvaloniaProperty.Register(nameof(SelectedUserProfile)); + + public Models.UserProfile SelectedUserProfile + { + get => GetValue(SelectedUserProfileProperty); + set => SetValue(SelectedUserProfileProperty, value); + } + public Preferences() { var pref = ViewModels.Preferences.Instance; @@ -495,6 +504,49 @@ private async void EditCustomActionControls(object sender, RoutedEventArgs e) e.Handled = true; } + private void OnAddUserProfile(object sender, RoutedEventArgs e) + { + var action = new Models.UserProfile() { ProfileName = "New Profile" }; + ViewModels.Preferences.Instance.UserProfiles.Add(action); + SelectedUserProfile = action; + + e.Handled = true; + } + + private void OnRemoveSelectedUserProfile(object sender, RoutedEventArgs e) + { + if (SelectedUserProfile == null) + return; + + ViewModels.Preferences.Instance.UserProfiles.Remove(SelectedUserProfile); + SelectedUserProfile = null; + e.Handled = true; + } + + private void OnMoveSelectedUserProfileUp(object sender, RoutedEventArgs e) + { + if (SelectedUserProfile == null) + return; + + var idx = ViewModels.Preferences.Instance.UserProfiles.IndexOf(SelectedUserProfile); + if (idx > 0) + ViewModels.Preferences.Instance.UserProfiles.Move(idx - 1, idx); + + e.Handled = true; + } + + private void OnMoveSelectedUserProfileDown(object sender, RoutedEventArgs e) + { + if (SelectedUserProfile == null) + return; + + var idx = ViewModels.Preferences.Instance.UserProfiles.IndexOf(SelectedUserProfile); + if (idx < ViewModels.Preferences.Instance.UserProfiles.Count - 1) + ViewModels.Preferences.Instance.UserProfiles.Move(idx + 1, idx); + + e.Handled = true; + } + private void UpdateGitVersion() { GitVersion = Native.OS.GitVersionString; From 78d7a7c22c35e139aef1dcc0729a5d1f275d3343 Mon Sep 17 00:00:00 2001 From: jernejp21 Date: Sun, 19 Apr 2026 22:35:27 +0200 Subject: [PATCH 2/3] feature: Multi User Profile Switcher #911 In Repository Configure menu, added drop down menu for selecting a user. --- src/Models/RepositorySettings.cs | 6 ++++ src/Resources/Locales/en_US.axaml | 1 + src/ViewModels/RepositoryConfigure.cs | 42 +++++++++++++++++++++++++++ src/Views/RepositoryConfigure.axaml | 24 ++++++++++++++- 4 files changed, 72 insertions(+), 1 deletion(-) diff --git a/src/Models/RepositorySettings.cs b/src/Models/RepositorySettings.cs index 4cc1e3778..cbb93cc02 100644 --- a/src/Models/RepositorySettings.cs +++ b/src/Models/RepositorySettings.cs @@ -18,6 +18,12 @@ public string DefaultRemote set; } = string.Empty; + public string ProfileName + { + get; + set; + } = string.Empty; + public int PreferredMergeMode { get; diff --git a/src/Resources/Locales/en_US.axaml b/src/Resources/Locales/en_US.axaml index 95a0c523e..d8981416f 100644 --- a/src/Resources/Locales/en_US.axaml +++ b/src/Resources/Locales/en_US.axaml @@ -243,6 +243,7 @@ Minute(s) Conventional Commit Types Default Remote + User Profile Preferred Merge Mode ISSUE TRACKER Add Azure DevOps Rule diff --git a/src/ViewModels/RepositoryConfigure.cs b/src/ViewModels/RepositoryConfigure.cs index 4a129e630..79746b90a 100644 --- a/src/ViewModels/RepositoryConfigure.cs +++ b/src/ViewModels/RepositoryConfigure.cs @@ -1,9 +1,13 @@ using System; using System.Collections.Generic; +using System.ComponentModel; using System.Threading.Tasks; using Avalonia.Collections; +using Avalonia.Controls; using CommunityToolkit.Mvvm.ComponentModel; +using SourceGit.Models; +using SourceGit.Views; namespace SourceGit.ViewModels { @@ -26,6 +30,11 @@ public List Remotes get; } + public List UserProfileNames + { + get; + } + public string DefaultRemote { get => _repo.Settings.DefaultRemote; @@ -39,6 +48,25 @@ public string DefaultRemote } } + public string ProfileName + { + set + { + foreach(var profile in _profiles) + { + if (profile.ProfileName == value) + { + UserName = profile.UserName; + UserEmail = profile.Email; + GPGUserSigningKey = profile.Key; + OnPropertyChanged(nameof(UserName)); + OnPropertyChanged(nameof(UserEmail)); + OnPropertyChanged(nameof(GPGUserSigningKey)); + } + } + } + } + public int PreferredMergeMode { get => _repo.Settings.PreferredMergeMode; @@ -154,6 +182,15 @@ public RepositoryConfigure(Repository repo) foreach (var remote in _repo.Remotes) Remotes.Add(remote.Name); + UserProfileNames = new List(); + _profiles = new List(); + foreach (var profile in Preferences.Instance.UserProfiles) + { + UserProfileNames.Add(profile.ProfileName); + _profiles.Add(profile); + } + + AvailableOpenAIServices = new List() { "---" }; foreach (var service in Preferences.Instance.OpenAIServices) AvailableOpenAIServices.Add(service.Name); @@ -346,5 +383,10 @@ private async Task ApplyIssueTrackerChangesAsync() private Models.CommitTemplate _selectedCommitTemplate = null; private Models.IssueTracker _selectedIssueTracker = null; private Models.CustomAction _selectedCustomAction = null; + + public List _profiles + { + get; + } } } diff --git a/src/Views/RepositoryConfigure.axaml b/src/Views/RepositoryConfigure.axaml index d08052fc5..ef9645c3a 100644 --- a/src/Views/RepositoryConfigure.axaml +++ b/src/Views/RepositoryConfigure.axaml @@ -44,7 +44,7 @@ - + @@ -62,6 +63,7 @@ @@ -143,6 +145,7 @@ @@ -179,6 +182,25 @@ + + + + + + + + + + + + From 42dad91c07809cb0f86c1326ff40899f524e35e7 Mon Sep 17 00:00:00 2001 From: jernejp21 Date: Mon, 20 Apr 2026 07:48:07 +0200 Subject: [PATCH 3/3] UI changes Better spacing and better naming. --- src/Resources/Locales/en_US.axaml | 2 +- src/Views/Preferences.axaml | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Resources/Locales/en_US.axaml b/src/Resources/Locales/en_US.axaml index d8981416f..6f87116d1 100644 --- a/src/Resources/Locales/en_US.axaml +++ b/src/Resources/Locales/en_US.axaml @@ -268,7 +268,7 @@ User Name User name for this repository USER PROFILE - User Profile + Profile Name User Name Email Address User Signing Key diff --git a/src/Views/Preferences.axaml b/src/Views/Preferences.axaml index 337ae0ca3..c2283fbe1 100644 --- a/src/Views/Preferences.axaml +++ b/src/Views/Preferences.axaml @@ -524,13 +524,13 @@ - + - + - +