diff --git a/Easydict/App/Assets.xcassets/menu-icon/status_icon.imageset/Contents.json b/Easydict/App/Assets.xcassets/menu-icon/rounded_menu_bar_icon.imageset/Contents.json similarity index 70% rename from Easydict/App/Assets.xcassets/menu-icon/status_icon.imageset/Contents.json rename to Easydict/App/Assets.xcassets/menu-icon/rounded_menu_bar_icon.imageset/Contents.json index d0d1860d8..ca238cdf9 100644 --- a/Easydict/App/Assets.xcassets/menu-icon/status_icon.imageset/Contents.json +++ b/Easydict/App/Assets.xcassets/menu-icon/rounded_menu_bar_icon.imageset/Contents.json @@ -1,17 +1,15 @@ { "images" : [ { - "filename" : "release_18.png", "idiom" : "universal", "scale" : "1x" }, { - "filename" : "release_36.png", + "filename" : "rounded.png", "idiom" : "universal", "scale" : "2x" }, { - "filename" : "release_54.png", "idiom" : "universal", "scale" : "3x" } @@ -19,5 +17,8 @@ "info" : { "author" : "xcode", "version" : 1 + }, + "properties" : { + "localizable" : true } } diff --git a/Easydict/App/Assets.xcassets/menu-icon/rounded_menu_bar_icon.imageset/rounded.png b/Easydict/App/Assets.xcassets/menu-icon/rounded_menu_bar_icon.imageset/rounded.png new file mode 100644 index 000000000..72cd3f200 Binary files /dev/null and b/Easydict/App/Assets.xcassets/menu-icon/rounded_menu_bar_icon.imageset/rounded.png differ diff --git a/Easydict/App/Assets.xcassets/menu-icon/status_icon_debug.imageset/Contents.json b/Easydict/App/Assets.xcassets/menu-icon/square_menu_bar_icon.imageset/Contents.json similarity index 70% rename from Easydict/App/Assets.xcassets/menu-icon/status_icon_debug.imageset/Contents.json rename to Easydict/App/Assets.xcassets/menu-icon/square_menu_bar_icon.imageset/Contents.json index cdd79c551..b8568e6df 100644 --- a/Easydict/App/Assets.xcassets/menu-icon/status_icon_debug.imageset/Contents.json +++ b/Easydict/App/Assets.xcassets/menu-icon/square_menu_bar_icon.imageset/Contents.json @@ -1,17 +1,15 @@ { "images" : [ { - "filename" : "debug_20 1.png", "idiom" : "universal", "scale" : "1x" }, { - "filename" : "debug_40 1.png", + "filename" : "square.png", "idiom" : "universal", "scale" : "2x" }, { - "filename" : "debug_60 1.png", "idiom" : "universal", "scale" : "3x" } diff --git a/Easydict/App/Assets.xcassets/menu-icon/square_menu_bar_icon.imageset/square.png b/Easydict/App/Assets.xcassets/menu-icon/square_menu_bar_icon.imageset/square.png new file mode 100644 index 000000000..946f0b75b Binary files /dev/null and b/Easydict/App/Assets.xcassets/menu-icon/square_menu_bar_icon.imageset/square.png differ diff --git a/Easydict/App/Assets.xcassets/menu-icon/status_icon.imageset/release_18.png b/Easydict/App/Assets.xcassets/menu-icon/status_icon.imageset/release_18.png deleted file mode 100644 index 24e2328eb..000000000 Binary files a/Easydict/App/Assets.xcassets/menu-icon/status_icon.imageset/release_18.png and /dev/null differ diff --git a/Easydict/App/Assets.xcassets/menu-icon/status_icon.imageset/release_36.png b/Easydict/App/Assets.xcassets/menu-icon/status_icon.imageset/release_36.png deleted file mode 100644 index 2a7dbe540..000000000 Binary files a/Easydict/App/Assets.xcassets/menu-icon/status_icon.imageset/release_36.png and /dev/null differ diff --git a/Easydict/App/Assets.xcassets/menu-icon/status_icon.imageset/release_54.png b/Easydict/App/Assets.xcassets/menu-icon/status_icon.imageset/release_54.png deleted file mode 100644 index 22fa1bbc3..000000000 Binary files a/Easydict/App/Assets.xcassets/menu-icon/status_icon.imageset/release_54.png and /dev/null differ diff --git a/Easydict/App/Assets.xcassets/menu-icon/status_icon_debug.imageset/debug_20 1.png b/Easydict/App/Assets.xcassets/menu-icon/status_icon_debug.imageset/debug_20 1.png deleted file mode 100644 index 9f51401bc..000000000 Binary files a/Easydict/App/Assets.xcassets/menu-icon/status_icon_debug.imageset/debug_20 1.png and /dev/null differ diff --git a/Easydict/App/Assets.xcassets/menu-icon/status_icon_debug.imageset/debug_40 1.png b/Easydict/App/Assets.xcassets/menu-icon/status_icon_debug.imageset/debug_40 1.png deleted file mode 100644 index 76d13685b..000000000 Binary files a/Easydict/App/Assets.xcassets/menu-icon/status_icon_debug.imageset/debug_40 1.png and /dev/null differ diff --git a/Easydict/App/Assets.xcassets/menu-icon/status_icon_debug.imageset/debug_60 1.png b/Easydict/App/Assets.xcassets/menu-icon/status_icon_debug.imageset/debug_60 1.png deleted file mode 100644 index 0e7cca491..000000000 Binary files a/Easydict/App/Assets.xcassets/menu-icon/status_icon_debug.imageset/debug_60 1.png and /dev/null differ diff --git a/Easydict/App/Localizable.xcstrings b/Easydict/App/Localizable.xcstrings index 26d47dd1d..187199ca0 100644 --- a/Easydict/App/Localizable.xcstrings +++ b/Easydict/App/Localizable.xcstrings @@ -1805,6 +1805,23 @@ } } }, + "modify_menubar_icon" : { + "extractionState" : "manual", + "localizations" : { + "en" : { + "stringUnit" : { + "state" : "translated", + "value" : "Menu bar icon" + } + }, + "zh-Hans" : { + "stringUnit" : { + "state" : "translated", + "value" : "菜单栏图标" + } + } + } + }, "mouse_select_translate_window_type" : { "localizations" : { "en" : { @@ -3877,4 +3894,4 @@ } }, "version" : "1.0" -} +} \ No newline at end of file diff --git a/Easydict/Feature/StatusItem/EZMenuItemManager.m b/Easydict/Feature/StatusItem/EZMenuItemManager.m index 9f40e3fc9..81497fd5e 100644 --- a/Easydict/Feature/StatusItem/EZMenuItemManager.m +++ b/Easydict/Feature/StatusItem/EZMenuItemManager.m @@ -83,9 +83,9 @@ - (void)setup { NSStatusBarButton *button = statusItem.button; #if DEBUG - NSImage *image = [NSImage imageNamed:@"status_icon_debug"]; + NSImage *image = [NSImage imageNamed:@"rounded_menu_bar_icon"]; #else - NSImage *image = [NSImage imageNamed:@"status_icon"]; + NSImage *image = [NSImage imageNamed:@"square_menu_bar_icon"]; #endif [button setImage:image]; diff --git a/Easydict/NewApp/Configuration/Configuration+Defaults.swift b/Easydict/NewApp/Configuration/Configuration+Defaults.swift index bfe859765..e749b2e0c 100644 --- a/Easydict/NewApp/Configuration/Configuration+Defaults.swift +++ b/Easydict/NewApp/Configuration/Configuration+Defaults.swift @@ -52,6 +52,7 @@ extension Defaults.Keys { static let appearanceType = Key("EZConfiguration_kApperanceKey", default: .followSystem) static let fontSizeOptionIndex = Key("EZConfiguration_kTranslationControllerFontKey", default: 0) + static let selectedMenuBarIcon = Key("EZConfiguration_kSelectedMenuBarIconKey", default: .square) } extension Defaults.Keys { diff --git a/Easydict/NewApp/EasydictApp.swift b/Easydict/NewApp/EasydictApp.swift index bb3e1be41..95e985b93 100644 --- a/Easydict/NewApp/EasydictApp.swift +++ b/Easydict/NewApp/EasydictApp.swift @@ -31,13 +31,8 @@ struct EasydictApp: App { @AppStorage(Defaults.Key.hideMenuBarIcon.name) private var hideMenuBar = Defaults.Key.hideMenuBarIcon.defaultValue - private var menuBarImage: String { - #if DEBUG - "status_icon_debug" - #else - "status_icon" - #endif - } + @Default(.selectedMenuBarIcon) + private var menuBarIcon var body: some Scene { if #available(macOS 13, *) { @@ -47,9 +42,13 @@ struct EasydictApp: App { Label { Text("Easydict") } icon: { - Image(menuBarImage) + Image(menuBarIcon.rawValue) .resizable() + #if DEBUG + .renderingMode(.original) + #else .renderingMode(.template) + #endif .scaledToFit() } .help("Easydict 🍃") @@ -67,3 +66,10 @@ extension Bool { mutating set { self = newValue.toggledValue } } } + +enum MenuBarIconType: String, CaseIterable, Defaults.Serializable, Identifiable { + var id: Self { self } + + case square = "square_menu_bar_icon" + case rounded = "rounded_menu_bar_icon" +} diff --git a/Easydict/NewApp/View/SettingView/Tabs/GeneralTab.swift b/Easydict/NewApp/View/SettingView/Tabs/GeneralTab.swift index 26e427fee..a1e59e04e 100644 --- a/Easydict/NewApp/View/SettingView/Tabs/GeneralTab.swift +++ b/Easydict/NewApp/View/SettingView/Tabs/GeneralTab.swift @@ -11,6 +11,8 @@ import SwiftUI @available(macOS 13, *) struct GeneralTab: View { + @Environment(\.colorScheme) var colorScheme + var body: some View { Form { Section { @@ -136,6 +138,16 @@ struct GeneralTab: View { Toggle(isOn: $hideMenuBarIcon) { Text("hide_menu_bar_icon") } + Picker( + "modify_menubar_icon", + selection: $selectedMenuBarIcon + ) { + ForEach(MenuBarIconType.allCases) { option in + Image(option.rawValue) + .renderingMode(.template) + .foregroundStyle(.primary) + } + } } header: { Text("setting.general.other.header") } @@ -180,6 +192,7 @@ struct GeneralTab: View { @Default(.appearanceType) private var appearanceType @Default(.fontSizeOptionIndex) private var fontSizeOptionIndex + @Default(.selectedMenuBarIcon) private var selectedMenuBarIcon } @available(macOS 13, *)