@@ -57,16 +57,16 @@ BOOL isUserAdmin()
5757// READ EMBEDDED HTML TEMPLATE
5858// FOR ERROR MESSAGES:
5959// ==============================
60- QString readHtmlErrorTemplate ( )
60+ QString readHtmlTemplate (QString fileName )
6161{
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 ;
7070}
7171
7272// ==============================
@@ -129,7 +129,7 @@ int main(int argc, char **argv)
129129 // SET BASIC APPLICATION VARIABLES:
130130 // ==============================
131131 application.setApplicationName (" Perl Executing Browser" );
132- application.setApplicationVersion (" 0.1 " );
132+ application.setApplicationVersion (" 0.2 " );
133133 bool startedAsRoot = false ;
134134
135135 // ==============================
@@ -331,7 +331,7 @@ int main(int argc, char **argv)
331331 // Display embedded HTML error message if application is started by
332332 // a user with administrative privileges:
333333 if (startedAsRoot == true ) {
334- QString htmlErrorContents = readHtmlErrorTemplate ( );
334+ QString htmlErrorContents = readHtmlTemplate ( " error.html " );
335335 QString errorMessage =
336336 " Using "
337337 + application.applicationName ().toLatin1 () + " "
@@ -350,7 +350,7 @@ int main(int argc, char **argv)
350350 // Display embedded HTML error message if
351351 // Perl interpreter is not found:
352352 if (perlInterpreterFullPath.length () == 0 ) {
353- QString htmlErrorContents = readHtmlErrorTemplate ( );
353+ QString htmlErrorContents = readHtmlTemplate ( " error.html " );
354354 QString errorMessage = privatePerlInterpreterFullPath + " <br>"
355355 + " is not found and "
356356 + " Perl interpreter is not available on PATH." ;
@@ -402,7 +402,7 @@ int main(int argc, char **argv)
402402 QUrl (" http://" + QString (PSEUDO_DOMAIN)
403403 + " /index.pl" ));
404404 } else {
405- QString htmlErrorContents = readHtmlErrorTemplate ( );
405+ QString htmlErrorContents = readHtmlTemplate ( " error.html " );
406406 QString errorMessage = " Start page was not found." ;
407407 htmlErrorContents.replace (" ERROR_MESSAGE" , errorMessage);
408408 mainWindow.webViewWidget ->setHtml (htmlErrorContents);
@@ -835,7 +835,12 @@ bool QPage::acceptNavigationRequest(QWebFrame *frame,
835835 request.url ().fileName () == " about.function" and
836836 request.url ().query () == " type=browser" ) {
837837
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);
839844
840845 return false ;
841846 }
@@ -877,18 +882,15 @@ bool QPage::acceptNavigationRequest(QWebFrame *frame,
877882 selectScriptToDebugDialog.deleteLater ();
878883
879884 if (debuggerScriptToDebug.length () > 1 ) {
880- qDebug () << " File to load in the Perl Debugger: "
881- << debuggerScriptToDebug;
885+ debuggerScriptToDebug =
886+ QDir::toNativeSeparators ( debuggerScriptToDebug) ;
882887
883888 // Get Perl debugger command (if any):
884889 debuggerLastCommand = request.url ().query ().toLatin1 ()
885890 .replace (" action=select-file" , " " )
886891 .replace (" &command=" , " " )
887892 .replace (" +" , " " );
888893
889- qDebug () << " Debugger command:"
890- << debuggerLastCommand;
891-
892894 // Close any still open Perl debugger session:
893895 debuggerHandler.close ();
894896
@@ -904,9 +906,6 @@ bool QPage::acceptNavigationRequest(QWebFrame *frame,
904906 .replace (" command=" , " " )
905907 .replace (" +" , " " );
906908
907- qDebug () << " Debugger command:"
908- << debuggerLastCommand;
909-
910909 qStartPerlDebuggerSlot ();
911910 return false ;
912911 }
0 commit comments