File indexing completed on 2025-01-05 04:49:27
0001 /* 0002 SPDX-FileCopyrightText: 2017-2024 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #include "insertemailplugineditorinterface.h" 0008 #include "selectmaildialog.h" 0009 #include <KActionCollection> 0010 #include <KLocalizedString> 0011 #include <QAction> 0012 #include <TextCustomEditor/RichTextEditor> 0013 0014 InsertEmailPluginEditorInterface::InsertEmailPluginEditorInterface(QObject *parent) 0015 : MessageComposer::PluginEditorInterface(parent) 0016 { 0017 } 0018 0019 InsertEmailPluginEditorInterface::~InsertEmailPluginEditorInterface() = default; 0020 0021 void InsertEmailPluginEditorInterface::createAction(KActionCollection *ac) 0022 { 0023 auto action = new QAction(i18n("Insert Email..."), this); 0024 ac->addAction(QStringLiteral("insert_email"), action); 0025 connect(action, &QAction::triggered, this, &InsertEmailPluginEditorInterface::slotActivated); 0026 MessageComposer::PluginActionType type(action, MessageComposer::PluginActionType::Insert); 0027 setActionType(type); 0028 } 0029 0030 void InsertEmailPluginEditorInterface::slotActivated() 0031 { 0032 Q_EMIT emitPluginActivated(this); 0033 } 0034 0035 void InsertEmailPluginEditorInterface::exec() 0036 { 0037 if (!mSelectMailDialog) { 0038 mSelectMailDialog = new SelectMailDialog(parentWidget()); 0039 connect(mSelectMailDialog.data(), &SelectMailDialog::emailSelected, this, &InsertEmailPluginEditorInterface::slotEmailSelected); 0040 } 0041 mSelectMailDialog->show(); 0042 } 0043 0044 void InsertEmailPluginEditorInterface::slotEmailSelected(const QStringList &lst) 0045 { 0046 Q_EMIT insertText(lst.join(QLatin1Char(' '))); 0047 } 0048 0049 #include "moc_insertemailplugineditorinterface.cpp"