Skip to content

Commit 0915ffb

Browse files
committed
make axaml toggle thing also
1 parent 855a40f commit 0915ffb

7 files changed

Lines changed: 55 additions & 32 deletions

File tree

StabilityMatrix.Avalonia/Controls/BetterComboBox.cs

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ public class BetterComboBox : ComboBox
2727
BetterComboBox,
2828
string
2929
>(nameof(SearchWatermark), defaultValue: "Search...");
30-
public static readonly StyledProperty<bool> UseLegacyModelSearchProperty = AvaloniaProperty.Register<
30+
public static readonly StyledProperty<bool> UseLegacySearchProperty = AvaloniaProperty.Register<
3131
BetterComboBox,
3232
bool
33-
>(nameof(UseLegacyModelSearch));
33+
>(nameof(UseLegacySearch));
3434
public static readonly DirectProperty<BetterComboBox, string> SearchTextProperty =
3535
AvaloniaProperty.RegisterDirect<BetterComboBox, string>(nameof(SearchText), o => o.SearchText);
3636

@@ -40,10 +40,10 @@ public string SearchWatermark
4040
set => SetValue(SearchWatermarkProperty, value);
4141
}
4242

43-
public bool UseLegacyModelSearch
43+
public bool UseLegacySearch
4444
{
45-
get => GetValue(UseLegacyModelSearchProperty);
46-
set => SetValue(UseLegacyModelSearchProperty, value);
45+
get => GetValue(UseLegacySearchProperty);
46+
set => SetValue(UseLegacySearchProperty, value);
4747
}
4848

