Commit e7bf4eda authored by Laurent Montel's avatar Laurent Montel 😁

Add more features

parent 67a84bc0
......@@ -32,6 +32,7 @@
#include <QPointer>
#include <QLabel>
#include <QMenu>
#include <QTextCursor>
#include <MessageComposer/TextPart>
MarkdownInterface::MarkdownInterface(QObject *parent)
......@@ -66,6 +67,9 @@ void MarkdownInterface::createAction(KActionCollection *ac)
mPopupMenuAction->setEnabled(false);
mardownMenu->addAction(i18n("Add Title"), this, &MarkdownInterface::addTitle);
mardownMenu->addAction(i18n("Horizontal Rule"), this, &MarkdownInterface::addHorizontalRule);
mardownMenu->addAction(i18n("Change as Bold"), this, &MarkdownInterface::addBold);
mardownMenu->addAction(i18n("Change as Italic"), this, &MarkdownInterface::addItalic);
mardownMenu->addAction(i18n("Add Link"), this, &MarkdownInterface::addLink);
MessageComposer::PluginActionType typePopup(mPopupMenuAction, MessageComposer::PluginActionType::PopupMenu);
addActionType(typePopup);
}
......@@ -75,6 +79,27 @@ void MarkdownInterface::addHorizontalRule()
richTextEditor()->insertPlainText(QStringLiteral("---"));
}
void MarkdownInterface::addBold()
{
const QString selectedText = richTextEditor()->textCursor().selectedText();
if (!selectedText.isEmpty()) {
richTextEditor()->textCursor().insertText(QStringLiteral("**%1**").arg(selectedText));
}
}
void MarkdownInterface::addItalic()
{
const QString selectedText = richTextEditor()->textCursor().selectedText();
if (!selectedText.isEmpty()) {
richTextEditor()->textCursor().insertText(QStringLiteral("_%1_").arg(selectedText));
}
}
void MarkdownInterface::addLink()
{
//TODO
}
void MarkdownInterface::addTitle()
{
......
......@@ -42,7 +42,10 @@ public Q_SLOTS:
void reloadConfig() override;
private:
void addBold();
void addItalic();
void addTitle();
void addLink();
void addHorizontalRule();
void slotActivated(bool checked);
QAction *mAction = 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