[vlc-commits] [Git][videolan/vlc][master] macosx: Start timer during library window search field input to wait for...

Felix Paul Kühne (@fkuehne) gitlab at videolan.org
Fri Feb 23 08:32:25 UTC 2024



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 <developer at claudiocambra.com>

- - - - -


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;
 }
 
+ at 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


More information about the vlc-commits mailing list