Improve desktop settings UX - window style

- No longer requires app restart on window style change
This commit is contained in:
filtered
2025-01-11 23:23:52 +11:00
parent 6df7a45d61
commit 56e18aee3e
3 changed files with 29 additions and 7 deletions

View File

@@ -386,6 +386,8 @@ export const CORE_SETTINGS: SettingParams[] = [
category: ['Comfy', 'Menu', 'UseNewMenu'],
defaultValue: 'Top',
name: 'Use new menu',
tooltip:
'(Desktop, Windows only): When using custom window style, only Top is supported',
type: 'combo',
options: ['Disabled', 'Top', 'Bottom'],
migrateDeprecatedValue: (value: string) => {

View File

@@ -1,8 +1,8 @@
import { t } from '@/i18n'
import { app } from '@/scripts/app'
import { useDialogService } from '@/services/dialogService'
import { useSettingStore } from '@/stores/settingStore'
import { electronAPI as getElectronAPI, isElectron } from '@/utils/envUtil'
;(async () => {
if (!isElectron()) return
@@ -49,9 +49,12 @@ import { electronAPI as getElectronAPI, isElectron } from '@/utils/envUtil'
) => {
if (!oldValue) return
electronAPI.Config.setWindowStyle(newValue)
// Custom window mode requires the Top menu.
if (newValue === 'custom' && oldValue !== newValue) {
useSettingStore().set('Comfy.UseNewMenu', 'Top')
}
onChangeRestartApp(newValue, oldValue)
electronAPI.Config.setWindowStyle(newValue)
}
}
],
@@ -190,4 +193,21 @@ import { electronAPI as getElectronAPI, isElectron } from '@/utils/envUtil'
}
]
})
// TODO: Replace monkey patch with API or replace UX.
// If the user changes frontend menu type, ensure custom window style is disabled.
const menuSetting = useSettingStore().settingsById['Comfy.UseNewMenu']
if (menuSetting) {
const { onChange } = menuSetting
menuSetting.onChange = (
newValue: 'Disabled' | 'Top' | 'Bottom',
oldValue?: 'Disabled' | 'Top' | 'Bottom'
) => {
const style = useSettingStore().get('Comfy-Desktop.WindowStyle')
if (oldValue === 'Top' && newValue !== oldValue && style === 'custom') {
useSettingStore().set('Comfy-Desktop.WindowStyle', 'default')
}
return onChange?.(newValue, oldValue)
}
}
})()

View File

@@ -7,10 +7,10 @@
},
"Comfy-Desktop_WindowStyle": {
"name": "Window Style",
"tooltip": "Choose custom option to hide the system title bar",
"tooltip": "Custom: Replace the system title bar with ComfyUI's Top menu",
"options": {
"default": "default",
"custom": "custom"
"default": "Default",
"custom": "Custom"
}
},
"Comfy_ConfirmClear": {
@@ -312,4 +312,4 @@
"pysssss_SnapToGrid": {
"name": "Always snap to grid"
}
}
}