| |
Changeset 119
- Timestamp:
- 02/10/08 19:18:38
(1 year ago)
- Author:
- mike
- Message:
[new] smartfolder for Q Control (get rid of default folder)
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r106 |
r119 |
|
| 86 | 86 | <key>prefLog</key> |
|---|
| 87 | 87 | <string>id</string> |
|---|
| 88 | | <key>prefPathChoose</key> |
|---|
| 89 | | <string>id</string> |
|---|
| 90 | | <key>prefPathReset</key> |
|---|
| 91 | | <string>id</string> |
|---|
| 92 | 88 | <key>prefUpdates</key> |
|---|
| 93 | 89 | <string>id</string> |
|---|
| … | … | |
| 111 | 107 | <key>buttonEdit</key> |
|---|
| 112 | 108 | <string>NSButton</string> |
|---|
| | 109 | <key>loadProgressIndicator</key> |
|---|
| | 110 | <string>id</string> |
|---|
| | 111 | <key>loadProgressText</key> |
|---|
| | 112 | <string>id</string> |
|---|
| 113 | 113 | <key>mainWindow</key> |
|---|
| 114 | 114 | <string>id</string> |
|---|
| r116 |
r119 |
|
| 11 | 11 | <key>IBOpenObjects</key> |
|---|
| 12 | 12 | <array> |
|---|
| 13 | | <integer>221</integer> |
|---|
| | 13 | <integer>216</integer> |
|---|
| 14 | 14 | </array> |
|---|
| 15 | 15 | <key>IBSystem Version</key> |
|---|
| r112 |
r119 |
|
| 40 | 40 | [NSNumber numberWithBool:TRUE], // yellow |
|---|
| 41 | 41 | [NSNumber numberWithBool:TRUE], // showFullscreenWarning |
|---|
| 42 | | [@"~/Documents/QEMU" stringByExpandingTildeInPath], // standart path |
|---|
| 43 | 42 | [NSMutableArray array], // known VMs |
|---|
| 44 | 43 | nil |
|---|
| … | … | |
| 47 | 46 | @"yellow", |
|---|
| 48 | 47 | @"showFullscreenWarning", |
|---|
| 49 | | @"dataPath", |
|---|
| 50 | 48 | @"knownVMs", |
|---|
| 51 | 49 | nil]]]; |
|---|
| … | … | |
| 61 | 59 | if ([userDefaults objectForKey:@"enableCheckForUpdates"]) { |
|---|
| 62 | 60 | [userDefaults removeObjectForKey:@"enableCheckForUpdates"]; |
|---|
| | 61 | } |
|---|
| | 62 | if ([userDefaults objectForKey:@"dataPath"]) { |
|---|
| | 63 | [userDefaults removeObjectForKey:@"dataPath"]; |
|---|
| 63 | 64 | } |
|---|
| 64 | 65 | #pragma mark TODO:Sparclekey for userdefaults |
|---|
| r106 |
r119 |
|
| 47 | 47 | BOOL isPrefAnimating; |
|---|
| 48 | 48 | BOOL isPrefShown; |
|---|
| 49 | | IBOutlet id prefPath; |
|---|
| 50 | 49 | IBOutlet id prefUpdates; |
|---|
| 51 | 50 | IBOutlet id prefLog; |
|---|
| … | … | |
| 55 | 54 | IBOutlet NSButton *buttonEdit; |
|---|
| 56 | 55 | IBOutlet NSButton *buttonAdd; |
|---|
| | 56 | |
|---|
| | 57 | // loading VMs |
|---|
| | 58 | IBOutlet id loadProgressIndicator; |
|---|
| | 59 | IBOutlet id loadProgressText; |
|---|
| | 60 | |
|---|
| | 61 | // browsing for qvms |
|---|
| | 62 | NSMetadataQuery *query; |
|---|
| 57 | 63 | /* |
|---|
| 58 | 64 | // progressPanel |
|---|
| … | … | |
| 98 | 104 | - (IBAction) prefYellow:(id)sender; |
|---|
| 99 | 105 | - (IBAction) prefFSWarning:(id)sender; |
|---|
| 100 | | - (IBAction) prefPathReset:(id)sender; |
|---|
| 101 | | - (IBAction) prefPathChoose:(id)sender; |
|---|
| 102 | 106 | |
|---|
| 103 | 107 | /* |
|---|
| r118 |
r119 |
|
| 32 | 32 | |
|---|
| 33 | 33 | |
|---|
| 34 | | #define PREFS_HEIGHT 190.0 |
|---|
| | 34 | #define PREFS_HEIGHT 100.0 |
|---|
| 35 | 35 | |
|---|
| 36 | 36 | @implementation QControlController |
|---|
| … | … | |
| 45 | 45 | qApplication = [NSApp delegate]; |
|---|
| 46 | 46 | |
|---|
| 47 | | // load known VMs |
|---|
| | 47 | // load known VMs, search for new VMs |
|---|
| 48 | 48 | [self loadConfigurations]; |
|---|
| 49 | | |
|---|
| 50 | | // change status to "shutdown" after corrupt termination of QEMU |
|---|
| 51 | | int i; |
|---|
| 52 | | for (i = 0; i < [VMs count]; i++) { |
|---|
| 53 | | if ([[[[VMs objectAtIndex:i] objectForKey:@"PC Data"] objectForKey:@"state"] isEqual:@"running"] ) { |
|---|
| 54 | | [[[VMs objectAtIndex:i] objectForKey:@"PC Data"] setObject:@"shutdown" forKey:@"state"]; |
|---|
| 55 | | [[QQvmManager sharedQvmManager] saveVMConfiguration:[VMs objectAtIndex:i]]; |
|---|
| 56 | | } |
|---|
| 57 | | } |
|---|
| | 49 | |
|---|
| | 50 | // Listen if new VMs are found |
|---|
| | 51 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(queryFinished:) name:NSMetadataQueryDidFinishGatheringNotification object:query]; |
|---|
| 58 | 52 | |
|---|
| 59 | 53 | // Listen to VM updates |
|---|
| … | … | |
| 68 | 62 | |
|---|
| 69 | 63 | [[NSNotificationCenter defaultCenter] removeObserver:self]; |
|---|
| | 64 | [query release]; |
|---|
| 70 | 65 | [super dealloc]; |
|---|
| 71 | 66 | } |
|---|
| … | … | |
| 76 | 71 | |
|---|
| 77 | 72 | #pragma mark TODO: load other nibs |
|---|
| | 73 | |
|---|
| | 74 | NSPredicate *predicate; |
|---|
| 78 | 75 | |
|---|
| 79 | 76 | [buttonEdit setCell:[[[QButtonCell alloc] initImageCell:[[buttonEdit cell] image] buttonType:QButtonCellLeft target:[[buttonEdit cell] target] action:[[buttonEdit cell] action]] autorelease]]; |
|---|
| 80 | 77 | [buttonAdd setCell:[[[QButtonCell alloc] initImageCell:[[buttonAdd cell] image] buttonType:QButtonCellRight target:[[buttonAdd cell] target] action:[[buttonAdd cell] action]] autorelease]]; |
|---|
| 81 | 78 | |
|---|
| 82 | | |
|---|
| | 79 | // search for qvms |
|---|
| | 80 | |
|---|
| | 81 | query = [[NSMetadataQuery alloc] init]; |
|---|
| | 82 | [query setDelegate:self]; |
|---|
| | 83 | [loadProgressIndicator startAnimation:self]; |
|---|
| | 84 | predicate = [NSPredicate predicateWithFormat:@"kMDItemDisplayName ENDSWITH 'qvm'", nil]; |
|---|
| | 85 | [query setPredicate:predicate]; |
|---|
| | 86 | [query setSearchScopes:[NSArray arrayWithObject:@"/Users/"]]; |
|---|
| | 87 | [query startQuery]; |
|---|
| | 88 | |
|---|
| | 89 | |
|---|
| 83 | 90 | // preferences |
|---|
| 84 | | [prefPath setStringValue:[[qApplication userDefaults] objectForKey:@"dataPath"]]; |
|---|
| 85 | 91 | if ([[qApplication userDefaults] boolForKey:@"SUCheckAtStartup"]) { |
|---|
| 86 | 92 | [prefUpdates setState:NSOnState]; |
|---|
| … | … | |
| 119 | 125 | { |
|---|
| 120 | 126 | Q_DEBUG(@"loadConfigurations"); |
|---|
| 121 | | |
|---|
| | 127 | |
|---|
| 122 | 128 | if (VMs) |
|---|
| 123 | 129 | [VMs release]; |
|---|
| 124 | 130 | |
|---|
| 125 | 131 | VMs = [[NSMutableArray alloc] init]; |
|---|
| 126 | | NSString *qvmFile; |
|---|
| 127 | 132 | NSMutableDictionary *tempVM; |
|---|
| 128 | | NSDirectoryEnumerator *enumerator = [[NSFileManager defaultManager] enumeratorAtPath:[[qApplication userDefaults] objectForKey:@"dataPath"]]; |
|---|
| 129 | | while ((qvmFile = [enumerator nextObject])) { |
|---|
| 130 | | if ([[qvmFile pathExtension] isEqual:@"qvm"]) { |
|---|
| 131 | | tempVM = [[QQvmManager sharedQvmManager] loadVMConfiguration:[NSString stringWithFormat:@"%@/%@", [[qApplication userDefaults] objectForKey:@"dataPath"], qvmFile]]; |
|---|
| 132 | | if (tempVM) |
|---|
| 133 | | [VMs addObject:tempVM]; |
|---|
| 134 | | } |
|---|
| 135 | | } |
|---|
| | 133 | |
|---|
| 136 | 134 | // add knownVMs |
|---|
| 137 | 135 | int i; |
|---|
| … | … | |
| 482 | 480 | } |
|---|
| 483 | 481 | |
|---|
| 484 | | - (IBAction) prefPathReset:(id)sender |
|---|
| 485 | | { |
|---|
| 486 | | Q_DEBUG(@"prefPathReset"); |
|---|
| 487 | | |
|---|
| 488 | | [[qApplication userDefaults] setObject:[@"~/Documents/QEMU" stringByExpandingTildeInPath] forKey:@"dataPath"]; |
|---|
| 489 | | [prefPath setStringValue:[[qApplication userDefaults] objectForKey:@"dataPath"]]; |
|---|
| 490 | | } |
|---|
| 491 | | |
|---|
| 492 | | - (void) genericFolderSelectPanelDidEnd:(NSOpenPanel *)sheet returnCode:(int)returnCode contextInfo:(id)contextInfo |
|---|
| 493 | | { |
|---|
| 494 | | Q_DEBUG(@"genericFolderSelectPanelDidEnd"); |
|---|
| 495 | | |
|---|
| 496 | | [ sheet orderOut:self ]; // hide Sheet |
|---|
| 497 | | if ( returnCode == NSOKButton ) { |
|---|
| 498 | | [[qApplication userDefaults] setObject:[sheet filename] forKey:@"dataPath"]; |
|---|
| 499 | | [prefPath setStringValue:[sheet filename]]; |
|---|
| 500 | | } |
|---|
| 501 | | } |
|---|
| 502 | | |
|---|
| 503 | | - (IBAction) prefPathChoose:(id)sender |
|---|
| 504 | | { |
|---|
| 505 | | Q_DEBUG(@"prefPathChoose"); |
|---|
| 506 | | |
|---|
| 507 | | NSOpenPanel *openPanel = [[NSOpenPanel alloc] init]; |
|---|
| 508 | | [openPanel setCanChooseDirectories:YES]; |
|---|
| 509 | | [openPanel setCanCreateDirectories:YES]; |
|---|
| 510 | | [openPanel setCanChooseFiles:NO]; |
|---|
| 511 | | [openPanel beginSheetForDirectory:[@"~/Documents" stringByExpandingTildeInPath] |
|---|
| 512 | | file:nil |
|---|
| 513 | | types:nil |
|---|
| 514 | | modalForWindow:mainWindow |
|---|
| 515 | | modalDelegate:self |
|---|
| 516 | | didEndSelector:@selector(genericFolderSelectPanelDidEnd:returnCode:contextInfo:) |
|---|
| 517 | | contextInfo:sender]; |
|---|
| | 482 | |
|---|
| | 483 | |
|---|
| | 484 | #pragma mark query handlers |
|---|
| | 485 | - (void)queryFinished:(NSNotification*)note |
|---|
| | 486 | { |
|---|
| | 487 | Q_DEBUG(@"queryFinished"); |
|---|
| | 488 | |
|---|
| | 489 | int i; |
|---|
| | 490 | NSArray *searchResults; |
|---|
| | 491 | NSString *VMPath; |
|---|
| | 492 | NSMutableArray *knownVMs; |
|---|
| | 493 | |
|---|
| | 494 | knownVMs = [[[[qApplication userDefaults] objectForKey:@"knownVMs"] mutableCopy] autorelease]; |
|---|
| | 495 | searchResults = [(NSMetadataQuery*)[note object] results]; |
|---|
| | 496 | |
|---|
| | 497 | for (i = 0; i < [searchResults count]; i++) { |
|---|
| | 498 | VMPath = [[[searchResults objectAtIndex:i] valueForAttribute: (NSString *)kMDItemPath] stringByResolvingSymlinksInPath]; |
|---|
| | 499 | if (![knownVMs containsObject:VMPath]) { |
|---|
| | 500 | [knownVMs addObject:VMPath]; |
|---|
| | 501 | } |
|---|
| | 502 | } |
|---|
| | 503 | [[qApplication userDefaults] setObject:knownVMs forKey:@"knownVMs"]; |
|---|
| | 504 | |
|---|
| | 505 | // change status to "shutdown" after corrupt termination of QEMU |
|---|
| | 506 | for (i = 0; i < [VMs count]; i++) { |
|---|
| | 507 | if ([[[[VMs objectAtIndex:i] objectForKey:@"PC Data"] objectForKey:@"state"] isEqual:@"running"] ) { |
|---|
| | 508 | [[[VMs objectAtIndex:i] objectForKey:@"PC Data"] setObject:@"shutdown" forKey:@"state"]; |
|---|
| | 509 | [[QQvmManager sharedQvmManager] saveVMConfiguration:[VMs objectAtIndex:i]]; |
|---|
| | 510 | } |
|---|
| | 511 | } |
|---|
| | 512 | |
|---|
| | 513 | [loadProgressText setHidden:TRUE]; |
|---|
| | 514 | [loadProgressIndicator stopAnimation:self]; |
|---|
| | 515 | [table reloadData]; |
|---|
| 518 | 516 | } |
|---|
| 519 | 517 | |
|---|
| r113 |
r119 |
|
| 29 | 29 | |
|---|
| 30 | 30 | |
|---|
| 31 | | #define ICON_WIDTH 12.0 |
|---|
| 32 | | #define ICON_HEIGHT 12.0 |
|---|
| | 31 | #define ICON_WIDTH 9.0 |
|---|
| | 32 | #define ICON_HEIGHT 9.0 |
|---|
| | 33 | #define ICON_X 45.0 |
|---|
| | 34 | #define ICON_Y 31.0 |
|---|
| 33 | 35 | |
|---|
| 34 | 36 | @implementation QControlTableView |
|---|
| … | … | |
| 189 | 191 | |
|---|
| 190 | 192 | // edit icon |
|---|
| 191 | | point = NSMakePoint(cellRect.origin.x + cellRect.size.width - 4 * (ICON_WIDTH + 4), cellRect.origin.y + cellRect.size.height - (ICON_HEIGHT + 4)); |
|---|
| | 193 | point = NSMakePoint(cellRect.origin.x + ICON_X + (ICON_WIDTH + 4), cellRect.origin.y + ICON_Y); |
|---|
| 192 | 194 | if (NSPointInRect(pointClicked, NSMakeRect(point.x, point.y, ICON_WIDTH, ICON_HEIGHT))) { |
|---|
| 193 | 195 | qFraction = 1.0; |
|---|
| … | … | |
| 206 | 208 | } |
|---|
| 207 | 209 | [qEditIcon |
|---|
| 208 | | drawAtPoint: point |
|---|
| 209 | | fromRect: NSMakeRect(0, 0, ICON_WIDTH, ICON_HEIGHT) |
|---|
| | 210 | drawInRect: NSMakeRect(point.x, point.y, ICON_WIDTH, ICON_HEIGHT) |
|---|
| | 211 | fromRect: NSMakeRect(0, 0, [qEditIcon size].width, [qEditIcon size].height) |
|---|
| 210 | 212 | operation: NSCompositeSourceOver |
|---|
| 211 | 213 | fraction: qFraction |
|---|
| … | … | |
| 213 | 215 | |
|---|
| 214 | 216 | // play/pause icon |
|---|
| 215 | | point = NSMakePoint(cellRect.origin.x + cellRect.size.width - 3 * (ICON_WIDTH + 4), cellRect.origin.y + cellRect.size.height - (ICON_HEIGHT + 4)); |
|---|
| | 217 | point = NSMakePoint(cellRect.origin.x + ICON_X + 2 * (ICON_WIDTH + 4), cellRect.origin.y + ICON_Y); |
|---|
| 216 | 218 | if (NSPointInRect(pointClicked, NSMakeRect(point.x, point.y, ICON_WIDTH, ICON_HEIGHT))) { |
|---|
| 217 | 219 | qFraction = 1.0; |
|---|
| … | … | |
| 243 | 245 | } |
|---|
| 244 | 246 | [image |
|---|
| 245 | | drawAtPoint: point |
|---|
| 246 | | fromRect: NSMakeRect(0, 0, ICON_WIDTH, ICON_HEIGHT) |
|---|
| | 247 | drawInRect: NSMakeRect(point.x, point.y, ICON_WIDTH, ICON_HEIGHT) |
|---|
| | 248 | fromRect: NSMakeRect(0, 0, [image size].width, [image size].height) |
|---|
| 247 | 249 | operation: NSCompositeSourceOver |
|---|
| 248 | 250 | fraction: qFraction |
|---|
| … | … | |
| 250 | 252 | |
|---|
| 251 | 253 | // stop icon |
|---|
| 252 | | point = NSMakePoint(cellRect.origin.x + cellRect.size.width - 2 * (ICON_WIDTH + 4), cellRect.origin.y + cellRect.size.height - (ICON_HEIGHT + 4)); |
|---|
| | 254 | point = NSMakePoint(cellRect.origin.x + ICON_X + 3 * (ICON_WIDTH + 4), cellRect.origin.y + ICON_Y); |
|---|
| 253 | 255 | if (NSPointInRect(pointClicked, NSMakeRect(point.x, point.y, ICON_WIDTH, ICON_HEIGHT))) { |
|---|
| 254 | 256 | qFraction = 1.0; |
|---|
| … | … | |
| 267 | 269 | } |
|---|
| 268 | 270 | [qStopIcon |
|---|
| 269 | | drawAtPoint: point |
|---|
| 270 | | fromRect: NSMakeRect(0, 0, ICON_WIDTH, ICON_HEIGHT) |
|---|
| | 271 | drawInRect: NSMakeRect(point.x, point.y, ICON_WIDTH, ICON_HEIGHT) |
|---|
| | 272 | fromRect: NSMakeRect(0, 0, [qStopIcon size].width, [qStopIcon size].height) |
|---|
| 271 | 273 | operation: NSCompositeSourceOver |
|---|
| 272 | 274 | fraction: qFraction |
|---|
| … | … | |
| 274 | 276 | |
|---|
| 275 | 277 | // delete icon |
|---|
| 276 | | point = NSMakePoint(cellRect.origin.x + cellRect.size.width - (ICON_WIDTH + 4), cellRect.origin.y + cellRect.size.height - (ICON_HEIGHT + 4)); |
|---|
| | 278 | point = NSMakePoint(cellRect.origin.x + ICON_X + 4 * (ICON_WIDTH + 4), cellRect.origin.y + ICON_Y); |
|---|
| 277 | 279 | if (NSPointInRect(pointClicked, NSMakeRect(point.x, point.y, ICON_WIDTH, ICON_HEIGHT))) |
|---|
| 278 | 280 | qFraction = 1.0; |
|---|
| … | … | |
| 282 | 284 | qFraction = 0.5; |
|---|
| 283 | 285 | [qDeleteIcon |
|---|
| 284 | | drawAtPoint: point |
|---|
| 285 | | fromRect: NSMakeRect(0, 0, ICON_WIDTH, ICON_HEIGHT) |
|---|
| | 286 | drawInRect: NSMakeRect(point.x, point.y, ICON_WIDTH, ICON_HEIGHT) |
|---|
| | 287 | fromRect: NSMakeRect(0, 0, [qDeleteIcon size].width, [qDeleteIcon size].height) |
|---|
| 286 | 288 | operation: NSCompositeSourceOver |
|---|
| 287 | 289 | fraction: qFraction |
|---|
| r116 |
r119 |
|
| 82 | 82 | |
|---|
| 83 | 83 | id VM; |
|---|
| 84 | | NSString *platform; |
|---|
| 85 | 84 | NSString *state; |
|---|
| | 85 | NSString *name; |
|---|
| | 86 | NSString *path; |
|---|
| | 87 | NSColor *color; |
|---|
| 86 | 88 | QDocument *qDocument; |
|---|
| 87 | | |
|---|
| 88 | | platform = @""; |
|---|
| 89 | | VM = [[qControl VMs] objectAtIndex:rowIndex]; |
|---|
| 90 | | qDocument = [[NSDocumentController sharedDocumentController] documentForURL:[[VM objectForKey:@"Temporary"] objectForKey:@"URL"]]; |
|---|
| 91 | | if (qDocument) { |
|---|
| 92 | | switch ([qDocument VMState]) { |
|---|
| 93 | | case(QDocumentSaving): |
|---|
| 94 | | state = NSLocalizedStringFromTable(@"saving", @"Localizable", @"vmstate"); |
|---|
| 95 | | break; |
|---|
| 96 | | case(QDocumentSaved): |
|---|
| 97 | | state = NSLocalizedStringFromTable(@"saved", @"Localizable", @"vmstate"); |
|---|
| 98 | | break; |
|---|
| 99 | | case(QDocumentLoading): |
|---|
| 100 | | state = NSLocalizedStringFromTable(@"loading", @"Localizable", @"vmstate"); |
|---|
| 101 | | break; |
|---|
| 102 | | case(QDocumentPaused): |
|---|
| 103 | | state = NSLocalizedStringFromTable(@"paused", @"Localizable", @"vmstate"); |
|---|
| 104 | | break; |
|---|
| 105 | | case(QDocumentRunning): |
|---|
| 106 | | state = NSLocalizedStringFromTable(@"running", @"Localizable", @"vmstate"); |
|---|
| 107 | | break; |
|---|
| 108 | | case(QDocumentEditing): |
|---|
| 109 | | state = NSLocalizedStringFromTable(@"editing", @"Localizable", @"vmstate"); |
|---|
| 110 | | break; |
|---|
| 111 | | case(QDocumentInvalid): |
|---|
| 112 | | state = NSLocalizedStringFromTable(@"invalid", @"Localizable", @"vmstate"); |
|---|
| 113 | | break; |
|---|
| 114 | | default: |
|---|
| 115 | | state = NSLocalizedStringFromTable(@"shutdown", @"Localizable", @"vmstate"); |
|---|
| 116 | | break; |
|---|
| 117 | | } |
|---|
| 118 | | } else { |
|---|
| 119 | | state = NSLocalizedStringFromTable([[VM objectForKey:@"PC Data"] objectForKey:@"state"], @"Localizable", @"vmstate"); |
|---|
| 120 | | } |
|---|
| | 89 | NSMutableParagraphStyle *paragraphStyle; |
|---|
| | 90 | NSMutableAttributedString *attrString; |
|---|
| | 91 | |
|---|
| 121 | 92 | |
|---|
| 122 | 93 | if ([[aTableColumn identifier] isEqualTo: @"image"]) { |
|---|
| … | … | |
| 128 | 99 | } |
|---|
| 129 | 100 | else if ([[aTableColumn identifier] isEqualTo: @"description"]) { |
|---|
| 130 | | |
|---|
| 131 | | if ([[[VM objectForKey:@"PC Data"] objectForKey:@"architecture"] isEqual:@"x86"]) { |
|---|
| 132 | | platform = [NSString stringWithString:@"x86 PC"]; |
|---|
| 133 | | } else if ([[[VM objectForKey:@"PC Data"] objectForKey:@"architecture"] isEqual:@"x86-64"]) { |
|---|
| 134 | | platform = [NSString stringWithString:@"x86-64 PC"]; |
|---|
| 135 | | } else if ([[[VM objectForKey:@"PC Data"] objectForKey:@"architecture"] isEqual:@"PowerPC"] && [[[VM objectForKey:@"Temporary"] objectForKey:@"-M"] isEqual:@"prep"]) { |
|---|
| 136 | | platform = [NSString stringWithString:@"PPC PREP"]; |
|---|
| 137 | | } else if ([[[VM objectForKey:@"PC Data"] objectForKey:@"architecture"] isEqual:@"PowerPC"]) { |
|---|
| 138 | | platform = [NSString stringWithString:@"PPC PowerMac"]; |
|---|
| 139 | | } else if ([[[VM objectForKey:@"PC Data"] objectForKey:@"architecture"] isEqual:@"SPARC"]) { |
|---|
| 140 | | platform = [NSString stringWithString:@"SPARC"]; |
|---|
| 141 | | } else if ([[[VM objectForKey:@"PC Data"] objectForKey:@"architecture"] isEqual:@"MIPS"]) { |
|---|
| 142 | | platform = [NSString stringWithString:@"MIPS"]; |
|---|
| 143 | | } else if ([[[VM objectForKey:@"PC Data"] objectForKey:@"architecture"] isEqual:@"ARM"]) { |
|---|
| 144 | | platform = [NSString stringWithString:@"ARM"]; |
|---|
| 145 | | } |
|---|
| 146 | | |
|---|
| 147 | | NSMutableAttributedString *attrString = [[[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat: @"%@\n", [[[[VM objectForKey:@"Temporary"] objectForKey:@"URL"] path] lastPathComponent]] attributes:[NSDictionary dictionaryWithObject: [NSFont boldSystemFontOfSize:[NSFont smallSystemFontSize]] forKey:NSFontAttributeName]] autorelease]; |
|---|
| | 101 | |
|---|
| | 102 | VM = [[qControl VMs] objectAtIndex:rowIndex]; |
|---|
| | 103 | qDocument = [[NSDocumentController sharedDocumentController] documentForURL:[[VM objectForKey:@"Temporary"] objectForKey:@"URL"]]; |
|---|
| | 104 | if (qDocument) { |
|---|
| | 105 | switch ([qDocument VMState]) { |
|---|
| | 106 | case(QDocumentSaving): |
|---|
| | 107 | state = NSLocalizedStringFromTable(@"saving", @"Localizable", @"vmstate"); |
|---|
| | 108 | break; |
|---|
| | 109 | case(QDocumentSaved): |
|---|
| | 110 | state = NSLocalizedStringFromTable(@"saved", @"Localizable", @"vmstate"); |
|---|
| | 111 | break; |
|---|
| | 112 | case(QDocumentLoading): |
|---|
| | 113 | state = NSLocalizedStringFromTable(@"loading", @"Localizable", @"vmstate"); |
|---|
| | 114 | break; |
|---|
| | 115 | case(QDocumentPaused): |
|---|
| | 116 | state = NSLocalizedStringFromTable(@"paused", @"Localizable", @"vmstate"); |
|---|
| | 117 | break; |
|---|
| | 118 | case(QDocumentRunning): |
|---|
| | 119 | state = NSLocalizedStringFromTable(@"running", @"Localizable", @"vmstate"); |
|---|
| | 120 | break; |
|---|
| | 121 | case(QDocumentEditing): |
|---|
| | 122 | state = NSLocalizedStringFromTable(@"editing", @"Localizable", @"vmstate"); |
|---|
| | 123 | break; |
|---|
| | 124 | case(QDocumentInvalid): |
|---|
| | 125 | state = NSLocalizedStringFromTable(@"invalid", @"Localizable", @"vmstate"); |
|---|
| | 126 | break; |
|---|
| | 127 | default: |
|---|
| | 128 | state = NSLocalizedStringFromTable(@"shutdown", @"Localizable", @"vmstate"); |
|---|
| | 129 | break; |
|---|
| | 130 | } |
|---|
| | 131 | } else { |
|---|
| | 132 | state = NSLocalizedStringFromTable([[VM objectForKey:@"PC Data"] objectForKey:@"state"], @"Localizable", @"vmstate"); |
|---|
| | 133 | } |
|---|
| | 134 | path = [[[VM objectForKey:@"Temporary"] objectForKey:@"URL"] path]; |
|---|
| | 135 | name = [path lastPathComponent]; |
|---|
| | 136 | name = [name substringToIndex:[name length] - 4]; |
|---|
| | 137 | paragraphStyle = [[[NSMutableParagraphStyle alloc] init] autorelease]; |
|---|
| | 138 | |
|---|
| | 139 | color = [NSColor colorWithDeviceRed:0.5 green:0.5 blue:0.5 alpha:1.0]; |
|---|
| | 140 | [paragraphStyle setLineBreakMode:NSLineBreakByTruncatingHead]; |
|---|
| | 141 | |
|---|
| | 142 | attrString = [[[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat: @"%@\n", name] attributes:[NSDictionary dictionaryWithObject: [NSFont boldSystemFontOfSize:[NSFont smallSystemFontSize]] forKey:NSFontAttributeName]] autorelease]; |
|---|
| | 143 | [attrString appendAttributedString: [[[NSAttributedString alloc] initWithString:[NSString stringWithFormat: @"%@\n", [path stringByDeletingLastPathComponent]] attributes:[NSDictionary dictionaryWithObjectsAndKeys: [NSFont systemFontOfSize:[NSFont smallSystemFontSize]], NSFontAttributeName, paragraphStyle, NSParagraphStyleAttributeName, color, NSForegroundColorAttributeName, nil]] autorelease]]; |
|---|
| 148 | 144 | [attrString appendAttributedString: [[[NSAttributedString alloc] initWithString:state attributes:[NSDictionary dictionaryWithObject:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]] forKey:NSFontAttributeName]] autorelease]]; |
|---|
| 149 | | |
|---|
| | 145 | |
|---|
| 150 | 146 | return attrString; |
|---|
| 151 | 147 | } |
|---|
| r106 |
r119 |
|
| 181 | 181 | cpuTypes = [[[NSDictionary alloc] initWithObjects:[NSArray arrayWithObjects:@"i386-softmmu",@"x86_64-softmmu",@"ppc-softmmu",@"sparc-softmmu",@"mips-softmmu",@"arm-softmmu",nil] forKeys:[NSArray arrayWithObjects:@"x86",@"x86-64",@"PowerPC",@"SPARC",@"MIPS",@"ARM",nil]] autorelease]; |
|---|
| 182 | 182 | |
|---|
| 183 | | |
|---|
| 184 | 183 | // if this PC is already running, abort |
|---|
| 185 | 184 | if ([[[[document configuration] objectForKey:@"PC Data"] objectForKey:@"state"] isEqual:@"running"]) { |
|---|
Download in other formats:
| |