Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

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

Move method to messageaction

parent 51748527
......@@ -2675,7 +2675,7 @@ void KMMainWidget::showMessagePopup(const Akonadi::Item &msg, const QUrl &url, c
}
Akonadi::Collection parentCol = msg.parentCollection();
if (parentCol.isValid() && CommonKernel->folderIsTemplates(parentCol)) {
menu.addAction(mNewMessageFromTemplateAction);
menu.addAction(mMsgActions->newMessageFromTemplateAction());
} else {
menu.addAction(mMsgActions->replyMenu());
menu.addAction(mMsgActions->forwardMenu());
......@@ -3044,11 +3044,6 @@ void KMMainWidget::setupActions()
}
mFilterMenu->addAction(mMsgActions->listFilterAction());
mNewMessageFromTemplateAction = new QAction(QIcon::fromTheme(QStringLiteral("document-new")), i18n("New Message From &Template"), this);
actionCollection()->addAction(QStringLiteral("use_template"), mNewMessageFromTemplateAction);
connect(mNewMessageFromTemplateAction, &QAction::triggered, this, &KMMainWidget::slotUseTemplate);
actionCollection()->setDefaultShortcut(mNewMessageFromTemplateAction, QKeySequence(Qt::SHIFT + Qt::Key_N));
//----- "Mark Thread" submenu
mThreadStatusMenu = new KActionMenu(i18n("Mark &Thread"), this);
actionCollection()->addAction(QStringLiteral("thread_status"), mThreadStatusMenu);
......@@ -3724,7 +3719,7 @@ void KMMainWidget::updateMessageActionsDelayed()
mMsgActions->forwardAttachedAction()->setEnabled(mass_actions && !CommonKernel->folderIsTemplates(mCurrentCollection));
mMsgActions->forwardMenu()->setEnabled(mass_actions && !CommonKernel->folderIsTemplates(mCurrentCollection));
mNewMessageFromTemplateAction->setEnabled(single_actions && CommonKernel->folderIsTemplates(mCurrentCollection));
mMsgActions->newMessageFromTemplateAction()->setEnabled(single_actions && CommonKernel->folderIsTemplates(mCurrentCollection));
filterMenu()->setEnabled(single_actions);
mMsgActions->redirectAction()->setEnabled(/*single_actions &&*/ mass_actions && !CommonKernel->folderIsTemplates(mCurrentCollection));
......
......@@ -521,7 +521,6 @@ private:
QAction *mTrashThreadAction = nullptr;
QAction *mDeleteThreadAction = nullptr;
QAction *mSaveAsAction = nullptr;
QAction *mNewMessageFromTemplateAction = nullptr;
QAction *mApplyAllFiltersAction = nullptr;
QAction *mSaveAttachmentsAction = nullptr;
QAction *mOpenAction = nullptr;
......
......@@ -578,7 +578,7 @@ void KMReaderMainWin::showMessagePopup(const Akonadi::Item &msg, const QUrl &url
menu->addAction(mMsgActions->forwardMenu());
menu->addSeparator();
} else if (col.isValid() && CommonKernel->folderIsTemplates(col)) {
//TODO add use newTemplate (sync with kmail mainwidget)
menu->addAction(mMsgActions->newMessageFromTemplateAction());
}
if (col.isValid() && CommonKernel->folderIsSentMailFolder(col)) {
......
......@@ -193,6 +193,11 @@ MessageActions::MessageActions(KActionCollection *ac, QWidget *parent)
ac->addAction(QStringLiteral("send_again"), mSendAgainAction);
connect(mSendAgainAction, &QAction::triggered, this, &MessageActions::slotResendMessage);
mNewMessageFromTemplateAction = new QAction(QIcon::fromTheme(QStringLiteral("document-new")), i18n("New Message From &Template"), this);
ac->addAction(QStringLiteral("use_template"), mNewMessageFromTemplateAction);
connect(mNewMessageFromTemplateAction, &QAction::triggered, this, &MessageActions::slotUseTemplate);
ac->setDefaultShortcut(mNewMessageFromTemplateAction, QKeySequence(Qt::SHIFT + Qt::Key_N));
updateActions();
}
......@@ -207,6 +212,15 @@ TemplateParser::CustomTemplatesMenu *MessageActions::customTemplatesMenu() const
return mCustomTemplatesMenu;
}
void MessageActions::slotUseTemplate()
{
if (!mCurrentItem.isValid()) {
return;
}
KMCommand *command = new KMUseTemplateCommand(mParent, mCurrentItem);
command->start();
}
void MessageActions::setCurrentMessage(const Akonadi::Item &msg, const Akonadi::Item::List &items)
{
mCurrentItem = msg;
......@@ -698,6 +712,11 @@ void MessageActions::slotResendMessage()
command->start();
}
QAction *MessageActions::newMessageFromTemplateAction() const
{
return mNewMessageFromTemplateAction;
}
QAction *MessageActions::sendAgainAction() const
{
return mSendAgainAction;
......
......@@ -95,6 +95,8 @@ public:
QAction *sendAgainAction() const;
QAction *newMessageFromTemplateAction() const;
Q_SIGNALS:
// This signal is emitted when a reply is triggered and the
// action has finished.
......@@ -135,6 +137,7 @@ private Q_SLOTS:
void slotAddFollowupReminder();
void slotResendMessage();
void slotUseTemplate();
private:
QList<QAction *> mMailListActionList;
......@@ -163,6 +166,7 @@ private:
QAction *mAddFollowupReminderAction = nullptr;
QAction *mDebugAkonadiSearchAction = nullptr;
QAction *mSendAgainAction = nullptr;
QAction *mNewMessageFromTemplateAction = nullptr;
KIO::KUriFilterSearchProviderActions *mWebShortcutMenuManager = nullptr;
};
}
......
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