diff --git a/src/logic/Preferences.swift b/src/logic/Preferences.swift index 1782650b..2de7d43a 100644 --- a/src/logic/Preferences.swift +++ b/src/logic/Preferences.swift @@ -169,23 +169,36 @@ class Preferences { } private static func updateToNewPreferences(_ currentVersion: String) { - if currentVersion.compare("6.27.1", options: .numeric) != .orderedDescending { - // "Start at login" new implem doesn't use Login Items; we remove the entry from previous versions - migrateLoginItem() - if currentVersion.compare("6.23.0", options: .numeric) != .orderedDescending { - // "Show windows from:" got the "Active Space" option removed - migrateShowWindowsFrom() - if currentVersion.compare("6.18.1", options: .numeric) != .orderedDescending { - // nextWindowShortcut used to be able to have modifiers already present in holdShortcut; we remove these - migrateNextWindowShortcuts() - // dropdowns preferences used to store English text; now they store indexes - migrateDropdownsFromTextToIndexes() - // the "Hide menubar icon" checkbox was replaced with a dropdown of: icon1, icon2, hidden - migrateMenubarIconFromCheckboxToDropdown() - // "Show minimized/hidden/fullscreen windows" checkboxes were replaced with dropdowns - migrateShowWindowsCheckboxToDropdown() - // "Max size on screen" was split into max width and max height - migrateMaxSizeOnScreenToWidthAndHeight() + if currentVersion.compare("6.28.1", options: .numeric) != .orderedDescending { + migrateMinMaxWindowsWidthInRow() + if currentVersion.compare("6.27.1", options: .numeric) != .orderedDescending { + // "Start at login" new implem doesn't use Login Items; we remove the entry from previous versions + migrateLoginItem() + if currentVersion.compare("6.23.0", options: .numeric) != .orderedDescending { + // "Show windows from:" got the "Active Space" option removed + migrateShowWindowsFrom() + if currentVersion.compare("6.18.1", options: .numeric) != .orderedDescending { + // nextWindowShortcut used to be able to have modifiers already present in holdShortcut; we remove these + migrateNextWindowShortcuts() + // dropdowns preferences used to store English text; now they store indexes + migrateDropdownsFromTextToIndexes() + // the "Hide menubar icon" checkbox was replaced with a dropdown of: icon1, icon2, hidden + migrateMenubarIconFromCheckboxToDropdown() + // "Show minimized/hidden/fullscreen windows" checkboxes were replaced with dropdowns + migrateShowWindowsCheckboxToDropdown() + // "Max size on screen" was split into max width and max height + migrateMaxSizeOnScreenToWidthAndHeight() + } + } + } + } + } + + private static func migrateMinMaxWindowsWidthInRow() { + ["windowMinWidthInRow", "windowMaxWidthInRow"].forEach { + if let old = defaults.string(forKey: $0) { + if old == "0" { + defaults.set("1", forKey: $0) } } } diff --git a/src/ui/main-window/ThumbnailView.swift b/src/ui/main-window/ThumbnailView.swift index 2fc9e4a7..1cf39092 100644 --- a/src/ui/main-window/ThumbnailView.swift +++ b/src/ui/main-window/ThumbnailView.swift @@ -151,13 +151,14 @@ class ThumbnailView: NSStackView { if appIconChanged || dockLabelChanged { setAccessibilityHelp(getAccessibilityHelp(element.application.runningApplication.localizedName, element.dockLabel)) } - assignIfDifferent(&frame.size.width, max((Preferences.hideThumbnails ? hStackView.fittingSize.width : thumbnail.frame.size.width) + Preferences.intraCellPadding * 2, ThumbnailView.widthMin(screen)).rounded()) + let widthMin = ThumbnailView.widthMin(screen) + assignIfDifferent(&frame.size.width, max((Preferences.hideThumbnails ? hStackView.fittingSize.width : thumbnail.frame.size.width) + Preferences.intraCellPadding * 2, widthMin).rounded()) assignIfDifferent(&frame.size.height, newHeight) let fontIconWidth = CGFloat([fullscreenIcon, minimizedIcon, hiddenIcon, spaceIcon].filter { !$0.isHidden }.count) * (Preferences.fontHeight + Preferences.intraCellPadding) assignIfDifferent(&label.textContainer!.size.width, frame.width - Preferences.iconSize - Preferences.intraCellPadding * 3 - fontIconWidth) assignIfDifferent(&windowlessIcon.isHidden, !element.isWindowlessApp || Preferences.hideThumbnails) if element.isWindowlessApp { - let maxWidth = (ThumbnailView.widthMin(screen) - Preferences.intraCellPadding * 2).rounded() + let maxWidth = (widthMin - Preferences.intraCellPadding * 2).rounded() let maxHeight = ((ThumbnailView.height(screen) - hStackView.fittingSize.height) - Preferences.intraCellPadding * 2).rounded() // heuristic to determine font size based on bounding box let fontSize = (min(maxWidth, maxHeight) * 0.6).rounded() diff --git a/src/ui/preferences-window/tabs/AppearanceTab.swift b/src/ui/preferences-window/tabs/AppearanceTab.swift index 50c98c32..4076a0b6 100644 --- a/src/ui/preferences-window/tabs/AppearanceTab.swift +++ b/src/ui/preferences-window/tabs/AppearanceTab.swift @@ -7,8 +7,8 @@ class AppearanceTab { static func initTab() -> NSView { rowsCount = LabelAndControl.makeLabelWithSlider(NSLocalizedString("Rows of thumbnails:", comment: ""), "rowsCount", 1, 20, 20, true) - minWidthInRow = LabelAndControl.makeLabelWithSlider(NSLocalizedString("Window min width in row:", comment: ""), "windowMinWidthInRow", 0, 100, 10, true, "%", extraAction: { _ in capMinMaxWidthInRow() }) - maxWidthInRow = LabelAndControl.makeLabelWithSlider(NSLocalizedString("Window max width in row:", comment: ""), "windowMaxWidthInRow", 0, 100, 10, true, "%", extraAction: { _ in capMinMaxWidthInRow() }) + minWidthInRow = LabelAndControl.makeLabelWithSlider(NSLocalizedString("Window min width in row:", comment: ""), "windowMinWidthInRow", 1, 100, 10, true, "%", extraAction: { _ in capMinMaxWidthInRow() }) + maxWidthInRow = LabelAndControl.makeLabelWithSlider(NSLocalizedString("Window max width in row:", comment: ""), "windowMaxWidthInRow", 1, 100, 10, true, "%", extraAction: { _ in capMinMaxWidthInRow() }) let grid = GridView([ LabelAndControl.makeLabelWithDropdown(NSLocalizedString("Theme:", comment: ""), "theme", ThemePreference.allCases),