Profiles: auto exec promptly (#14133)
Some checks failed
macos / macOS 13 x86-64 🔨15.2 🎯10.15 (push) Has been cancelled
macos / macOS 14 ARM64 🔨15.4 🎯11.0 (push) Has been cancelled

This commit is contained in:
hius07
2025-08-05 12:25:00 +03:00
committed by GitHub
parent c4f9c60742
commit 176d3dec6c

View File

@@ -156,7 +156,19 @@ function Profiles:getSubMenuItems()
return v.settings.auto_exec_ask
end,
callback = function()
self.data[k].settings.auto_exec_ask = not v.settings.auto_exec_ask and true or nil
self.data[k].settings.auto_exec_ask = not v.settings.auto_exec_ask or nil
self.updated = true
end,
},
{
text = _("Execute promptly"),
help_text = _([[Enable this option to execute the profile before some other operations triggered by the event.
For example, with a trigger "on document closing" the profile will be executed before the document is closed.]]),
checked_func = function()
return v.settings.auto_exec_promptly
end,
callback = function()
self.data[k].settings.auto_exec_promptly = not v.settings.auto_exec_promptly or nil
self.updated = true
end,
},
@@ -236,7 +248,7 @@ function Profiles:getSubMenuItems()
return v.settings.notify
end,
callback = function()
self.data[k].settings.notify = not v.settings.notify and true or nil
self.data[k].settings.notify = not v.settings.notify or nil
self.updated = true
end,
separator = true,
@@ -1053,20 +1065,25 @@ function Profiles:executeAutoExec(profile_name, event)
ok_callback = function()
logger.dbg("Profiles - auto executing:", profile_name)
UIManager:nextTick(function()
Dispatcher:execute(self.data[profile_name])
Dispatcher:execute(profile)
end)
end,
})
else
logger.dbg("Profiles - auto executing:", profile_name)
if event == "CloseDocument" or event == "CloseDocumentAll" then
UIManager:tickAfterNext(function()
Dispatcher:execute(self.data[profile_name])
end)
if profile.settings.auto_exec_promptly then
logger.dbg("Profiles - auto executing promptly:", profile_name)
Dispatcher:execute(profile)
else
UIManager:nextTick(function()
Dispatcher:execute(self.data[profile_name])
end)
logger.dbg("Profiles - auto executing:", profile_name)
if event == "CloseDocument" or event == "CloseDocumentAll" then
UIManager:tickAfterNext(function()
Dispatcher:execute(profile)
end)
else
UIManager:nextTick(function()
Dispatcher:execute(profile)
end)
end
end
end
end