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
12ed609d
Commit
12ed609d
authored
Jun 19, 2020
by
Shubham .
Browse files
Add QTextBrowser as doc viewing widget, follow coding guidelines
parent
f5f50eb9
Changes
6
Hide whitespace changes
Inline
Side-by-side
CMakeLists.txt
View file @
12ed609d
...
...
@@ -103,6 +103,7 @@ if(NOT WIN32)
endif
(
NOT WIN32
)
add_subdirectory
(
src
)
add_subdirectory
(
icons
)
add_subdirectory
(
documentation
)
set
(
CMAKECONFIG_INSTALL_DIR
"
${
KDE_INSTALL_CMAKEPACKAGEDIR
}
/Cantor"
)
configure_package_config_file
(
...
...
admin/documentation/maxima_compressed_help.qch
deleted
100644 → 0
View file @
f5f50eb9
File deleted
admin/documentation/maxima_help_collection.qhc
deleted
100644 → 0
View file @
f5f50eb9
File deleted
src/panelplugins/documentationpanel/documentationpanelplugin.h
View file @
12ed609d
...
...
@@ -21,8 +21,8 @@
#ifndef _DOCUMENTATIONPANELPLUGIN_H
#define _DOCUMENTATIONPANELPLUGIN_H
#include "panelplugin.h"
#include "documentationpanelwidget.h"
#include "panelplugin.h"
class
DocumentationPanelWidget
;
...
...
src/panelplugins/documentationpanel/documentationpanelwidget.cpp
View file @
12ed609d
...
...
@@ -38,7 +38,6 @@
#include <QTabWidget>
#include <QTextBrowser>
#include <QUrl>
#include <QVBoxLayout>
DocumentationPanelWidget
::
DocumentationPanelWidget
(
Cantor
::
Session
*
session
,
QWidget
*
parent
)
:
QWidget
(
parent
),
m_engine
(
nullptr
),
m_path
(
QString
())
{
...
...
@@ -60,15 +59,14 @@ void DocumentationPanelWidget::setSession(Cantor::Session* session)
void
DocumentationPanelWidget
::
addWidgets
()
{
//QPointer<QSplitter> m_splitter;
m_engine
=
new
QHelpEngine
(
QLatin1String
(
"documentation/maxima/maxima_help_collection.qhc"
),
this
);
//m_engine = new QHelpEngine(QApplication::applicationDirPath() + QLatin1String("/documentation/maxima_help_collection.qhc"), this);
m_engine
=
new
QHelpEngine
(
QApplication
::
applicationDirPath
()
+
QLatin1String
(
"admin/documentation/maxima_help_collection.qhc"
),
this
);
if
(
!
m_engine
->
setupData
()
)
{
if
(
!
m_engine
->
setupData
()
)
{
qWarning
()
<<
"Couldn't setup QtHelp Collection file"
;
}
QByteArray
helpData
=
m_engine
->
fileData
(
QUrl
(
QLatin1String
(
"qthelp://org.kde.cantor/doc/maxima_7.html#SEC36"
)));
//
QByteArray helpData = m_engine->fileData(QUrl(QLatin1String("qthelp://org.kde.cantor/doc/maxima_7.html#SEC36")));
QPointer
<
QTabWidget
>
m_tabWidget
=
new
QTabWidget
(
this
);
m_tabWidget
->
setMaximumWidth
(
1000
);
...
...
@@ -80,7 +78,10 @@ void DocumentationPanelWidget::addWidgets()
QPointer
<
QTextBrowser
>
m_textBrowser
=
new
QTextBrowser
(
this
);
m_textBrowser
->
setSource
(
QUrl
(
QLatin1String
(
"qthelp://org.kde.cantor/doc/maxima_7.html#SEC36"
)),
QTextDocument
::
HtmlResource
);
m_textBrowser
->
setSource
(
QUrl
(
QLatin1String
(
"qthelp://org.kde.cantor/doc/maxima.html#SEC_Top"
)),
QTextDocument
::
HtmlResource
);
connect
(
m_engine
->
contentWidget
(),
SIGNAL
(
linkActivated
(
QUrl
)),
m_textBrowser
,
SLOT
(
setSource
(
QUrl
)));
connect
(
m_engine
->
indexWidget
(),
SIGNAL
(
linkActivated
(
QUrl
,
QString
)),
m_textBrowser
,
SLOT
(
setSource
(
QUrl
)));
QVBoxLayout
*
layout
=
new
QVBoxLayout
(
this
);
layout
->
addWidget
(
m_tabWidget
,
1
);
...
...
@@ -91,19 +92,24 @@ void DocumentationPanelWidget::addWidgets()
void
DocumentationPanelWidget
::
loadDocumentation
()
{
if
(
m_path
.
isEmpty
())
{
if
(
m_path
.
isEmpty
())
{
return
;
}
}
const
QStringList
files
=
qchFiles
();
if
(
files
.
isEmpty
())
{
if
(
files
.
isEmpty
())
{
qWarning
()
<<
"Could not find QCH file in directory"
<<
m_path
;
return
;
}
for
(
const
QString
&
fileName
:
files
)
{
for
(
const
QString
&
fileName
:
files
)
{
QString
fileNamespace
=
QHelpEngineCore
::
namespaceName
(
fileName
);
if
(
!
fileNamespace
.
isEmpty
()
&&
!
m_engine
->
registeredDocumentations
().
contains
(
fileNamespace
))
{
if
(
!
fileNamespace
.
isEmpty
()
&&
!
m_engine
->
registeredDocumentations
().
contains
(
fileNamespace
))
{
qDebug
()
<<
"Loading doc"
<<
fileName
<<
fileNamespace
;
if
(
!
m_engine
->
registerDocumentation
(
fileName
))
qCritical
()
<<
"Error >> "
<<
fileName
<<
m_engine
->
error
();
...
...
@@ -116,24 +122,33 @@ QStringList DocumentationPanelWidget::qchFiles() const
{
QStringList
files
;
const
QVector
<
QString
>
paths
{
// test directories
const
QVector
<
QString
>
paths
{
// test directories
m_path
,
m_path
+
QLatin1String
(
"/qch/"
),
};
for
(
const
auto
&
path
:
paths
)
{
for
(
const
auto
&
path
:
paths
)
{
QDir
d
(
path
);
if
(
path
.
isEmpty
()
||
!
d
.
exists
())
{
if
(
path
.
isEmpty
()
||
!
d
.
exists
())
{
continue
;
}
const
auto
fileInfos
=
d
.
entryInfoList
(
QDir
::
Files
);
for
(
const
auto
&
file
:
fileInfos
)
{
for
(
const
auto
&
file
:
fileInfos
)
{
files
<<
file
.
absoluteFilePath
();
}
}
if
(
files
.
isEmpty
())
{
if
(
files
.
isEmpty
())
{
qDebug
()
<<
"No QCH file found at all"
;
}
return
files
;
}
...
...
@@ -144,6 +159,5 @@ QIcon DocumentationPanelWidget::icon() const
QString
DocumentationPanelWidget
::
name
()
const
{
// return the help name of the backend
return
QString
(
m_session
->
backend
()
->
name
());
}
src/panelplugins/documentationpanel/documentationpanelwidget.h
View file @
12ed609d
...
...
@@ -40,10 +40,15 @@ class DocumentationPanelWidget : public QWidget
void
setSession
(
Cantor
::
Session
*
session
);
void
addWidgets
();
/** @return icon of the current backend **/
QIcon
icon
()
const
;
/** @return name of the current backend **/
QString
name
()
const
;
void
loadDocumentation
();
/** @return local paths to all QCH files found in cantor/admin/documentation directory **/
QStringList
qchFiles
()
const
;
private:
...
...
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