File indexing completed on 2025-02-16 04:49:26

0001 /*
0002    SPDX-FileCopyrightText: 2018-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include <MessageComposer/PluginEditorConvertTextInterface>
0010 class QObject;
0011 #include <QPointer>
0012 
0013 namespace MessageComposer
0014 {
0015 class StatusBarLabelToggledState;
0016 }
0017 
0018 class KActionCollection;
0019 class MarkdownPreviewDialog;
0020 class MarkdownInterface : public MessageComposer::PluginEditorConvertTextInterface
0021 {
0022     Q_OBJECT
0023 public:
0024     explicit MarkdownInterface(QObject *parent = nullptr);
0025     ~MarkdownInterface() override;
0026     void createAction(KActionCollection *ac) override;
0027 
0028     [[nodiscard]] bool reformatText() override;
0029     [[nodiscard]] MessageComposer::PluginEditorConvertTextInterface::ConvertTextStatus convertTextToFormat(MessageComposer::TextPart *textPart) override;
0030     void enableDisablePluginActions(bool richText) override;
0031 
0032 public Q_SLOTS:
0033     void reloadConfig() override;
0034 
0035 private:
0036     void addEmbeddedImages(MessageComposer::TextPart *textPart, QString &textVersion, QString &htmlVersion) const;
0037     void addBold();
0038     void addItalic();
0039     void addTitle(int i);
0040     void addLink();
0041     void addImage();
0042     void addHorizontalRule();
0043     void slotActivated(bool checked);
0044     void slotSelectionChanged();
0045     void addCode();
0046     void addBlockQuote();
0047     QAction *mAction = nullptr;
0048     QAction *mBoldAction = nullptr;
0049     QAction *mItalicAction = nullptr;
0050     QAction *mCodeAction = nullptr;
0051     QAction *mBlockQuoteAction = nullptr;
0052     QAction *mPopupMenuAction = nullptr;
0053     QPointer<MarkdownPreviewDialog> mDialog;
0054     bool mEnableEmbeddedLabel = false;
0055     bool mEnableExtraDefinitionLists = false;
0056     MessageComposer::StatusBarLabelToggledState *mStatusBarLabel = nullptr;
0057 };