[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Gavin D. Smith |
Date: |
Wed, 30 Nov 2022 13:36:35 -0500 (EST) |
branch: old/qt-info
commit dcbc6c35dfff2cb4ead8006997520677826522a0
Author: Gavin Smith <gavinsmith0123@gmail.com>
AuthorDate: Sun Apr 7 17:07:06 2019 +0100
load_manual in Core
---
js/docbrowser/core.cpp | 19 +++++++++++++++++++
js/docbrowser/core.h | 4 ++++
js/docbrowser/mainwindow.cpp | 23 +++--------------------
js/docbrowser/mainwindow.h | 1 -
4 files changed, 26 insertions(+), 21 deletions(-)
diff --git a/js/docbrowser/core.cpp b/js/docbrowser/core.cpp
index df7cfd4a1a..333d1675d0 100644
--- a/js/docbrowser/core.cpp
+++ b/js/docbrowser/core.cpp
@@ -1,4 +1,6 @@
#include "core.h"
+#include "ui_mainwindow.h"
+
#include <QMessageBox>
#include <QtGlobal>
#include <QCoreApplication>
@@ -10,6 +12,7 @@ Core::Core(Ui::MainWindow *ui, QObject *parent)
{
}
+/* slot */
void
Core::external_manual (const QString &url)
{
@@ -21,3 +24,19 @@ Core::external_manual (const QString &url)
// Repace the file being viewed
}
+
+bool
+Core::load_manual (const char *manual)
+{
+ char *path = locate_manual (manual);
+
+ if (path)
+ {
+ qDebug() << "got path" << path;
+ ui->webEngineView->load(QUrl("file:" + QString(path)));
+ free (path);
+ return true;
+ }
+ return false;
+}
+
diff --git a/js/docbrowser/core.h b/js/docbrowser/core.h
index d31a728600..0b05f36b01 100644
--- a/js/docbrowser/core.h
+++ b/js/docbrowser/core.h
@@ -1,6 +1,8 @@
#ifndef CORE_H
#define CORE_H
+#include "infopath.h"
+
#include <QObject>
namespace Ui {
@@ -13,6 +15,8 @@ class Core : public QObject
public:
explicit Core(Ui::MainWindow *ui, QObject *parent = nullptr);
+ bool load_manual (const char *manual);
+
signals:
// Signals emitted from the C++ side and received on the HTML client side.
void setUrl (const QString &text);
diff --git a/js/docbrowser/mainwindow.cpp b/js/docbrowser/mainwindow.cpp
index ac91cda6c1..434447a3a5 100644
--- a/js/docbrowser/mainwindow.cpp
+++ b/js/docbrowser/mainwindow.cpp
@@ -3,8 +3,6 @@
#include "websocketclientwrapper.h"
#include "websockettransport.h"
-#include "infopath.h"
-
#include <stdlib.h>
#include <QWebEngineView>
@@ -39,7 +37,7 @@ MainWindow::MainWindow(QWidget *parent) :
QObject::connect(clientWrapper, &WebSocketClientWrapper::clientConnected,
channel, &QWebChannel::connectTo);
- auto *core = new Core(ui, this);
+ this->core = new Core(ui, this);
channel->registerObject(QStringLiteral("core"), core);
@@ -59,7 +57,7 @@ MainWindow::MainWindow(QWidget *parent) :
this->qwebchannel_js = QString(b);
#define MANUAL "hello-html"
- load_manual (MANUAL);
+ core->load_manual (MANUAL);
}
/* Load qwebchannel.js into the current page. */
@@ -84,21 +82,6 @@ MainWindow::inject_qwebchannel(bool finished_ok)
-bool
-MainWindow::load_manual (const char *manual)
-{
- char *path = locate_manual (manual);
-
- if (path)
- {
- qDebug() << "got path" << path;
- ui->webEngineView->load(QUrl("file:" + QString(path)));
- free (path);
- return true;
- }
- return false;
-}
-
MainWindow::~MainWindow()
{
delete ui;
@@ -117,5 +100,5 @@ void MainWindow::on_quitButton_clicked()
void MainWindow::on_loadButton_clicked()
{
- load_manual (qPrintable(ui->manualEdit->text()));
+ core->load_manual (qPrintable(ui->manualEdit->text()));
}
diff --git a/js/docbrowser/mainwindow.h b/js/docbrowser/mainwindow.h
index f8a845ab79..83da54d08c 100644
--- a/js/docbrowser/mainwindow.h
+++ b/js/docbrowser/mainwindow.h
@@ -32,7 +32,6 @@ private:
QString qwebchannel_js;
char *datadir;
- bool load_manual (const char *manual);
void quit();
void inject_qwebchannel(bool ok);
};
- [no subject], (continued)
- [no subject], Gavin D. Smith, 2022/11/30
- [no subject], Gavin D. Smith, 2022/11/30
- [no subject], Gavin D. Smith, 2022/11/30
- [no subject], Gavin D. Smith, 2022/11/30
- [no subject], Gavin D. Smith, 2022/11/30
- [no subject], Gavin D. Smith, 2022/11/30
- [no subject], Gavin D. Smith, 2022/11/30
- [no subject], Gavin D. Smith, 2022/11/30
- [no subject], Gavin D. Smith, 2022/11/30
- [no subject], Gavin D. Smith, 2022/11/30
- [no subject],
Gavin D. Smith <=
- [no subject], Gavin D. Smith, 2022/11/30
- [no subject], Gavin D. Smith, 2022/11/30
- [no subject], Gavin D. Smith, 2022/11/30
- [no subject], Gavin D. Smith, 2022/11/30
- [no subject], Gavin D. Smith, 2022/11/30
- [no subject], Gavin D. Smith, 2022/11/30
- [no subject], Gavin D. Smith, 2022/11/30
- [no subject], Gavin D. Smith, 2022/11/30
- [no subject], Gavin D. Smith, 2022/11/30
- [no subject], Gavin D. Smith, 2022/11/30