Commit e1171bfa authored by Andreas Cord-Landwehr's avatar Andreas Cord-Landwehr
Browse files

Replace Webkit by QTextBrowser

There is no need to pull-in a fully fledged web browser for just
displaying a few HTML pages. QTextBrowser already manages this, as long
as only a basic set of HTML and CSS is used.
parent 5545712b
......@@ -49,8 +49,6 @@ find_package(Qt5 5.4 REQUIRED NO_MODULE COMPONENTS
Gui
QuickWidgets
Script
WebKit
WebKitWidgets
Widgets
ScriptTools
Svg
......
......@@ -103,8 +103,6 @@ target_link_libraries(rocs
Qt5::Core
Qt5::Quick
Qt5::QuickWidgets
Qt5::WebKit
Qt5::WebKitWidgets
Qt5::XmlPatterns
)
......
......@@ -33,7 +33,7 @@
<li id="{{ property.documentAnchor }}">
<strong>{{ property.name }}</strong> :
{% if property.typeLink %}
<a href="http://virtual/{{ property.typeLink }}">{{ property.type }}</a>
<a href="{{ property.typeLink }}">{{ property.type }}</a>
{% else %}
{{ property.type }}
{% endif %}
......@@ -69,7 +69,7 @@
<tr>
<td><strong>{{ parameter.name }}</strong> :
{% if parameter.typeLink %}
<a href="http://virtual/{{ parameter.typeLink }}">{{ parameter.type }}</a>
<a href="{{ parameter.typeLink }}">{{ parameter.type }}</a>
{% else %}
{{ parameter.type }}
{% endif %}
......@@ -82,7 +82,7 @@
{% endif %}
<p><b>{{ i18nReturnType }}</b> :
{% if method.returnTypeLink %}
<a href="http://virtual/{{ method.returnTypeLink }}">{{ method.returnType }}</a>
<a href="{{ method.returnTypeLink }}">{{ method.returnType }}</a>
{% else %}
{{ method.returnType }}
{% endif %}
......
......@@ -20,7 +20,7 @@
<ul>
{% for component in kernelElements %}
<li>
<a href="http://virtual/{{ component.id }}">{{ component.title }}</a>
<a href="{{ component.id }}">{{ component.title }}</a>
</li>
{% endfor %}
</ul>
......@@ -29,7 +29,7 @@
<ul>
{% for component in kernelModules %}
<li>
<a href="http://virtual/{{ component.id }}">{{ component.title }}</a>
<a href="{{ component.id }}">{{ component.title }}</a>
</li>
{% endfor %}
</ul>
......
......@@ -79,8 +79,8 @@ QString ScriptApiManager::objectApiDocument(const QString &identifier)
}
// get object API object
Object *objectApi = 0;
foreach (Object *obj, m_objectApiList) {
Object *objectApi {nullptr};
for (Object *obj : m_objectApiList) {
if (obj->id() == identifier) {
objectApi = obj;
break;
......
......@@ -22,8 +22,8 @@
#include "scriptapimanager.h"
#include "scriptapimodel.h"
#include <QWebView>
#include <QDebug>
#include <QUrl>
#include <QStandardPaths>
#include <QIcon>
......@@ -55,15 +55,16 @@ ScriptApiWidget::ScriptApiWidget(QWidget* parent)
connect(ui->buttonPrev, &QPushButton::clicked, this, &ScriptApiWidget::historyGoBack);
// listen to all links for ids
connect(ui->docDetails, &QWebView::linkClicked, this, static_cast<void (ScriptApiWidget::*)(const QUrl&)>(&ScriptApiWidget::showObjectApi));
connect(ui->docDetails, &QTextBrowser::anchorClicked, this, static_cast<void (ScriptApiWidget::*)(const QUrl&)>(&ScriptApiWidget::showObjectApi));
// this option has the following idea:
// * handle relative anchor calls directly in the web engine
// * use for switching between object pages the path "http://virtual/<object-id>"
// such that that path is handles as external and progapages to this widget
// drawback: history only works for object pages, not for anchors
ui->docDetails->page()->setLinkDelegationPolicy(QWebPage::DelegateExternalLinks);
ui->docDetails->setOpenExternalLinks(false);
ui->docTree->setModel(m_model);
showHtmlOutline();
}
void ScriptApiWidget::showTreeOutline()
......@@ -78,7 +79,7 @@ void ScriptApiWidget::showHtmlOutline()
void ScriptApiWidget::showHtmlOutline(bool logHistory)
{
ui->docDetails->setHtml(m_manager->apiOverviewDocument(), m_baseUrl);
ui->docDetails->setHtml(m_manager->apiOverviewDocument());
ui->pageStack->setCurrentIndex(1);
if (!logHistory) {
......@@ -112,7 +113,7 @@ void ScriptApiWidget::showDetails(const QModelIndex &index)
void ScriptApiWidget::showObjectApi(const QString &id, bool logHistory=true)
{
QString htmlDocument = m_manager->objectApiDocument(id);
ui->docDetails->setHtml(htmlDocument, m_baseUrl);
ui->docDetails->setHtml(htmlDocument);
ui->pageStack->setCurrentIndex(1);
if (logHistory) {
......@@ -138,17 +139,12 @@ void ScriptApiWidget::showObjectApi(const QUrl &aliasPage)
return;
}
QString path = aliasPage.toString();
int len = path.length() - 1;
while (path.at(len) != '/' && len >= 0) {
--len;
}
if (len <= 0) {
showObjectApi(path);
// distinguish anchors and pages
const QString path = aliasPage.toString();
if (path.startsWith('#')) {
ui->docDetails->scrollToAnchor(path);
} else {
QString id = path.mid(len + 1);
showObjectApi(id);
showObjectApi(path);
}
}
......
......@@ -20,7 +20,7 @@
<item row="3" column="0">
<widget class="QStackedWidget" name="pageStack">
<property name="currentIndex">
<number>0</number>
<number>1</number>
</property>
<widget class="QWidget" name="treeView">
<layout class="QVBoxLayout" name="verticalLayout_3">
......@@ -32,13 +32,7 @@
<widget class="QWidget" name="detailsView">
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QWebView" name="docDetails">
<property name="url">
<url>
<string>about:blank</string>
</url>
</property>
</widget>
<widget class="QTextBrowser" name="docDetails"/>
</item>
</layout>
</widget>
......@@ -119,13 +113,6 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>QWebView</class>
<extends>QWidget</extends>
<header>QtWebKit/QWebView</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
......@@ -86,11 +86,6 @@ DocumentTypesWidget::DocumentTypesWidget(QWidget *parent)
show();
}
DocumentTypesWidget::~DocumentTypesWidget()
{
}
void DocumentTypesWidget::setDocument(GraphDocumentPtr document)
{
m_createNodeTypeButton->setEnabled(document ? true : false);
......
......@@ -33,7 +33,7 @@ class DocumentTypesWidget : public QWidget
Q_OBJECT
public:
explicit DocumentTypesWidget(QWidget *parent);
~DocumentTypesWidget();
~DocumentTypesWidget() = default;
public Q_SLOTS:
void setDocument(GraphTheory::GraphDocumentPtr document);
......
......@@ -30,7 +30,7 @@
JournalEditorWidget::JournalEditorWidget(QWidget* parent)
: QWidget(parent)
, m_currentProject(0)
, m_currentProject(nullptr)
, m_modified(false)
{
ui = new Ui::JournalEditorWidget;
......
......@@ -72,7 +72,7 @@ using namespace GraphTheory;
MainWindow::MainWindow()
: KXmlGuiWindow()
, m_currentProject(0)
, m_currentProject(nullptr)
, m_kernel(new Kernel)
, m_codeEditorWidget(new CodeEditorWidget(this))
, m_graphEditorWidget(new GraphEditorWidget(this))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment