mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-01-19 12:22:32 +00:00
Add "Open Memory Stick" to File menu on Mac
This commit is contained in:
parent
c24f7eb084
commit
eeaeb8b7cc
@ -41,7 +41,7 @@ variableName.state = [self controlStateForBool: ConfigurationValueName];
|
||||
@interface BarItemsManager : NSObject <NSMenuDelegate>
|
||||
+(instancetype)sharedInstance;
|
||||
-(void)setupAppBarItems;
|
||||
@property (assign) NSMenu *openMenu;
|
||||
@property (assign) NSMenu *fileMenu;
|
||||
@property (assign) std::shared_ptr<I18NCategory> mainSettingsLocalization;
|
||||
@property (assign) std::shared_ptr<I18NCategory> graphicsLocalization;
|
||||
@end
|
||||
@ -65,9 +65,9 @@ void initializeOSXExtras() {
|
||||
|
||||
-(void)setupAppBarItems {
|
||||
|
||||
NSMenuItem *openMenuItem = [[NSMenuItem alloc] init];
|
||||
openMenuItem.submenu = [self makeOpenSubmenu];
|
||||
openMenuItem.submenu.delegate = self;
|
||||
NSMenuItem *fileMenuItem = [[NSMenuItem alloc] init];
|
||||
fileMenuItem.submenu = [self makeFileSubmenu];
|
||||
fileMenuItem.submenu.delegate = self;
|
||||
|
||||
NSMenuItem *graphicsMenuItem = [[NSMenuItem alloc] init];
|
||||
graphicsMenuItem.submenu = [self makeGraphicsMenu];
|
||||
@ -80,7 +80,7 @@ void initializeOSXExtras() {
|
||||
NSMenuItem *helpMenuItem = [[NSMenuItem alloc] init];
|
||||
helpMenuItem.submenu = [self makeHelpMenu];
|
||||
|
||||
[NSApplication.sharedApplication.menu addItem:openMenuItem];
|
||||
[NSApplication.sharedApplication.menu addItem:fileMenuItem];
|
||||
[NSApplication.sharedApplication.menu addItem:graphicsMenuItem];
|
||||
[NSApplication.sharedApplication.menu addItem:debugMenuItem];
|
||||
[NSApplication.sharedApplication.menu addItem:helpMenuItem];
|
||||
@ -206,16 +206,23 @@ void initializeOSXExtras() {
|
||||
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"https://discord.gg/5NJB6dD"]];
|
||||
}
|
||||
|
||||
-(NSMenu *)makeOpenSubmenu {
|
||||
-(NSMenu *)makeFileSubmenu {
|
||||
NSMenu *menu = [[NSMenu alloc] initWithTitle:@"File"];
|
||||
NSMenuItem *openWithSystemFolderBrowserItem = [[NSMenuItem alloc] initWithTitle:@"Open..." action:@selector(openSystemFileBrowser) keyEquivalent:@"o"];
|
||||
openWithSystemFolderBrowserItem.keyEquivalentModifierMask = NSEventModifierFlagCommand;
|
||||
openWithSystemFolderBrowserItem.enabled = YES;
|
||||
openWithSystemFolderBrowserItem.target = self;
|
||||
[menu addItem:openWithSystemFolderBrowserItem];
|
||||
self.openMenu = menu;
|
||||
|
||||
self.fileMenu = menu;
|
||||
[self addOpenRecentlyItem];
|
||||
|
||||
[self.fileMenu addItem:[NSMenuItem separatorItem]];
|
||||
|
||||
NSMenuItem *openMemstickFolderItem = [[NSMenuItem alloc] initWithTitle:@"Open Memory Stick" action:@selector(openMemstickFolder) keyEquivalent:@""];
|
||||
openMemstickFolderItem.enabled = YES;
|
||||
openMemstickFolderItem.target = self;
|
||||
[self.fileMenu addItem:openMemstickFolderItem];
|
||||
|
||||
return menu;
|
||||
}
|
||||
|
||||
@ -504,7 +511,7 @@ TOGGLE_METHOD(ShowDebugStats, g_Config.bShowDebugStats, NativeMessageReceived("c
|
||||
}
|
||||
|
||||
openRecent.submenu = recentsMenu;
|
||||
[self.openMenu addItem:openRecent];
|
||||
[self.fileMenu addItem:openRecent];
|
||||
}
|
||||
|
||||
-(void)openRecentItem: (NSMenuItem *)item {
|
||||
@ -522,6 +529,12 @@ TOGGLE_METHOD(ShowDebugStats, g_Config.bShowDebugStats, NativeMessageReceived("c
|
||||
services.presentDirectoryPanel(callback, /* allowFiles = */ true, /* allowDirectorites = */ true);
|
||||
}
|
||||
|
||||
-(void)openMemstickFolder {
|
||||
NSString *script = [NSString stringWithFormat:@"tell application \"Finder\"\nactivate\nopen folder (\"%s\" as POSIX file)\nend tell\n", g_Config.memStickDirectory.c_str()];
|
||||
NSAppleScript *openScript = [[NSAppleScript alloc] initWithSource: script];
|
||||
[openScript executeAndReturnError:nil];
|
||||
}
|
||||
|
||||
- (void)dealloc {
|
||||
[NSNotificationCenter.defaultCenter removeObserver:self];
|
||||
}
|
||||
|
@ -1183,6 +1183,7 @@ int main(int argc, char *argv[]) {
|
||||
NativeKey(key);
|
||||
break;
|
||||
}
|
||||
// TODO: Should we even keep the "non-precise" events?
|
||||
if (event.wheel.y > 0) {
|
||||
key.keyCode = NKCODE_EXT_MOUSEWHEEL_UP;
|
||||
mouseWheelMovedUpFrames = 5;
|
||||
|
@ -454,7 +454,7 @@ namespace MainWindow {
|
||||
break;
|
||||
|
||||
case ID_FILE_MEMSTICK:
|
||||
ShellExecute(NULL, L"open", g_Config.memStickDirectory.ToWString().c_str(), 0, 0, SW_SHOW);
|
||||
ShellExecute(NULL, L"open", g_Config.memStickDirectory.ToWString().c_str(), 0, 0, SW_SHOWNORMAL);
|
||||
break;
|
||||
|
||||
case ID_TOGGLE_BREAK:
|
||||
|
Loading…
x
Reference in New Issue
Block a user