Commit 2e2f486f authored by Laurent Montel's avatar Laurent Montel 😁

Fix use menu

parent 1083bc23
......@@ -23,6 +23,7 @@
#include <KLocalizedString>
#include <KActionCollection>
#include <QAction>
#include <QMenu>
InsertTemplateCommandPluginEditorInterface::InsertTemplateCommandPluginEditorInterface(QObject *parent)
: MessageComposer::PluginEditorInterface(parent)
......@@ -35,11 +36,12 @@ InsertTemplateCommandPluginEditorInterface::~InsertTemplateCommandPluginEditorIn
void InsertTemplateCommandPluginEditorInterface::createAction(KActionCollection *ac)
{
TemplateParser::TemplatesInsertCommandAction *action = new TemplateParser::TemplatesInsertCommandAction(this);
action->setText(i18n("Insert Template Command..."));
ac->addAction(QStringLiteral("insert_template_command"), action);
connect(action, &TemplateParser::TemplatesInsertCommandAction::insertCommand, this, &InsertTemplateCommandPluginEditorInterface::slotInsertCommand);
MessageComposer::ActionType type(action, MessageComposer::ActionType::ToolBar);
mCommandAction = new TemplateParser::TemplatesInsertCommandAction(this);
mCommandAction->setText(i18n("Insert Template Command..."));
ac->addAction(QStringLiteral("insert_template_command"), mCommandAction);
connect(mCommandAction, &TemplateParser::TemplatesInsertCommandAction::triggered, this, &InsertTemplateCommandPluginEditorInterface::slotOpenMenu);
connect(mCommandAction, &TemplateParser::TemplatesInsertCommandAction::insertCommand, this, &InsertTemplateCommandPluginEditorInterface::slotInsertCommand);
MessageComposer::ActionType type(mCommandAction, MessageComposer::ActionType::ToolBar);
setActionType(type);
}
......@@ -48,6 +50,11 @@ void InsertTemplateCommandPluginEditorInterface::slotActivated()
Q_EMIT emitPluginActivated(this);
}
void InsertTemplateCommandPluginEditorInterface::slotOpenMenu()
{
mCommandAction->menu()->exec(QCursor::pos());
}
void InsertTemplateCommandPluginEditorInterface::exec()
{
if (!mCommand.isEmpty()) {
......
......@@ -21,7 +21,9 @@
#define INSERTTEMPLATECOMMANDPLUGINEDITORINTERFACE_H
#include <messagecomposer/plugineditorinterface.h>
namespace TemplateParser {
class TemplatesInsertCommandAction;
}
class InsertTemplateCommandPluginEditorInterface : public MessageComposer::PluginEditorInterface
{
Q_OBJECT
......@@ -35,8 +37,10 @@ public:
private:
void slotInsertCommand(const QString &cmd, int adjustCursor);
void slotActivated();
void slotOpenMenu();
QString mCommand;
int mAdjustCursor = 0;
TemplateParser::TemplatesInsertCommandAction *mCommandAction = nullptr;
};
#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