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
b12e534f
Commit
b12e534f
authored
Jul 19, 2020
by
Shubham .
Browse files
Refactor
parent
0e26e356
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/panelplugins/documentationpanel/documentationpanelplugin.cpp
View file @
b12e534f
...
...
@@ -33,20 +33,11 @@ DocumentationPanelPlugin::~DocumentationPanelPlugin()
delete
m_widget
;
}
void
DocumentationPanelPlugin
::
onSessionChan
ge
d
()
QWidget
*
DocumentationPanelPlugin
::
wid
ge
t
()
{
m_backendName
=
session
()
->
backend
()
->
name
();
m_backendIcon
=
session
()
->
backend
()
->
icon
();
if
(
m_widget
)
{
m_widget
->
setBackend
(
m_backendName
);
m_widget
->
setBackendIcon
(
m_backendIcon
);
}
}
QWidget
*
DocumentationPanelPlugin
::
widget
()
{
if
(
!
m_widget
)
{
m_widget
=
new
DocumentationPanelWidget
(
m_backendName
,
m_backendIcon
,
parentWidget
());
...
...
src/panelplugins/documentationpanel/documentationpanelplugin.h
View file @
b12e534f
...
...
@@ -43,9 +43,6 @@ class DocumentationPanelPlugin : public Cantor::PanelPlugin
/** @return name of the current backend **/
QString
backendName
()
const
;
protected:
void
onSessionChanged
()
override
;
private:
QPointer
<
DocumentationPanelWidget
>
m_widget
;
QString
m_backendName
;
...
...
src/panelplugins/documentationpanel/documentationpanelwidget.cpp
View file @
b12e534f
...
...
@@ -27,7 +27,6 @@
#include <QAction>
#include <QCompleter>
#include <QComboBox>
#include <QDebug>
#include <QFrame>
#include <QHBoxLayout>
#include <QHelpContentWidget>
...
...
@@ -51,24 +50,11 @@
DocumentationPanelWidget
::
DocumentationPanelWidget
(
const
QString
&
backend
,
const
QString
&
backendIcon
,
QWidget
*
parent
)
:
QWidget
(
parent
)
{
m_backend
=
backend
;
m_icon
=
backendIcon
;
const
QString
&
fileName
=
QStandardPaths
::
locate
(
QStandardPaths
::
AppDataLocation
,
QLatin1String
(
"documentation/"
)
+
m_backend
+
QLatin1String
(
"/help.qhc"
));
m_engine
=
new
QHelpEngine
(
fileName
,
this
);
m_index
=
m_engine
->
indexWidget
();
if
(
!
m_engine
->
setupData
())
{
qWarning
()
<<
"Couldn't setup QtHelp Engine"
;
qWarning
()
<<
m_engine
->
error
();
}
if
(
m_backend
!=
QLatin1String
(
"Octave"
))
{
m_engine
->
setProperty
(
"_q_readonly"
,
QVariant
::
fromValue
<
bool
>
(
true
));
}
// initialize the Help engine
initHelpEngine
();
// register the Qt help files
loadDocumentation
();
m_textBrowser
=
new
QWebEngineView
(
this
);
...
...
@@ -81,14 +67,15 @@ DocumentationPanelWidget::DocumentationPanelWidget(const QString& backend, const
QWebEngineUrlScheme
qthelp
(
"qthelp"
);
QWebEngineUrlScheme
::
registerScheme
(
qthelp
);
m_textBrowser
->
page
()
->
profile
()
->
installUrlSchemeHandler
(
"qthelp"
,
new
QtHelpSchemeHandler
(
m_engine
));
m_textBrowser
->
page
()
->
action
(
QWebEnginePage
::
ViewSource
)
->
setVisible
(
false
);
m_textBrowser
->
page
()
->
action
(
QWebEnginePage
::
OpenLinkInNewTab
)
->
setVisible
(
false
);
m_textBrowser
->
page
()
->
action
(
QWebEnginePage
::
OpenLinkInNewWindow
)
->
setVisible
(
false
);
m_textBrowser
->
page
()
->
action
(
QWebEnginePage
::
DownloadLinkToDisk
)
->
setVisible
(
false
);
m_textBrowser
->
page
()
->
action
(
QWebEnginePage
::
Reload
)
->
setVisible
(
false
);
qthelpRegistered
=
true
;
}
m_textBrowser
->
page
()
->
action
(
QWebEnginePage
::
ViewSource
)
->
setVisible
(
false
);
m_textBrowser
->
page
()
->
action
(
QWebEnginePage
::
OpenLinkInNewTab
)
->
setVisible
(
false
);
m_textBrowser
->
page
()
->
action
(
QWebEnginePage
::
OpenLinkInNewWindow
)
->
setVisible
(
false
);
m_textBrowser
->
page
()
->
action
(
QWebEnginePage
::
DownloadLinkToDisk
)
->
setVisible
(
false
);
m_textBrowser
->
page
()
->
action
(
QWebEnginePage
::
Reload
)
->
setVisible
(
false
);
// set initial page contents, otherwise page is blank
if
(
m_backend
==
QLatin1String
(
"Maxima"
))
{
...
...
@@ -111,7 +98,7 @@ DocumentationPanelWidget::DocumentationPanelWidget(const QString& backend, const
QComboBox
*
documentationSelector
=
new
QComboBox
(
this
);
// iterate through the available docs for current backend, for example python may have matplotlib, scikitlearn etc
documentationSelector
->
addItem
(
QIcon
::
fromTheme
(
m_i
con
),
m_backend
);
documentationSelector
->
addItem
(
QIcon
::
fromTheme
(
backendI
con
),
m_backend
);
// real time searcher
m_search
=
new
QLineEdit
(
this
);
...
...
@@ -196,7 +183,6 @@ DocumentationPanelWidget::DocumentationPanelWidget(const QString& backend, const
label
->
setText
(
i18n
(
"Find:"
));
m_findText
=
new
QLineEdit
(
this
);
m_findText
->
setPlaceholderText
(
i18nc
(
"@info:placeholder"
,
"Search..."
));
m_findText
->
setClearButtonEnabled
(
true
);
QToolButton
*
next
=
new
QToolButton
(
this
);
...
...
@@ -309,14 +295,23 @@ DocumentationPanelWidget::~DocumentationPanelWidget()
//delete m_index; this crashes
}
void
DocumentationPanelWidget
::
setBackend
(
const
QString
&
backend
)
void
DocumentationPanelWidget
::
initHelpEngine
(
)
{
m_backend
=
backend
;
}
const
QString
&
fileName
=
QStandardPaths
::
locate
(
QStandardPaths
::
AppDataLocation
,
QLatin1String
(
"documentation/"
)
+
m_backend
+
QLatin1String
(
"/help.qhc"
));
void
DocumentationPanelWidget
::
setBackendIcon
(
const
QString
&
icon
)
{
m_icon
=
icon
;
m_engine
=
new
QHelpEngine
(
fileName
,
this
);
m_index
=
m_engine
->
indexWidget
();
if
(
!
m_engine
->
setupData
())
{
qWarning
()
<<
"Couldn't setup QtHelp Engine"
;
qWarning
()
<<
m_engine
->
error
();
}
if
(
m_backend
!=
QLatin1String
(
"Octave"
))
{
m_engine
->
setProperty
(
"_q_readonly"
,
QVariant
::
fromValue
<
bool
>
(
true
));
}
}
void
DocumentationPanelWidget
::
displayHelp
(
const
QUrl
&
url
)
...
...
src/panelplugins/documentationpanel/documentationpanelwidget.h
View file @
b12e534f
...
...
@@ -44,11 +44,6 @@ class DocumentationPanelWidget : public QWidget
DocumentationPanelWidget
(
const
QString
&
backend
,
const
QString
&
backendIcon
,
QWidget
*
parent
);
~
DocumentationPanelWidget
();
void
setBackend
(
const
QString
&
);
void
setBackendIcon
(
const
QString
&
);
void
loadDocumentation
();
Q_SIGNALS:
void
activateBrowser
();
void
zoomFactorChanged
();
...
...
@@ -64,13 +59,16 @@ class DocumentationPanelWidget : public QWidget
void
downloadResource
(
QWebEngineDownloadItem
*
);
// slot for saving the image or html to local disk
private:
void
initHelpEngine
();
void
loadDocumentation
();
private:
QHelpEngine
*
m_engine
=
nullptr
;
QWebEngineView
*
m_textBrowser
=
nullptr
;
QStackedWidget
*
m_displayArea
=
nullptr
;
QHelpIndexWidget
*
m_index
=
nullptr
;
QString
m_backend
;
QString
m_icon
;
// member variables for find in page text widget
QLineEdit
*
m_search
=
nullptr
;
// for searching through keywords
...
...
src/worksheettextitem.cpp
View file @
b12e534f
...
...
@@ -472,8 +472,9 @@ void WorksheetTextItem::keyPressEvent(QKeyEvent *event)
qDebug
()
<<
"Tab"
;
break
;
case
Qt
::
Key_F2
:
if
(
textCursor
().
hasSelection
())
{
const
QString
&
keyword
=
textCursor
().
block
().
t
ext
();
QString
keyword
=
textCursor
().
selectedT
ext
();
emit
worksheet
()
->
requestDocumentation
(
keyword
);
}
break
;
...
...
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