mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-25 00:14:15 +02:00
Script buttons: a manager to write, try and delete stored scripts
Projet > Scripts > Gérer les scripts… lists the stored scripts with their icons, and the files that get no button with the reason. For each one it edits the name, icon (a file copied next to the script, a theme icon, or the initials), tooltip, shortcut, when it is enabled, and the script itself; "Tester" saves it and runs it on the current project, one Ctrl+Z to undo; "Supprimer" deletes it with its icon if no other script uses it. It only reads and writes the files in the scripts folder, so a script written here, by hand or by an assistant over the qet MCP server is the same thing, and the folder's watcher turns each into a button. ScriptHeader gains compose(), bodyOf() and idFor(), header-only and tested: what the manager writes reads back as what was typed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
#ifdef QET_HAS_SCRIPTING
|
||||
#include "scripting/qetscripting.h"
|
||||
#include "scripting/scriptlibrary.h"
|
||||
#include "scripting/scriptmanagerdialog.h"
|
||||
#endif
|
||||
#include <QCoreApplication>
|
||||
#include <QToolButton>
|
||||
@@ -710,6 +711,23 @@ void QETDiagramEditor::setUpActions()
|
||||
" dans le script pour l'API disponible)"));
|
||||
connect(m_run_script, &QAction::triggered, this, &QETDiagramEditor::slot_runScript);
|
||||
|
||||
//Write, try, give an icon to and delete stored scripts
|
||||
m_manage_scripts = new QAction(tr("Gérer les scripts…"), this);
|
||||
m_manage_scripts->setStatusTip(tr("Écrire un script et en faire un bouton avec une icône"));
|
||||
connect(m_manage_scripts, &QAction::triggered, this, [this]() {
|
||||
if (!m_script_manager) {
|
||||
m_script_manager = new ScriptManagerDialog(
|
||||
[this](const QString &path, const QString &name) {
|
||||
runStoredScript(path, name);
|
||||
}, this);
|
||||
}
|
||||
m_script_manager->show();
|
||||
m_script_manager->raise();
|
||||
m_script_manager->activateWindow();
|
||||
});
|
||||
ShortcutManager::instance().registerAction(m_manage_scripts, "diagrameditor.manage_scripts",
|
||||
tr("Éditeur de schémas"), QKeySequence());
|
||||
|
||||
//Stored scripts are files in a folder, written by hand, by the
|
||||
//script manager or by an assistant: open it to add one.
|
||||
m_open_scripts_folder = new QAction(QET::Icons::FolderOpen, tr("Ouvrir le dossier des scripts"), this);
|
||||
@@ -3867,6 +3885,7 @@ void QETDiagramEditor::rebuildScriptActions()
|
||||
}
|
||||
|
||||
m_scripts_menu->addSeparator();
|
||||
m_scripts_menu->addAction(m_manage_scripts);
|
||||
m_scripts_menu->addAction(m_run_script);
|
||||
m_scripts_menu->addAction(m_open_scripts_folder);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user