53 QAction *action = actionRegistry->
makeQAction(
id(),
this);
54 actionCollection->
addAction(
id(), action);
59 Q_FOREACH(QAction *action, actions) {
60 if (action->objectName().isEmpty()) {
61 qWarning() <<
"Tool" <<
id() <<
"tries to add an action without a name";
64 QAction *existingAction = actionCollection->
action(action->objectName());
67 action = existingAction;
71 if (action->property(
"tool_action").isValid()) {
72 tools = action->property(
"tool_action").toStringList();
75 action->setProperty(
"tool_action", tools);
76 if (!existingAction) {
77 actionCollection->
addAction(action->objectName(), action);
79 toolActions << action;
84 if (toolActions.size() > 0) {
87 QDomElement e = doc.createElement(
"Actions");
88 e.setAttribute(
"name",
id);
89 e.setAttribute(
"version",
"2");
92 Q_FOREACH (QAction *action, toolActions) {
93 QDomElement a = doc.createElement(
"Action");
94 a.setAttribute(
"name", action->objectName());
97 auto addElement = [&](QString title, QString content) {
98 QDomElement newNode = doc.createElement(title);
99 QDomText newText = doc.createTextNode(content);
100 newNode.appendChild(newText);
101 a.appendChild(newNode);
104 addElement(
"icon", action->icon().name());
105 addElement(
"text", action->text());
106 addElement(
"whatsThis" , action->whatsThis());
107 addElement(
"toolTip" , action->toolTip());
108 addElement(
"iconText" , action->iconText());
109 addElement(
"shortcut" , action->shortcut().toString());
110 addElement(
"isCheckable" , QString((action->isChecked() ?
"true" :
"false")));
111 addElement(
"statusTip", action->statusTip());
114 QFile f(
id()z +
".action");
115 f.open(QFile::WriteOnly);
116 f.write(doc.toString().toUtf8());