[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:38 -0500 (EST) |
branch: old/qt-info
commit e391d8fd53fa70532bdf6952d6dfefe9b0bb1b24
Author: Gavin Smith <gavinsmith0123@gmail.com>
AuthorDate: Thu Apr 11 12:12:39 2019 +0100
inject js via function
---
js/docbrowser/mainwindow.cpp | 42 ++++++++++++++++++------------------------
js/docbrowser/mainwindow.h | 1 +
2 files changed, 19 insertions(+), 24 deletions(-)
diff --git a/js/docbrowser/mainwindow.cpp b/js/docbrowser/mainwindow.cpp
index 8d1e9f5bd8..1fb97f3690 100644
--- a/js/docbrowser/mainwindow.cpp
+++ b/js/docbrowser/mainwindow.cpp
@@ -94,32 +94,33 @@ MainWindow::inject_qwebchannel(bool finished_ok)
0 );
}
+QString
+MainWindow::inject_js_file (const QString &filename)
+{
+ QString script;
+ QFile file;
+ file.setFileName (QString(this->datadir)
+ + "/" + filename);
+ file.open(QIODevice::ReadOnly);
+ QByteArray b = file.readAll();
+ script = QString(b);
+
+ return script;
+}
+
void
MainWindow::setup_profile(QWebEngineProfile *profile)
{
/* First load the data from disk */
+
#define INFO_JS "info.js"
- if (info_js.isNull()) {
- QFile file;
- file.setFileName (QString(this->datadir)
- + "/" INFO_JS);
- file.open(QIODevice::ReadOnly);
- QByteArray b = file.readAll();
- info_js = QString(b);
- }
+ info_js = inject_js_file (INFO_JS);
#define MODERNIZR_JS "modernizr.js"
- if (modernizr_js.isNull()) {
- QFile file;
- file.setFileName (QString(this->datadir)
- + "/" MODERNIZR_JS);
- file.open(QIODevice::ReadOnly);
- QByteArray b = file.readAll();
- modernizr_js = QString(b);
- }
+ modernizr_js = inject_js_file (MODERNIZR_JS);
#define INFO_CSS "info.css"
@@ -134,14 +135,7 @@ MainWindow::setup_profile(QWebEngineProfile *profile)
#define QWEBCHANNEL_JS "qwebchannel.js"
- if (qwebchannel_js.isNull()) {
- QFile file;
- file.setFileName (QString(this->datadir)
- + "/docbrowser/" + QWEBCHANNEL_JS);
- file.open(QIODevice::ReadOnly);
- QByteArray b = file.readAll();
- qwebchannel_js = QString(b);
- }
+ qwebchannel_js = inject_js_file ("docbrowser/" QWEBCHANNEL_JS);
/* Set up JavaScript to load info.css. This relies on there being no
single quotes or backslashes in info.css. The simplified() call
diff --git a/js/docbrowser/mainwindow.h b/js/docbrowser/mainwindow.h
index 5082548c7c..161368bc95 100644
--- a/js/docbrowser/mainwindow.h
+++ b/js/docbrowser/mainwindow.h
@@ -39,6 +39,7 @@ private:
void quit();
void inject_qwebchannel(bool ok);
+ QString inject_js_file(const QString &filename);
void setup_profile(QWebEngineProfile *profile);
void setup_channel();
void focusChanged (QWidget *old, QWidget *now);
- branch old/qt-info created (now e2d72c0f4f), 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