Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
6805b18
feat: add visual keyboard layout editor and cheatsheet
kevintraver Dec 14, 2025
2f8c729
style(cheatsheet): improve background visibility on light backgrounds
kevintraver Dec 15, 2025
799d3af
fix(cheatsheet): center keyboard cheatsheet to match theme window pos…
kevintraver Dec 16, 2025
0a57a87
refactor(settings): streamline group editor UI with improved action flow
kevintraver Dec 16, 2025
fd708c0
refactor(keyboard): improve breadcrumb navigation with icon-only home…
kevintraver Dec 16, 2025
5ac3f34
fix(keyboard): align spacebar and bottom row with standard layout
kevintraver Dec 16, 2025
4a2b79e
feat(cheatsheet): add breadcrumb navigation to keyboard cheatsheet
kevintraver Dec 16, 2025
ebf992e
feat(favicon): improve favicon display with larger size and rounded c…
kevintraver Dec 16, 2025
629865e
feat: add usage statistics tracking with SQLite storage
kevintraver Dec 14, 2025
1436936
Merge feat/usage-stats into main
kevintraver Dec 17, 2025
c129d04
fix(stats): correct Settings.Section usage in StatsPane
kevintraver Dec 18, 2025
a409514
fix(keyboard): correct row width calculation and simplify centering
kevintraver Dec 18, 2025
019dba3
fix(keyboard): correct row width calculation and simplify centering
kevintraver Dec 18, 2025
79b610d
feat: add custom PNG/JPEG/ICNS icon support
kevintraver Dec 20, 2025
d93016b
Merge branch 'feat/custom-png-icon-support' into main
kevintraver Dec 20, 2025
80705d7
feat: add custom PNG/JPEG/ICNS icon support
kevintraver Dec 20, 2025
4b96f48
fix(cheatsheet): prevent hint popup from showing when keyboard cheats…
kevintraver Dec 29, 2025
b29a3d3
Merge branch 'main' into feat/keyboard-layout
kevintraver Nov 10, 2026
886c619
fix(settings): stop pane titles repeating under the tab bar
kevintraver Nov 10, 2026
7ad9482
fix(cheatsheet): center keyboard cheatsheet when set to always show
kevintraver Nov 10, 2026
20d98ce
feat(keyboard): drag bindings to rearrange, follow the active layout
kevintraver Nov 10, 2026
43adaa0
feat(mystery-box): show the group's icon in the hint
kevintraver Nov 10, 2026
21ce2f9
perf(cheatsheet): keep the keyboard cheatsheet at one scale
kevintraver Nov 10, 2026
1e2bd76
perf(icons): cache rendered app and custom icons
kevintraver Nov 10, 2026
f01efd9
feat(keyboard): right-click a key to open, edit or delete its binding
kevintraver Nov 10, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 70 additions & 4 deletions Leader Key.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions Leader Key/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,20 @@ class AppDelegate: NSObject, NSApplicationDelegate,
contentView: {
AdvancedPane().environmentObject(self.config)
}),
Settings.Pane(
identifier: .keyboard, title: "Keyboard",
toolbarIcon: NSImage(
systemSymbolName: "keyboard", accessibilityDescription: "Keyboard")!,
contentView: {
KeyboardPane().environmentObject(self.config)
}),
Settings.Pane(
identifier: .stats, title: "Stats",
toolbarIcon: NSImage(
systemSymbolName: "chart.bar.fill", accessibilityDescription: "Stats")!,
contentView: {
StatsPane().environmentObject(self.config)
}),
],
style: .segmentedControl,
)
Expand Down Expand Up @@ -271,6 +285,9 @@ class AppDelegate: NSObject, NSApplicationDelegate,
private func showSettings() {
// Behave like a normal app while Settings is open
NSApp.setActivationPolicy(.regular)
// The segmented control already names each pane; without this the toolbar
// repeats every title as a label underneath it.
settingsWindowController.window?.toolbar?.displayMode = .iconOnly
settingsWindowController.show()
NSApp.activate(ignoringOtherApps: true)
settingsWindowController.window?.delegate = self
Expand Down
245 changes: 83 additions & 162 deletions Leader Key/Cheatsheet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,195 +3,116 @@ import Kingfisher
import SwiftUI

enum Cheatsheet {
private static let iconSize = NSSize(width: 24, height: 24)
static func createWindow(for userState: UserState) -> NSWindow {
let view = CheatsheetView()
.environmentObject(userState)
.environmentObject(userState.userConfig as UserConfig)
let controller = NSHostingController(rootView: view)
controller.sizingOptions = .preferredContentSize
let cheatsheet = PanelWindow(
contentRect: NSRect(x: 0, y: 0, width: 700, height: 640)
)
cheatsheet.contentViewController = controller
return cheatsheet
}
}

struct KeyBadge: SwiftUI.View {
let key: String
struct CheatsheetView: SwiftUI.View {
@EnvironmentObject var userState: UserState
@Default(.cheatsheetStyle) var cheatsheetStyle
@State private var contentHeight: CGFloat = 0

var body: some SwiftUI.View {
Text(KeyMaps.glyph(for: key) ?? key)
.font(.system(.body, design: .rounded))
.multilineTextAlignment(.center)
.fontWeight(.bold)
.padding(.vertical, 4)
.frame(width: 24)
.background(.white.opacity(0.1))
.clipShape(RoundedRectangle(cornerRadius: 5.0, style: .continuous))
var maxHeight: CGFloat {
if let screen = NSScreen.main {
return screen.visibleFrame.height - 40
}
return 640
}

struct ActionRow: SwiftUI.View {
let action: Action
let indent: Int
@Default(.showDetailsInCheatsheet) var showDetails
@Default(.showAppIconsInCheatsheet) var showIcons

var body: some SwiftUI.View {
HStack {
HStack {
ForEach(0..<indent, id: \.self) { _ in
Text(" ")
}
KeyBadge(key: action.key ?? "●")

if showIcons {
actionIcon(item: ActionOrGroup.action(action), iconSize: iconSize)
}

Text(action.displayName)
.lineLimit(1)
.truncationMode(.middle)
}
Spacer()
if showDetails {
Text(action.value)
.foregroundStyle(.secondary)
.lineLimit(1)
.truncationMode(.middle)
}
}
// Constrain to edge of screen
static var preferredWidth: CGFloat {
if let screen = NSScreen.main {
let screenHalf = screen.visibleFrame.width / 2
let desiredWidth: CGFloat = 700
let margin: CGFloat = 20
return desiredWidth > screenHalf ? screenHalf - margin : desiredWidth
}
return 700
}

struct GroupRow: SwiftUI.View {
@Default(.expandGroupsInCheatsheet) var expand
@Default(.showDetailsInCheatsheet) var showDetails
@Default(.showAppIconsInCheatsheet) var showIcons
var actions: [ActionOrGroup] {
(userState.currentGroup != nil)
? userState.currentGroup!.actions : userState.userConfig.root.actions
}

let group: Group
let indent: Int
var body: some SwiftUI.View {
switch cheatsheetStyle {
case .list:
listView
case .keyboard:
KeyboardCheatsheetView()
.fixedSize()
.clipShape(RoundedRectangle(cornerRadius: 12, style: .continuous))
}
}

var body: some SwiftUI.View {
var listView: some View {
ScrollView {
VStack(alignment: .leading, spacing: 4) {
HStack {
ForEach(0..<indent, id: \.self) { _ in
Text(" ")
}
KeyBadge(key: group.key ?? "")

if showIcons {
actionIcon(item: ActionOrGroup.group(group), iconSize: iconSize)
}

Image(systemName: "chevron.right")
.foregroundStyle(.secondary)

Text(group.displayName)

Spacer()
if showDetails {
Text("\(group.actions.count.description) item(s)")
if let group = userState.currentGroup {
HStack {
KeyBadge(key: group.key ?? "•")
Text(group.key == nil ? "Leader Key" : group.displayName)
.foregroundStyle(.secondary)
.lineLimit(1)
.truncationMode(.middle)
}
}
if expand {
ForEach(Array(group.actions.enumerated()), id: \.offset) { _, item in
switch item {
case .action(let action):
Cheatsheet.ActionRow(action: action, indent: indent + 1)
case .group(let group):
Cheatsheet.GroupRow(group: group, indent: indent + 1)
}
}
}
}
}
}

struct CheatsheetView: SwiftUI.View {
@EnvironmentObject var userState: UserState
@State private var contentHeight: CGFloat = 0

var maxHeight: CGFloat {
if let screen = NSScreen.main {
return screen.visibleFrame.height - 40 // Leave some margin
}
return 640
}

// Constrain to edge of screen
static var preferredWidth: CGFloat {
if let screen = NSScreen.main {
let screenHalf = screen.visibleFrame.width / 2
let desiredWidth: CGFloat = 580
let margin: CGFloat = 20
return desiredWidth > screenHalf ? screenHalf - margin : desiredWidth
}
return 580
}

var actions: [ActionOrGroup] {
(userState.currentGroup != nil)
? userState.currentGroup!.actions : userState.userConfig.root.actions
}

var body: some SwiftUI.View {
ScrollView {
SwiftUI.VStack(alignment: .leading, spacing: 4) {
if let group = userState.currentGroup {
HStack {
KeyBadge(key: group.key ?? "•")
Text(group.key == nil ? "Leader Key" : group.displayName)
.foregroundStyle(.secondary)
}
.padding(.bottom, 8)
Divider()
.padding(.bottom, 8)
Divider()
.padding(.bottom, 8)
}
}

ForEach(Array(actions.enumerated()), id: \.offset) { _, item in
switch item {
case .action(let action):
Cheatsheet.ActionRow(action: action, indent: 0)
case .group(let group):
Cheatsheet.GroupRow(group: group, indent: 0)
}
ForEach(Array(actions.enumerated()), id: \.offset) { _, item in
switch item {
case .action(let action):
ActionRow(action: action, indent: 0)
case .group(let group):
GroupRow(group: group, indent: 0)
}
}
.padding()
.overlay(
GeometryReader { geo in
Color.clear.preference(
key: HeightPreferenceKey.self,
value: geo.size.height
)
}
)
}
.frame(width: Cheatsheet.CheatsheetView.preferredWidth)
.frame(height: min(contentHeight, maxHeight))
.background(
VisualEffectView(material: .hudWindow, blendingMode: .behindWindow)
.padding()
.overlay(
GeometryReader { geo in
Color.clear.preference(
key: HeightPreferenceKey.self,
value: geo.size.height
)
}
)
.onPreferenceChange(HeightPreferenceKey.self) { height in
self.contentHeight = height
}
}
}

struct HeightPreferenceKey: PreferenceKey {
static var defaultValue: CGFloat = 0
static func reduce(value: inout CGFloat, nextValue: () -> CGFloat) {
value = nextValue()
.frame(width: CheatsheetView.preferredWidth)
.frame(height: min(contentHeight, maxHeight))
.background(
ZStack {
VisualEffectView(material: .popover, blendingMode: .behindWindow)
Color(NSColor.windowBackgroundColor).opacity(0.7)
}
)
.onPreferenceChange(HeightPreferenceKey.self) { height in
self.contentHeight = height
}
}
}

static func createWindow(for userState: UserState) -> NSWindow {
let view = CheatsheetView().environmentObject(userState)
let controller = NSHostingController(rootView: view)
let cheatsheet = PanelWindow(
contentRect: NSRect(x: 0, y: 0, width: 580, height: 640)
)
cheatsheet.contentViewController = controller
return cheatsheet
struct HeightPreferenceKey: PreferenceKey {
static var defaultValue: CGFloat = 0
static func reduce(value: inout CGFloat, nextValue: () -> CGFloat) {
value = nextValue()
}
}

struct CheatsheetView_Previews: PreviewProvider {
static var previews: some View {
Cheatsheet.CheatsheetView()
CheatsheetView()
.environmentObject(UserState(userConfig: UserConfig()))
}
}
}
Loading