Skip to content

Commit

Permalink
Update global hotkey
Browse files Browse the repository at this point in the history
  • Loading branch information
phucledien committed Aug 25, 2020
1 parent 43261dd commit d31c785
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 11 deletions.
16 changes: 8 additions & 8 deletions Hidden Bar.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -558,16 +558,16 @@
CODE_SIGN_IDENTITY = "Mac Developer";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 9;
DEVELOPMENT_TEAM = VGURA84Q2L;
CURRENT_PROJECT_VERSION = 10;
DEVELOPMENT_TEAM = W777S7V8TN;
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = hidden/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.12;
MARKETING_VERSION = 1.5;
MARKETING_VERSION = 1.6;
PRODUCT_BUNDLE_IDENTIFIER = com.dwarvesv.minimalbar;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand All @@ -583,16 +583,16 @@
CODE_SIGN_IDENTITY = "Mac Developer";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 9;
DEVELOPMENT_TEAM = VGURA84Q2L;
CURRENT_PROJECT_VERSION = 10;
DEVELOPMENT_TEAM = W777S7V8TN;
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = hidden/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.12;
MARKETING_VERSION = 1.5;
MARKETING_VERSION = 1.6;
PRODUCT_BUNDLE_IDENTIFIER = com.dwarvesv.minimalbar;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand All @@ -608,7 +608,7 @@
CODE_SIGN_IDENTITY = "Mac Developer";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
DEVELOPMENT_TEAM = VGURA84Q2L;
DEVELOPMENT_TEAM = W777S7V8TN;
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = LauncherApplication/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
Expand All @@ -632,7 +632,7 @@
CODE_SIGN_IDENTITY = "Mac Developer";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
DEVELOPMENT_TEAM = VGURA84Q2L;
DEVELOPMENT_TEAM = W777S7V8TN;
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = LauncherApplication/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
Expand Down
15 changes: 12 additions & 3 deletions hidden/Features/Preferences/PreferencesViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class PreferencesViewController: NSViewController {
characters: nil,
keyCode: uint32(event.keyCode))

updateKeybindButton(newGlobalKeybind)
updateModifierbindButton(newGlobalKeybind)

}

Expand All @@ -148,12 +148,21 @@ class PreferencesViewController: NSViewController {
// Set the shortcut button to show the keys to press
private func updateKeybindButton(_ globalKeybindPreference : GlobalKeybindPreferences) {
btnShortcut.title = globalKeybindPreference.description

if globalKeybindPreference.description.isEmpty {
if globalKeybindPreference.description.count <= 1 {
unregister(nil)
}
}

// Set the shortcut button to show the modifier to press
private func updateModifierbindButton(_ globalKeybindPreference : GlobalKeybindPreferences) {
btnShortcut.title = globalKeybindPreference.description

if globalKeybindPreference.description.isEmpty {
unregister(nil)
}
}

// If a keybind is set, allow users to clear it by enabling the clear button.
private func updateClearButton(_ globalKeybindPreference : GlobalKeybindPreferences?) {
btnClear.isEnabled = globalKeybindPreference != nil
Expand Down
11 changes: 11 additions & 0 deletions hidden/Models/GlobalKeybindingPreferences.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,20 @@ struct GlobalKeybindPreferences: Codable, CustomStringConvertible {
if self.capsLock {
stringBuilder += ""
}
if keyCode == 36 { // return
stringBuilder += ""
return stringBuilder
}

if keyCode == 51 { // delete
stringBuilder += ""
return stringBuilder
}

if let characters = self.characters {
stringBuilder += characters.uppercased()
}

return "\(stringBuilder)"
}
}
Expand Down

0 comments on commit d31c785

Please sign in to comment.