Commit 1083bc23 authored by Laurent Montel's avatar Laurent Montel 😁

Implement method

parent ab837aa1
......@@ -38,7 +38,7 @@ void InsertTemplateCommandPluginEditorInterface::createAction(KActionCollection
TemplateParser::TemplatesInsertCommandAction *action = new TemplateParser::TemplatesInsertCommandAction(this);
action->setText(i18n("Insert Template Command..."));
ac->addAction(QStringLiteral("insert_template_command"), action);
connect(action, &QAction::triggered, this, &InsertTemplateCommandPluginEditorInterface::slotActivated);
connect(action, &TemplateParser::TemplatesInsertCommandAction::insertCommand, this, &InsertTemplateCommandPluginEditorInterface::slotInsertCommand);
MessageComposer::ActionType type(action, MessageComposer::ActionType::ToolBar);
setActionType(type);
}
......@@ -50,4 +50,20 @@ void InsertTemplateCommandPluginEditorInterface::slotActivated()
void InsertTemplateCommandPluginEditorInterface::exec()
{
if (!mCommand.isEmpty()) {
QTextCursor cursor = richTextEditor()->textCursor();
cursor.insertText(mCommand);
cursor.setPosition(cursor.position() + mAdjustCursor);
richTextEditor()->setTextCursor(cursor);
richTextEditor()->setFocus();
}
}
void InsertTemplateCommandPluginEditorInterface::slotInsertCommand(const QString &cmd, int adjustCursor)
{
if (!cmd.isEmpty()) {
mCommand = cmd;
mAdjustCursor = adjustCursor;
slotActivated();
}
}
......@@ -33,7 +33,10 @@ public:
void exec() override;
private:
void slotInsertCommand(const QString &cmd, int adjustCursor);
void slotActivated();
QString mCommand;
int mAdjustCursor = 0;
};
#endif
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