Skip to content

Commit e61a39a

Browse files
committed
refactor: remove imageDirectory from PrankLockerConfig and related tests
1 parent b577be1 commit e61a39a

5 files changed

Lines changed: 41 additions & 25 deletions

File tree

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ Settings are stored in `~/.prank-locker/config.json` (created on first run):
122122
{
123123
"activationShortcut": { "modifiers": ["control", "option", "command"], "keyCode": 37 },
124124
"deactivationSequence": "unlock",
125-
"imageDirectory": "~/.prank-locker/images/",
126125
"imageIntervalSeconds": 3.0,
127126
"maxSimultaneousImages": 15,
128127
"failsafeTimeoutMinutes": 30,

Sources/ScreenPrankLocker/ConfigView.swift

Lines changed: 39 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,33 @@
55
import SwiftUI
66
import AppKit
77

8+
// A reusable component that encapsulates styling and hover logic
9+
struct HoverLink: View {
10+
let title: String
11+
let urlString: String
12+
13+
var body: some View {
14+
// Safely unwrap the URL
15+
if let url = URL(string: urlString) {
16+
Link(destination: url) {
17+
Text(title)
18+
.font(.system(size: 11, weight: .medium, design: .rounded))
19+
.foregroundColor(.blue)
20+
.underline()
21+
}
22+
.onHover { isHovered in
23+
if isHovered {
24+
// Push the hand cursor onto the system cursor stack
25+
NSCursor.pointingHand.push()
26+
} else {
27+
// Pop it off when the mouse leaves
28+
NSCursor.pop()
29+
}
30+
}
31+
}
32+
}
33+
}
34+
835
// MARK: - Theme
936

1037
private enum Theme {
@@ -531,24 +558,21 @@ private struct AboutView: View {
531558

532559
VStack(spacing: 6) {
533560
HStack(spacing: 12) {
534-
Link(destination: URL(string: "https://github.com/SlashGordon")!) {
535-
Text("SlashGordon")
536-
.font(.system(size: 11, weight: .medium, design: .rounded))
537-
.foregroundColor(Theme.subtleText)
538-
}
561+
HoverLink(
562+
title: "SlashGordon",
563+
urlString: "https://github.com/SlashGordon"
564+
)
539565

540-
Link(destination: URL(string: "https://www.slashgordon.link/")!) {
541-
Text("slashgordon.link")
542-
.font(.system(size: 11, weight: .medium, design: .rounded))
543-
.foregroundColor(Theme.subtleText)
544-
}
566+
HoverLink(
567+
title: "slashgordon.link",
568+
urlString: "https://www.slashgordon.link/"
569+
)
545570
}
546571

547-
Link(destination: URL(string: "mailto:slash.gordon.dev@gmail.com")!) {
548-
Text("slash.gordon.dev@gmail.com")
549-
.font(.system(size: 11, weight: .medium, design: .rounded))
550-
.foregroundColor(Theme.subtleText)
551-
}
572+
HoverLink(
573+
title: "slash.gordon.dev@gmail.com",
574+
urlString: "mailto:slash.gordon.dev@gmail.com"
575+
)
552576
}
553577

554578
Button("Close") {

Sources/ScreenPrankLocker/Models.swift

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ enum ProtectionMode: String, Codable {
126126
struct PrankLockerConfig: Codable {
127127
var activationShortcut: KeyCombo
128128
var deactivationSequence: String
129-
var imageDirectory: String
130129
var imageIntervalSeconds: TimeInterval
131130
var maxSimultaneousImages: Int
132131
var failsafeTimeoutMinutes: Int
@@ -147,7 +146,6 @@ struct PrankLockerConfig: Codable {
147146
let container = try decoder.container(keyedBy: CodingKeys.self)
148147
activationShortcut = try container.decode(KeyCombo.self, forKey: .activationShortcut)
149148
deactivationSequence = try container.decode(String.self, forKey: .deactivationSequence)
150-
imageDirectory = try container.decode(String.self, forKey: .imageDirectory)
151149
imageIntervalSeconds = try container.decode(TimeInterval.self, forKey: .imageIntervalSeconds)
152150
maxSimultaneousImages = try container.decode(Int.self, forKey: .maxSimultaneousImages)
153151
failsafeTimeoutMinutes = try container.decode(Int.self, forKey: .failsafeTimeoutMinutes)
@@ -168,7 +166,6 @@ struct PrankLockerConfig: Codable {
168166

169167
init(activationShortcut: KeyCombo,
170168
deactivationSequence: String,
171-
imageDirectory: String,
172169
imageIntervalSeconds: TimeInterval,
173170
maxSimultaneousImages: Int,
174171
failsafeTimeoutMinutes: Int,
@@ -186,7 +183,6 @@ struct PrankLockerConfig: Codable {
186183
telegramChatID: String? = nil) {
187184
self.activationShortcut = activationShortcut
188185
self.deactivationSequence = deactivationSequence
189-
self.imageDirectory = imageDirectory
190186
self.imageIntervalSeconds = imageIntervalSeconds
191187
self.maxSimultaneousImages = maxSimultaneousImages
192188
self.failsafeTimeoutMinutes = failsafeTimeoutMinutes
@@ -210,7 +206,6 @@ struct PrankLockerConfig: Codable {
210206
keyCode: 37 // 'L' key
211207
),
212208
deactivationSequence: "unlock",
213-
imageDirectory: "~/.prank-locker/images/",
214209
imageIntervalSeconds: 3.0,
215210
maxSimultaneousImages: 15,
216211
failsafeTimeoutMinutes: 30,

Tests/ScreenPrankLockerTests/PropertyTests/ConfigUIPropertyTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ final class ConfigUIPropertyTests: XCTestCase {
3434
return PrankLockerConfig(
3535
activationShortcut: KeyCombo(modifiers: [.maskCommand], keyCode: 37),
3636
deactivationSequence: deactivationSequence,
37-
imageDirectory: "~/.prank-locker/images/",
37+
3838
imageIntervalSeconds: 3.0,
3939
maxSimultaneousImages: 15,
4040
failsafeTimeoutMinutes: failsafeTimeoutMinutes,

Tests/ScreenPrankLockerTests/UnitTests/ConfigurationManagerTests.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ final class ConfigurationManagerTests: XCTestCase {
2727

2828
let config = manager.config
2929
XCTAssertEqual(config.deactivationSequence, "unlock")
30-
XCTAssertEqual(config.imageDirectory, "~/.prank-locker/images/")
3130
XCTAssertEqual(config.imageIntervalSeconds, 3.0)
3231
XCTAssertEqual(config.maxSimultaneousImages, 15)
3332
XCTAssertEqual(config.failsafeTimeoutMinutes, 30)
@@ -50,7 +49,6 @@ final class ConfigurationManagerTests: XCTestCase {
5049
"keyCode": 12
5150
},
5251
"deactivationSequence": "opensesame",
53-
"imageDirectory": "/tmp/my-images/",
5452
"imageIntervalSeconds": 5.0,
5553
"maxSimultaneousImages": 10,
5654
"failsafeTimeoutMinutes": 60
@@ -64,7 +62,7 @@ final class ConfigurationManagerTests: XCTestCase {
6462

6563
let config = manager.config
6664
XCTAssertEqual(config.deactivationSequence, "opensesame")
67-
XCTAssertEqual(config.imageDirectory, "/tmp/my-images/")
65+
6866
XCTAssertEqual(config.imageIntervalSeconds, 5.0)
6967
XCTAssertEqual(config.maxSimultaneousImages, 10)
7068
XCTAssertEqual(config.failsafeTimeoutMinutes, 60)

0 commit comments

Comments
 (0)