Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ extension IndicatorWindowController {
size: preferences.indicatorSize ?? .medium,
bgColor: preferencesVM.defaultIndicatorBgNSColor,
textColor: preferencesVM.defaultIndicatorTextNSColor,
prefersTextInputSourceIcons: preferences.prefersTextInputSourceIcons,
badge: .init(glyph: mode.badgeGlyph, title: mode.displayName)
))

Expand All @@ -34,7 +35,8 @@ extension IndicatorWindowController {
kind: preferences.indicatorKind,
size: preferences.indicatorSize ?? .medium,
bgColor: preferencesVM.getBgNSColor(inputSource),
textColor: preferencesVM.getTextNSColor(inputSource)
textColor: preferencesVM.getTextNSColor(inputSource),
prefersTextInputSourceIcons: preferences.prefersTextInputSourceIcons
))

if isActive {
Expand Down
4 changes: 4 additions & 0 deletions Input Source Pro/Models/PreferencesVM.swift
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ struct Preferences {
static let isAutoAppearanceMode = "isAutoAppearanceMode"
static let appearanceMode = "appearanceMode"
static let isShowInputSourcesLabel = "isShowInputSourcesLabel"
static let prefersTextInputSourceIcons = "prefersTextInputSourceIcons"
static let indicatorBackground = "indicatorBackground"
static let indicatorForgeground = "indicatorForgeground"

Expand Down Expand Up @@ -505,6 +506,9 @@ struct Preferences {
@CodableUserDefault(Preferences.Key.indicatorSize)
var indicatorSize = IndicatorSize.medium

@UserDefault(Preferences.Key.prefersTextInputSourceIcons)
var prefersTextInputSourceIcons = true

@UserDefault(Preferences.Key.isAutoAppearanceMode)
var isAutoAppearanceMode = true

Expand Down
1 change: 1 addition & 0 deletions Input Source Pro/Resources/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@

"Appearance" = "Appearance";
"Indicator Info" = "Indicator Info";
"Use Text Input Source Icons" = "Use Text Input Source Icons";
"Icon and Title" = "Icon and Title";
"Icon" = "Icon";
"Title" = "Title";
Expand Down
1 change: 1 addition & 0 deletions Input Source Pro/Resources/ja.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@

"Appearance" = "外観";
"Indicator Info" = "インジケーター情報";
"Use Text Input Source Icons" = "文字入力ソースアイコンを使用";
"Icon and Title" = "アイコンとタイトル";
"Icon" = "アイコン";
"Title" = "タイトル";
Expand Down
1 change: 1 addition & 0 deletions Input Source Pro/Resources/ko.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@

"Appearance" = "외관";
"Indicator Info" = "표시기 정보";
"Use Text Input Source Icons" = "텍스트 입력 소스 아이콘 사용";
"Icon and Title" = "아이콘 및 제목";
"Icon" = "아이콘";
"Title" = "제목";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@

"Appearance" = "外观";
"Indicator Info" = "指示器信息";
"Use Text Input Source Icons" = "使用文字输入法图标";
"Icon and Title" = "图标和标题";
"Icon" = "图标";
"Title" = "标题";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@

"Appearance" = "外觀";
"Indicator Info" = "指示器資訊";
"Use Text Input Source Icons" = "使用文字輸入法圖示";
"Icon and Title" = "圖示和標題";
"Icon" = "圖示";
"Title" = "標題";
Expand Down
5 changes: 3 additions & 2 deletions Input Source Pro/UI/Components/CustomizedIndicatorView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ struct CustomizedIndicatorView: View {
inputSource: inputSource,
kind: preferencesVM.preferences.indicatorKind,
size: preferencesVM.preferences.indicatorSize ?? .medium,
bgColor: NSColor(preferencesVM.getBgColor(inputSource)),
textColor: NSColor(preferencesVM.getTextColor(inputSource))
bgColor: nil,
textColor: NSColor(preferencesVM.getTextColor(inputSource)),
prefersTextInputSourceIcons: preferencesVM.preferences.prefersTextInputSourceIcons
))
}
}
Expand Down
3 changes: 2 additions & 1 deletion Input Source Pro/UI/Components/IndicatorView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ struct IndicatorView: NSViewControllerRepresentable {
kind: preferencesVM.preferences.indicatorKind,
size: preferencesVM.preferences.indicatorSize ?? .medium,
bgColor: NSColor(preferencesVM.preferences.indicatorBackgroundColor),
textColor: NSColor(preferencesVM.preferences.indicatorForgegroundColor)
textColor: NSColor(preferencesVM.preferences.indicatorForgegroundColor),
prefersTextInputSourceIcons: preferencesVM.preferences.prefersTextInputSourceIcons
))

