Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 4 additions & 4 deletions Leader Key.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
115AA5BF2DA521C600C17E18 /* ActionIcon.swift in Sources */ = {isa = PBXBuildFile; fileRef = 115AA5BE2DA521C200C17E18 /* ActionIcon.swift */; };
115AA5C22DA546D500C17E18 /* SymbolPicker in Frameworks */ = {isa = PBXBuildFile; productRef = 115AA5C12DA546D500C17E18 /* SymbolPicker */; };
130196C62D73B3DE0093148B /* Breadcrumbs.swift in Sources */ = {isa = PBXBuildFile; fileRef = 130196C52D73B3DC0093148B /* Breadcrumbs.swift */; };
423632132D676F5200878D92 /* FileMonitor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 423632122D676F5200878D92 /* FileMonitor.swift */; };

423632222D68CA6500878D92 /* MysteryBox.swift in Sources */ = {isa = PBXBuildFile; fileRef = 423632212D68CA6500878D92 /* MysteryBox.swift */; };
423632262D68CDBB00878D92 /* Mini.swift in Sources */ = {isa = PBXBuildFile; fileRef = 423632252D68CDBB00878D92 /* Mini.swift */; };
423632282D6A806700878D92 /* Theme.swift in Sources */ = {isa = PBXBuildFile; fileRef = 423632272D6A806700878D92 /* Theme.swift */; };
Expand Down Expand Up @@ -66,7 +66,7 @@
/* Begin PBXFileReference section */
115AA5BE2DA521C200C17E18 /* ActionIcon.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionIcon.swift; sourceTree = "<group>"; };
130196C52D73B3DC0093148B /* Breadcrumbs.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Breadcrumbs.swift; sourceTree = "<group>"; };
423632122D676F5200878D92 /* FileMonitor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileMonitor.swift; sourceTree = "<group>"; };

423632142D678F4400878D92 /* TestPlan.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; path = TestPlan.xctestplan; sourceTree = "<group>"; };
423632212D68CA6500878D92 /* MysteryBox.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MysteryBox.swift; sourceTree = "<group>"; };
423632252D68CDBB00878D92 /* Mini.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Mini.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -186,7 +186,7 @@
427C184C2BD65C5C00955B98 /* Defaults.swift */,
42DFCD712D5B7D46002EA111 /* Events.swift */,
42F4CDD02D48C51F00D0DD76 /* Extensions.swift */,
423632122D676F5200878D92 /* FileMonitor.swift */,

42F4CDC82D458FF700D0DD76 /* MainMenu.swift */,
427C18252BD31E2E00955B98 /* MainWindow.swift */,
427C18532BD6E59300955B98 /* NSWindow+Animations.swift */,
Expand Down Expand Up @@ -409,7 +409,7 @@
425495402D75EFAD0020300E /* ForTheHorde.swift in Sources */,
42F4CDCF2D46E2B300D0DD76 /* Cheatsheet.swift in Sources */,
42DFCD722D5B7D48002EA111 /* Events.swift in Sources */,
423632132D676F5200878D92 /* FileMonitor.swift in Sources */,

427C182D2BD31F9500955B98 /* Settings.swift in Sources */,
426E625B2D2E6A98009FD2F2 /* CommandRunner.swift in Sources */,
427C18382BD3262100955B98 /* VisualEffectBackground.swift in Sources */,
Expand Down
17 changes: 17 additions & 0 deletions Leader Key/Alerts.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import Cocoa

protocol AlertHandler {
func showAlert(style: NSAlert.Style, message: String)
func showAlert(style: NSAlert.Style, message: String, informativeText: String, buttons: [String])
-> NSApplication.ModalResponse
}

class DefaultAlertHandler: AlertHandler {
Expand All @@ -11,4 +13,19 @@ class DefaultAlertHandler: AlertHandler {
alert.messageText = message
alert.runModal()
}

func showAlert(style: NSAlert.Style, message: String, informativeText: String, buttons: [String])
-> NSApplication.ModalResponse
{
let alert = NSAlert()
alert.alertStyle = style
alert.messageText = message
alert.informativeText = informativeText

for button in buttons {
alert.addButton(withTitle: button)
}

return alert.runModal()
}
}
18 changes: 2 additions & 16 deletions Leader Key/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ class AppDelegate: NSObject, NSApplicationDelegate,

