Add displaying progress and eta.

new_installer
ivan 14 years ago
parent 72f4b36670
commit a6ceffc4ee

@ -4,7 +4,7 @@
#include <QLocale>
#include <QTranslator>
#include <QMessageBox>
#include <QtDebug>
#include "systeminstaller.h"

@ -16,12 +16,18 @@ PageInstall::PageInstall(const QString& title, InstallerSettings* settings) :
m_Output = new QTextEdit;
m_Output->setReadOnly(true);
m_LabelEta = new QLabel( tr("Eta: unknown") );
m_Progress = new QProgressBar(0);
QHBoxLayout* hbox = new QHBoxLayout;
hbox->addWidget(m_LabelEta);
hbox->addWidget(m_Progress);
QVBoxLayout* vbox = new QVBoxLayout;
vbox->addWidget(m_Output);
vbox->addWidget(m_Progress);
vbox->addLayout(hbox);
m_Widget->setLayout(vbox);
}
@ -69,17 +75,43 @@ void PageInstall::onError(QProcess::ProcessError error)
void PageInstall::showStdOut()
{
// debug
QString str = m_clProc->readAllStandardOutput();
qDebug() << "cl out: " << str;
if (m_clProc)
{
// debug
QString str = m_clProc->readAllStandardOutput();
// TODO: parse out
m_Output->insertPlainText( str );
}
}
void PageInstall::showStdErr()
{
QString eta;
QString progress;
if (m_clProc)
qDebug() << tr("Process Error: ") << m_clProc->readAllStandardError();
{
QString str = m_clProc->readAllStandardError();
if ( str.contains("eta:") )
{
QRegExp eta_regexp("\\b(\\d{1,2}:\\d{1,2}:\\d{1,2})\\b");
QRegExp percent_regexp("\\d{1,2}.%");
if ( eta_regexp.indexIn(str) )
eta = eta_regexp.cap(0);
if ( percent_regexp.indexIn(str) )
progress = percent_regexp.cap(0);
if ( !eta.isEmpty() )
m_LabelEta->setText( tr("Eta: %1").arg(eta) );
if ( !progress.isEmpty() )
m_Progress->setValue( progress.toInt() );
}
}
}

@ -7,6 +7,7 @@
class QTextEdit;
class QProgressBar;
class QLabel;
class PageInstall : public InstallerPage
{
@ -27,6 +28,7 @@ private slots:
private:
QTextEdit* m_Output;
QLabel* m_LabelEta;
QProgressBar* m_Progress;
InstallerSettings* m_Settings;

Loading…
Cancel
Save