Skip to content

Commit

Permalink
Adds a new keyboard shortcut to open settings (#201)
Browse files Browse the repository at this point in the history
  • Loading branch information
niklasr22 authored Jan 12, 2025
1 parent 3946cf0 commit a4350d2
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 10 deletions.
16 changes: 8 additions & 8 deletions BrightIntosh.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@
CODE_SIGN_ENTITLEMENTS = BrightIntosh/BrightIntosh_SE.entitlements;
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 61;
CURRENT_PROJECT_VERSION = 62;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "";
DEVELOPMENT_TEAM = 9K32WDUN2H;
Expand All @@ -419,7 +419,7 @@
LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks";
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 13.0;
MARKETING_VERSION = 3.6.0;
MARKETING_VERSION = 3.7.0;
PRODUCT_BUNDLE_IDENTIFIER = de.brightintosh.app;
PRODUCT_NAME = BrightIntosh;
SDKROOT = auto;
Expand All @@ -444,7 +444,7 @@
CODE_SIGN_ENTITLEMENTS = BrightIntosh/BrightIntosh_SE.entitlements;
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 61;
CURRENT_PROJECT_VERSION = 62;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "";
DEVELOPMENT_TEAM = 9K32WDUN2H;
Expand All @@ -471,7 +471,7 @@
LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks";
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 13.0;
MARKETING_VERSION = 3.6.0;
MARKETING_VERSION = 3.7.0;
PRODUCT_BUNDLE_IDENTIFIER = de.brightintosh.app;
PRODUCT_NAME = BrightIntosh;
SDKROOT = auto;
Expand All @@ -494,7 +494,7 @@
CODE_SIGN_ENTITLEMENTS = BrightIntosh/BrightIntosh.entitlements;
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 61;
CURRENT_PROJECT_VERSION = 62;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "";
DEVELOPMENT_TEAM = 9K32WDUN2H;
Expand All @@ -521,7 +521,7 @@
LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks";
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 13.0;
MARKETING_VERSION = 3.6.0;
MARKETING_VERSION = 3.7.0;
PRODUCT_BUNDLE_IDENTIFIER = de.brightintosh.app;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = auto;
Expand All @@ -545,7 +545,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 61;
CURRENT_PROJECT_VERSION = 62;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "";
DEVELOPMENT_TEAM = 9K32WDUN2H;
Expand All @@ -572,7 +572,7 @@
LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks";
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 13.0;
MARKETING_VERSION = 3.6.0;
MARKETING_VERSION = 3.7.0;
PRODUCT_BUNDLE_IDENTIFIER = de.brightintosh.app;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = auto;
Expand Down
11 changes: 9 additions & 2 deletions BrightIntosh/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
if userActivity.activityType == CSSearchableItemActionType,
let uniqueIdentifier = userActivity.userInfo?[CSSearchableItemActivityIdentifier] as? String {
if uniqueIdentifier == "de.brightintosh.app.settings" {
self.settingsWindowController.showWindow(nil)
self.showSettingsWindow()
return true
}
}
Expand Down Expand Up @@ -83,7 +83,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
let stillEntitledToTrial = (try await TrialData.getTrialData()).stillEntitled()
if !stillEntitledToTrial && offerUpgrade {
DispatchQueue.main.async {
self.settingsWindowController.showWindow(nil)
self.showSettingsWindow()
}
}
startTrialTimer()
Expand Down Expand Up @@ -114,6 +114,9 @@ class AppDelegate: NSObject, NSApplicationDelegate {
KeyboardShortcuts.onKeyUp(for: .decreaseBrightness) {
self.decreaseBrightness()
}
KeyboardShortcuts.onKeyUp(for: .openSettings, action: {
self.showSettingsWindow()
})
}

@objc func toggleBrightIntosh() {
Expand All @@ -131,6 +134,10 @@ class AppDelegate: NSObject, NSApplicationDelegate {
UserDefaults.standard.set(true, forKey: "agreementAccepted")
}

func showSettingsWindow() {
self.settingsWindowController.showWindow(nil)
}

func startTrialTimer() {
if trialTimer != nil {
return
Expand Down
1 change: 1 addition & 0 deletions BrightIntosh/Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ extension KeyboardShortcuts.Name {
static let toggleBrightIntosh = Self("toggleIncreasedBrightness", default: .init(carbonKeyCode: kVK_ANSI_B, carbonModifiers: (0 | optionKey | cmdKey)))
static let increaseBrightness = Self("increaseBrightness", default: .init(carbonKeyCode: kVK_ANSI_N, carbonModifiers: (0 | optionKey | cmdKey)))
static let decreaseBrightness = Self("decreaseBrightness", default: .init(carbonKeyCode: kVK_ANSI_M, carbonModifiers: (0 | optionKey | cmdKey)))
static let openSettings = Self("openSettings", default: .init(carbonKeyCode: kVK_ANSI_B, carbonModifiers: (0 | optionKey | cmdKey | shiftKey)))
}

let appVersion = (Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String)!
Expand Down
3 changes: 3 additions & 0 deletions BrightIntosh/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -1145,6 +1145,9 @@
}
}
}
},
"Open settings:" : {

},
"Quit" : {
"localizations" : {
Expand Down
2 changes: 2 additions & 0 deletions BrightIntosh/UI/SettingsWindow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ struct BasicSettings: View {
"Increase brightness:", name: .increaseBrightness)
KeyboardShortcuts.Recorder(
"Decrease brightness:", name: .decreaseBrightness)
KeyboardShortcuts.Recorder(
"Open settings:", name: .openSettings)
}
}
Section(header: Text("General").bold()) {
Expand Down
1 change: 1 addition & 0 deletions BrightIntosh/UI/StatusBarMenu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ class StatusBarMenu : NSObject, NSMenuDelegate {
toggleTimerItem.target = self

let settingsItem = NSMenuItem(title: String(localized: "Settings"), action: #selector(openSettings), keyEquivalent: "")
settingsItem.setShortcut(for: .openSettings)
settingsItem.target = self

let aboutUsItem = NSMenuItem(title: String(localized: "About us"), action: #selector(openLegalNotice), keyEquivalent: "")
Expand Down

0 comments on commit a4350d2

Please sign in to comment.