4949
public string SearchText
@@ -104,7 +104,7 @@ public BetterComboBox()
104104
settingsManager = App.Services.GetService<ISettingsManager>();
105105
if (settingsManager is not null)
106106
{
107-
UseLegacyModelSearch = settingsManager.Settings.UseLegacyModelSearch;
107+
ApplyGlobalLegacySearchOverride(settingsManager.Settings.UseLegacySearch);
108108
settingsManager.SettingsPropertyChanged += OnSettingsPropertyChanged;
109109
}
110110
}
@@ -160,7 +160,7 @@ protected override void OnTextInput(TextInputEventArgs e)
160160
if (IsDropDownOpen)
161161
{
162162
UpdateSearchTextBoxText(keyboardSearchText);
163-
if (!UseLegacyModelSearch)
163+
if (!UseLegacySearch)
164164
{
165165
Dispatcher.UIThread.Post(() => searchTextBox?.Focus(), DispatcherPriority.Input);
166166
}
@@ -199,7 +199,7 @@ private void OnDropDownOpened(object? sender, EventArgs e)
199199
StopLegacySearchResetTimer();
200200
ResetSearchText();
201201
ApplyFilter(string.Empty);
202-
if (!UseLegacyModelSearch)
202+
if (!UseLegacySearch)
203203
{
204204
Dispatcher.UIThread.Post(() => searchTextBox?.Focus(), DispatcherPriority.Input);
205205
}
@@ -235,7 +235,7 @@ private void ResetSearchText()
235235

236236
private void RestartLegacySearchResetTimer()
237237
{
238-
if (!UseLegacyModelSearch || string.IsNullOrEmpty(keyboardSearchText))
238+
if (!UseLegacySearch || string.IsNullOrEmpty(keyboardSearchText))
239239
return;
240240

241241
legacySearchResetTimer.Stop();
@@ -249,7 +249,7 @@ private void StopLegacySearchResetTimer()
249249

250250
private void UpdateLegacySearchPopupText(string text)
251251
{
252-
if (!UseLegacyModelSearch || string.IsNullOrWhiteSpace(text))
252+
if (!UseLegacySearch || string.IsNullOrWhiteSpace(text))
253253
{
254254
HideLegacySearchPopup();
255255
return;
@@ -278,7 +278,7 @@ private void OnLegacySearchResetTimerTick(object? sender, EventArgs e)
278278
{
279279
legacySearchResetTimer.Stop();
280280

281-
if (!UseLegacyModelSearch || string.IsNullOrWhiteSpace(keyboardSearchText))
281+
if (!UseLegacySearch || string.IsNullOrWhiteSpace(keyboardSearchText))
282282
return;
283283

284284
ResetSearchText();
@@ -288,7 +288,7 @@ private void OnInputReceived(string input)
288288
{
289289
if (IsDropDownOpen)
290290
{
291-
if (UseLegacyModelSearch)
291+
if (UseLegacySearch)
292292
{
293293
var query = input.Trim();
294294
if (string.IsNullOrWhiteSpace(query))
@@ -320,7 +320,7 @@ private void OnInputReceived(string input)
320320
return;
321321
}
322322

323-
if (UseLegacyModelSearch)
323+
if (UseLegacySearch)
324324
{
325325
var legacyMatch = FindLegacyMatch(input);
326326
if (legacyMatch is null)
@@ -393,9 +393,9 @@ private void ApplyFilter(string input)
393393

394394
private bool IsItemMatch(object item, string query)
395395
{
396-
var itemText = GetItemSearchText(item, UseLegacyModelSearch);
396+
var itemText = GetItemSearchText(item, UseLegacySearch);
397397

398-
if (UseLegacyModelSearch)
398+
if (UseLegacySearch)
399399
{
400400
return itemText.Contains(query, StringComparison.OrdinalIgnoreCase);
401401
}
@@ -475,7 +475,7 @@ Func<TItem, string> getSearchText
475475

476476
private void OnContainerPrepared(object? sender, ContainerPreparedEventArgs e)
477477
{
478-
if (!IsDropDownOpen || UseLegacyModelSearch)
478+
if (!IsDropDownOpen || UseLegacySearch)
479479
return;
480480

481481
var query = keyboardSearchText.Trim();
@@ -493,7 +493,7 @@ private void OnContainerPrepared(object? sender, ContainerPreparedEventArgs e)
493493

494494
private void OnContainerIndexChanged(object? sender, ContainerIndexChangedEventArgs e)
495495
{
496-
if (!IsDropDownOpen || UseLegacyModelSearch)
496+
if (!IsDropDownOpen || UseLegacySearch)
497497
return;
498498

499499
var query = keyboardSearchText.Trim();
@@ -518,22 +518,34 @@ protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs chang
518518
searchCache.Clear();
519519
}
520520

521-
if (change.Property == UseLegacyModelSearchProperty && !UseLegacyModelSearch)
521+
if (change.Property == UseLegacySearchProperty && !UseLegacySearch)
522522
{
523523
StopLegacySearchResetTimer();
524524
HideLegacySearchPopup();
525525
}
526526
}
527527

528+
private void ApplyGlobalLegacySearchOverride(bool globalOverride)
529+
{
530+
if (globalOverride)
531+
{
532+
SetValue(UseLegacySearchProperty, true);
533+
}
534+
else
535+
{
536+
ClearValue(UseLegacySearchProperty);
537+
}
538+
}
539+
528540
private void OnSettingsPropertyChanged(object? sender, RelayPropertyChangedEventArgs e)
529541
{
530-
if (e.PropertyName != nameof(Settings.UseLegacyModelSearch) || settingsManager is null)
542+
if (e.PropertyName != nameof(Settings.UseLegacySearch) || settingsManager is null)
531543
return;
532544

533545
Dispatcher.UIThread.Post(() =>
534546
{
535-
UseLegacyModelSearch = settingsManager.Settings.UseLegacyModelSearch;
536-
if (!UseLegacyModelSearch)
547+
ApplyGlobalLegacySearchOverride(settingsManager.Settings.UseLegacySearch);
548+
if (!UseLegacySearch)
537549
{
538550
StopLegacySearchResetTimer();
539551
HideLegacySearchPopup();

StabilityMatrix.Avalonia/Controls/Inference/SamplerCard.axaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@
4646
DisplayMemberBinding="{Binding DisplayName}"
4747
IsVisible="{Binding IsSamplerSelectionEnabled}"
4848
ItemsSource="{Binding ClientManager.Samplers}"
49-
SelectedItem="{Binding SelectedSampler}" />
49+
SelectedItem="{Binding SelectedSampler}"
50+
UseLegacySearch="True" />
5051
<!-- Scheduler -->
5152
<TextBlock
5253
Grid.Row="1"
@@ -63,7 +64,8 @@
6364
DisplayMemberBinding="{Binding DisplayName}"
6465
IsVisible="{Binding IsSchedulerSelectionEnabled}"
6566
ItemsSource="{Binding ClientManager.Schedulers}"
66-
SelectedItem="{Binding SelectedScheduler}" />
67+
SelectedItem="{Binding SelectedScheduler}"
68+
UseLegacySearch="True" />
6769

6870
<TextBlock
6971
Grid.Row="2"

StabilityMatrix.Avalonia/Services/NotificationService.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,14 @@ public void Initialize(
4545

4646
public void Show(INotification notification)
4747
{
48-
notificationManager?.Show(notification);
48+
if (Dispatcher.UIThread.CheckAccess())
49+
{
50+
notificationManager?.Show(notification);
51+
}
52+
else
53+
{
54+
Dispatcher.UIThread.Post(() => notificationManager?.Show(notification));
55+
}
4956
}
5057

5158
/// <inheritdoc />

StabilityMatrix.Avalonia/Styles/ControlThemes/BetterComboBoxStyles.axaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@
310310
</Style>
311311
</Style>
312312

313-
<Style Selector="^[UseLegacyModelSearch=true] /template/ TextBox#PART_SearchTextBox">
313+
<Style Selector="^[UseLegacySearch=true] /template/ TextBox#PART_SearchTextBox">
314314
<Setter Property="IsVisible" Value="False" />
315315
<Setter Property="Margin" Value="0" />
316316
<Setter Property="MinHeight" Value="0" />

StabilityMatrix.Avalonia/ViewModels/Settings/InferenceSettingsViewModel.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public partial class InferenceSettingsViewModel : PageViewModelBase
7070
private bool filterExtraNetworksByBaseModel;
7171

7272
[ObservableProperty]
73-
private bool useLegacyModelSearch;
73+
private bool useLegacySearch;
7474

7575
private List<string> ignoredFileNameFormatVars =
7676
[
@@ -152,8 +152,8 @@ ISettingsManager settingsManager
152152

153153
settingsManager.RelayPropertyFor(
154154
this,
155-
vm => vm.UseLegacyModelSearch,
156-
settings => settings.UseLegacyModelSearch,
155+
vm => vm.UseLegacySearch,
156+
settings => settings.UseLegacySearch,
157157
true
158158
);
159159

StabilityMatrix.Avalonia/Views/Settings/InferenceSettingsPage.axaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,13 +169,13 @@
169169

170170
<ui:SettingsExpander
171171
Grid.Row="4"
172-
Description="Use the previous combo box model search behavior (floating typed text and auto-select first match)."
173-
Header="Legacy Model Search">
172+
Description="Force all combo boxes to use floating search (floating typed text, auto-select first match). When off, each combo box uses its own configured search mode."
173+
Header="Use Floating Search">
174174
<ui:SettingsExpander.IconSource>
175175
<controls:FASymbolIconSource Symbol="fa-solid fa-magnifying-glass" />
176176
</ui:SettingsExpander.IconSource>
177177
<ui:SettingsExpander.Footer>
178-
<ToggleSwitch IsChecked="{Binding UseLegacyModelSearch}" />
178+
<ToggleSwitch IsChecked="{Binding UseLegacySearch}" />
179179
</ui:SettingsExpander.Footer>
180180
</ui:SettingsExpander>
181181

StabilityMatrix.Core/Models/Settings/Settings.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,9 @@ public IReadOnlyDictionary<string, string> EnvironmentVariables
205205
public bool SortConnectedModelsFirst { get; set; } = true;
206206
public int ConsoleFontSize { get; set; } = 14;
207207
public bool AutoLoadCivitModels { get; set; } = true;
208-
public bool UseLegacyModelSearch { get; set; }
208+
209+
[JsonPropertyName("UseLegacyModelSearch")]
210+
public bool UseLegacySearch { get; set; }
209211

210212
/// <summary>
211213
/// When false, will copy files when drag/drop import happens

0 commit comments

Comments
 (0)