Commit d0d53896 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Create own akonadi action

CCBUG: 424184
parent 32a480f7
Pipeline #34345 failed with stage
in 12 minutes and 37 seconds
......@@ -2823,6 +2823,7 @@ void KMMainWidget::setupActions()
KMailPluginInterface::self()->setParentWidget(this);
KMailPluginInterface::self()->createPluginInterface();
mMsgActions = new KMail::MessageActions(actionCollection(), this);
mMsgActions->fillAkonadiStandardAction(mAkonadiStandardActionManager);
mMsgActions->setMessageView(mMsgView);
//----- File Menu
......
......@@ -424,12 +424,31 @@ void KMReaderMainWin::slotConfigChanged()
mMsgActions->setupForwardingActionsList(this);
}
void KMReaderMainWin::initializeAkonadiStandardAction()
{
const auto mailActions = {
Akonadi::StandardMailActionManager::MarkAllMailAsRead,
Akonadi::StandardMailActionManager::MarkMailAsRead,
Akonadi::StandardMailActionManager::MarkMailAsUnread,
Akonadi::StandardMailActionManager::MarkMailAsImportant,
Akonadi::StandardMailActionManager::MarkMailAsActionItem
};
for (Akonadi::StandardMailActionManager::Type mailAction : mailActions) {
mAkonadiStandardActionManager->createAction(mailAction);
}
}
void KMReaderMainWin::setupAccel()
{
if (!kmkernel->xmlGuiInstanceName().isEmpty()) {
setComponentName(kmkernel->xmlGuiInstanceName(), i18n("KMail2"));
}
mMsgActions = new KMail::MessageActions(actionCollection(), this);
mAkonadiStandardActionManager = new Akonadi::StandardMailActionManager(actionCollection(), this);
initializeAkonadiStandardAction();
mMsgActions->fillAkonadiStandardAction(mAkonadiStandardActionManager);
mMsgActions->setMessageView(mReaderWin);
connect(mMsgActions, &KMail::MessageActions::replyActionFinished, this, &KMReaderMainWin::slotReplyOrForwardFinished);
......
......@@ -23,7 +23,9 @@ namespace KMail {
class MessageActions;
class TagActionManager;
}
namespace Akonadi {
class StandardMailActionManager;
}
namespace KMime {
class Message;
class Content;
......@@ -103,6 +105,7 @@ private:
void showPreviousMessage();
void updateButtons();
void slotToggleMenubar(bool dontShowWarning);
void initializeAkonadiStandardAction();
QVector<KMime::Message::Ptr> mListMessage;
int mCurrentMessageIndex = 0;
......@@ -116,6 +119,7 @@ private:
ZoomLabelWidget *mZoomLabelIndicator = nullptr;
KMail::TagActionManager *mTagActionManager = nullptr;
KToggleAction *mHideMenuBarAction = nullptr;
Akonadi::StandardMailActionManager *mAkonadiStandardActionManager = nullptr;
};
#endif /*KMReaderMainWin_h*/
......@@ -101,21 +101,6 @@ MessageActions::MessageActions(KActionCollection *ac, QWidget *parent)
mStatusMenu = new KActionMenu(i18n("Mar&k Message"), this);
ac->addAction(QStringLiteral("set_status"), mStatusMenu);
KMMainWidget *mainwin = kmkernel->getKMMainWidget();
if (mainwin) {
QAction *action = mainwin->akonadiStandardAction(Akonadi::StandardMailActionManager::MarkMailAsRead);
mStatusMenu->addAction(action);
action = mainwin->akonadiStandardAction(Akonadi::StandardMailActionManager::MarkMailAsUnread);
mStatusMenu->addAction(action);
mStatusMenu->addSeparator();
action = mainwin->akonadiStandardAction(Akonadi::StandardMailActionManager::MarkMailAsImportant);
mStatusMenu->addAction(action);
action = mainwin->akonadiStandardAction(Akonadi::StandardMailActionManager::MarkMailAsActionItem);
mStatusMenu->addAction(action);
}
mAnnotateAction = new QAction(QIcon::fromTheme(QStringLiteral("view-pim-notes")), i18n("Add Note..."), this);
ac->addAction(QStringLiteral("annotate"), mAnnotateAction);
......@@ -207,6 +192,22 @@ MessageActions::~MessageActions()
delete mCustomTemplatesMenu;
}
void MessageActions::fillAkonadiStandardAction(Akonadi::StandardMailActionManager *akonadiStandardActionManager)
{
QAction *action = akonadiStandardActionManager->action(Akonadi::StandardMailActionManager::MarkMailAsRead);
mStatusMenu->addAction(action);
action = akonadiStandardActionManager->action(Akonadi::StandardMailActionManager::MarkMailAsUnread);
mStatusMenu->addAction(action);
mStatusMenu->addSeparator();
action = akonadiStandardActionManager->action(Akonadi::StandardMailActionManager::MarkMailAsImportant);
mStatusMenu->addAction(action);
action = akonadiStandardActionManager->action(Akonadi::StandardMailActionManager::MarkMailAsActionItem);
mStatusMenu->addAction(action);
}
TemplateParser::CustomTemplatesMenu *MessageActions::customTemplatesMenu() const
{
return mCustomTemplatesMenu;
......
......@@ -24,6 +24,7 @@ class QMenu;
namespace Akonadi {
class Item;
class StandardMailActionManager;
}
namespace TemplateParser {
......@@ -90,6 +91,7 @@ public:
QAction *exportToPdfAction() const;
void setExportToPdfAction(QAction *exportToPdfAction);
void fillAkonadiStandardAction(Akonadi::StandardMailActionManager *akonadiStandardActionManager);
Q_SIGNALS:
// This signal is emitted when a reply is triggered and the
// action has finished.
......
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