mirror of
https://github.com/morgan9e/macos-stats
synced 2026-04-14 00:04:15 +09:00
fix: fixed bug on macOS 26 when settings autosaveName to menu bar item prevents it from loading (#2768)
This commit is contained in:
@@ -213,6 +213,12 @@ open class WidgetWrapper: NSView, widget_p {
|
|||||||
return width
|
return width
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public func redraw() {
|
||||||
|
DispatchQueue.main.async { [weak self] in
|
||||||
|
self?.display()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
open func settings() -> NSView { return NSView() }
|
open func settings() -> NSView { return NSView() }
|
||||||
|
|
||||||
open override func mouseDown(with event: NSEvent) {
|
open override func mouseDown(with event: NSEvent) {
|
||||||
@@ -318,18 +324,12 @@ public class SWidget {
|
|||||||
|
|
||||||
public func setMenuBarItem(state: Bool) {
|
public func setMenuBarItem(state: Bool) {
|
||||||
if state {
|
if state {
|
||||||
let prevTag = "NSStatusItem Preferred Position \(self.module)_\(self.type.name())"
|
|
||||||
let prevPosition = Store.shared.int(key: prevTag, defaultValue: -1)
|
|
||||||
if prevPosition != -1 {
|
|
||||||
Store.shared.set(key: "NSStatusItem Preferred Position \(self.module)_\(self.type.rawValue)", value: prevPosition)
|
|
||||||
Store.shared.remove(prevTag)
|
|
||||||
}
|
|
||||||
|
|
||||||
restoreNSStatusItemPosition(id: "\(self.module)_\(self.type.rawValue)")
|
restoreNSStatusItemPosition(id: "\(self.module)_\(self.type.rawValue)")
|
||||||
|
|
||||||
DispatchQueue.main.async(execute: {
|
DispatchQueue.main.async(execute: {
|
||||||
self.menuBarItem = NSStatusBar.system.statusItem(withLength: self.item.frame.width)
|
self.menuBarItem = NSStatusBar.system.statusItem(withLength: self.item.frame.width)
|
||||||
self.menuBarItem?.autosaveName = "\(self.module)_\(self.type.rawValue)"
|
DispatchQueue.main.async(execute: {
|
||||||
|
self.menuBarItem?.autosaveName = "\(self.module)_\(self.type.rawValue)"
|
||||||
|
})
|
||||||
if self.item.frame.origin.x != self.originX {
|
if self.item.frame.origin.x != self.originX {
|
||||||
self.item.setFrameOrigin(NSPoint(x: self.originX, y: self.item.frame.origin.y))
|
self.item.setFrameOrigin(NSPoint(x: self.originX, y: self.item.frame.origin.y))
|
||||||
}
|
}
|
||||||
@@ -393,12 +393,8 @@ public class MenuBar {
|
|||||||
|
|
||||||
private var _active: Bool = false
|
private var _active: Bool = false
|
||||||
public var active: Bool {
|
public var active: Bool {
|
||||||
get {
|
get { self.queue.sync { self._active } }
|
||||||
self.queue.sync { self._active }
|
set { self.queue.sync { self._active = newValue } }
|
||||||
}
|
|
||||||
set {
|
|
||||||
self.queue.sync { self._active = newValue }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
init(moduleName: String) {
|
init(moduleName: String) {
|
||||||
@@ -475,7 +471,9 @@ public class MenuBar {
|
|||||||
if state && self.active {
|
if state && self.active {
|
||||||
restoreNSStatusItemPosition(id: self.moduleName)
|
restoreNSStatusItemPosition(id: self.moduleName)
|
||||||
self.menuBarItem = NSStatusBar.system.statusItem(withLength: 0)
|
self.menuBarItem = NSStatusBar.system.statusItem(withLength: 0)
|
||||||
self.menuBarItem?.autosaveName = self.moduleName
|
DispatchQueue.main.async(execute: {
|
||||||
|
self.menuBarItem?.autosaveName = self.moduleName
|
||||||
|
})
|
||||||
self.menuBarItem?.isVisible = true
|
self.menuBarItem?.isVisible = true
|
||||||
|
|
||||||
self.menuBarItem?.button?.addSubview(self.view)
|
self.menuBarItem?.button?.addSubview(self.view)
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
<key>CFBundleShortVersionString</key>
|
<key>CFBundleShortVersionString</key>
|
||||||
<string>$(MARKETING_VERSION)</string>
|
<string>$(MARKETING_VERSION)</string>
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
<string>726</string>
|
<string>739</string>
|
||||||
<key>Description</key>
|
<key>Description</key>
|
||||||
<string>Simple macOS system monitor in your menu bar</string>
|
<string>Simple macOS system monitor in your menu bar</string>
|
||||||
<key>LSApplicationCategoryType</key>
|
<key>LSApplicationCategoryType</key>
|
||||||
|
|||||||
@@ -70,7 +70,9 @@ internal class CombinedView: NSObject, NSGestureRecognizerDelegate {
|
|||||||
|
|
||||||
public func enable() {
|
public func enable() {
|
||||||
self.menuBarItem = NSStatusBar.system.statusItem(withLength: 0)
|
self.menuBarItem = NSStatusBar.system.statusItem(withLength: 0)
|
||||||
self.menuBarItem?.autosaveName = "CombinedModules"
|
DispatchQueue.main.async(execute: {
|
||||||
|
self.menuBarItem?.autosaveName = "CombinedModules"
|
||||||
|
})
|
||||||
self.menuBarItem?.button?.addSubview(self.view)
|
self.menuBarItem?.button?.addSubview(self.view)
|
||||||
self.menuBarItem?.button?.image = NSImage()
|
self.menuBarItem?.button?.image = NSImage()
|
||||||
self.menuBarItem?.button?.toolTip = localizedString("Combined modules")
|
self.menuBarItem?.button?.toolTip = localizedString("Combined modules")
|
||||||
|
|||||||
@@ -257,7 +257,9 @@ extension AppDelegate {
|
|||||||
internal func icon() {
|
internal func icon() {
|
||||||
if self.pauseState {
|
if self.pauseState {
|
||||||
self.menuBarItem = NSStatusBar.system.statusItem(withLength: AppIcon.size.width)
|
self.menuBarItem = NSStatusBar.system.statusItem(withLength: AppIcon.size.width)
|
||||||
self.menuBarItem?.autosaveName = "Stats"
|
DispatchQueue.main.async(execute: {
|
||||||
|
self.menuBarItem?.autosaveName = "Stats"
|
||||||
|
})
|
||||||
self.menuBarItem?.button?.addSubview(AppIcon())
|
self.menuBarItem?.button?.addSubview(AppIcon())
|
||||||
|
|
||||||
self.menuBarItem?.button?.target = self
|
self.menuBarItem?.button?.target = self
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
<key>CFBundleShortVersionString</key>
|
<key>CFBundleShortVersionString</key>
|
||||||
<string>2.11.58</string>
|
<string>2.11.58</string>
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
<string>726</string>
|
<string>739</string>
|
||||||
<key>NSExtension</key>
|
<key>NSExtension</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>NSExtensionPointIdentifier</key>
|
<key>NSExtensionPointIdentifier</key>
|
||||||
|
|||||||
Reference in New Issue
Block a user