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
f341d993
Commit
f341d993
authored
Jun 27, 2020
by
Shubham .
Browse files
[WIP] Add code for context sensitive help for keywords
parent
974efa9a
Changes
8
Hide whitespace changes
Inline
Side-by-side
src/panelplugins/CMakeLists.txt
View file @
f341d993
...
...
@@ -6,7 +6,8 @@ function(add_panel name)
INSTALL_NAMESPACE
"cantor/panels"
)
target_link_libraries
(
"cantor_
${
name
}
"
cantorlibs
)
cantorpart
cantorlibs
)
endfunction
()
...
...
src/panelplugins/documentationpanel/CMakeLists.txt
View file @
f341d993
set
(
DocumentationPanelPlugin_SRCS
../../worksheet.cpp
../../worksheettextitem.cpp
documentationpanelplugin.cpp
documentationpanelwidget.cpp
)
...
...
@@ -6,10 +8,13 @@ set( DocumentationPanelPlugin_SRCS
add_panel
(
documentationpanelplugin
${
DocumentationPanelPlugin_SRCS
}
)
target_link_libraries
(
cantor_documentationpanelplugin
cantorpart
cantorlibs
Qt5::Widgets
Qt5::Help
Qt5::Gui
Qt5::Core
Qt5::WebKitWidgets
Qt5::WebEngine
Qt5::WebEngineWidgets
)
Qt5::WebEngineWidgets
Qt5::Xml
)
src/panelplugins/documentationpanel/documentationpanelwidget.cpp
View file @
f341d993
...
...
@@ -20,14 +20,14 @@
#include "cantor_macros.h"
#include "documentationpanelplugin.h"
#include "session.h"
#include "../../worksheet.h"
#include "../../worksheettextitem.h"
#include <KLocalizedString>
#include <QApplication>
#include <QByteArray>
#include <QDebug>
#include <QDir>
#include <QHBoxLayout>
#include <QHelpContentWidget>
#include <QHelpEngine>
...
...
@@ -59,6 +59,8 @@ DocumentationPanelWidget::DocumentationPanelWidget(QWidget* parent) :QWidget(par
delete
m_splitter
;
}
loadDocumentation
();
m_tabWidget
=
new
QTabWidget
(
this
);
m_tabWidget
->
setMovable
(
true
);
m_tabWidget
->
setElideMode
(
Qt
::
ElideRight
);
...
...
@@ -83,9 +85,13 @@ DocumentationPanelWidget::DocumentationPanelWidget(QWidget* parent) :QWidget(par
m_textBrowser
->
setContent
(
contents
,
QLatin1String
(
"text/html;charset=UTF-8"
));
m_textBrowser
->
show
();
connect
(
m_engine
->
contentWidget
(),
SIGNAL
(
linkActivated
(
QUrl
)),
this
,
SLOT
(
displayHelp
(
QUrl
)));
connect
(
m_engine
->
indexWidget
(),
SIGNAL
(
linkActivated
(
QUrl
,
QString
)),
this
,
SLOT
(
displayHelp
(
QUrl
)));
connect
(
search
,
SIGNAL
(
clicked
(
bool
)),
this
,
SLOT
(
doSearch
(
QString
)));
connect
(
m_engine
->
contentWidget
(),
&
QHelpContentWidget
::
linkActivated
,
this
,
&
DocumentationPanelWidget
::
displayHelp
);
connect
(
m_engine
->
indexWidget
(),
&
QHelpIndexWidget
::
linkActivated
,
this
,
&
DocumentationPanelWidget
::
displayHelp
);
Worksheet
*
worksheet
=
new
Worksheet
(
Cantor
::
Backend
::
getBackend
(
QLatin1String
(
"maxima"
)),
parent
);
WorksheetTextItem
*
textItem
=
worksheet
->
currentTextItem
();
connect
(
textItem
,
&
WorksheetTextItem
::
requestDocumentation
,
this
,
&
DocumentationPanelWidget
::
contextSensitiveHelp
);
//connect(search, SIGNAL(clicked(bool)), this, SLOT(doSearch(QString)));
m_splitter
=
new
QSplitter
(
Qt
::
Horizontal
,
this
);
m_splitter
->
addWidget
(
m_tabWidget
);
...
...
@@ -93,8 +99,6 @@ DocumentationPanelWidget::DocumentationPanelWidget(QWidget* parent) :QWidget(par
QHBoxLayout
*
layout
=
new
QHBoxLayout
(
this
);
layout
->
addWidget
(
m_splitter
);
loadDocumentation
();
}
void
DocumentationPanelWidget
::
displayHelp
(
const
QUrl
&
url
)
...
...
@@ -109,6 +113,11 @@ void DocumentationPanelWidget::doSearch(const QString& str)
// perform searching of the string passed
}
void
DocumentationPanelWidget
::
contextSensitiveHelp
(
const
QString
&
keyword
)
{
}
void
DocumentationPanelWidget
::
loadDocumentation
()
{
//1. Get the backend name
...
...
src/panelplugins/documentationpanel/documentationpanelwidget.h
View file @
f341d993
...
...
@@ -50,12 +50,15 @@ class DocumentationPanelWidget : public QWidget
private
Q_SLOTS
:
void
displayHelp
(
const
QUrl
&
);
void
doSearch
(
const
QString
&
);
void
contextSensitiveHelp
(
const
QString
&
);
private:
QPointer
<
QHelpEngine
>
m_engine
;
QPointer
<
QWebEngineView
>
m_textBrowser
;
QPointer
<
QTabWidget
>
m_tabWidget
;
QPointer
<
QSplitter
>
m_splitter
;
// later add member variable for path to help files
};
#endif
/* _DOCUMENTATIONPANELWIDGET_H */
src/panelplugins/helppanel/helppanelplugin.cpp
View file @
f341d993
...
...
@@ -73,7 +73,5 @@ bool HelpPanelPlugin::showOnStartup()
return
false
;
}
K_PLUGIN_FACTORY_WITH_JSON
(
helppanelplugin
,
"helppanelplugin.json"
,
registerPlugin
<
HelpPanelPlugin
>
();)
#include "helppanelplugin.moc"
src/panelplugins/helppanel/helppanelplugin.h
View file @
f341d993
...
...
@@ -30,7 +30,7 @@ class HelpPanelPlugin : public Cantor::PanelPlugin
{
Q_OBJECT
public:
HelpPanelPlugin
(
QObject
*
parent
,
QList
<
QVariant
>
args
);
HelpPanelPlugin
(
QObject
*
parent
,
QList
<
QVariant
>
args
);
~
HelpPanelPlugin
()
override
;
QWidget
*
widget
()
override
;
...
...
src/worksheettextitem.cpp
View file @
f341d993
...
...
@@ -471,9 +471,30 @@ void WorksheetTextItem::keyPressEvent(QKeyEvent *event)
case
Qt
::
Key_Tab
:
qDebug
()
<<
"Tab"
;
break
;
case
Qt
::
Key_H
:
// logic to display help for keyword under selection
if
(
textCursor
().
hasSelection
())
{
QString
keyword
=
textCursor
().
selectedText
();
// remove extra whitespaces from the selection
keyword
=
keyword
.
simplified
();
keyword
.
replace
(
QStringLiteral
(
" "
),
QStringLiteral
(
""
));
emit
requestDocumentation
(
keyword
);
qDebug
()
<<
"Searching help for "
<<
keyword
;
return
;
}
else
{
// when the keyword is not under selection and the user presses key
QTextCursor
cursor
;
cursor
.
select
(
QTextCursor
::
WordUnderCursor
);
setTextCursor
(
cursor
);
const
QString
keyword
=
textCursor
().
selectedText
();
emit
requestDocumentation
(
keyword
);
qDebug
()
<<
"Searching help for "
<<
keyword
;
return
;
}
break
;
default:
break
;
}
int
p
=
textCursor
().
position
();
bool
b
=
textCursor
().
hasSelection
();
QGraphicsTextItem
::
keyPressEvent
(
event
);
...
...
src/worksheettextitem.h
View file @
f341d993
...
...
@@ -128,6 +128,7 @@ class WorksheetTextItem : public QGraphicsTextItem
void
cutAvailable
(
bool
);
void
copyAvailable
(
bool
);
void
pasteAvailable
(
bool
);
void
requestDocumentation
(
const
QString
&
);
public
Q_SLOTS
:
void
insertTab
();
...
...
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