let statusItem = StatusItem()
let config = UserConfig()
var fileMonitor: FileMonitor!

var state: UserState!
@IBOutlet var updaterController: SPUStandardUpdaterController!
Expand Down Expand Up @@ -55,27 +54,14 @@ class AppDelegate: NSObject, NSApplicationDelegate,
state = UserState(userConfig: config)
controller = Controller(userState: state, userConfig: config)

Task {
for await _ in Defaults.updates(.configDir) {
self.fileMonitor?.stopMonitoring()

self.fileMonitor = FileMonitor(
fileURL: config.url,
callback: {
self.config.reloadConfig()
})
self.fileMonitor.startMonitoring()
}
}

statusItem.handlePreferences = {
self.showSettings()
}
statusItem.handleAbout = {
NSApp.orderFrontStandardAboutPanel(nil)
}
statusItem.handleReloadConfig = {
self.config.reloadConfig()
self.config.reloadFromFile()
}
statusItem.handleRevealConfig = {
NSWorkspace.shared.activateFileViewerSelecting([self.config.url])
Expand Down Expand Up @@ -143,7 +129,7 @@ class AppDelegate: NSObject, NSApplicationDelegate,
}

func applicationWillTerminate(_ notification: Notification) {
config.saveConfig()
// Config saves automatically on changes
}

@IBAction
Expand Down
2 changes: 1 addition & 1 deletion Leader Key/Cheatsheet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ enum Cheatsheet {
let key: String

var body: some SwiftUI.View {
Text(key)
Text(KeyMaps.glyph(for: key) ?? key)
.font(.system(.body, design: .rounded))
.multilineTextAlignment(.center)
.fontWeight(.bold)
Expand Down
90 changes: 0 additions & 90 deletions Leader Key/FileMonitor.swift

This file was deleted.

8 changes: 2 additions & 6 deletions Leader Key/Settings/GeneralPane.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,8 @@ struct GeneralPane: View {
Divider()
.frame(height: 20)

Button("Save to file") {
config.saveConfig()
}

Button("Reload from file") {
config.reloadConfig()
Button("Read from file") {
config.reloadFromFile()
}
}

Expand Down
4 changes: 3 additions & 1 deletion Leader Key/Themes/ForTheHorde.swift
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ enum ForTheHorde {
.rotationEffect(.degrees(fgRotation))

// Text in the middle
let text = Text(userState.currentGroup?.key ?? userState.display ?? "●")
let keyText = userState.currentGroup?.key ?? userState.display ?? "●"
let glyphText = KeyMaps.glyph(for: keyText) ?? keyText
let text = Text(glyphText)
.fontDesign(.rounded)
.fontWeight(.semibold)
.font(.system(size: 28, weight: .semibold, design: .rounded))
Expand Down
4 changes: 3 additions & 1 deletion Leader Key/Themes/Mini.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ enum Mini {

var body: some View {
ZStack {
let text = Text(userState.currentGroup?.key ?? userState.display ?? "●")
let keyText = userState.currentGroup?.key ?? userState.display ?? "●"
let glyphText = KeyMaps.glyph(for: keyText) ?? keyText
let text = Text(glyphText)
.fontDesign(.rounded)
.fontWeight(.bold)

Expand Down
4 changes: 3 additions & 1 deletion Leader Key/Themes/MysteryBox.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ enum MysteryBox {

var body: some View {
ZStack {
let text = Text(userState.currentGroup?.key ?? userState.display ?? "●")
let keyText = userState.currentGroup?.key ?? userState.display ?? "●"
let glyphText = KeyMaps.glyph(for: keyText) ?? keyText
let text = Text(glyphText)
.fontDesign(.rounded)
.fontWeight(.semibold)
.font(.system(size: 28, weight: .semibold, design: .rounded))
Expand Down
Loading
Loading