@@ -57,16 +57,16 @@ BOOL isUserAdmin()
57
57
// READ EMBEDDED HTML TEMPLATE
58
58
// FOR ERROR MESSAGES:
59
59
// ==============================
60
- QString readHtmlErrorTemplate ( )
60
+ QString readHtmlTemplate (QString fileName )
61
61
{
62
- QString htmlErrorFileName (" :/html/error.html " );
63
- QFile htmlErrorFile (htmlErrorFileName );
64
- htmlErrorFile .open (QIODevice::ReadOnly | QIODevice::Text);
65
- QTextStream htmlErrorStream (&htmlErrorFile );
66
- QString htmlErrorContents = htmlErrorStream .readAll ();
67
- htmlErrorFile .close ();
68
-
69
- return htmlErrorContents ;
62
+ QString htmlTemplateFileName (" :/html/" + fileName );
63
+ QFile htmlTemplateFile (htmlTemplateFileName );
64
+ htmlTemplateFile .open (QIODevice::ReadOnly | QIODevice::Text);
65
+ QTextStream htmlTemplateStream (&htmlTemplateFile );
66
+ QString htmlTemplateContents = htmlTemplateStream .readAll ();
67
+ htmlTemplateFile .close ();
68
+
69
+ return htmlTemplateContents ;
70
70
}
71
71
72
72
// ==============================
@@ -129,7 +129,7 @@ int main(int argc, char **argv)
129
129
// SET BASIC APPLICATION VARIABLES:
130
130
// ==============================
131
131
application.setApplicationName (" Perl Executing Browser" );
132
- application.setApplicationVersion (" 0.1 " );
132
+ application.setApplicationVersion (" 0.2 " );
133
133
bool startedAsRoot = false ;
134
134
135
135
// ==============================
@@ -331,7 +331,7 @@ int main(int argc, char **argv)
331
331
// Display embedded HTML error message if application is started by
332
332
// a user with administrative privileges:
333
333
if (startedAsRoot == true ) {
334
- QString htmlErrorContents = readHtmlErrorTemplate ( );
334
+ QString htmlErrorContents = readHtmlTemplate ( " error.html " );
335
335
QString errorMessage =
336
336
" Using "
337
337
+ application.applicationName ().toLatin1 () + " "
@@ -350,7 +350,7 @@ int main(int argc, char **argv)
350
350
// Display embedded HTML error message if
351
351
// Perl interpreter is not found:
352
352
if (perlInterpreterFullPath.length () == 0 ) {
353
- QString htmlErrorContents = readHtmlErrorTemplate ( );
353
+ QString htmlErrorContents = readHtmlTemplate ( " error.html " );
354
354
QString errorMessage = privatePerlInterpreterFullPath + " <br>"
355
355
+ " is not found and "
356
356
+ " Perl interpreter is not available on PATH." ;
@@ -402,7 +402,7 @@ int main(int argc, char **argv)
402
402
QUrl (" http://" + QString (PSEUDO_DOMAIN)
403
403
+ " /index.pl" ));
404
404
} else {
405
- QString htmlErrorContents = readHtmlErrorTemplate ( );
405
+ QString htmlErrorContents = readHtmlTemplate ( " error.html " );
406
406
QString errorMessage = " Start page was not found." ;
407
407
htmlErrorContents.replace (" ERROR_MESSAGE" , errorMessage);
408
408
mainWindow.webViewWidget ->setHtml (htmlErrorContents);
@@ -835,7 +835,12 @@ bool QPage::acceptNavigationRequest(QWebFrame *frame,
835
835
request.url ().fileName () == " about.function" and
836
836
request.url ().query () == " type=browser" ) {
837
837
838
- frame->load (QUrl (" qrc:/html/about.html" ));
838
+ QString aboutPageContents = readHtmlTemplate (" about.html" );
839
+ aboutPageContents
840
+ .replace (" VERSION_STRING" ,
841
+ QApplication::applicationVersion ().toLatin1 ());
842
+
843
+ frame->setHtml (aboutPageContents);
839
844
840
845
return false ;
841
846
}
@@ -877,18 +882,15 @@ bool QPage::acceptNavigationRequest(QWebFrame *frame,
877
882
selectScriptToDebugDialog.deleteLater ();
878
883
879
884
if (debuggerScriptToDebug.length () > 1 ) {
880
- qDebug () << " File to load in the Perl Debugger: "
881
- << debuggerScriptToDebug;
885
+ debuggerScriptToDebug =
886
+ QDir::toNativeSeparators ( debuggerScriptToDebug) ;
882
887
883
888
// Get Perl debugger command (if any):
884
889
debuggerLastCommand = request.url ().query ().toLatin1 ()
885
890
.replace (" action=select-file" , " " )
886
891
.replace (" &command=" , " " )
887
892
.replace (" +" , " " );
888
893
889
- qDebug () << " Debugger command:"
890
- << debuggerLastCommand;
891
-
892
894
// Close any still open Perl debugger session:
893
895
debuggerHandler.close ();
894
896
@@ -904,9 +906,6 @@ bool QPage::acceptNavigationRequest(QWebFrame *frame,
904
906
.replace (" command=" , " " )
905
907
.replace (" +" , " " );
906
908
907
- qDebug () << " Debugger command:"
908
- << debuggerLastCommand;
909
-
910
909
qStartPerlDebuggerSlot ();
911
910
return false ;
912
911
}
0 commit comments