macosx: Track items that are currently loading in status notifier view

Signed-off-by: Claudio Cambra <developer@claudiocambra.com>
This commit is contained in:
Claudio Cambra 2024-11-16 17:19:14 +08:00 committed by Jean-Baptiste Kempf
parent df45819caf
commit d3986198f2

View File

@ -28,6 +28,7 @@
@interface VLCStatusNotifierView ()
@property NSUInteger remainingCount;
@property NSUInteger loadingCount;
@property (nonatomic) BOOL permanentDiscoveryMessageActive;
@end
@ -37,6 +38,7 @@
- (void)awakeFromNib
{
self.remainingCount = 0;
self.loadingCount = 0;
self.permanentDiscoveryMessageActive = NO;
self.label.stringValue = _NS("Idle");
@ -44,6 +46,22 @@
[defaultCenter addObserver:self selector:@selector(updateStatus:) name:nil object:nil];
}
- (void)displayStartLoad
{
if (self.loadingCount == 0) {
[self.progressIndicator startAnimation:self];
}
self.loadingCount++;
}
- (void)displayFinishLoad
{
self.loadingCount--;
if (self.loadingCount == 0) {
[self.progressIndicator stopAnimation:self];
}
}
- (void)setPermanentDiscoveryMessageActive:(BOOL)permanentDiscoveryMessageActive
{
if (_permanentDiscoveryMessageActive == permanentDiscoveryMessageActive) {
@ -53,10 +71,10 @@
_permanentDiscoveryMessageActive = permanentDiscoveryMessageActive;
if (permanentDiscoveryMessageActive) {
self.remainingCount++;
[self.progressIndicator startAnimation:self];
[self displayStartLoad];
} else {
self.remainingCount--;
[self.progressIndicator stopAnimation:self];
[self displayFinishLoad];
}
}