From 0e9cd54aa08bbb32716d54b2879f17b5ddfa12b1 Mon Sep 17 00:00:00 2001 From: Laurent Montel Date: Tue, 6 Mar 2018 08:55:32 +0100 Subject: [PATCH] Generate list of actions --- ...lugineditorconverttextmanagerinterface.cpp | 52 +++++++++++++++++++ ...lplugineditorconverttextmanagerinterface.h | 10 ++-- 2 files changed, 59 insertions(+), 3 deletions(-) diff --git a/src/editor/plugininterface/kmailplugineditorconverttextmanagerinterface.cpp b/src/editor/plugininterface/kmailplugineditorconverttextmanagerinterface.cpp index 54ec56807..22c17d78a 100644 --- a/src/editor/plugininterface/kmailplugineditorconverttextmanagerinterface.cpp +++ b/src/editor/plugininterface/kmailplugineditorconverttextmanagerinterface.cpp @@ -23,6 +23,7 @@ #include #include #include +#include KMailPluginEditorConvertTextManagerInterface::KMailPluginEditorConvertTextManagerInterface(QObject *parent) : QObject(parent) @@ -89,3 +90,54 @@ void KMailPluginEditorConvertTextManagerInterface::setRichTextEditor(KPIMTextEdi { mRichTextEditor = richTextEditor; } + +QHash > KMailPluginEditorConvertTextManagerInterface::actionsType() +{ + if (mActionHash.isEmpty()) { + for (MessageComposer::PluginEditorConvertTextInterface *interface : qAsConst(mListPluginInterface)) { + const MessageComposer::PluginActionType actionType = interface->actionType(); + MessageComposer::PluginActionType::Type type = actionType.type(); + QList lst = mActionHash.value(type); + if (!lst.isEmpty()) { + QAction *act = new QAction(this); + act->setSeparator(true); + lst << act << actionType.action(); + mActionHash.insert(type, lst); + } else { + mActionHash.insert(type, QList() << actionType.action()); + } + /* + if (interface->plugin()->hasPopupMenuSupport()) { + type = MessageComposer::PluginActionType::PopupMenu; + QList lst = mActionHash.value(type); + if (!lst.isEmpty()) { + QAction *act = new QAction(this); + act->setSeparator(true); + lst << act << actionType.action(); + mActionHash.insert(type, lst); + } else { + mActionHash.insert(type, QList() << actionType.action()); + } + } + if (interface->plugin()->hasToolBarSupport()) { + type = MessageComposer::PluginActionType::ToolBar; + QList lst = mActionHash.value(type); + if (!lst.isEmpty()) { + QAction *act = new QAction(this); + act->setSeparator(true); + lst << act << actionType.action(); + mActionHash.insert(type, lst); + } else { + mActionHash.insert(type, QList() << actionType.action()); + } + } + */ + } + } + return mActionHash; +} + +QList KMailPluginEditorConvertTextManagerInterface::actionsType(MessageComposer::PluginActionType::Type type) +{ + return mActionHash.value(type); +} diff --git a/src/editor/plugininterface/kmailplugineditorconverttextmanagerinterface.h b/src/editor/plugininterface/kmailplugineditorconverttextmanagerinterface.h index b7008b81f..f5e124af3 100644 --- a/src/editor/plugininterface/kmailplugineditorconverttextmanagerinterface.h +++ b/src/editor/plugininterface/kmailplugineditorconverttextmanagerinterface.h @@ -21,10 +21,9 @@ #define KMAILPLUGINEDITORCONVERTTEXTMANAGERINTERFACE_H #include +#include +#include class QWidget; -namespace MessageComposer { -class PluginEditorConvertTextInterface; -} namespace KPIMTextEdit { class RichTextComposer; } @@ -46,9 +45,14 @@ public: KPIMTextEdit::RichTextComposer *richTextEditor() const; void setRichTextEditor(KPIMTextEdit::RichTextComposer *richTextEditor); + QHash > actionsType(); + QList actionsType(MessageComposer::PluginActionType::Type type); + + private: Q_DISABLE_COPY(KMailPluginEditorConvertTextManagerInterface) QList mListPluginInterface; + QHash > mActionHash; KPIMTextEdit::RichTextComposer *mRichTextEditor = nullptr; QWidget *mParentWidget = nullptr; KActionCollection *mActionCollection = nullptr;