fix(panel): draggable header and configurable translation text size
Add a native AppKit drag grip to the non-activating panel header; it accepts the first mouse and calls performDrag, so the panel can be moved before it becomes key. Keep a moved position while the panel stays visible and only recenter near the cursor when it is shown again (DeepL-like transient position). Add persisted translationFontSize (default 17 pt, range 12–28) to AppSettings and PanelConfiguration, apply it to the translation text, and expose a native Settings stepper. Add English/German strings and AppSettings clamp/round-trip tests. Verified: make verify green; synthetic double-copy opened the panel, dragging the grip moved the window, and a 22 pt capture showed the larger translation text.
This commit is contained in:
1 parent
2cce12ff17
commit
40733473c5
12 files changed
+98
-5
No files matched your search
@@ -59,6 +59,8 @@ public struct AppSettings: Codable, Sendable, Equatable {
|
||||
public var autoCopy: Bool
|
||||
/// Show the source preview in the panel.
|
||||
public var showSourcePreview: Bool
|
||||
/// Translation text size in points (12–28).
|
||||
public var translationFontSize: Int
|
||||
/// Reflect the login-item setting.
|
||||
public var launchAtLogin: Bool
|
||||
/// Keep the last translation in memory for the panel.
|
||||
@@ -91,6 +93,7 @@ public struct AppSettings: Codable, Sendable, Equatable {
|
||||
promptVariantPolicy = .defaultOnly
|
||||
autoCopy = false
|
||||
showSourcePreview = true
|
||||
translationFontSize = 17
|
||||
launchAtLogin = false
|
||||
keepRecentTranslationInMemory = true
|
||||
hasCompletedOnboarding = false
|
||||
@@ -132,6 +135,7 @@ public struct AppSettings: Codable, Sendable, Equatable {
|
||||
topP = min(max(topP, 0), 1)
|
||||
topK = Self.clamp(topK, to: 1 ... 100)
|
||||
repeatPenalty = min(max(repeatPenalty, 0.5), 2)
|
||||
translationFontSize = Self.clamp(translationFontSize, to: 12 ... 28)
|
||||
if !["5m", "30m", "1h", "0"].contains(keepModelLoaded) {
|
||||
keepModelLoaded = HyMT3ModelPreset.defaultKeepAlive
|
||||
}
|
||||
@@ -161,6 +165,7 @@ public struct AppSettings: Codable, Sendable, Equatable {
|
||||
let cjk: Int
|
||||
let numCtx: Int
|
||||
let numPredict: Int
|
||||
let fontSize: Int
|
||||
}
|
||||
|
||||
private struct DecodedSampling {
|
||||
@@ -197,6 +202,11 @@ public struct AppSettings: Codable, Sendable, Equatable {
|
||||
numPredict: clamp(
|
||||
container.decodeIfPresent(Int.self, forKey: .numPredict) ?? defaults.numPredict,
|
||||
to: 1 ... 8192
|
||||
),
|
||||
fontSize: clamp(
|
||||
container.decodeIfPresent(Int.self, forKey: .translationFontSize)
|
||||
?? defaults.translationFontSize,
|
||||
to: 12 ... 28
|
||||
)
|
||||
)
|
||||
}
|
||||
@@ -225,7 +235,7 @@ public struct AppSettings: Codable, Sendable, Equatable {
|
||||
case endpoint, allowRemoteEndpoint, model, fastModel, targetLanguage, recentTargetLanguages
|
||||
case doubleCopyWindowMs, maxCharactersLatin, maxCharactersCJK, numCtx, numPredict
|
||||
case temperature, topP, topK, repeatPenalty, keepModelLoaded, warmUpOnLaunch
|
||||
case promptVariantPolicy, autoCopy, showSourcePreview, launchAtLogin
|
||||
case promptVariantPolicy, autoCopy, showSourcePreview, translationFontSize, launchAtLogin
|
||||
case keepRecentTranslationInMemory, hasCompletedOnboarding, settingsVersion
|
||||
}
|
||||
|
||||
@@ -257,6 +267,7 @@ public struct AppSettings: Codable, Sendable, Equatable {
|
||||
maxCharactersCJK = limits.cjk
|
||||
numCtx = limits.numCtx
|
||||
numPredict = limits.numPredict
|
||||
translationFontSize = limits.fontSize
|
||||
let sampling = try Self.decodeSampling(from: container, defaults: defaults)
|
||||
temperature = sampling.temperature
|
||||
topP = sampling.topP
|
||||
@@ -307,6 +318,7 @@ public struct AppSettings: Codable, Sendable, Equatable {
|
||||
try container.encode(promptVariantPolicy, forKey: .promptVariantPolicy)
|
||||
try container.encode(autoCopy, forKey: .autoCopy)
|
||||
try container.encode(showSourcePreview, forKey: .showSourcePreview)
|
||||
try container.encode(translationFontSize, forKey: .translationFontSize)
|
||||
try container.encode(launchAtLogin, forKey: .launchAtLogin)
|
||||
try container.encode(keepRecentTranslationInMemory, forKey: .keepRecentTranslationInMemory)
|
||||
try container.encode(hasCompletedOnboarding, forKey: .hasCompletedOnboarding)
|
||||
|
||||
@@ -28,6 +28,8 @@ public struct PanelConfiguration: Sendable, Equatable {
|
||||
public var sampling: SamplingOptions
|
||||
/// Whether to show the source preview.
|
||||
public var showSourcePreview: Bool
|
||||
/// Translation text size in points.
|
||||
public var translationFontSize: Int
|
||||
/// Recent targets, most recent first.
|
||||
public var recentTargets: [ModelLanguage]
|
||||
|
||||
@@ -38,6 +40,7 @@ public struct PanelConfiguration: Sendable, Equatable {
|
||||
keepAlive: String,
|
||||
sampling: SamplingOptions = .publisherDefault,
|
||||
showSourcePreview: Bool = true,
|
||||
translationFontSize: Int = 17,
|
||||
recentTargets: [ModelLanguage] = []
|
||||
) {
|
||||
self.target = target
|
||||
@@ -45,6 +48,7 @@ public struct PanelConfiguration: Sendable, Equatable {
|
||||
self.keepAlive = keepAlive
|
||||
self.sampling = sampling
|
||||
self.showSourcePreview = showSourcePreview
|
||||
self.translationFontSize = translationFontSize
|
||||
self.recentTargets = recentTargets
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user