From 71a520840eb3debe46173c1f73bc85bbea0b1aa6 Mon Sep 17 00:00:00 2001
From: Ariver <shanghai3168@gmail.com>
Date: Sun, 28 Jun 2026 23:42:38 +0800
Subject: [PATCH] Implement Pro custom hotkeys for 8.2.0

---
 src/Apptag/ContentView.swift |   46 ++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 44 insertions(+), 2 deletions(-)

diff --git a/src/Apptag/ContentView.swift b/src/Apptag/ContentView.swift
index 80fb99e..743ec5f 100644
--- a/src/Apptag/ContentView.swift
+++ b/src/Apptag/ContentView.swift
@@ -19,6 +19,7 @@
     static let theme = "theme"
     static let tags = "tags"
     static let data = "data"
+    static let about = "about"
 }
 
 // MARK: - Edit Phase
@@ -447,6 +448,8 @@
     @AppStorage("showUncommonAppBubbles") private var showUncommonAppBubbles = AppDefaults.showUncommonAppBubbles
     @AppStorage("hideUsageTips") private var hideUsageTips = AppDefaults.hideUsageTips
     @AppStorage(AppGridTheme.storageKey) private var appGridThemeID = AppDefaults.appGridThemeID
+    @AppStorage(AppGridTheme.deepBlueTuningStorageKey) private var deepBlueThemeTuning = AppGridTheme.deepBlue.defaultColorTuning
+    @AppStorage(AppGridTheme.colorfulTuningStorageKey) private var colorfulThemeTuning = AppGridTheme.colorful.defaultColorTuning
     @AppStorage("useAppKitTagNavigation") private var useAppKitTagNavigation = AppDefaults.useAppKitTagNavigation
     @AppStorage("skipTagRemovalDropConfirm") private var skipTagRemovalDropConfirm = false
     @AppStorage("skipUncategorizedDropConfirm") private var skipUncategorizedDropConfirm = false
@@ -486,6 +489,25 @@
         editPhase == .none
             ? ProEntitlementPolicy.effectiveTheme(for: appGridTheme)
             : .defaultLight
+    }
+
+    private var renderedAppGridThemeTuning: Double? {
+        guard editPhase == .none else { return nil }
+        return ProEntitlementPolicy.effectiveThemeTuning(
+            for: appGridTheme,
+            storedTuning: storedThemeTuning(for: appGridTheme)
+        )
+    }
+
+    private func storedThemeTuning(for theme: AppGridTheme) -> Double? {
+        switch theme {
+        case .deepBlue:
+            return deepBlueThemeTuning
+        case .colorful:
+            return colorfulThemeTuning
+        case .defaultLight, .black, .pink, .purple, .green, .blue:
+            return nil
+        }
     }
 
     private var isSideLayout: Bool {
@@ -991,6 +1013,7 @@
 
     private var appGridBackground: some View {
         let theme = renderedAppGridTheme
+        let tuning = renderedAppGridThemeTuning
         return ZStack {
             if theme.usesVisualEffectBackdrop {
                 VisualEffectView(
@@ -1003,12 +1026,12 @@
             }
             if !theme.isDefaultLight {
                 LinearGradient(
-                    colors: theme.backgroundBaseColors,
+                    colors: theme.backgroundBaseColors(tuning: tuning),
                     startPoint: .topLeading,
                     endPoint: .bottomTrailing
                 )
                 LinearGradient(
-                    colors: theme.backgroundAccentColors,
+                    colors: theme.backgroundAccentColors(tuning: tuning),
                     startPoint: .topTrailing,
                     endPoint: .bottomLeading
                 )
@@ -2953,6 +2976,15 @@
             closeQuickSearch(hideOverlayIfNeeded: true)
             hideOverlay()
         }
+        if isCurrentApp(app) {
+            if closeQuickSearchOnSuccess && !closeQuickSearchAndOverlayBeforeOpening {
+                closeQuickSearch(hideOverlayIfNeeded: closeOverlayOnSuccess)
+            }
+            if closeOverlayOnSuccess && !closeQuickSearchAndOverlayBeforeOpening {
+                hideOverlay()
+            }
+            return
+        }
         let configuration = NSWorkspace.OpenConfiguration()
         NSWorkspace.shared.openApplication(at: app.path, configuration: configuration) { _, error in
             DispatchQueue.main.async {
@@ -2974,6 +3006,16 @@
         }
     }
 
+    private func isCurrentApp(_ app: AppInfo) -> Bool {
+        if app.bundleIdentifier?.caseInsensitiveCompare(AppIdentity.bundleIdentifier) == .orderedSame {
+            return true
+        }
+
+        let currentURL = Bundle.main.bundleURL.standardizedFileURL.resolvingSymlinksInPath()
+        let appURL = app.path.standardizedFileURL.resolvingSymlinksInPath()
+        return currentURL == appURL
+    }
+
     func openApp(_ app: AppInfo) {
         hideOverlay()
         launchApp(app, closeOverlayOnSuccess: false)

--
Gitblit v1.9.3