Skip to content

Commit 197b66c

Browse files
committed
code refactoring
1 parent 2854d73 commit 197b66c

File tree

4 files changed

+12
-20
lines changed

4 files changed

+12
-20
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ Inspired by [NW.js](http://nwjs.io/) and [Electron](http://electron.atom.io/), P
9494
* Qt 5.1 - 5.5 (including ``QtWebKit`` libraries and headers)
9595
``QtWebKit`` is deprecated and replaced by the Blink-based ``QtWebEngine`` in all later versions of Qt.
9696

97-
The implementation of the local pseudodomain and all requests to local content depend on the ``QNetworkAccessManager`` class, which is incompatible with ``QtWebEngine``.
97+
The local pseudodomain is implement using the ``QNetworkAccessManager`` class, which is incompatible with ``QtWebEngine``.
9898

9999
If you want to render the HTML user interface of your Perl desktop application using the Blink web engine, you may use [Electron](http://electron.atom.io/) or [NW.js](http://nwjs.io/) combined with [camel-harness](https://github.com/ddmitov/camel-harness).
100100

@@ -288,7 +288,7 @@ PEB is designed to run from any directory without setting anything beforehand an
288288

289289
<a name="log-files"></a>
290290
* **Log files:**
291-
If log files are needed for debugging of PEB or a PEB-based application, they can easily be turned on by manually creating ``{PEB_binary_directory}/logs``. If this directory is found during application startup, the browser assumes that logging is required and a separate log file is created for every browser session following the naming convention: ``{application_name}-started-at-{four_digit_year}-{month}-{day}--{hour}-{minute}-{second}.log``. PEB will not create ``{PEB_binary_directory}/logs`` on its own and if this directory is missing, no logs will be written, which is the default behavior. Please note that every requested link is logged and log files can grow rapidly. If disc space is an issue, writing log files can be turned off by simply removing or renaming ``{PEB_binary_directory}/logs``.
291+
If log files are needed for debugging of PEB or a PEB-based application, they can easily be turned on by manually creating ``{PEB_binary_directory}/logs``. If this directory is found during application startup, the browser assumes that logging is required and a separate log file is created for every browser session following the naming convention: ``{application_name}-started-at-{four_digit_year}-{month}-{day}--{hour}-{minute}-{second}.log``. PEB will not create ``{PEB_binary_directory}/logs`` on its own and if this directory is missing, no logs will be written, which is the default behavior. Please note that log files can grow rapidly. If disc space is an issue, writing log files can be turned off by simply removing or renaming ``{PEB_binary_directory}/logs``.
292292

293293
**Settings based on JavaScript code:**
294294

src/access-manager.h

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,10 @@
1919
#define ACCESSMANAGER_H
2020

2121
#include <QApplication>
22-
#include <QDesktopWidget>
2322
#include <QDir>
2423
#include <QMimeDatabase>
2524
#include <QtNetwork/QNetworkAccessManager>
2625

27-
#include "file-reader.h"
2826
#include "local-reply.h"
2927
#include "script-handler.h"
3028

@@ -44,9 +42,14 @@ class QAccessManager : public QNetworkAccessManager
4442
const QNetworkRequest &request,
4543
QIODevice *outgoingData = 0)
4644
{
47-
if (request.url().host() ==
48-
qApp->property("pseudoDomain").toString() and
49-
(!request.url().path().contains(".function"))) {
45+
if (request.url().host() == qApp->property("pseudoDomain").toString()) {
46+
// Window closing URL:
47+
if (request.url().fileName() == "close-window.function") {
48+
emit closeWindowSignal();
49+
50+
QLocalReply *reply = new QLocalReply(request.url());
51+
return reply;
52+
}
5053

5154
// Compose the full file path:
5255
QString fullFilePath = QDir::toNativeSeparators
@@ -84,15 +87,6 @@ class QAccessManager : public QNetworkAccessManager
8487
}
8588
}
8689

87-
// Window closing URL:
88-
if (operation == GetOperation and
89-
request.url().fileName() == "close-window.function") {
90-
emit closeWindowSignal();
91-
92-
QLocalReply *reply = new QLocalReply(request.url());
93-
return reply;
94-
}
95-
9690
return QNetworkAccessManager::createRequest
9791
(QNetworkAccessManager::GetOperation,
9892
QNetworkRequest(request));

src/page.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#ifndef PAGE_H
1919
#define PAGE_H
2020

21-
2221
#include <QJsonDocument>
2322
#include <QJsonObject>
2423
#include <QMessageBox>
@@ -58,6 +57,7 @@ public slots:
5857
if (ok) {
5958
emit changeTitleSignal();
6059

60+
// Inject all browser-specific Javascript:
6161
QFileReader *resourceReader =
6262
new QFileReader(QString(":/peb.js"));
6363
QString pebJavaScript = resourceReader->fileContents;

src/view.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public slots:
7272
QString selectAllLabel;
7373

7474
QVariant contextMenuJsResult =
75-
mainPage->currentFrame()->
75+
mainPage->mainFrame()->
7676
evaluateJavaScript("pebFindContextMenu()");
7777

7878
QJsonDocument contextMenuJsonDocument =
@@ -316,8 +316,6 @@ public slots:
316316
window->setGeometry(qApp->desktop()->availableGeometry());
317317
window->showMaximized();
318318

319-
qDebug() << "New window opened.";
320-
321319
return window;
322320
}
323321

0 commit comments

Comments
 (0)