- add missing translation to the Pictogram setting in the Network module

- reset Network module settings!
This commit is contained in:
Serhiy Mytrovtsiy
2020-10-31 16:01:22 +01:00
parent ca98ce4ebb
commit 8ac2d90e1e
13 changed files with 68 additions and 27 deletions

View File

@@ -12,17 +12,8 @@
import Cocoa
import StatsKit
public enum speed_icon_t: String {
case none = "None"
case separator = "separator"
case dot = "Dots"
case arrow = "Arrows"
case char = "Character"
}
extension speed_icon_t: CaseIterable {}
public class SpeedWidget: Widget {
private var icon: speed_icon_t = .dot
private var icon: String = "dots"
private var state: Bool = false
private var valueState: Bool = true
private var baseValue: String = "byte"
@@ -45,7 +36,7 @@ public class SpeedWidget: Widget {
if let symbols = config!["Symbols"] as? [String] {
self.symbols = symbols
}
if let iconName = config!["Icon"] as? String, let icon = speed_icon_t(rawValue: iconName) {
if let icon = config!["Icon"] as? String {
self.icon = icon
}
}
@@ -57,11 +48,11 @@ public class SpeedWidget: Widget {
if self.store != nil {
self.valueState = store!.pointee.bool(key: "\(self.title)_\(self.type.rawValue)_value", defaultValue: self.valueState)
self.icon = speed_icon_t(rawValue: store!.pointee.string(key: "\(self.title)_\(self.type.rawValue)_icon", defaultValue: self.icon.rawValue)) ?? self.icon
self.baseValue = store!.pointee.string(key: "\(self.title)_base", defaultValue: self.baseValue)
self.icon = store!.pointee.string(key: "\(self.title)_\(self.type.rawValue)_icon", defaultValue: self.baseValue)
self.baseValue = store!.pointee.string(key: "\(self.title)_\(self.type.rawValue)_base", defaultValue: self.baseValue)
}
if self.valueState && self.icon != .none {
if self.valueState && self.icon != "none" {
self.state = true
}
@@ -82,11 +73,11 @@ public class SpeedWidget: Widget {
var x: CGFloat = 10
switch self.icon {
case .dot:
case "dots":
self.drawDots(dirtyRect)
case .arrow:
case "arrows":
self.drawArrows(dirtyRect)
case .char:
case "chars":
self.drawChars(dirtyRect)
default:
x = 0
@@ -220,12 +211,12 @@ public class SpeedWidget: Widget {
height: superview.frame.height - (Constants.Settings.margin*2)
))
view.addSubview(SelectTitleRow(
view.addSubview(SelectRow(
frame: NSRect(x: 0, y: (rowHeight+Constants.Settings.margin) * 2, width: view.frame.width, height: rowHeight),
title: LocalizedString("Pictogram"),
action: #selector(toggleIcon),
items: speed_icon_t.allCases.map{ return $0.rawValue },
selected: self.icon.rawValue
items: SpeedPictogram,
selected: self.icon
))
view.addSubview(SelectRow(
@@ -254,7 +245,7 @@ public class SpeedWidget: Widget {
state = sender is NSButton ? (sender as! NSButton).state: nil
}
self.valueState = state! == .on ? true : false
self.store?.pointee.set(key: "\(self.title)_\(self.type.rawValue)_value", value: self.valueState)
self.store?.pointee.set(key: "\(self.title)_\(self.type.rawValue)_\(self.type.rawValue)_value", value: self.valueState)
self.display()
if !self.valueState && self.icon == .none {
@@ -267,12 +258,14 @@ public class SpeedWidget: Widget {
}
@objc private func toggleIcon(_ sender: NSMenuItem) {
let newIcon: speed_icon_t = speed_icon_t(rawValue: sender.title) ?? .none
self.icon = newIcon
self.store?.pointee.set(key: "\(self.title)_\(self.type.rawValue)_icon", value: self.icon.rawValue)
guard let key = sender.representedObject as? String else {
return
}
self.icon = key
self.store?.pointee.set(key: "\(self.title)_\(self.type.rawValue)_icon", value: key)
self.display()
if !self.valueState && self.icon == .none {
if !self.valueState && self.icon == "none" {
NotificationCenter.default.post(name: .toggleModule, object: nil, userInfo: ["module": self.title, "state": false])
self.state = false
} else if !self.state {
@@ -286,7 +279,7 @@ public class SpeedWidget: Widget {
return
}
self.baseValue = key
self.store?.pointee.set(key: "\(self.title)_base", value: self.baseValue)
self.store?.pointee.set(key: "\(self.title)_\(self.type.rawValue)_base", value: self.baseValue)
}
public func setValue(upload: Int64, download: Int64) {

View File

@@ -75,7 +75,7 @@
<key>Order</key>
<integer>3</integer>
<key>Icon</key>
<string>Character</string>
<string>characters</string>
<key>Symbols</key>
<array>
<string>W</string>

View File

@@ -24,6 +24,10 @@
"Yes" = "Ja";
"No" = "Nein";
"Automatic" = "Automatisch";
"None" = "Keiner";
"Dots" = "Punkte";
"Arrows" = "Pfeile";
"Characters" = "Briefe";
// Alerts
"New version available" = "Neue Version verfügbar";

View File

@@ -24,6 +24,10 @@
"Yes" = "Yes";
"No" = "No";
"Automatic" = "Automatic";
"None" = "None";
"Dots" = "Dots";
"Arrows" = "Arrows";
"Characters" = "Character";
// Alerts
"New version available" = "New version available";

View File

@@ -24,6 +24,10 @@
"Yes" = "Si";
"No" = "No";
"Automatic" = "Automático";
"None" = "Ninguna";
"Dots" = "Puntos";
"Arrows" = "Flechas";
"Characters" = "Letras";
// Alerts
"New version available" = "Nueva versión disponible";

View File

@@ -24,6 +24,10 @@
"Yes" = "예";
"No" = "아니요";
"Automatic" = "자동적 인";
"None" = "없음";
"Dots" = "도트";
"Arrows" = "화살";
"Characters" = "편지";
// Alerts
"New version available" = "새로운 버전을 이용할 수 있습니다";

View File

@@ -24,6 +24,10 @@
"Yes" = "Tak";
"No" = "Nie";
"Automatic" = "Automatyczny";
"None" = "Brak";
"Dots" = "Punkty";
"Arrows" = "Strzałki";
"Characters" = "Litery";
// Alerts
"New version available" = "Nowa wersja dostępna";

View File

@@ -24,6 +24,10 @@
"Yes" = "Да";
"No" = "Нет";
"Automatic" = "Автоматический";
"None" = "Никакой";
"Dots" = "Точки";
"Arrows" = "Стрелки";
"Characters" = "Символы";
// Alerts
"New version available" = "Доступна новая версия";

View File

@@ -24,6 +24,10 @@
"Yes" = "Evet";
"No" = "Hayır";
"Automatic" = "Otomatik";
"None" = "Yok";
"Dots" = "Noktalar";
"Arrows" = "Oklar";
"Characters" = "Mektuplar";
// Alerts
"New version available" = "Yeni versiyon indirilebilir";

View File

@@ -24,6 +24,10 @@
"Yes" = "Так";
"No" = "Ні";
"Automatic" = "Автоматичний";
"None" = "Ніяка";
"Dots" = "Пункти";
"Arrows" = "Стрілки";
"Characters" = "Літери";
// Alerts
"New version available" = "Доступна нова версія";

View File

@@ -24,6 +24,10 @@
"Yes" = "是";
"No" = "否";
"Automatic" = "自动";
"None" = "没有";
"Dots" = "点";
"Arrows" = "箭";
"Characters" = "字母";
// Alerts
"New version available" = "新版本可用";

View File

@@ -24,6 +24,10 @@
"Yes" = "是";
"No" = "否";
"Automatic" = "自動";
"None" = "沒有";
"Dots" = "點";
"Arrows" = "箭";
"Characters" = "字母";
// Alerts
"New version available" = "新版本可用";

View File

@@ -58,6 +58,14 @@ public let SensorsWidgetMode: [KeyValue_t] = [
KeyValue_t(key: "twoRows", value: "Two rows"),
]
public let SpeedPictogram: [KeyValue_t] = [
KeyValue_t(key: "none", value: "None"),
KeyValue_t(key: "separator", value: "separator"),
KeyValue_t(key: "dots", value: "Dots"),
KeyValue_t(key: "arrows", value: "Arrows"),
KeyValue_t(key: "chars", value: "Characters"),
]
public let ReaderUpdateIntervals: [Int] = [1, 2, 3, 5, 10, 15, 30]
public let NumbersOfProcesses: [Int] = [3, 5, 8, 10, 15]