Skip to content

Commit

Permalink
Merge pull request #99 from gao-sun/v1.4.4
Browse files Browse the repository at this point in the history
v1.4.4
  • Loading branch information
gao-sun authored Nov 19, 2020
2 parents 7fa8739 + 1431197 commit d0fc820
Show file tree
Hide file tree
Showing 18 changed files with 111 additions and 44 deletions.
2 changes: 2 additions & 0 deletions Resource/de.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@
"language.pt" = "Português";
"language.ja" = "日本語";
"language.fr" = "Français";
"language.mn" = "Монгол";
"language.ko" = "한국어";

// MARK: General UI
"ui.app" = "App";
Expand Down
2 changes: 2 additions & 0 deletions Resource/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@
"language.pt" = "Português";
"language.ja" = "日本語";
"language.fr" = "Français";
"language.mn" = "Монгол";
"language.ko" = "한국어";

// MARK: General UI
"ui.app" = "App";
Expand Down
3 changes: 2 additions & 1 deletion Resource/es.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@
"language.pt" = "Português";
"language.ja" = "日本語";
"language.fr" = "Français";

"language.mn" = "Монгол";
"language.ko" = "한국어";
// MARK: General UI
"ui.app" = "Aplicación";
"ui.general" = "General";
Expand Down
3 changes: 3 additions & 0 deletions Resource/fr.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,10 @@
"language.ru" = "Русский";
"language.es" = "Español";
"language.pt" = "Português";
"language.ja" = "日本語";
"language.fr" = "Français";
"language.mn" = "Монгол";
"language.ko" = "한국어";

// MARK: General UI
"ui.app" = "Application";
Expand Down
2 changes: 2 additions & 0 deletions Resource/ja.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@
"language.pt" = "Português";
"language.ja" = "日本語";
"language.fr" = "Français";
"language.mn" = "Монгол";
"language.ko" = "한국어";

// MARK: General UI
"ui.app" = "App";
Expand Down
3 changes: 3 additions & 0 deletions Resource/ko.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@
"language.ru" = "Русский";
"language.es" = "Español";
"language.pt" = "Português";
"language.ja" = "日本語";
"language.fr" = "Français";
"language.mn" = "Монгол";
"language.ko" = "한국어";

// MARK: General UI
Expand Down
3 changes: 3 additions & 0 deletions Resource/mn.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,10 @@
"language.ru" = "Русский";
"language.es" = "Español";
"language.pt" = "Português";
"language.ja" = "日本語";
"language.fr" = "Français";
"language.mn" = "Монгол";
"language.ko" = "한국어";

// MARK: General UI
"ui.app" = "Апп";
Expand Down
2 changes: 2 additions & 0 deletions Resource/pt.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@
"language.pt" = "Português";
"language.ja" = "日本語";
"language.fr" = "Français";
"language.mn" = "Монгол";
"language.ko" = "한국어";

// MARK: General UI
"ui.app" = "App";
Expand Down
2 changes: 2 additions & 0 deletions Resource/ru.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@
"language.pt" = "Português";
"language.ja" = "日本語";
"language.fr" = "Français";
"language.mn" = "Монгол";
"language.ko" = "한국어";

// MARK: General UI
"ui.app" = "Приложение";
Expand Down
2 changes: 2 additions & 0 deletions Resource/zh-Hans.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@
"language.pt" = "Português";
"language.ja" = "日本語";
"language.fr" = "Français";
"language.mn" = "Монгол";
"language.ko" = "한국어";

