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

Added an action to the context menu of the command entry to show the

documentation("help") for the currently active keyword.
parent 0aaff70f
......@@ -349,11 +349,15 @@ void CommandEntry::populateMenu(QMenu* menu, QPointF pos)
menu->addAction(i18n("Hide Results"), this, &CommandEntry::collapseResults);
}
if (!command().simplified().isEmpty())
menu->addAction(QIcon::fromTheme(QLatin1String("help-whatsthis")), i18n("Show Help"), this, &CommandEntry::showHelp);
if (m_isExecutionEnabled)
menu->addAction(i18n("Exclude from Execution"), this, &CommandEntry::excludeFromExecution);
else
menu->addAction(i18n("Add to Execution"), this, &CommandEntry::addToExecution);
menu->addSeparator();
menu->addMenu(m_backgroundColorMenu);
menu->addMenu(m_textColorMenu);
menu->addMenu(m_fontMenu);
......@@ -1553,6 +1557,25 @@ qreal CommandEntry::promptItemWidth()
return m_promptItem->width();
}
/*!
* called when the "Get Help" action is triggered in the context menu.
* requests the worksheet to show the current keyword in the documentation panel.
* the current keyword is either the currenly selected text or the text under
* the cursor if there is no selection.
*/
void CommandEntry::showHelp()
{
QString keyword;
const QTextCursor& cursor = m_commandItem->textCursor();
if (cursor.hasSelection())
keyword = cursor.selectedText();
else
keyword = cursor.block().text();
if (!keyword.simplified().isEmpty())
emit worksheet()->requestDocumentation(keyword);
}
void CommandEntry::excludeFromExecution()
{
m_isExecutionEnabled = false;
......
......@@ -165,6 +165,7 @@ class CommandEntry : public WorksheetEntry
void setMidPrompt();
void setHidePrompt();
void showHelp();
private:
static const double VerticalSpacing;
......
......@@ -427,6 +427,7 @@ void WorksheetEntry::populateMenu(QMenu* menu, QPointF pos)
if (!worksheet()->isRunning() && wantToEvaluate())
menu->addAction(QIcon::fromTheme(QLatin1String("media-playback-start")), i18n("Evaluate Entry"), this, SLOT(evaluate()), 0);
menu->addSeparator();
menu->addAction(QIcon::fromTheme(QLatin1String("edit-delete")), i18n("Remove Entry"), this, SLOT(startRemoving()), 0);
menu->addSeparator();
worksheet()->populateMenu(menu, mapToScene(pos));
......
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