You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
calculate-utils-2.2-install.../src/pageinstall.cpp

97 lines
2.2 KiB

14 years ago
#include "pageinstall.h"
#include <QtDebug>
14 years ago
#include <QBoxLayout>
#include <QLabel>
#include <QTextEdit>
#include <QProgressBar>
PageInstall::PageInstall(const QString& title, InstallerSettings* settings) :
InstallerPage(title),
m_Settings(settings),
m_clProc(0)
14 years ago
{
//QLabel* label = new QLabel( tr("") )
m_Output = new QTextEdit;
m_Output->setReadOnly(true);
m_Progress = new QProgressBar(0);
QVBoxLayout* vbox = new QVBoxLayout;
vbox->addWidget(m_Output);
vbox->addWidget(m_Progress);
m_Widget->setLayout(vbox);
}
void PageInstall::show()
{
emit changeNext(false);
emit changePrev(false);
qDebug() << "install show()";
emit changeNext(false);
emit changePrev(false);
if ( !m_clProc )
{
m_clProc = new QProcess(this);
connect( m_clProc, SIGNAL(error(QProcess::ProcessError)), this, SLOT(onError(QProcess::ProcessError)) );
connect( m_clProc, SIGNAL(readyReadStandardOutput()), this, SLOT(showStdOut()) );
connect( m_clProc, SIGNAL(readyReadStandardError()), this, SLOT(showStdErr()) );
connect( m_clProc, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(onFinish(int,QProcess::ExitStatus)) );
QStringList args;
args << QString("--disk=%1").arg(m_Settings->disk);
args << QString("--set-hostname=%1").arg(m_Settings->host);
args << QString("--set-format=%1").arg(m_Settings->fs);
args << QString("--set-lang=%1").arg(m_Settings->language);
args << QString("--set-timezone=%1").arg(m_Settings->timezone);
m_clProc->start("calculate", args);
}
14 years ago
}
bool PageInstall::validate()
{
return true;
}
void PageInstall::onError(QProcess::ProcessError error)
{
qDebug() << "failed to run process 'calculate' error=" << error ;
onFinish(-error);
}
void PageInstall::showStdOut()
{
// debug
QString str = m_clProc->readAllStandardOutput();
qDebug() << "cl out: " << str;
if (m_clProc)
m_Output->insertPlainText( str );
}
void PageInstall::showStdErr()
{
if (m_clProc)
qDebug() << tr("Process Error: ") << m_clProc->readAllStandardError();
}
void PageInstall::onFinish(int exitCode, QProcess::ExitStatus exitStatus)
{
qDebug() << "install onFinish()";
emit changeNext(true);
emit changePrev(true);
delete m_clProc;
m_clProc = 0;
}