feat: added feature to set keyboard shortcut to open/close popup window (#1976)

This commit is contained in:
Serhiy Mytrovtsiy
2025-01-20 17:04:55 +01:00
parent b4c835e97d
commit 58ad6c568b
25 changed files with 346 additions and 39 deletions

View File

@@ -13,8 +13,6 @@ import Cocoa
import Kit
internal class Popup: PopupWrapper {
private var title: String
private let dashboardHeight: CGFloat = 90
private let chartHeight: CGFloat = 120 + Constants.Popup.separatorHeight
private var detailsHeight: CGFloat {
@@ -125,14 +123,10 @@ internal class Popup: PopupWrapper {
}
public init(_ module: ModuleType) {
self.title = module.rawValue
super.init(frame: NSRect(x: 0, y: 0, width: Constants.Popup.width, height: 0))
super.init(module, frame: NSRect(x: 0, y: 0, width: Constants.Popup.width, height: 0))
self.spacing = 0
self.orientation = .vertical
// self.setAccessibilityElement(true)
// self.toolTip = self.title
self.systemColorState = SColor.fromString(Store.shared.string(key: "\(self.title)_systemColor", defaultValue: self.systemColorState.key))
self.userColorState = SColor.fromString(Store.shared.string(key: "\(self.title)_userColor", defaultValue: self.userColorState.key))
@@ -546,6 +540,13 @@ internal class Popup: PopupWrapper {
public override func settings() -> NSView? {
let view = SettingsContainerView()
view.addArrangedSubview(PreferencesSection([
PreferencesRow(localizedString("Keyboard shortcut"), component: KeyboardShartcutView(
callback: self.setKeyboardShortcut,
value: self.keyboardShortcut
))
]))
view.addArrangedSubview(PreferencesSection([
PreferencesRow(localizedString("System color"), component: selectView(
action: #selector(self.toggleSystemColor),