Commit 7e5369f0 authored by Victor Yacovlev's avatar Victor Yacovlev

Robot-specific editor macros

parent e3d2d002
<?xml version='1.0' encoding='UTF-8'?>
<macros>
<macro title="использовать Робот" key="1">
<command name="InsertImport" text="Робот" />
</macro>
<macro title="вверх" key="Up">
<command name="InsertText" text="вверх\n" />
</macro>
......@@ -15,4 +18,5 @@
<macro title="закрасить" key="Space">
<command name="InsertText" text="закрасить\n" />
</macro>
</macros>
......@@ -278,19 +278,22 @@ void EditorInstance::loadMacros()
systemMacros_ = loadFromFile(systemMacrosPath);
// Actor-specific macros
if (analizerName == "kum") {
const QList<const KPlugin*> actorPlugins =
PluginManager::instance()->loadedConstPlugins("Actor*");
foreach (const KPlugin* plugin, actorPlugins) {
ActorInterface * actor = qobject_cast<ActorInterface*>(plugin);
const QString canonicalName = actorCanonicalName<QString>(actor->asciiModuleName());
const QString actorMacrosFileName = plugin_->myResourcesDir().absoluteFilePath(
"editor/macros-" + plugin->pluginSpec().name + ".xml");
"macros-" + analizerName + "-" + canonicalName + ".xml"
);
if (QFile::exists(actorMacrosFileName)) {
systemMacros_.push_back(Macro());
systemMacros_ += loadFromFile(actorMacrosFileName);
}
}
}
// Import macros
if (analizerName == "kum") {
......@@ -306,20 +309,20 @@ void EditorInstance::loadMacros()
}
}
if (!availableActorNames.empty()) {
systemMacros_.push_back(Macro());
for (size_t i=0; i<qMin(size_t(9), availableActorNames.size()); i++) {
const QString & actorName = availableActorNames.at(i);
const QString insertText = tr("import %1").arg(actorName);
Macro macro;
macro.title = insertText;
macro.key = QString::number(i+1).at(0);
macro.commands.push_back(
KeyCommand(KeyCommand::InsertImport, actorName)
);
systemMacros_.push_back(macro);
}
}
// if (!availableActorNames.empty()) {
// systemMacros_.push_back(Macro());
// for (size_t i=0; i<qMin(size_t(9), availableActorNames.size()); i++) {
// const QString & actorName = availableActorNames.at(i);
// const QString insertText = tr("import %1").arg(actorName);
// Macro macro;
// macro.title = insertText;
// macro.key = QString::number(i+1).at(0);
// macro.commands.push_back(
// KeyCommand(KeyCommand::InsertImport, actorName)
// );
// systemMacros_.push_back(macro);
// }
// }
}
......
......@@ -32,6 +32,7 @@ static const QString sSelectAll = "SelectAll";
static const QString sCopy = "Copy";
static const QString sInsertText = "InsertText";
static const QString sInsertImport = "InsertImport";
static const QString sBackspace = "Backspace";
static const QString sDelete = "Delete";
static const QString sRemoveLine = "RemoveLine";
......@@ -70,6 +71,7 @@ extern QString dumpKeyCommandType(KeyCommand::Type type)
case KeyCommand::Copy: return sCopy;
case KeyCommand::InsertText: return sInsertText;
case KeyCommand::InsertImport: return sInsertImport;
case KeyCommand::Backspace: return sBackspace;
case KeyCommand::Delete: return sDelete;
case KeyCommand::RemoveLine: return sRemoveLine;
......@@ -110,6 +112,7 @@ KeyCommand::Type loadKeyCommandType(const QString &s)
else if (s.toLower()==sCopy.toLower()) return KeyCommand::Copy;
else if (s.toLower()==sInsertText.toLower()) return KeyCommand::InsertText;
else if (s.toLower()==sInsertImport.toLower()) return KeyCommand::InsertImport;
else if (s.toLower()==sBackspace.toLower()) return KeyCommand::Backspace;
else if (s.toLower()==sDelete.toLower()) return KeyCommand::Delete;
else if (s.toLower()==sRemoveLine.toLower()) return KeyCommand::RemoveLine;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment