Skip to content

Move setting declarations from ui to coreSettings #847

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/components/appMenu/floating/FloatingMenu.vue
Original file line number Diff line number Diff line change
@@ -4,10 +4,23 @@

<script setup lang="ts">
import { app } from '@/scripts/app'
import { onMounted, ref } from 'vue'
import { useSettingStore } from '@/stores/settingStore'
import { onMounted, ref, watch } from 'vue'

const container = ref<HTMLDivElement | null>(null)

const settingStore = useSettingStore()
watch(
() => settingStore.get('Comfy.DevMode'),
(value) => {
const element = document.getElementById('comfy-dev-save-api-button')
if (element) {
element.style.display = value ? 'flex' : 'none'
}
},
{ immediate: true }
)

onMounted(() => {
app.ui.setup(container.value)
})
102 changes: 11 additions & 91 deletions src/scripts/ui.ts
Original file line number Diff line number Diff line change
@@ -379,82 +379,7 @@ export class ComfyUI {
}

setup(containerElement: HTMLElement) {
const confirmClear = this.settings.addSetting({
id: 'Comfy.ConfirmClear',
category: ['Comfy', 'Workflow', 'ConfirmClear'],
name: 'Require confirmation when clearing workflow',
type: 'boolean',
defaultValue: true
})

const promptFilename = this.settings.addSetting({
id: 'Comfy.PromptFilename',
category: ['Comfy', 'Workflow', 'PromptFilename'],
name: 'Prompt for filename when saving workflow',
type: 'boolean',
defaultValue: true
})

/**
* file format for preview
*
* format;quality
*
* ex)
* webp;50 -> webp, quality 50
* jpeg;80 -> rgb, jpeg, quality 80
*
* @type {string}
*/
const previewImage = this.settings.addSetting({
id: 'Comfy.PreviewFormat',
category: ['Comfy', 'Node Widget', 'PreviewFormat'],
name: 'Preview image format',
tooltip:
'When displaying a preview in the image widget, convert it to a lightweight image, e.g. webp, jpeg, webp;50, etc.',
type: 'text',
defaultValue: ''
})

this.settings.addSetting({
id: 'Comfy.DisableSliders',
category: ['Comfy', 'Node Widget', 'DisableSliders'],
name: 'Disable node widget sliders',
type: 'boolean',
defaultValue: false
})

this.settings.addSetting({
id: 'Comfy.DisableFloatRounding',
category: ['Comfy', 'Node Widget', 'DisableFloatRounding'],
name: 'Disable default float widget rounding.',
tooltip:
'(requires page reload) Cannot disable round when round is set by the node in the backend.',
type: 'boolean',
defaultValue: false
})

this.settings.addSetting({
id: 'Comfy.FloatRoundingPrecision',
category: ['Comfy', 'Node Widget', 'FloatRoundingPrecision'],
name: 'Float widget rounding decimal places [0 = auto].',
tooltip: '(requires page reload)',
type: 'slider',
attrs: {
min: 0,
max: 6,
step: 1
},
defaultValue: 0
})

this.settings.addSetting({
id: 'Comfy.EnableTooltips',
category: ['Comfy', 'Node', 'EnableTooltips'],
name: 'Enable Tooltips',
type: 'boolean',
defaultValue: true
})
const settingStore = useSettingStore()

const fileInput = $el('input', {
id: 'comfy-file-input',
@@ -668,7 +593,7 @@ export class ComfyUI {
textContent: 'Save',
onclick: () => {
let filename = 'workflow.json'
if (promptFilename.value) {
if (settingStore.get('Comfy.PromptFilename')) {
filename = prompt('Save workflow as:', filename)
if (!filename) return
if (!filename.toLowerCase().endsWith('.json')) {
@@ -699,7 +624,7 @@ export class ComfyUI {
style: { width: '100%', display: 'none' },
onclick: () => {
let filename = 'workflow_api.json'
if (promptFilename.value) {
if (settingStore.get('Comfy.PromptFilename')) {
filename = prompt('Save workflow (API) as:', filename)
if (!filename) return
if (!filename.toLowerCase().endsWith('.json')) {
@@ -744,7 +669,10 @@ export class ComfyUI {
id: 'comfy-clear-button',
textContent: 'Clear',
onclick: () => {
if (!confirmClear.value || confirm('Clear workflow?')) {
if (
!settingStore.get('Comfy.ConfirmClear') ||
confirm('Clear workflow?')
) {
app.clean()
app.graph.clear()
app.resetView()
@@ -756,7 +684,10 @@ export class ComfyUI {
id: 'comfy-load-default-button',
textContent: 'Load Default',
onclick: async () => {
if (!confirmClear.value || confirm('Load default workflow?')) {
if (
!settingStore.get('Comfy.ConfirmClear') ||
confirm('Load default workflow?')
) {
app.resetView()
await app.loadGraphData()
}
@@ -797,17 +728,6 @@ export class ComfyUI {
})
]) as HTMLDivElement

this.settings.addSetting({
id: 'Comfy.DevMode',
name: 'Enable dev mode options (API save, etc.)',
type: 'boolean',
defaultValue: false,
onChange: function (value) {
document.getElementById('comfy-dev-save-api-button').style.display =
value ? 'flex' : 'none'
}
})

this.restoreMenuPosition = dragElement(this.menuContainer, this.settings)

this.setStatus({ exec_info: { queue_remaining: 'X' } })
76 changes: 76 additions & 0 deletions src/stores/coreSettings.ts
Original file line number Diff line number Diff line change
@@ -262,5 +262,81 @@ export const CORE_SETTINGS: SettingParams[] = [
type: 'combo',
options: [NodeBadgeMode.None, NodeBadgeMode.ShowAll],
defaultValue: NodeBadgeMode.ShowAll
},
{
id: 'Comfy.ConfirmClear',
category: ['Comfy', 'Workflow', 'ConfirmClear'],
name: 'Require confirmation when clearing workflow',
type: 'boolean',
defaultValue: true
},
{
id: 'Comfy.PromptFilename',
category: ['Comfy', 'Workflow', 'PromptFilename'],
name: 'Prompt for filename when saving workflow',
type: 'boolean',
defaultValue: true
},
/**
* file format for preview
*
* format;quality
*
* ex)
* webp;50 -> webp, quality 50
* jpeg;80 -> rgb, jpeg, quality 80
*
* @type {string}
*/
{
id: 'Comfy.PreviewFormat',
category: ['Comfy', 'Node Widget', 'PreviewFormat'],
name: 'Preview image format',
tooltip:
'When displaying a preview in the image widget, convert it to a lightweight image, e.g. webp, jpeg, webp;50, etc.',
type: 'text',
defaultValue: ''
},
{
id: 'Comfy.DisableSliders',
category: ['Comfy', 'Node Widget', 'DisableSliders'],
name: 'Disable node widget sliders',
type: 'boolean',
defaultValue: false
},
{
id: 'Comfy.DisableFloatRounding',
category: ['Comfy', 'Node Widget', 'DisableFloatRounding'],
name: 'Disable default float widget rounding.',
tooltip:
'(requires page reload) Cannot disable round when round is set by the node in the backend.',
type: 'boolean',
defaultValue: false
},
{
id: 'Comfy.FloatRoundingPrecision',
category: ['Comfy', 'Node Widget', 'FloatRoundingPrecision'],
name: 'Float widget rounding decimal places [0 = auto].',
tooltip: '(requires page reload)',
type: 'slider',
attrs: {
min: 0,
max: 6,
step: 1
},
defaultValue: 0
},
{
id: 'Comfy.EnableTooltips',
category: ['Comfy', 'Node', 'EnableTooltips'],
name: 'Enable Tooltips',
type: 'boolean',
defaultValue: true
},
{
id: 'Comfy.DevMode',
name: 'Enable dev mode options (API save, etc.)',
type: 'boolean',
defaultValue: false
}
]