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
ab42ef6d
Commit
ab42ef6d
authored
Jul 13, 2020
by
Shubham .
Browse files
Remove session handling from documentationpanelwidget
parent
cecaf6b2
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/panelplugins/documentationpanel/documentationpanelplugin.cpp
View file @
ab42ef6d
...
...
@@ -21,7 +21,6 @@
#include "documentationpanelplugin.h"
#include "session.h"
#include <QDebug>
#include <QIcon>
DocumentationPanelPlugin
::
DocumentationPanelPlugin
(
QObject
*
parent
,
QList
<
QVariant
>
args
)
:
Cantor
::
PanelPlugin
(
parent
),
m_widget
(
nullptr
)
...
...
@@ -37,14 +36,20 @@ DocumentationPanelPlugin::~DocumentationPanelPlugin()
void
DocumentationPanelPlugin
::
onSessionChanged
()
{
if
(
m_widget
)
m_widget
->
setSession
(
session
());
{
m_widget
->
setBackend
(
m_backendName
);
m_widget
->
setBackendIcon
(
m_backendIcon
);
}
}
QWidget
*
DocumentationPanelPlugin
::
widget
()
{
m_backendName
=
session
()
->
backend
()
->
name
();
m_backendIcon
=
session
()
->
backend
()
->
icon
();
if
(
!
m_widget
)
{
m_widget
=
new
DocumentationPanelWidget
(
session
()
,
parentWidget
());
m_widget
=
new
DocumentationPanelWidget
(
m_backendName
,
m_backendIcon
,
parentWidget
());
connect
(
parent
()
->
parent
(),
SIGNAL
(
requestDocumentation
(
QString
)),
m_widget
,
SLOT
(
contextSensitiveHelp
(
QString
)));
connect
(
parent
()
->
parent
(),
SIGNAL
(
requestDocumentation
(
QString
)),
this
,
SIGNAL
(
visibilityRequested
()));
}
...
...
@@ -59,12 +64,12 @@ bool DocumentationPanelPlugin::showOnStartup()
QIcon
DocumentationPanelPlugin
::
icon
()
const
{
return
QIcon
::
fromTheme
(
m_
widget
->
m_session
->
backend
()
->
i
con
()
);
return
QIcon
::
fromTheme
(
m_backend
I
con
);
}
QString
DocumentationPanelPlugin
::
backendName
()
const
{
return
m_
widget
->
m_session
->
backend
()
->
n
ame
()
;
return
m_backend
N
ame
;
}
K_PLUGIN_FACTORY_WITH_JSON
(
documentationpanelplugin
,
"documentationpanelplugin.json"
,
registerPlugin
<
DocumentationPanelPlugin
>
();)
...
...
src/panelplugins/documentationpanel/documentationpanelplugin.h
View file @
ab42ef6d
...
...
@@ -48,6 +48,8 @@ class DocumentationPanelPlugin : public Cantor::PanelPlugin
private:
QPointer
<
DocumentationPanelWidget
>
m_widget
;
QString
m_backendName
;
QString
m_backendIcon
;
};
#endif
/* _DOCUMENTATIONPANELPLUGIN_H */
src/panelplugins/documentationpanel/documentationpanelwidget.cpp
View file @
ab42ef6d
...
...
@@ -20,7 +20,6 @@
#include "cantor_macros.h"
#include "documentationpanelplugin.h"
#include "session.h"
#include <KLocalizedString>
...
...
@@ -45,9 +44,11 @@
#include <QWebEngineUrlScheme>
#include <QWebEngineView>
DocumentationPanelWidget
::
DocumentationPanelWidget
(
Cantor
::
Session
*
sessi
on
,
QWidget
*
parent
)
:
QWidget
(
parent
)
,
m_backend
(
QString
())
DocumentationPanelWidget
::
DocumentationPanelWidget
(
const
QString
&
backend
,
const
QString
&
backendIc
on
,
QWidget
*
parent
)
:
QWidget
(
parent
)
{
m_backend
=
session
->
backend
()
->
name
();
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
);
...
...
@@ -72,7 +73,7 @@ DocumentationPanelWidget::DocumentationPanelWidget(Cantor::Session* session, QWi
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
(
session
->
backend
()
->
icon
()
),
m_backend
);
documentationSelector
->
addItem
(
QIcon
::
fromTheme
(
m_
icon
),
m_backend
);
// Add a seperator
QFrame
*
seperator
=
new
QFrame
(
this
);
...
...
@@ -231,8 +232,6 @@ DocumentationPanelWidget::DocumentationPanelWidget(Cantor::Session* session, QWi
connect
(
m_matchCase
,
&
QAbstractButton
::
toggled
,
this
,
[
=
]{
m_textBrowser
->
findText
(
QString
());
});
setSession
(
session
);
}
DocumentationPanelWidget
::~
DocumentationPanelWidget
()
...
...
@@ -246,9 +245,14 @@ DocumentationPanelWidget::~DocumentationPanelWidget()
delete
m_matchCase
;
}
void
DocumentationPanelWidget
::
setSession
(
Cantor
::
Session
*
session
)
void
DocumentationPanelWidget
::
setBackend
(
const
QString
&
backend
)
{
m_backend
=
backend
;
}
void
DocumentationPanelWidget
::
setBackendIcon
(
const
QString
&
icon
)
{
m_
session
=
sessi
on
;
m_
icon
=
ic
on
;
}
void
DocumentationPanelWidget
::
displayHelp
(
const
QUrl
&
url
)
...
...
src/panelplugins/documentationpanel/documentationpanelwidget.h
View file @
ab42ef6d
...
...
@@ -27,11 +27,6 @@
#include <QWebEngineUrlSchemeHandler>
#include <QWidget>
namespace
Cantor
{
class
Session
;
}
class
QHelpEngine
;
class
QHelpIndexWidget
;
class
QLineEdit
;
...
...
@@ -45,19 +40,18 @@ class DocumentationPanelWidget : public QWidget
Q_OBJECT
public:
DocumentationPanelWidget
(
Cantor
::
Session
*
sessi
on
,
QWidget
*
parent
);
DocumentationPanelWidget
(
const
QString
&
backend
,
const
QString
&
backendIc
on
,
QWidget
*
parent
);
~
DocumentationPanelWidget
();
void
setSession
(
Cantor
::
Session
*
session
);
void
setBackend
(
const
QString
&
);
void
setBackendIcon
(
const
QString
&
);
/** @return name of the current backend **/
QString
backendName
()
const
;
void
loadDocumentation
();
public:
Cantor
::
Session
*
m_session
=
nullptr
;
Q_SIGNALS:
void
activateBrowser
();
...
...
@@ -76,6 +70,7 @@ class DocumentationPanelWidget : public QWidget
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
...
...
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