Felix Paul Kühne pushed to branch master at VideoLAN / VLC


Commits:
f38e13ca by Claudio Cambra at 2024-02-23T08:11:23+00:00
macosx: Start timer during library window search field input to wait for 
further keystrokes, easing up load

Signed-off-by: Claudio Cambra <[email protected]>

- - - - -


1 changed file:

- modules/gui/macosx/library/VLCLibraryWindow.m


Changes:

=====================================
modules/gui/macosx/library/VLCLibraryWindow.m
=====================================
@@ -89,6 +89,8 @@ const NSUserInterfaceItemIdentifier 
VLCLibraryWindowIdentifier = @"VLCLibraryWin
     NSInteger _currentSelectedViewModeSegment;
 }
 
+@property NSTimer *searchInputTimer;
+
 - (IBAction)goToBrowseSection:(id)sender;
 
 @end
@@ -567,8 +569,9 @@ static void addShadow(NSImageView *__unsafe_unretained 
imageView)
 {
     if (!visible) {
         [self hideToolbarItem:_librarySearchToolbarItem];
+        [self stopSearchTimer];
         _librarySearchField.stringValue = @"";
-        [VLCMain.sharedInstance.libraryController filterByString:@""];
+        [self updateFilterString];
         return;
     }
 
@@ -716,15 +719,32 @@ static void addShadow(NSImageView *__unsafe_unretained 
imageView)
     [NSMenu popUpContextMenu:_librarySortingMenuController.librarySortingMenu 
withEvent:[NSApp currentEvent] forView:sender];
 }
 
+- (void)stopSearchTimer
+{
+    [self.searchInputTimer invalidate];
+    self.searchInputTimer = nil;
+}
+
 - (IBAction)filterLibrary:(id)sender
+{
+    [self stopSearchTimer];
+    self.searchInputTimer = [NSTimer scheduledTimerWithTimeInterval:0.3
+                                                            target:self
+                                                           
selector:@selector(updateFilterString)
+                                                           userInfo:nil
+                                                            repeats:NO];
+}
+
+- (void)updateFilterString
 {
     [VLCMain.sharedInstance.libraryController 
filterByString:_librarySearchField.stringValue];
 }
 
 - (void)clearLibraryFilterString
 {
+    [self stopSearchTimer];
     _librarySearchField.stringValue = @"";
-    [self filterLibrary:self];
+    [self updateFilterString];
 }
 
 - (IBAction)openMedia:(id)sender



View it on GitLab: 
https://code.videolan.org/videolan/vlc/-/commit/f38e13cad4cb20a1ef1d35164043307b1ac059e5

-- 
View it on GitLab: 
https://code.videolan.org/videolan/vlc/-/commit/f38e13cad4cb20a1ef1d35164043307b1ac059e5
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance
_______________________________________________
vlc-commits mailing list
[email protected]
https://mailman.videolan.org/listinfo/vlc-commits

Reply via email to