// MARK: General UI
"ui.app" = "App";
Expand Down
46 changes: 26 additions & 20 deletions eul.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,8 @@
6CB260AF250DF1A900328DAA /* BatteryIconView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BatteryIconView.swift; sourceTree = "<group>"; };
6CB26F7824E8310900E809FE /* SectionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SectionView.swift; sourceTree = "<group>"; };
6CC0798B250CD793000D7DAC /* PreferenceGeneralView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreferenceGeneralView.swift; sourceTree = "<group>"; };
6CC7384E2566C07D003A15AC /* mn */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = mn; path = mn.lproj/Localizable.strings; sourceTree = "<group>"; };
6CC738502566C140003A15AC /* ko */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ko; path = ko.lproj/Localizable.strings; sourceTree = "<group>"; };
6CDBB4C0254462B100D01EA0 /* PreferenceSectionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreferenceSectionView.swift; sourceTree = "<group>"; };
6CDBB4C225447B7500D01EA0 /* EulMenuComponent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EulMenuComponent.swift; sourceTree = "<group>"; };
6CDBB4C425447D8B00D01EA0 /* ComponentsStore.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ComponentsStore.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1030,6 +1032,8 @@
pt,
ja,
fr,
mn,
ko,
);
mainGroup = 6C5F8532249FACE000CF0EF8;
packageReferences = (
Expand Down Expand Up @@ -1356,6 +1360,8 @@
6C2F1647255C1EAD0062F76F /* pt */,
CBD2B8D02562D42500CB7E90 /* ja */,
D27F239C2564E5B700D3F565 /* fr */,
6CC7384E2566C07D003A15AC /* mn */,
6CC738502566C140003A15AC /* ko */,
);
name = Localizable.strings;
sourceTree = "<group>";
Expand Down Expand Up @@ -1441,7 +1447,7 @@
CODE_SIGN_ENTITLEMENTS = MemoryWidget/MemoryWidget.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 22;
CURRENT_PROJECT_VERSION = 23;
DEVELOPMENT_TEAM = M8G2RFZVFV;
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = MemoryWidget/Info.plist;
Expand All @@ -1451,7 +1457,7 @@
"@executable_path/../../../../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 11.0;
MARKETING_VERSION = 1.4.3;
MARKETING_VERSION = 1.4.4;
PRODUCT_BUNDLE_IDENTIFIER = com.gaosun.eul.MemoryWidget;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
Expand All @@ -1467,7 +1473,7 @@
CODE_SIGN_ENTITLEMENTS = MemoryWidget/MemoryWidget.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 22;
CURRENT_PROJECT_VERSION = 23;
DEVELOPMENT_TEAM = M8G2RFZVFV;
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = MemoryWidget/Info.plist;
Expand All @@ -1477,7 +1483,7 @@
"@executable_path/../../../../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 11.0;
MARKETING_VERSION = 1.4.3;
MARKETING_VERSION = 1.4.4;
PRODUCT_BUNDLE_IDENTIFIER = com.gaosun.eul.MemoryWidget;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
Expand All @@ -1493,7 +1499,7 @@
CODE_SIGN_ENTITLEMENTS = NetworkWidget/NetworkWidget.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 22;
CURRENT_PROJECT_VERSION = 23;
DEVELOPMENT_TEAM = M8G2RFZVFV;
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = NetworkWidget/Info.plist;
Expand All @@ -1503,7 +1509,7 @@
"@executable_path/../../../../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 11.0;
MARKETING_VERSION = 1.4.3;
MARKETING_VERSION = 1.4.4;
PRODUCT_BUNDLE_IDENTIFIER = com.gaosun.eul.NetworkWidget;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
Expand All @@ -1519,7 +1525,7 @@
CODE_SIGN_ENTITLEMENTS = NetworkWidget/NetworkWidget.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 22;
CURRENT_PROJECT_VERSION = 23;
DEVELOPMENT_TEAM = M8G2RFZVFV;
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = NetworkWidget/Info.plist;
Expand All @@ -1529,7 +1535,7 @@
"@executable_path/../../../../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 11.0;
MARKETING_VERSION = 1.4.3;
MARKETING_VERSION = 1.4.4;
PRODUCT_BUNDLE_IDENTIFIER = com.gaosun.eul.NetworkWidget;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
Expand Down Expand Up @@ -1664,7 +1670,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 22;
CURRENT_PROJECT_VERSION = 23;
DEVELOPMENT_ASSET_PATHS = "";
DEVELOPMENT_TEAM = M8G2RFZVFV;
ENABLE_HARDENED_RUNTIME = YES;
Expand All @@ -1676,7 +1682,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.15;
MARKETING_VERSION = 1.4.3;
MARKETING_VERSION = 1.4.4;
PRODUCT_BUNDLE_IDENTIFIER = com.gaosun.eul;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "";
Expand All @@ -1695,7 +1701,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 22;
CURRENT_PROJECT_VERSION = 23;
DEVELOPMENT_ASSET_PATHS = "";
DEVELOPMENT_TEAM = M8G2RFZVFV;
ENABLE_HARDENED_RUNTIME = YES;
Expand All @@ -1707,7 +1713,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.15;
MARKETING_VERSION = 1.4.3;
MARKETING_VERSION = 1.4.4;
PRODUCT_BUNDLE_IDENTIFIER = com.gaosun.eul;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "";
Expand All @@ -1723,7 +1729,7 @@
CODE_SIGN_ENTITLEMENTS = BatteryWidget/BatteryWidget.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 22;
CURRENT_PROJECT_VERSION = 23;
DEVELOPMENT_TEAM = M8G2RFZVFV;
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = BatteryWidget/Info.plist;
Expand All @@ -1733,7 +1739,7 @@
"@executable_path/../../../../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 11.0;
MARKETING_VERSION = 1.4.3;
MARKETING_VERSION = 1.4.4;
PRODUCT_BUNDLE_IDENTIFIER = com.gaosun.eul.BatteryWidget;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
Expand All @@ -1749,7 +1755,7 @@
CODE_SIGN_ENTITLEMENTS = BatteryWidget/BatteryWidget.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 22;
CURRENT_PROJECT_VERSION = 23;
DEVELOPMENT_TEAM = M8G2RFZVFV;
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = BatteryWidget/Info.plist;
Expand All @@ -1759,7 +1765,7 @@
"@executable_path/../../../../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 11.0;
MARKETING_VERSION = 1.4.3;
MARKETING_VERSION = 1.4.4;
PRODUCT_BUNDLE_IDENTIFIER = com.gaosun.eul.BatteryWidget;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
Expand All @@ -1775,7 +1781,7 @@
CODE_SIGN_ENTITLEMENTS = CpuWidget/CpuWidget.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 22;
CURRENT_PROJECT_VERSION = 23;
DEVELOPMENT_TEAM = M8G2RFZVFV;
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = CpuWidget/Info.plist;
Expand All @@ -1785,7 +1791,7 @@
"@executable_path/../../../../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 11.0;
MARKETING_VERSION = 1.4.3;
MARKETING_VERSION = 1.4.4;
PRODUCT_BUNDLE_IDENTIFIER = com.gaosun.eul.CpuWidget;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
Expand All @@ -1801,7 +1807,7 @@
CODE_SIGN_ENTITLEMENTS = CpuWidget/CpuWidget.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 22;
CURRENT_PROJECT_VERSION = 23;
DEVELOPMENT_TEAM = M8G2RFZVFV;
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = CpuWidget/Info.plist;
Expand All @@ -1811,7 +1817,7 @@
"@executable_path/../../../../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 11.0;
MARKETING_VERSION = 1.4.3;
MARKETING_VERSION = 1.4.4;
PRODUCT_BUNDLE_IDENTIFIER = com.gaosun.eul.CpuWidget;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
Expand Down
35 changes: 35 additions & 0 deletions eul/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,28 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate {
NSApplication.shared.terminate(self)
}

