Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Education
Cantor
Commits
e8e56192
Commit
e8e56192
authored
Nov 22, 2020
by
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
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/commandentry.cpp
View file @
e8e56192
...
...
@@ -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
;
...
...
src/commandentry.h
View file @
e8e56192
...
...
@@ -165,6 +165,7 @@ class CommandEntry : public WorksheetEntry
void
setMidPrompt
();
void
setHidePrompt
();
void
showHelp
();
private:
static
const
double
VerticalSpacing
;
...
...
src/worksheetentry.cpp
View file @
e8e56192
...
...
@@ -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
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment