ui/cocoa.m: fix help menus

Make the help menus actually work. The code will search thru three different
locations for the help file. If it can't be found a dialog will tell the user
the file can't be found.

Signed-off-by: John Arbuckle <programmingkidx@gmail.com>
Message-id: F6B689F9-4DBD-4C50-BC38-35E5DD03D396@gmail.com
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
John Arbuckle 2016-03-23 14:26:17 +00:00 committed by Peter Maydell
parent 2538039f2c
commit f474790061

View File

@ -858,6 +858,7 @@ QemuCocoaView *cocoaView;
- (void)ejectDeviceMedia:(id)sender; - (void)ejectDeviceMedia:(id)sender;
- (void)changeDeviceMedia:(id)sender; - (void)changeDeviceMedia:(id)sender;
- (BOOL)verifyQuit; - (BOOL)verifyQuit;
- (void)openDocumentation:(NSString *)filename;
@end @end
@implementation QemuCocoaAppController @implementation QemuCocoaAppController
@ -994,20 +995,42 @@ QemuCocoaView *cocoaView;
[cocoaView toggleFullScreen:sender]; [cocoaView toggleFullScreen:sender];
} }
/* Tries to find then open the specified filename */
- (void) openDocumentation: (NSString *) filename
{
/* Where to look for local files */
NSString *path_array[] = {@"../share/doc/qemu/", @"../doc/qemu/", @"../"};
NSString *full_file_path;
/* iterate thru the possible paths until the file is found */
int index;
for (index = 0; index < ARRAY_SIZE(path_array); index++) {
full_file_path = [[NSBundle mainBundle] executablePath];
full_file_path = [full_file_path stringByDeletingLastPathComponent];
full_file_path = [NSString stringWithFormat: @"%@/%@%@", full_file_path,
path_array[index], filename];
if ([[NSWorkspace sharedWorkspace] openFile: full_file_path] == YES) {
return;
}
}
/* If none of the paths opened a file */
NSBeep();
QEMU_Alert(@"Failed to open file");
}
- (void)showQEMUDoc:(id)sender - (void)showQEMUDoc:(id)sender
{ {
COCOA_DEBUG("QemuCocoaAppController: showQEMUDoc\n"); COCOA_DEBUG("QemuCocoaAppController: showQEMUDoc\n");
[[NSWorkspace sharedWorkspace] openFile:[NSString stringWithFormat:@"%@/../doc/qemu/qemu-doc.html", [self openDocumentation: @"qemu-doc.html"];
[[NSBundle mainBundle] resourcePath]] withApplication:@"Help Viewer"];
} }
- (void)showQEMUTec:(id)sender - (void)showQEMUTec:(id)sender
{ {
COCOA_DEBUG("QemuCocoaAppController: showQEMUTec\n"); COCOA_DEBUG("QemuCocoaAppController: showQEMUTec\n");
[[NSWorkspace sharedWorkspace] openFile:[NSString stringWithFormat:@"%@/../doc/qemu/qemu-tech.html", [self openDocumentation: @"qemu-tech.html"];
[[NSBundle mainBundle] resourcePath]] withApplication:@"Help Viewer"];
} }
/* Stretches video to fit host monitor size */ /* Stretches video to fit host monitor size */