private var isSleeping = false

var window: NSWindow!
let statusBarManager = StatusBarManager()
@ObservedObject var preferenceStore = PreferenceStore.shared

func refreshSMCRepeatedly() {
guard !isSleeping else {
return
}

NotificationCenter.default.post(name: .SMCShouldRefresh, object: nil)
DispatchQueue.main.asyncAfter(deadline: .now() + Double(preferenceStore.smcRefreshRate)) { [self] in
refreshSMCRepeatedly()
}
}

func refreshNetworkRepeatedly() {
guard !isSleeping else {
return
}

NotificationCenter.default.post(name: .NetworkShouldRefresh, object: nil)
DispatchQueue.main.asyncAfter(deadline: .now() + Double(preferenceStore.networkRefreshRate)) { [self] in
refreshNetworkRepeatedly()
Expand Down Expand Up @@ -67,10 +77,35 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate {
// NSApp.activate(ignoringOtherApps: true)

SmcControl.shared.start()
wakeUp()

let notificationCenter = NSWorkspace.shared.notificationCenter
notificationCenter.addObserver(forName: NSWorkspace.willSleepNotification, object: nil, queue: nil) { _ in
print("😪 going to sleep")
self.sleep()
}
notificationCenter.addObserver(forName: NSWorkspace.didWakeNotification, object: nil, queue: nil) { _ in
print("🤩 woke up")
self.wakeUp()
}
}

func applicationShouldTerminate(_: NSApplication) -> NSApplication.TerminateReply {
print("🤚 should terminate")
SmcControl.shared.close()
return .terminateNow
}

func wakeUp() {
isSleeping = false
refreshSMCRepeatedly()
refreshNetworkRepeatedly()
}

func sleep() {
isSleeping = true
}

func windowDidBecomeMain(_: Notification) {
PreferenceStore.shared.checkUpdate()
}
Expand Down
5 changes: 5 additions & 0 deletions eul/StatusBar/StatusBarItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ class StatusBarItem: NSObject, NSMenuDelegate {

func menuWillOpen(_ menu: NSMenu) {
UIStore.shared.menuWidth = menu.size.width
UIStore.shared.menuOpened = true
}

func menuDidClose(_: NSMenu) {
UIStore.shared.menuOpened = false
}

func checkStatusItemVisibility() {
Expand Down
8 changes: 6 additions & 2 deletions eul/Store/CpuTopStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,13 @@ class CpuTopStore: ObservableObject {

init() {
activeCancellable = Publishers
.CombineLatest(preferenceStore.$showCPUTopActivities, sharedMenuComponentsStore.$activeComponents)
.CombineLatest3(
preferenceStore.$showCPUTopActivities,
sharedMenuComponentsStore.$activeComponents,
UIStore.shared.$menuOpened
)
.map {
$0 && $1.contains(.CPU)
$0 && $1.contains(.CPU) && $2
}
.sink { [self] in
update(shouldStart: $0)
Expand Down
Loading

0 comments on commit d0fc820

Please sign in to comment.