Commit abe867eb authored by Laurent Montel's avatar Laurent Montel 😁

Start to implement load menu when necessary

parent d1fc5796
......@@ -415,7 +415,6 @@ void TemplatesCommandMenu::fillMenuFromActionMap(const QMap< QString, TemplatesC
TemplatesCommandMenu::TemplatesCommandMenu(QObject *parent)
: QObject(parent)
{
fillMenu();
}
TemplatesCommandMenu::~TemplatesCommandMenu()
......@@ -430,11 +429,13 @@ QMenu *TemplatesCommandMenu::menu() const
void TemplatesCommandMenu::fillMenu()
{
QMap< QString, Command > commandMap;
mMenu = new KActionMenu(i18n("Insert Command"), this);
fillSubMenus();
}
void TemplatesCommandMenu::fillSubMenus()
{
QMap< QString, Command > commandMap;
// ******************************************************
KActionMenu *menu = new KActionMenu(i18n("Original Message"), mMenu);
mMenu->addAction(menu);
......
......@@ -107,6 +107,7 @@ public:
};
QMenu *menu() const;
void fillMenu();
Q_SIGNALS:
void insertCommand(TemplatesCommandMenu::Command cmd);
void insertCommand(const QString &cmd, int adjustCursor = 0);
......@@ -118,9 +119,8 @@ protected:
KActionMenu *mMenu = nullptr;
private:
void fillMenu();
void fillMenuFromActionMap(const QMap<QString, TemplatesCommandMenu::Command> &map, KActionMenu *menu);
void fillSubMenus();
};
}
......
......@@ -26,6 +26,7 @@ TemplatesInsertCommandAction::TemplatesInsertCommandAction(QObject *parent)
: QAction(parent)
{
mMenuCommand = new TemplatesCommandMenu(this);
mMenuCommand->fillMenu();
mMenuCommand->setObjectName(QStringLiteral("templatescommandmenu"));
connect(mMenuCommand, QOverload<const QString &, int>::of(&TemplatesCommandMenu::insertCommand), this, &TemplatesInsertCommandAction::insertCommand);
......
......@@ -37,6 +37,7 @@ TemplatesInsertCommandPushButton::TemplatesInsertCommandPushButton(QWidget *pare
mMenuCommand = new TemplatesCommandMenu(this);
mMenuCommand->setObjectName(QStringLiteral("templatescommandmenu"));
mMenuCommand->fillMenu();
connect(mMenuCommand, QOverload<const QString &, int>::of(&TemplatesCommandMenu::insertCommand), this, &TemplatesInsertCommandPushButton::insertCommand);
setMenu(mMenuCommand->menu());
......
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