Live mode: remember the start warning and "always" across restarts

Live mode asked at every start (the "Mode direct" warning) and forgot
"always" for scripts when QElectroTech closed, so a user who works
with an assistant every day re-enabled it every day. Both are now
opt-in and remembered: the warning has a "Ne plus demander au
démarrage" checkbox (scripting/live_skip_warning), and the ask-first
choice is saved (scripting/live_ask_first; the Assistant panel's
checkbox and "Toujours" in the script window). The status bar still
shows live mode whenever it is open. Switching live mode off in the
settings clears "don't ask again", so turning it back on warns again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ispyisail
2026-10-05 19:11:47 +13:00
parent ecf995174e
commit 550dcdda71
5 changed files with 62 additions and 6 deletions
+16 -3
View File
@@ -47,6 +47,7 @@
#include <QPixmap>
#include <QPlainTextEdit>
#include <QVBoxLayout>
#include <QCheckBox>
#include <QDialog>
#include <QDialogButtonBox>
#include <QLabel>
@@ -73,7 +74,8 @@ LiveServer &LiveServer::instance()
return server;
}
LiveServer::LiveServer()
LiveServer::LiveServer() :
m_ask_first(QetSettings::liveAskFirst())
{
connect(qApp, &QCoreApplication::aboutToQuit, this, &LiveServer::stop);
}
@@ -104,6 +106,10 @@ void LiveServer::askAndStart(QWidget *parent)
return;
}
m_asked = true;
if (QetSettings::liveSkipStartWarning()) {
start();
return;
}
QMessageBox box(QMessageBox::Warning, tr("Mode direct"),
tr("Le mode direct est activé : un assistant IA connecté "
@@ -117,11 +123,17 @@ void LiveServer::askAndStart(QWidget *parent)
box.addButton(tr("&Pas pour cette session"), QMessageBox::RejectRole);
QPushButton *off = box.addButton(tr("&Désactiver"), QMessageBox::DestructiveRole);
box.setDefaultButton(go);
auto *remember = new QCheckBox(tr("Ne plus demander au démarrage"), &box);
remember->setToolTip(tr("Le mode direct s'ouvrira à chaque démarrage. Pour être "
"de nouveau averti, désactivez-le puis réactivez-le dans "
"Configurer QElectroTech > Général > Projets."));
box.setCheckBox(remember);
box.exec();
if (box.clickedButton() == off) {
QetSettings::setLiveAssistantEnabled(false);
} else if (box.clickedButton() == go) {
if (remember->isChecked()) QetSettings::setLiveSkipStartWarning(true);
start();
}
}
@@ -241,7 +253,7 @@ void LiveServer::handle(const QJsonObject &request)
const QString name = request.value(QStringLiteral("name")).toString();
const QString source = request.value(QStringLiteral("source")).toString();
//A script the assistant just wrote: the user sees it first,
//unless they said "always" this session. A stored script
//unless they chose "always" (remembered). A stored script
//is one the user already has, so it runs as a click would.
if (m_ask_first && !confirm(name, source))
answer = failure(QStringLiteral("refused by the user"));
@@ -380,6 +392,7 @@ void LiveServer::setAskFirst(bool ask)
{
if (ask == m_ask_first) return;
m_ask_first = ask;
QetSettings::setLiveAskFirst(ask);
emit askFirstChanged(ask);
}
@@ -514,7 +527,7 @@ bool LiveServer::confirm(const QString &name, const QString &source)
auto *buttons = new QDialogButtonBox(&dialog);
QPushButton *run = buttons->addButton(tr("&Exécuter"), QDialogButtonBox::AcceptRole);
buttons->addButton(tr("&Refuser"), QDialogButtonBox::RejectRole);
QPushButton *always = buttons->addButton(tr("&Toujours pour cette session"),
QPushButton *always = buttons->addButton(tr("&Toujours"),
QDialogButtonBox::AcceptRole);
layout->addWidget(buttons);
QPushButton *clicked = nullptr;