mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-06 11:14:14 +02:00
Assistant house style: rewrite qet-assistant.json when the style changes
qet.setHouseStyle() only saved the setting, so an assistant reading qet-assistant.json saw the old text until QElectroTech restarted. AssistantInfo::refresh() writes the file again, but only in a QElectroTech that writes it at all: a headless --run would otherwise replace the open QElectroTech's live channel with its own empty one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -36,6 +36,7 @@
|
||||
namespace {
|
||||
QJsonObject s_live; ///< empty while live mode is closed
|
||||
bool s_running = true;
|
||||
bool s_watching = false; ///< this QElectroTech writes the file (an editor opened)
|
||||
}
|
||||
|
||||
namespace AssistantInfo {
|
||||
@@ -54,14 +55,25 @@ QString path()
|
||||
*/
|
||||
void watch()
|
||||
{
|
||||
static bool watching = false;
|
||||
if (watching) return;
|
||||
watching = true;
|
||||
if (s_watching) return;
|
||||
s_watching = true;
|
||||
QObject::connect(&ScriptLibrary::instance(), &ScriptLibrary::changed, &write);
|
||||
QObject::connect(qApp, &QCoreApplication::aboutToQuit, &markStopped);
|
||||
write();
|
||||
}
|
||||
|
||||
/**
|
||||
@brief refresh
|
||||
Write the file again after a setting it carries changed, but only in a
|
||||
QElectroTech that writes it at all: a headless --run never opened an
|
||||
editor, and writing from it would replace the open QElectroTech's live
|
||||
channel with its own empty one.
|
||||
*/
|
||||
void refresh()
|
||||
{
|
||||
if (s_watching) write();
|
||||
}
|
||||
|
||||
void write()
|
||||
{
|
||||
QJsonArray scripts, refused;
|
||||
|
||||
Reference in New Issue
Block a user