Skip to content

Commit a2dcfd8

Browse files
committed
QFileWriter
1 parent 57c20ec commit a2dcfd8

File tree

6 files changed

+75
-7
lines changed

6 files changed

+75
-7
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,9 @@ in the documentation of this project are to be interpreted as described in [RFC
7373

7474
## Limitations
7575

76-
* No pop-up windows
7776
* No Perl scripting inside frames
77+
* Limited HTML5 support
78+
* No pop-up windows
7879
* No file download
7980
* No printing
8081

doc/screenshot.png

190 Bytes
Loading

src/file-writer.cpp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
Perl Executing Browser
3+
4+
This program is free software;
5+
you can redistribute it and/or modify it under the terms of the
6+
GNU Lesser General Public License,
7+
as published by the Free Software Foundation;
8+
either version 3 of the License, or (at your option) any later version.
9+
This program is distributed in the hope that it will be useful,
10+
but WITHOUT ANY WARRANTY;
11+
without even the implied warranty of MERCHANTABILITY or
12+
FITNESS FOR A PARTICULAR PURPOSE.
13+
Dimitar D. Mitov, 2013 - 2019
14+
Valcho Nedelchev, 2014 - 2016
15+
https://github.com/ddmitov/perl-executing-browser
16+
*/
17+
18+
#include <QFile>
19+
#include <QTextStream>
20+
21+
#include "file-writer.h"
22+
23+
// ==============================
24+
// FILE READER CONSTRUCTOR:
25+
// ==============================
26+
QFileWriter::QFileWriter(QString filePath, QString fileContents)
27+
: QObject(0)
28+
{
29+
QFile file(filePath);
30+
if (file.open(QIODevice::ReadWrite | QIODevice::Text)) {
31+
QTextStream fileStream(&file);
32+
fileStream << fileContents <<endl;
33+
file.close();
34+
}
35+
}

src/file-writer.h

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
Perl Executing Browser
3+
4+
This program is free software;
5+
you can redistribute it and/or modify it under the terms of the
6+
GNU Lesser General Public License,
7+
as published by the Free Software Foundation;
8+
either version 3 of the License, or (at your option) any later version.
9+
This program is distributed in the hope that it will be useful,
10+
but WITHOUT ANY WARRANTY;
11+
without even the implied warranty of MERCHANTABILITY or
12+
FITNESS FOR A PARTICULAR PURPOSE.
13+
Dimitar D. Mitov, 2013 - 2019
14+
Valcho Nedelchev, 2014 - 2016
15+
https://github.com/ddmitov/perl-executing-browser
16+
*/
17+
18+
#ifndef FILE_WRITER_H
19+
#define FILE_WRITER_H
20+
21+
#include <QObject>
22+
23+
// ==============================
24+
// FILE WRITER CLASS DEFINITION:
25+
// ==============================
26+
class QFileWriter : public QObject
27+
{
28+
Q_OBJECT
29+
30+
public:
31+
explicit QFileWriter(QString filePath, QString fileContents);
32+
};
33+
34+
#endif // FILE_WRITER_H

src/peb.pro

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ QT += widgets webkitwidgets
4848
SOURCES += \
4949
main.cpp \
5050
file-reader.cpp \
51+
file-writer.cpp \
5152
main-window.cpp \
5253
script-handler.cpp \
5354
webkit-page.cpp \
@@ -56,6 +57,7 @@ SOURCES += \
5657
# Header files:
5758
HEADERS += \
5859
file-reader.h \
60+
file-writer.h \
5961
script-handler.h \
6062
webkit-main-window.h \
6163
webkit-page.h \

src/webkit-page.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include <QWebPage>
3434

3535
#include "file-reader.h"
36+
#include "file-writer.h"
3637
#include "script-handler.h"
3738

3839
// ==============================
@@ -343,12 +344,7 @@ public slots:
343344

344345
void qWriteInScriptTempFile(QString tempFileFullPath, QString scriptInput)
345346
{
346-
QFile file(tempFileFullPath);
347-
if (file.open(QIODevice::ReadWrite | QIODevice::Text)) {
348-
QTextStream fileStream(&file);
349-
fileStream << scriptInput <<endl;
350-
file.close();
351-
}
347+
QFileWriter(tempFileFullPath, scriptInput);
352348
}
353349

354350
void qDisplayScriptOutputSlot(QString id, QString output)

0 commit comments

Comments
 (0)