indicatorViewController.refresh()
Expand Down
6 changes: 4 additions & 2 deletions Input Source Pro/UI/Components/KeyboardCustomization.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,17 @@ struct KeyboardCustomization: View {
kind: .alwaysOn,
size: preferencesVM.preferences.indicatorSize ?? .medium,
bgColor: NSColor(bgColor),
textColor: NSColor(textColor)
textColor: NSColor(textColor),
prefersTextInputSourceIcons: preferencesVM.preferences.prefersTextInputSourceIcons
))

DumpIndicatorView(config: IndicatorViewConfig(
inputSource: inputSource,
kind: preferencesVM.preferences.indicatorKind,
size: preferencesVM.preferences.indicatorSize ?? .medium,
bgColor: NSColor(bgColor),
textColor: NSColor(textColor)
textColor: NSColor(textColor),
prefersTextInputSourceIcons: preferencesVM.preferences.prefersTextInputSourceIcons
))

Text("Always-On Indicator Style")
Expand Down
12 changes: 12 additions & 0 deletions Input Source Pro/UI/Screens/AppearanceSettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,18 @@ struct AppearanceSettingsView: View {
.labelsHidden()
.pickerStyle(.segmented)
.padding()

HStack {
Toggle("", isOn: $preferencesVM.preferences.prefersTextInputSourceIcons)
.toggleStyle(.switch)
.labelsHidden()

Text("Use Text Input Source Icons".i18n())

Spacer()
}
.padding()
.border(width: 1, edges: [.top], color: NSColor.border2.color)
}
}

Expand Down
3 changes: 2 additions & 1 deletion Input Source Pro/UI/Screens/KeyboardsSettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,9 @@ struct KeyboardsSettingsView: View {
inputSource: indicatorVM.state.inputSource,
kind: preferencesVM.preferences.indicatorKind,
size: preferencesVM.preferences.indicatorSize ?? .medium,
bgColor: preferencesVM.defaultIndicatorBgNSColor,
bgColor: nil,
textColor: preferencesVM.defaultIndicatorTextNSColor,
prefersTextInputSourceIcons: preferencesVM.preferences.prefersTextInputSourceIcons,
badge: .init(
glyph: currentFunctionKeyMode.badgeGlyph,
title: currentFunctionKeyMode.displayName
Expand Down
32 changes: 16 additions & 16 deletions Input Source Pro/Utilities/Indicator/IndicatorViewConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ struct IndicatorViewConfig {
let size: IndicatorSize
let bgColor: NSColor?
let textColor: NSColor?
let prefersTextInputSourceIcons: Bool

/// When set, the indicator renders this glyph (SF Symbol or text) + title
/// instead of the input source. Lets the same pill machinery show
Expand Down Expand Up @@ -217,7 +218,9 @@ struct IndicatorViewConfig {
}

private func getImageView(_ inputSource: InputSource) -> NSView? {
// if let textImage = getTextImageView(inputSource) { return textImage }
if prefersTextInputSourceIcons, let textImage = getTextImageView(inputSource) {
return textImage
}

guard let image = inputSource.icon
else { return nil }
Expand Down Expand Up @@ -265,26 +268,23 @@ struct IndicatorViewConfig {
else { return nil }

let labelView = NSTextField(labelWithString: labelName)
let view = NSView()

view.addSubview(labelView)
view.wantsLayer = true
view.layer?.backgroundColor = textColor?.cgColor
view.layer?.cornerRadius = 2
labelView.textColor = textColor
labelView.alignment = .center

labelView.snp.makeConstraints {
$0.center.equalTo(view)
switch size {
case .small:
labelView.font = .systemFont(ofSize: labelName.count > 1 ? 7 : 10, weight: .regular)
case .medium:
labelView.font = .systemFont(ofSize: labelName.count > 1 ? 10 : 13, weight: .regular)
case .large:
labelView.font = .systemFont(ofSize: labelName.count > 1 ? 15 : 20, weight: .regular)
}

view.snp.makeConstraints {
// $0.width.equalTo(22)
$0.width.height.equalTo(16)
labelView.snp.makeConstraints { make in
make.width.equalTo(max(leadingIconWidth, labelView.intrinsicContentSize.width))
}

labelView.textColor = bgColor
labelView.font = .systemFont(ofSize: labelName.count > 1 ? 10 : 11, weight: .regular)

return view
return labelView
}

private func getContainerView() -> NSView {
Expand Down