diff --git a/kmail/editorconvertertextplugins/markdown/markdownconfigurewidget.cpp b/kmail/editorconvertertextplugins/markdown/markdownconfigurewidget.cpp index 0b72ae82..3e288dcb 100644 --- a/kmail/editorconvertertextplugins/markdown/markdownconfigurewidget.cpp +++ b/kmail/editorconvertertextplugins/markdown/markdownconfigurewidget.cpp @@ -1,67 +1,67 @@ /* Copyright (C) 2018-2019 Montel Laurent This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "markdownconfigurewidget.h" #include #include #include #include #include #include MarkdownConfigureWidget::MarkdownConfigureWidget(QWidget *parent) : MessageComposer::PluginEditorConvertTextConfigureWidget(parent) { QVBoxLayout *mainLayout = new QVBoxLayout(this); mainLayout->setObjectName(QStringLiteral("mainlayout")); mainLayout->setContentsMargins(0, 0, 0, 0); mLatexSupport = new QCheckBox(i18n("Enable embedded LaTeX"), this); mLatexSupport->setObjectName(QStringLiteral("latex")); mainLayout->addWidget(mLatexSupport); mExtraDefinitionLists = new QCheckBox(i18n("Enable PHP Markdown Extra definition lists"), this); mExtraDefinitionLists->setObjectName(QStringLiteral("extradefinitionlists")); mainLayout->addWidget(mExtraDefinitionLists); mainLayout->addStretch(1); } MarkdownConfigureWidget::~MarkdownConfigureWidget() { } void MarkdownConfigureWidget::loadSettings() { - KConfigGroup grp(KSharedConfig::openConfig(), "Mardown"); + KConfigGroup grp(KSharedConfig::openConfig(), "Markdown"); mLatexSupport->setChecked(grp.readEntry("Enable Embedded Latex", false)); mExtraDefinitionLists->setChecked(grp.readEntry("Enable Extra Definition Lists", false)); } void MarkdownConfigureWidget::saveSettings() { - KConfigGroup grp(KSharedConfig::openConfig(), "Mardown"); + KConfigGroup grp(KSharedConfig::openConfig(), "Markdown"); grp.writeEntry("Enable Embedded Latex", mLatexSupport->isChecked()); grp.writeEntry("Enable Extra Definition Lists", mExtraDefinitionLists->isChecked()); } void MarkdownConfigureWidget::resetSettings() { mLatexSupport->setChecked(false); mExtraDefinitionLists->setChecked(false); } diff --git a/kmail/editorconvertertextplugins/markdown/markdowninterface.cpp b/kmail/editorconvertertextplugins/markdown/markdowninterface.cpp index 1291e1b1..fc295758 100644 --- a/kmail/editorconvertertextplugins/markdown/markdowninterface.cpp +++ b/kmail/editorconvertertextplugins/markdown/markdowninterface.cpp @@ -1,219 +1,219 @@ /* Copyright (C) 2018-2019 Montel Laurent This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "markdowninterface.h" #include "markdownpreviewdialog.h" #include "markdownplugin_debug.h" #include "markdownconverter.h" #include "markdowncreatelinkdialog.h" #include "markdowncreateimagedialog.h" #include #include #include #include #include #include #include #include #include #include #include #include MarkdownInterface::MarkdownInterface(QObject *parent) : MessageComposer::PluginEditorConvertTextInterface(parent) { } MarkdownInterface::~MarkdownInterface() { } void MarkdownInterface::createAction(KActionCollection *ac) { mAction = new QAction(i18n("Generate HTML from markdown language."), this); mAction->setCheckable(true); mAction->setChecked(false); ac->addAction(QStringLiteral("generate_markdown"), mAction); connect(mAction, &QAction::triggered, this, &MarkdownInterface::slotActivated); MessageComposer::PluginActionType type(mAction, MessageComposer::PluginActionType::Edit); addActionType(type); mStatusBarLabel = new QLabel; QFont f = mStatusBarLabel->font(); f.setBold(true); mStatusBarLabel->setFont(f); setStatusBarWidget(mStatusBarLabel); mPopupMenuAction = new QAction(i18n("Markdown Action"), this); QMenu *mardownMenu = new QMenu; mPopupMenuAction->setMenu(mardownMenu); 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("Change as Code"), this, &MarkdownInterface::addCode); mardownMenu->addAction(i18n("Add Link"), this, &MarkdownInterface::addLink); mardownMenu->addAction(i18n("Add Image"), this, &MarkdownInterface::addImage); MessageComposer::PluginActionType typePopup(mPopupMenuAction, MessageComposer::PluginActionType::PopupMenu); addActionType(typePopup); } 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)); } else { qCWarning(KMAIL_EDITOR_MARKDOWN_PLUGIN_LOG) << "Any text selected"; } } void MarkdownInterface::addCode() { const QString selectedText = richTextEditor()->textCursor().selectedText(); if (!selectedText.isEmpty()) { richTextEditor()->textCursor().insertText(QStringLiteral("`%1`").arg(selectedText)); } else { qCWarning(KMAIL_EDITOR_MARKDOWN_PLUGIN_LOG) << "Any text selected"; } } void MarkdownInterface::addItalic() { const QString selectedText = richTextEditor()->textCursor().selectedText(); if (!selectedText.isEmpty()) { richTextEditor()->textCursor().insertText(QStringLiteral("_%1_").arg(selectedText)); } else { qCWarning(KMAIL_EDITOR_MARKDOWN_PLUGIN_LOG) << "Any text selected"; } } void MarkdownInterface::addLink() { QPointer dlg = new MarkdownCreateLinkDialog(parentWidget()); if (dlg->exec()) { const QString str = dlg->linkStr(); if (!str.isEmpty()) { richTextEditor()->textCursor().insertText(str); } } delete dlg; } void MarkdownInterface::addImage() { QPointer dlg = new MarkdownCreateImageDialog(parentWidget()); if (dlg->exec()) { const QString str = dlg->linkStr(); if (!str.isEmpty()) { richTextEditor()->textCursor().insertText(str); } } delete dlg; } void MarkdownInterface::addTitle() { const QString selectedText = richTextEditor()->textCursor().selectedText(); if (!selectedText.isEmpty()) { richTextEditor()->textCursor().insertText(QStringLiteral("#%1#").arg(selectedText)); } else { qCWarning(KMAIL_EDITOR_MARKDOWN_PLUGIN_LOG) << "Any text selected"; } } bool MarkdownInterface::reformatText() { return false; } MessageComposer::PluginEditorConvertTextInterface::ConvertTextStatus MarkdownInterface::convertTextToFormat(MessageComposer::TextPart *textPart) { //It can't work on html email if (richTextEditor()->composerControler()->isFormattingUsed()) { qCWarning(KMAIL_EDITOR_MARKDOWN_PLUGIN_LOG) << "We can't convert html email"; return MessageComposer::PluginEditorConvertTextInterface::ConvertTextStatus::NotConverted; } if (mAction->isChecked()) { const QString str = richTextEditor()->composerControler()->toCleanPlainText(); if (!str.isEmpty()) { MarkdownConverter converter; converter.setEnableEmbeddedLabel(mEnableEmbeddedLabel); converter.setEnableExtraDefinitionLists(mEnableExtraDefinitionLists); const QString result = converter.convertTextToMarkdown(str); if (!result.isEmpty()) { textPart->setCleanPlainText(str); textPart->setWrappedPlainText(richTextEditor()->composerControler()->toWrappedPlainText()); textPart->setCleanHtml(result); return MessageComposer::PluginEditorConvertTextInterface::ConvertTextStatus::Converted; } else { qCWarning(KMAIL_EDITOR_MARKDOWN_PLUGIN_LOG) << "Impossible to convert text"; return MessageComposer::PluginEditorConvertTextInterface::ConvertTextStatus::Error; } } else { qCWarning(KMAIL_EDITOR_MARKDOWN_PLUGIN_LOG) << "empty text! Bug ?"; return MessageComposer::PluginEditorConvertTextInterface::ConvertTextStatus::NotConverted; } } return MessageComposer::PluginEditorConvertTextInterface::ConvertTextStatus::NotConverted; } void MarkdownInterface::enableDisablePluginActions(bool richText) { if (mAction) { mAction->setEnabled(!richText); mPopupMenuAction->setEnabled(!richText && mAction->isChecked()); } } void MarkdownInterface::reloadConfig() { - KConfigGroup grp(KSharedConfig::openConfig(), "Mardown"); + KConfigGroup grp(KSharedConfig::openConfig(), "Markdown"); mEnableEmbeddedLabel = grp.readEntry("Enable Embedded Latex", false); mEnableExtraDefinitionLists = grp.readEntry("Enable Extra Definition Lists", false); } void MarkdownInterface::slotActivated(bool checked) { if (mDialog.isNull()) { mDialog = new MarkdownPreviewDialog(parentWidget()); mDialog->setText(richTextEditor()->toPlainText()); connect(richTextEditor(), &KPIMTextEdit::RichTextEditor::textChanged, this, [this]() { if (mDialog) { mDialog->setText(richTextEditor()->toPlainText()); } }); } if (checked) { mDialog->show(); } else { mDialog->hide(); } mStatusBarLabel->setText(checked ? i18n("Markdown") : QString()); mPopupMenuAction->setEnabled(checked); } diff --git a/kmail/grammarplugins/languagetool/CMakeLists.txt b/kmail/grammarplugins/languagetool/CMakeLists.txt index e9bf2c63..ac9afb47 100644 --- a/kmail/grammarplugins/languagetool/CMakeLists.txt +++ b/kmail/grammarplugins/languagetool/CMakeLists.txt @@ -1,6 +1,7 @@ add_subdirectory(src) add_subdirectory(plugin) if(BUILD_TESTING) add_subdirectory(tests) add_subdirectory(autotests) endif() +add_subdirectory(kconf_update) diff --git a/kmail/grammarplugins/languagetool/kconf_update/languagetool_kmail.upd b/kmail/grammarplugins/languagetool/kconf_update/languagetool_kmail.upd new file mode 100644 index 00000000..b898d363 --- /dev/null +++ b/kmail/grammarplugins/languagetool/kconf_update/languagetool_kmail.upd @@ -0,0 +1,14 @@ +# Fix typo in config + +Id=update_kmail_languagetools +File=kmail2rc +Group=Mardown,Markdown +AllKeys + +Id=update_kontact_languagetools +File=kontactrc +Group=Mardown,Markdown +AllKeys + + +