-
-
Notifications
You must be signed in to change notification settings - Fork 412
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes #481 - Keep selected filter option between application restarts. #503
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,18 +11,29 @@ public FilterSelector() | |
{ | ||
InitializeComponent(); | ||
DataContext = FilterLoader.Instance; | ||
EverythingSearch.Instance.PropertyChanged += OnCurrentFilterChanged; | ||
Loaded += (s, e) => { SelectCurrentFilter(); }; | ||
Loaded += (s, e) => { | ||
SelectCurrentFilter(); | ||
EverythingSearch.Instance.PropertyChanged += OnCurrentFilterChanged; | ||
}; | ||
} | ||
|
||
public int SelectedDefaultFilterIndex | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm happy to remove these and revert back, it's public because I was going to use it for the binding (which didn't stop the issue), but I figured I'd leave it in case that's actually the better way |
||
{ | ||
get => FilterLoader.Instance.DefaultFilters.IndexOf(EverythingSearch.Instance.CurrentFilter); | ||
} | ||
|
||
public int SelectedUserFilterIndex | ||
{ | ||
get => FilterLoader.Instance.UserFilters.IndexOf(EverythingSearch.Instance.CurrentFilter); | ||
} | ||
private void SelectCurrentFilter() | ||
{ | ||
TabControl.SelectionChanged -= OnTabItemSelected; | ||
TabControl.SelectedIndex = FilterLoader.Instance.DefaultFilters.IndexOf(EverythingSearch.Instance.CurrentFilter); | ||
TabControl.SelectedIndex = SelectedDefaultFilterIndex; | ||
TabControl.SelectionChanged += OnTabItemSelected; | ||
|
||
ComboBox.SelectionChanged -= OnComboBoxItemSelected; | ||
ComboBox.SelectedIndex = FilterLoader.Instance.UserFilters.IndexOf(EverythingSearch.Instance.CurrentFilter); | ||
ComboBox.SelectedIndex = SelectedUserFilterIndex; | ||
ComboBox.SelectionChanged += OnComboBoxItemSelected; | ||
} | ||
|
||
|
@@ -39,6 +50,11 @@ private void OnTabItemSelected(object sender, SelectionChangedEventArgs e) | |
if (TabControl.SelectedIndex < 0) | ||
return; | ||
|
||
if (!TabControl.IsFocused && !TabControl.IsMouseOver) { | ||
TabControl.SelectedIndex = -1; | ||
return; | ||
} | ||
|
||
EverythingSearch.Instance.CurrentFilter = TabControl.SelectedItem as Filter; | ||
} | ||
|
||
|
@@ -47,6 +63,11 @@ private void OnComboBoxItemSelected(object sender, SelectionChangedEventArgs e) | |
if (ComboBox.SelectedIndex < 0) | ||
return; | ||
|
||
if (!ComboBox.IsFocused && !ComboBox.IsMouseOver) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. During testing this code was reached (and toggles selection) when an item is selected from the dropdown list, there wasn't another reliable property I could find that would indicate that the window is actually open (during the |
||
ComboBox.SelectedIndex = -1; | ||
return; | ||
} | ||
|
||
EverythingSearch.Instance.CurrentFilter = ComboBox.SelectedItem as Filter; | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EverythinhSearch.Instance.PropertyChanged
could fire prior to the element loading