Skip to content

Commit

Permalink
fix: preferences would not be live (closes #188)
Browse files Browse the repository at this point in the history
closes #194
  • Loading branch information
lwouis committed Apr 2, 2020
1 parent 574a640 commit d5b74a1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/ui/App.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion src/ui/main-window/ThumbnailView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 4 additions & 1 deletion src/ui/preferences-window/PreferencesWindow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit d5b74a1

Please sign in to comment.