feat: useYacdDashboardMenuItem
(cherry picked from commit f5fe33cd285d846d068d3c2a2bb4b8982401aaea)
This commit is contained in:
parent
c6a4f425d7
commit
9e094e8c1f
|
@ -52,6 +52,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
|||
@IBOutlet var tunModeMenuItem: NSMenuItem!
|
||||
|
||||
@IBOutlet var hideUnselecableMenuItem: NSMenuItem!
|
||||
@IBOutlet var useYacdDashboardMenuItem: NSMenuItem!
|
||||
@IBOutlet var proxyProvidersMenu: NSMenu!
|
||||
@IBOutlet var ruleProvidersMenu: NSMenu!
|
||||
@IBOutlet var proxyProvidersMenuItem: NSMenuItem!
|
||||
|
@ -288,6 +289,10 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
|||
remoteConfigAutoupdateMenuItem.state = RemoteConfigManager.autoUpdateEnable ? .on : .off
|
||||
|
||||
hideUnselecableMenuItem.state = .init(rawValue: MenuItemFactory.hideUnselectable)
|
||||
|
||||
useYacdDashboardMenuItem.state = MenuItemFactory.useYacdDashboard ? .on : .off
|
||||
useYacdDashboardMenuItem.isHidden = !DashboardManager.shared.enableSwiftUI
|
||||
|
||||
useAlphaMetaMenuItem.state = MenuItemFactory.useAlphaCore ? .on : .off
|
||||
}
|
||||
|
||||
|
@ -1251,6 +1256,14 @@ extension AppDelegate {
|
|||
sender.state = newState
|
||||
MenuItemFactory.hideUnselectable = newState.rawValue
|
||||
}
|
||||
|
||||
@IBAction func useYacdDashboard(_ sender: NSMenuItem) {
|
||||
guard DashboardManager.shared.enableSwiftUI else { return }
|
||||
|
||||
let useYacd = sender.state == .off
|
||||
sender.state = useYacd ? .on : .off
|
||||
MenuItemFactory.useYacdDashboard = useYacd
|
||||
}
|
||||
|
||||
@IBAction func checkForUpdate(_ sender: NSMenuItem) {
|
||||
let unc = NSUserNotificationCenter.default
|
||||
|
|
|
@ -585,6 +585,7 @@
|
|||
<outlet property="tunModeMenuItem" destination="ZoW-Ax-rde" id="ep1-C4-irW"/>
|
||||
<outlet property="updateAlphaMetaMenuItem" destination="MWh-yg-3Yk" id="jJi-h8-7T2"/>
|
||||
<outlet property="useAlphaMetaMenuItem" destination="sk5-MZ-XB1" id="Ijq-xa-vVc"/>
|
||||
<outlet property="useYacdDashboardMenuItem" destination="GRz-PJ-MJ7" id="Jj1-Wl-NUt"/>
|
||||
</connections>
|
||||
</customObject>
|
||||
<menu id="Afa-lD-EbR">
|
||||
|
@ -820,6 +821,12 @@
|
|||
<action selector="hideUnselectable:" target="Voe-Tx-rLC" id="ifq-SY-ov8"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Use yacd Dashboard" id="GRz-PJ-MJ7">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="useYacdDashboard:" target="Voe-Tx-rLC" id="spp-Vf-uu4"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
</items>
|
||||
</menu>
|
||||
</menuItem>
|
||||
|
|
|
@ -25,6 +25,13 @@ class MenuItemFactory {
|
|||
recreateProxyMenuItems()
|
||||
}
|
||||
}
|
||||
|
||||
static var useYacdDashboard: Bool = UserDefaults.standard.object(forKey: "useYacdDashboard") as? Bool ?? false {
|
||||
didSet {
|
||||
UserDefaults.standard.set(useYacdDashboard, forKey: "useYacdDashboard")
|
||||
DashboardManager.shared.useYacd = useYacdDashboard
|
||||
}
|
||||
}
|
||||
|
||||
static var useAlphaCore: Bool = UserDefaults.standard.object(forKey: "useAlphaCore") as? Bool ?? false {
|
||||
didSet {
|
||||
|
|
|
@ -10,6 +10,9 @@ import Cocoa
|
|||
class DashboardManager: NSObject {
|
||||
static let shared = DashboardManager()
|
||||
|
||||
let enableSwiftUI = false
|
||||
var useYacd = true
|
||||
|
||||
var dashboardWindowController: ClashWebViewWindowController?
|
||||
|
||||
func show(_ sender: NSMenuItem?) {
|
||||
|
|
|
@ -18,10 +18,15 @@ class DashboardManager: NSObject {
|
|||
override init() {
|
||||
}
|
||||
|
||||
var useYacd = true {
|
||||
willSet {
|
||||
if newValue {
|
||||
let enableSwiftUI = true
|
||||
|
||||
var useYacd = MenuItemFactory.useYacdDashboard {
|
||||
didSet {
|
||||
if useYacd {
|
||||
deinitNotifications()
|
||||
dashboardWindowController?.close()
|
||||
} else {
|
||||
yacdWindowController?.close()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue