From 2daf066c2546eb889b300837033ae927a4e2361a Mon Sep 17 00:00:00 2001 From: Vadim Khitrin Date: Sun, 29 Dec 2024 19:55:30 +0200 Subject: [PATCH] fix: Adapt Keybindings For Platform + Fix macOS Bundle * Keybindings should not match the platform. Resolves #26. * Fixing macOS bundle. --- res/macOS/cosmicding.app/Contents/Info.plist | 69 ++++++++++---------- src/key_binds.rs | 28 ++++++-- 2 files changed, 56 insertions(+), 41 deletions(-) diff --git a/res/macOS/cosmicding.app/Contents/Info.plist b/res/macOS/cosmicding.app/Contents/Info.plist index 0bfc36d..ccafe30 100644 --- a/res/macOS/cosmicding.app/Contents/Info.plist +++ b/res/macOS/cosmicding.app/Contents/Info.plist @@ -1,39 +1,38 @@ - - CFBundleDevelopmentRegion - en - CFBundleExecutable - cosmicding - CFBundleIdentifier - com.vkhitrin.cosmicding - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - cosmicding - CFBundlePackageType - APPL - CFBundleShortVersionString - {{ VERSION }} - CFBundleSupportedPlatforms - - MacOSX - - CFBundleVersion - {{ BUILD }} - CFBundleIconFile - cosmicding.icns - NSHighResolutionCapable - - NSMainNibFile - - NSSupportsAutomaticGraphicsSwitching - - CFBundleDisplayName - cosmicding - NSRequiresAquaSystemAppearance - NO - CFBundleURLTypes - + + CFBundleDevelopmentRegion + en + CFBundleExecutable + cosmicding + CFBundleIdentifier + com.vkhitrin.cosmicding + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + cosmicding + CFBundlePackageType + APPL + CFBundleShortVersionString + __VERSION__ + CFBundleSupportedPlatforms + + MacOSX + + CFBundleVersion + __BUILD__ + CFBundleIconFile + AppIcon.icns + NSHighResolutionCapable + + NSMainNibFile + + NSSupportsAutomaticGraphicsSwitching + + CFBundleDisplayName + cosmicding + NSRequiresAquaSystemAppearance + NO + diff --git a/src/key_binds.rs b/src/key_binds.rs index ca6534e..4d94766 100644 --- a/src/key_binds.rs +++ b/src/key_binds.rs @@ -13,7 +13,7 @@ pub fn key_binds() -> HashMap { ([$($modifier:ident),* $(,)?], $key:expr, $action:ident) => {{ key_binds.insert( KeyBind { - modifiers: vec![$(Modifier::$modifier),*], + modifiers: vec![$($modifier),*], key: $key, }, MenuAction::$action, @@ -21,11 +21,27 @@ pub fn key_binds() -> HashMap { }}; } - bind!([Ctrl], Key::Character(",".into()), Settings); - bind!([Ctrl], Key::Character("i".into()), About); - bind!([Ctrl, Shift], Key::Character("n".into()), AddAccount); - bind!([Ctrl], Key::Character("n".into()), AddBookmark); - bind!([Ctrl], Key::Character("r".into()), RefreshBookmarks); + let primary_modifier = if cfg!(target_os = "macos") { + Modifier::Super // Use Cmd (Command) on macOS + } else { + Modifier::Ctrl // Default to Ctrl for other platforms (could be adjusted as needed) + }; + + let secondary_modifier = Modifier::Shift; + + bind!([primary_modifier], Key::Character(",".into()), Settings); + bind!([primary_modifier], Key::Character("i".into()), About); + bind!( + [primary_modifier, secondary_modifier], + Key::Character("n".into()), + AddAccount + ); + bind!([primary_modifier], Key::Character("n".into()), AddBookmark); + bind!( + [primary_modifier], + Key::Character("r".into()), + RefreshBookmarks + ); key_binds }