Commit 52522795 authored by Alexander Semke's avatar Alexander Semke
Browse files

Added an action to the context menu of markdown entry to enter the edit

mode.
parent cbfa4032
Pipeline #62906 passed with stage
in 24 minutes and 40 seconds
...@@ -34,7 +34,9 @@ extern "C" { ...@@ -34,7 +34,9 @@ extern "C" {
#endif #endif
MarkdownEntry::MarkdownEntry(Worksheet* worksheet) : WorksheetEntry(worksheet), m_textItem(new WorksheetTextItem(this, Qt::TextEditorInteraction)), rendered(false) MarkdownEntry::MarkdownEntry(Worksheet* worksheet) : WorksheetEntry(worksheet),
m_textItem(new WorksheetTextItem(this, Qt::TextEditorInteraction)),
rendered(false)
{ {
m_textItem->enableRichText(false); m_textItem->enableRichText(false);
m_textItem->setOpenExternalLinks(true); m_textItem->setOpenExternalLinks(true);
...@@ -48,7 +50,13 @@ MarkdownEntry::MarkdownEntry(Worksheet* worksheet) : WorksheetEntry(worksheet), ...@@ -48,7 +50,13 @@ MarkdownEntry::MarkdownEntry(Worksheet* worksheet) : WorksheetEntry(worksheet),
void MarkdownEntry::populateMenu(QMenu* menu, QPointF pos) void MarkdownEntry::populateMenu(QMenu* menu, QPointF pos)
{ {
if (!rendered) if (!rendered)
menu->addAction(i18n("Insert Image Attachment"), this, &MarkdownEntry::insertImage); menu->addAction(QIcon::fromTheme(QLatin1String("viewimage")), i18n("Insert Image"), this, &MarkdownEntry::insertImage);
else
{
menu->addAction(QIcon::fromTheme(QLatin1String("edit-entry")), i18n("Enter Edit Mode"), this, &MarkdownEntry::enterEditMode);
menu->addSeparator();
}
if (attachedImages.size() != 0) if (attachedImages.size() != 0)
menu->addAction(i18n("Clear Attachments"), this, &MarkdownEntry::clearAttachments); menu->addAction(i18n("Clear Attachments"), this, &MarkdownEntry::clearAttachments);
WorksheetEntry::populateMenu(menu, pos); WorksheetEntry::populateMenu(menu, pos);
...@@ -764,6 +772,13 @@ void MarkdownEntry::clearAttachments() ...@@ -764,6 +772,13 @@ void MarkdownEntry::clearAttachments()
animateSizeChange(); animateSizeChange();
} }
void MarkdownEntry::enterEditMode()
{
setPlainText(plain);
m_textItem->textCursor().clearSelection();
rendered = false;
}
QString MarkdownEntry::plainText() const QString MarkdownEntry::plainText() const
{ {
return m_textItem->toPlainText(); return m_textItem->toPlainText();
......
...@@ -76,6 +76,7 @@ class MarkdownEntry : public WorksheetEntry ...@@ -76,6 +76,7 @@ class MarkdownEntry : public WorksheetEntry
void handleMathRender(QSharedPointer<MathRenderResult> result); void handleMathRender(QSharedPointer<MathRenderResult> result);
void insertImage(); void insertImage();
void clearAttachments(); void clearAttachments();
void enterEditMode();
protected: protected:
WorksheetTextItem* m_textItem; WorksheetTextItem* m_textItem;
......
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