Set title for movie panel

This commit is contained in:
Matthias Neeracher 2011-08-20 04:51:51 +02:00
parent 531f55758b
commit 484e5279b3
4 changed files with 17 additions and 6 deletions

View File

@ -20,6 +20,7 @@
IBOutlet NSView * textExportAccessoryView; IBOutlet NSView * textExportAccessoryView;
IBOutlet MAMovieWindow * moviePanel; IBOutlet MAMovieWindow * moviePanel;
QTMovie * currentMovie; QTMovie * currentMovie;
NSString * currentMovieTitle;
QTTime lastMovieTime; QTTime lastMovieTime;
} }

View File

@ -29,6 +29,7 @@ static const char * kMADocWindowObserver = "MADocWindowObserver";
self = [super initWithWindow:window]; self = [super initWithWindow:window];
exportAnnotations = YES; exportAnnotations = YES;
currentMovieTitle = @"";
return self; return self;
} }
@ -40,6 +41,7 @@ static const char * kMADocWindowObserver = "MADocWindowObserver";
[annotationController setSortDescriptors:[NSArray arrayWithObject:[NSSortDescriptor sortDescriptorWithKey:@"location" ascending:YES]]]; [annotationController setSortDescriptors:[NSArray arrayWithObject:[NSSortDescriptor sortDescriptorWithKey:@"location" ascending:YES]]];
[NSTimer scheduledTimerWithTimeInterval:0.05 target:self selector:@selector(updateMovieTime:) userInfo:nil repeats:YES]; [NSTimer scheduledTimerWithTimeInterval:0.05 target:self selector:@selector(updateMovieTime:) userInfo:nil repeats:YES];
[mediaController addObserver:self forKeyPath:@"selection.media" options:0 context:&kMADocWindowObserver]; [mediaController addObserver:self forKeyPath:@"selection.media" options:0 context:&kMADocWindowObserver];
[mediaController addObserver:self forKeyPath:@"selection.name" options:0 context:&kMADocWindowObserver];
} }
- (MAMovieWindow *)moviePanel - (MAMovieWindow *)moviePanel
@ -50,7 +52,7 @@ static const char * kMADocWindowObserver = "MADocWindowObserver";
- (void)moviePanelDidAppear - (void)moviePanelDidAppear
{ {
[movieView setMovie:nil]; [movieView setMovie:nil];
if (![[self moviePanel] shouldDisplayMovie:currentMovie]) if (![[self moviePanel] shouldDisplayMovie:currentMovie withTitle:currentMovieTitle])
[movieView setMovie:currentMovie]; [movieView setMovie:currentMovie];
} }
@ -61,7 +63,7 @@ static const char * kMADocWindowObserver = "MADocWindowObserver";
- (void)moviePanelDidClose - (void)moviePanelDidClose
{ {
[[self moviePanel] shouldDisplayMovie:nil]; [[self moviePanel] shouldDisplayMovie:nil withTitle:@""];
[movieView setMovie:currentMovie]; [movieView setMovie:currentMovie];
} }
@ -77,8 +79,14 @@ static const char * kMADocWindowObserver = "MADocWindowObserver";
// //
// Current movie changed // Current movie changed
// //
MAMedia * currentMedia = [mediaController selection]; if ([[mediaController selectionIndexes] count] > 0) {
currentMovie = [[QTMovie alloc] initWithFile:[currentMedia valueForKey:@"media"] error:nil]; MAMedia * currentMedia = [[mediaController selectedObjects] objectAtIndex:0];
currentMovie = [[QTMovie alloc] initWithFile:[currentMedia media] error:nil];
currentMovieTitle = [currentMedia name];
} else {
currentMovie = nil;
currentMovieTitle = @"";
}
} }
[self moviePanelDidAppear]; [self moviePanelDidAppear];
} }

View File

@ -13,7 +13,7 @@
IBOutlet QTMovieView * panelMovieView; IBOutlet QTMovieView * panelMovieView;
} }
- (BOOL)shouldDisplayMovie:(QTMovie *)movie; - (BOOL)shouldDisplayMovie:(QTMovie *)movie withTitle:(NSString *)title;
- (IBAction)toggleWindow:(id)sender; - (IBAction)toggleWindow:(id)sender;
@end @end

View File

@ -23,13 +23,15 @@
[super windowDidLoad]; [super windowDidLoad];
} }
- (BOOL)shouldDisplayMovie:(QTMovie *)movie - (BOOL)shouldDisplayMovie:(QTMovie *)movie withTitle:(NSString *)title
{ {
if ([self isWindowLoaded] && [[self window] isVisible]) { if ([self isWindowLoaded] && [[self window] isVisible]) {
[panelMovieView setMovie:movie]; [panelMovieView setMovie:movie];
[[self window] setTitle:title];
return YES; return YES;
} else { } else {
[panelMovieView setMovie:nil]; [panelMovieView setMovie:nil];
[[self window] setTitle:@""];
return NO; return NO;
} }
} }