File indexing completed on 2025-05-04 04:51:07

0001 /*
0002    SPDX-FileCopyrightText: 2016-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include <MessageViewer/ViewerPluginInterface>
0010 class KActionCollection;
0011 class QActionGroup;
0012 namespace MessageViewer
0013 {
0014 class ViewerPluginExternalscriptInterface : public ViewerPluginInterface
0015 {
0016     Q_OBJECT
0017 public:
0018     explicit ViewerPluginExternalscriptInterface(KActionCollection *ac, QWidget *parent = nullptr);
0019     ~ViewerPluginExternalscriptInterface() override;
0020 
0021     [[nodiscard]] QList<QAction *> actions() const override;
0022     [[nodiscard]] ViewerPluginInterface::SpecificFeatureTypes featureTypes() const override;
0023     void execute() override;
0024 
0025     void setText(const QString &text) override;
0026     void setMessage(const KMime::Message::Ptr &msg) override;
0027     void refreshActionList(KActionCollection *ac) override;
0028     void setMessageItem(const Akonadi::Item &item) override;
0029 private Q_SLOTS:
0030     void slotScriptActivated(QAction *act);
0031 
0032 Q_SIGNALS:
0033     void configChanged();
0034 
0035 private:
0036     void createAction(KActionCollection *ac);
0037     void clear();
0038     void slotConfigure();
0039     QList<QAction *> mAction;
0040     [[nodiscard]] QStringList adaptArguments(const QStringList &scriptArguments);
0041     QStringList mCurrentInfo;
0042     QString mText;
0043     QString mAkonadiUrl;
0044     KMime::Message::Ptr mMessage;
0045     QActionGroup *mActionGroup = nullptr;
0046 };
0047 }