fix: preferences would not be live (closes #188)

closes #194
This commit is contained in:
Louis Pontoise authored and lwouis committed 2020-04-02 19:39:39 +09:00
1 parent 574a6401b9
commit d5b74a1afe
3 files changed
+9 -5

No files matched your search

+4 -3
View File
@@ -36,7 +36,7 @@ class App: NSApplication, NSApplicationDelegate {
Preferences.registerDefaults()
statusItem = Menubar.make(self)
loadMainMenuXib()
initPreferencesDependentComponents()
thumbnailsPanel = ThumbnailsPanel()
Spaces.initialDiscovery()
Applications.initialDiscovery()
Keyboard.listenToGlobalEvents(self)
@@ -55,8 +55,9 @@ class App: NSApplication, NSApplicationDelegate {
}
// we put application code here which should be executed on init() and Preferences change
func initPreferencesDependentComponents() {
thumbnailsPanel = ThumbnailsPanel(self)
func resetPreferencesDependentComponents() {
ThumbnailsView.recycledViews = ThumbnailsView.recycledViews.map { _ in ThumbnailView() }
thumbnailsPanel!.thumbnailsView.layer!.cornerRadius = Preferences.windowCornerRadius
}
func hideUi() {
+1 -1
View File
@@ -22,7 +22,7 @@ class ThumbnailView: NSStackView {
observeDragAndDrop()
}
func updateRecycledCellWithNewContent(_ element: Window, _ mouseDownCallback: @escaping MouseDownCallback, _ mouseMovedCallback: @escaping MouseMovedCallback, _ newHeight: CGFloat,_ screen: NSScreen) {
func updateRecycledCellWithNewContent(_ element: Window, _ mouseDownCallback: @escaping MouseDownCallback, _ mouseMovedCallback: @escaping MouseMovedCallback, _ newHeight: CGFloat, _ screen: NSScreen) {
window_ = element
// element.itemView = self
if thumbnail.image != element.thumbnail {
@@ -18,7 +18,10 @@ class PreferencesWindow: NSWindow {
let newValue = LabelAndControl.getControlValue(senderControl)
LabelAndControl.updateControlExtras(senderControl, newValue)
Preferences.set(senderControl.identifier!.rawValue, newValue)
(App.shared as! App).initPreferencesDependentComponents()
// some preferences require re-creating some components
if ["iconSize", "fontHeight", "theme"].contains(where: { $0 == senderControl.identifier!.rawValue }) {
(App.shared as! App).resetPreferencesDependentComponents()
}
}
private func setupWindow() {