[PC-BSD Commits] r173 - pcbsd/trunk/PBIsource
svn at pcbsd.org
svn at pcbsd.org
Fri Apr 13 11:09:21 PDT 2007
Author: kris
Date: 2007-04-13 19:09:21 +0100 (Fri, 13 Apr 2007)
New Revision: 173
Modified:
pcbsd/trunk/PBIsource/pbi.ui.h
Log:
Added options to PBI for displaying internel dialog boxes
Modified: pcbsd/trunk/PBIsource/pbi.ui.h
===================================================================
--- pcbsd/trunk/PBIsource/pbi.ui.h 2007-04-11 21:53:28 UTC (rev 172)
+++ pcbsd/trunk/PBIsource/pbi.ui.h 2007-04-13 18:09:21 UTC (rev 173)
@@ -105,8 +105,7 @@
setBackEnabled(currentPage(), FALSE);
setFinishEnabled(currentPage(),FALSE);
setNextEnabled(currentPage(), FALSE);
-
-
+
QDir NewDir;
NewDir.setPath("/Programs/" + ProgDirName);
@@ -115,10 +114,26 @@
if ( FirstRun.exists() ) {
StatusLabel->setText(tr("Running pre-install script..."));
progressTextDialog->setText("");
+
+ // Write out the wrapper script
+ QFile file( ".PBIwrapper.sh" );
+ if ( file.open( IO_WriteOnly ) ) {
+ QTextStream stream( &file );
+ stream << "#!/bin/sh\n";
+ stream << "PROGDIR=\"" + ProgDirName + "\"; export PROGDIR\n";
+ stream << "USERNAME=\"" + RealUserName + "\"; export USERNAME\n";
+ stream << "INSTALLMODE=\"GUI\"; export INSTALLMODE\n";
+ stream << "sh ./PBI.FirstRun.sh\nexit ${?}";
+
+ file.close();
+ }
+
FirstRunScript = new QProcess( this );
- FirstRunScript->addArgument( "./PBI.FirstRun.sh" );
- FirstRunScript->addArgument( ProgDirName );
- FirstRunScript->addArgument( RealUserName );
+ FirstRunScript->addArgument( "sh" );
+ FirstRunScript->addArgument( "./.PBIwrapper.sh" );
+ //FirstRunScript->addArgument( "./PBI.FirstRun.sh" );
+ //FirstRunScript->addArgument( ProgDirName );
+ //FirstRunScript->addArgument( RealUserName );
connect( FirstRunScript, SIGNAL(processExited()), this, SLOT(readFirstRunOutput() ) );
connect( FirstRunScript, SIGNAL(readyReadStdout()), this, SLOT(readyReadScriptOutput() ) );
@@ -1005,11 +1020,27 @@
if (ScriptCheck.exists() )
{
StatusLabel->setText(tr("Running install script..."));
+
+ // Write out the wrapper script
+ QFile file( ".PBIwrapper.sh" );
+ if ( file.open( IO_WriteOnly ) ) {
+ QTextStream stream( &file );
+ stream << "#!/bin/sh\n";
+ stream << "PROGDIR=\"" + ProgDirName + "\"; export PROGDIR\n";
+ stream << "USERNAME=\"" + RealUserName + "\"; export USERNAME\n";
+ stream << "INSTALLMODE=\"GUI\"; export INSTALLMODE\n";
+ stream << "sh /Programs/" + ProgDirName + "/PBI.SetupScript.sh\nexit ${?}";
+
+ file.close();
+ }
+
// Run the programs SetupScript
SetupScript = new QProcess( this );
- SetupScript->addArgument( "/Programs/" + ProgDirName + "/PBI.SetupScript.sh");
- SetupScript->addArgument( ProgDirName );
- SetupScript->addArgument( RealUserName );
+ SetupScript->addArgument( "sh");
+ SetupScript->addArgument( "./.PBIwrapper.sh");
+ //SetupScript->addArgument( "/Programs/" + ProgDirName + "/PBI.SetupScript.sh");
+ //SetupScript->addArgument( ProgDirName );
+ //SetupScript->addArgument( RealUserName );
connect( SetupScript, SIGNAL(processExited()), this, SLOT(FinishedInstallSlot() ) );
connect( SetupScript, SIGNAL(readyReadStdout()), this, SLOT(readyReadScriptOutput2() ) );
if ( !SetupScript->start() ) {
@@ -1223,6 +1254,10 @@
void PBI::readyReadScriptOutput()
{
+ QString DialogType = "";
+ QString DialogText = "";
+
+
// Function reads the output of script
// Script is able to set the number of steps for the progress bar
// Script is able to echo messages to be displayed in the progressTextDialog
@@ -1251,6 +1286,90 @@
value.truncate(30);
progressTextDialog->setText(value);
}
+
+
+ // Start the check to see if the user has defined a dialog question
+ if ( tmp.find("<Start Dialog>") != -1 )
+ {
+ while ( FirstRunScript->canReadLineStdout() )
+ {
+ tmp = FirstRunScript->readLineStdout();
+ // Look for the dialog type keyword, and set the type
+ if ( tmp.find("DialogType: " ) != -1 )
+ {
+
+ value = tmp.replace("DialogType: ", "");
+ // Set type of dialog to "info"
+ if ( value.find("Info") != -1)
+ {
+ DialogType = "Info";
+ }
+
+ if ( value.find("Question") != -1)
+ {
+ DialogType = "Question";
+ }
+
+ if ( value.find("Warning") != -1 )
+ {
+ DialogType = "Warning";
+ }
+
+ }
+
+ // Look for the dialog box text
+ if ( tmp.find("DialogText: " ) != -1 )
+ {
+ value = tmp.replace("DialogText: ", "");
+ DialogText = value;
+ }
+
+
+ // Look for the closing tag and take the user specified action
+ if ( tmp.find("<End Dialog>" ) != -1 )
+ {
+
+ if ( ! DialogType.isEmpty() && ! DialogText.isEmpty() )
+ {
+
+ // Display the Info dialog box
+ if ( DialogType == "Info" )
+ {
+ QMessageBox::information( this, ProgramName, DialogText );
+ }
+
+ // Display the Question dialog and return status
+ if ( DialogType == "Question" )
+ {
+ int result = QMessageBox::question(this, ProgramName, DialogText, tr("&Yes"), tr("&No"), QString::null, 0, 1 );
+ if ( result == 0 ) {
+ tmp = "Yes\n";
+ } else {
+ tmp = "No\n";
+ }
+
+ FirstRunScript->writeToStdin(tmp);
+ }
+
+ // Display the Question dialog and return status
+ if ( DialogType == "Warning" )
+ {
+ QMessageBox::warning( this, ProgramName, DialogText );
+ }
+
+ }
+
+ // Reset the variables
+ DialogType = "";
+ DialogText = "";
+
+ }
+
+ }
+ }
+
+
+
}
@@ -1259,6 +1378,10 @@
void PBI::readyReadScriptOutput2()
{
+ QString DialogType = "";
+ QString DialogText = "";
+
+
// Function reads the output of script
// Script is able to set the number of steps for the progress bar
// Script is able to echo messages to be displayed in the progressTextDialog
@@ -1287,6 +1410,87 @@
value.truncate(30);
progressTextDialog->setText(value);
}
+
+
+ // Start the check to see if the user has defined a dialog question
+ if ( tmp.find("<Start Dialog>") != -1 )
+ {
+ while ( SetupScript->canReadLineStdout() )
+ {
+ tmp = SetupScript->readLineStdout();
+ // Look for the dialog type keyword, and set the type
+ if ( tmp.find("DialogType: " ) != -1 )
+ {
+
+ value = tmp.replace("DialogType: ", "");
+ // Set type of dialog to "info"
+ if ( value.find("Info") != -1)
+ {
+ DialogType = "Info";
+ }
+
+ if ( value.find("Question") != -1)
+ {
+ DialogType = "Question";
+ }
+
+ if ( value.find("Warning") != -1 )
+ {
+ DialogType = "Warning";
+ }
+
+ }
+
+ // Look for the dialog box text
+ if ( tmp.find("DialogText: " ) != -1 )
+ {
+ value = tmp.replace("DialogText: ", "");
+ DialogText = value;
+ }
+
+
+ // Look for the closing tag and take the user specified action
+ if ( tmp.find("<End Dialog>" ) != -1 )
+ {
+
+ if ( ! DialogType.isEmpty() && ! DialogText.isEmpty() )
+ {
+
+ // Display the Info dialog box
+ if ( DialogType == "Info" )
+ {
+ QMessageBox::information( this, ProgramName, DialogText );
+ }
+
+ // Display the Question dialog and return status
+ if ( DialogType == "Question" )
+ {
+ int result = QMessageBox::question(this, ProgramName, DialogText, tr("&Yes"), tr("&No"), QString::null, 0, 1 );
+ if ( result == 0 ) {
+ tmp = "Yes\n";
+ } else {
+ tmp = "No\n";
+ }
+
+ SetupScript->writeToStdin(tmp);
+ }
+
+ // Display the Question dialog and return status
+ if ( DialogType == "Warning" )
+ {
+ QMessageBox::warning( this, ProgramName, DialogText );
+ }
+
+ }
+
+ // Reset the variables
+ DialogType = "";
+ DialogText = "";
+
+ }
+
+ }
+ }
}
}
More information about the Commits
mailing list