54 QAction *action = actionRegistry->
makeQAction(
id(),
this);
55 actionCollection->
addAction(
id(), action);
56 connect(action, &QAction::triggered, toolManager, [toolId =
id(), toolManager] () {
60 Q_FOREACH(QAction *action, actions) {
61 if (action->objectName().isEmpty()) {
62 qWarning() <<
"Tool" <<
id() <<
"tries to add an action without a name";
65 QAction *existingAction = actionCollection->
action(action->objectName());
68 action = existingAction;
72 if (action->property(
"tool_action").isValid()) {
73 tools = action->property(
"tool_action").toStringList();
76 action->setProperty(
"tool_action", tools);
77 if (!existingAction) {
78 actionCollection->
addAction(action->objectName(), action);
80 toolActions << action;
85 if (toolActions.size() > 0) {
88 QDomElement e = doc.createElement(
"Actions");
89 e.setAttribute(
"name",
id);
90 e.setAttribute(
"version",
"2");
93 Q_FOREACH (QAction *action, toolActions) {
94 QDomElement a = doc.createElement(
"Action");
95 a.setAttribute(
"name", action->objectName());
98 auto addElement = [&](QString title, QString content) {
99 QDomElement newNode = doc.createElement(title);
100 QDomText newText = doc.createTextNode(content);
101 newNode.appendChild(newText);
102 a.appendChild(newNode);
105 addElement(
"icon", action->icon().name());
106 addElement(
"text", action->text());
107 addElement(
"whatsThis" , action->whatsThis());
108 addElement(
"toolTip" , action->toolTip());
109 addElement(
"iconText" , action->iconText());
110 addElement(
"shortcut" , action->shortcut().toString());
111 addElement(
"isCheckable" , QString((action->isChecked() ?
"true" :
"false")));
112 addElement(
"statusTip", action->statusTip());
115 QFile f(
id()z +
".action");
116 f.open(QFile::WriteOnly);
117 f.write(doc.toString().toUtf8());