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
|
||||
}
|
||||
|
||||
public func redraw() {
|
||||
DispatchQueue.main.async { [weak self] in
|
||||
self?.display()
|
||||
}
|
||||
}
|
||||
|
||||
open func settings() -> NSView { return NSView() }
|
||||
|
||||
open override func mouseDown(with event: NSEvent) {
|
||||
@@ -318,18 +324,12 @@ public class SWidget {
|
||||
|
||||
public func setMenuBarItem(state: Bool) {
|
||||
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)")
|
||||
|
||||
DispatchQueue.main.async(execute: {
|
||||
self.menuBarItem = NSStatusBar.system.statusItem(withLength: self.item.frame.width)
|
||||
DispatchQueue.main.async(execute: {
|
||||
self.menuBarItem?.autosaveName = "\(self.module)_\(self.type.rawValue)"
|
||||
})
|
||||
if self.item.frame.origin.x != self.originX {
|
||||
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
|
||||
public var active: Bool {
|
||||
get {
|
||||
self.queue.sync { self._active }
|
||||
}
|
||||
set {
|
||||
self.queue.sync { self._active = newValue }
|
||||
}
|
||||
get { self.queue.sync { self._active } }
|
||||
set { self.queue.sync { self._active = newValue } }
|
||||
}
|
||||
|
||||
init(moduleName: String) {
|
||||
@@ -475,7 +471,9 @@ public class MenuBar {
|
||||
if state && self.active {
|
||||
restoreNSStatusItemPosition(id: self.moduleName)
|
||||
self.menuBarItem = NSStatusBar.system.statusItem(withLength: 0)
|
||||
DispatchQueue.main.async(execute: {
|
||||
self.menuBarItem?.autosaveName = self.moduleName
|
||||
})
|
||||
self.menuBarItem?.isVisible = true
|
||||
|
||||
self.menuBarItem?.button?.addSubview(self.view)
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>$(MARKETING_VERSION)</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>726</string>
|
||||
<string>739</string>
|
||||
<key>Description</key>
|
||||
<string>Simple macOS system monitor in your menu bar</string>
|
||||
<key>LSApplicationCategoryType</key>
|
||||
|
||||
@@ -70,7 +70,9 @@ internal class CombinedView: NSObject, NSGestureRecognizerDelegate {
|
||||
|
||||
public func enable() {
|
||||
self.menuBarItem = NSStatusBar.system.statusItem(withLength: 0)
|
||||
DispatchQueue.main.async(execute: {
|
||||
self.menuBarItem?.autosaveName = "CombinedModules"
|
||||
})
|
||||
self.menuBarItem?.button?.addSubview(self.view)
|
||||
self.menuBarItem?.button?.image = NSImage()
|
||||
self.menuBarItem?.button?.toolTip = localizedString("Combined modules")
|
||||
|
||||
@@ -257,7 +257,9 @@ extension AppDelegate {
|
||||
internal func icon() {
|
||||
if self.pauseState {
|
||||
self.menuBarItem = NSStatusBar.system.statusItem(withLength: AppIcon.size.width)
|
||||
DispatchQueue.main.async(execute: {
|
||||
self.menuBarItem?.autosaveName = "Stats"
|
||||
})
|
||||
self.menuBarItem?.button?.addSubview(AppIcon())
|
||||
|
||||
self.menuBarItem?.button?.target = self
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>2.11.58</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>726</string>
|
||||
<string>739</string>
|
||||
<key>NSExtension</key>
|
||||
<dict>
|
||||
<key>NSExtensionPointIdentifier</key>
|
||||
|
||||
Reference in New Issue
Block a user