Commit 22833574 authored by Marco Bubke's avatar Marco Bubke

QmlDesigner: Progress dialog for puppet creation

Change-Id: I9337fa70af18aca0018c16cf9152f912086330f8
Reviewed-by: default avatarThomas Hartmann <Thomas.Hartmann@digia.com>
parent 9e802e3a
......@@ -3,8 +3,12 @@ INCLUDEPATH += $$PWD/
HEADERS += $$PWD/../include/nodeinstance.h
HEADERS += $$PWD/nodeinstanceserverproxy.h
HEADERS += $$PWD/puppetcreator.h
HEADERS += $$PWD/puppetbuildprogressdialog.h
SOURCES += $$PWD/nodeinstanceserverproxy.cpp
SOURCES += $$PWD/nodeinstance.cpp
SOURCES += $$PWD/nodeinstanceview.cpp
SOURCES += $$PWD/puppetcreator.cpp
SOURCES += $$PWD/puppetbuildprogressdialog.cpp
FORMS += $$PWD/puppetbuildprogressdialog.ui
/****************************************************************************
**
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include "puppetbuildprogressdialog.h"
#include "ui_puppetbuildprogressdialog.h"
#include <QProcess>
#include <QtDebug>
#include <QApplication>
#include <coreplugin/icore.h>
namespace QmlDesigner {
PuppetBuildProgressDialog::PuppetBuildProgressDialog() :
QDialog(Core::ICore::dialogParent()),
ui(new Ui::PuppetBuildProgressDialog),
m_lineCount(0)
{
setWindowFlags(Qt::SplashScreen);
ui->setupUi(this);
ui->buildProgressBar->setMaximum(86);
}
PuppetBuildProgressDialog::~PuppetBuildProgressDialog()
{
delete ui;
}
void PuppetBuildProgressDialog::setProgress(int progress)
{
ui->buildProgressBar->setValue(progress);
QApplication::processEvents(QEventLoop::ExcludeUserInputEvents | QEventLoop::ExcludeSocketNotifiers);
}
void PuppetBuildProgressDialog::newBuildOutput(const QByteArray &standardOutput)
{
m_lineCount += standardOutput.count('\n');
setProgress(m_lineCount);
}
}
/****************************************************************************
**
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef PUPPETBUILDPROGRESSDIALOG_H
#define PUPPETBUILDPROGRESSDIALOG_H
#include <QDialog>
namespace Ui {
class PuppetBuildProgressDialog;
}
namespace QmlDesigner {
class PuppetBuildProgressDialog : public QDialog
{
Q_OBJECT
public:
explicit PuppetBuildProgressDialog();
~PuppetBuildProgressDialog();
void setProgress(int progress);
void newBuildOutput(const QByteArray &standardOutput);
private:
Ui::PuppetBuildProgressDialog *ui;
int m_lineCount;
};
}
#endif // PUPPETBUILDPROGRESSDIALOG_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PuppetBuildProgressDialog</class>
<widget class="QDialog" name="PuppetBuildProgressDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>609</width>
<height>67</height>
</rect>
</property>
<property name="windowTitle">
<string>Build Progress</string>
</property>
<property name="modal">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Build Adapter for the current Qt. Happens only for every Qt installation once.</string>
</property>
</widget>
</item>
<item>
<widget class="QProgressBar" name="buildProgressBar">
<property name="value">
<number>0</number>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
......@@ -42,6 +42,8 @@
#include <qtsupport/qtkitinformation.h>
#include <qtsupport/qtsupportconstants.h>
#include "puppetbuildprogressdialog.h"
#include <QtDebug>
namespace QmlDesigner {
......@@ -156,6 +158,8 @@ QProcess *PuppetCreator::qml2puppetProcess(const QString &puppetMode,
bool PuppetCreator::build(const QString &qmlPuppetProjectFilePath) const
{
PuppetBuildProgressDialog progressDialog;
m_compileLog.clear();
QTemporaryDir buildDirectory;
......@@ -169,8 +173,11 @@ bool PuppetCreator::build(const QString &qmlPuppetProjectFilePath) const
qmakeArguments.append(QStringLiteral("DESTDIR=") + qmlpuppetDirectory(UserSpacePuppet));
qmakeArguments.append(qmlPuppetProjectFilePath);
buildSucceeded = startBuildProcess(buildDirectory.path(), qmakeCommand(), qmakeArguments);
if (buildSucceeded)
buildSucceeded = startBuildProcess(buildDirectory.path(), buildCommand());
if (buildSucceeded) {
progressDialog.show();
buildSucceeded = startBuildProcess(buildDirectory.path(), buildCommand(), QStringList(), &progressDialog);
progressDialog.hide();
}
} else {
buildSucceeded = true;
}
......@@ -246,7 +253,8 @@ QString PuppetCreator::compileLog() const
bool PuppetCreator::startBuildProcess(const QString &buildDirectoryPath,
const QString &command,
const QStringList &processArguments) const
const QStringList &processArguments,
PuppetBuildProgressDialog *progressDialog) const
{
if (command.isEmpty())
return false;
......@@ -256,8 +264,19 @@ bool PuppetCreator::startBuildProcess(const QString &buildDirectoryPath,
process.setProcessEnvironment(processEnvironment());
process.setWorkingDirectory(buildDirectoryPath);
process.start(command, processArguments);
process.waitForFinished(-1);
m_compileLog.append(process.readAllStandardOutput());
process.waitForStarted();
while (true) {
if (process.waitForReadyRead(100)) {
QByteArray newOutput = process.readAllStandardOutput();
if (progressDialog) {
progressDialog->newBuildOutput(newOutput);
m_compileLog.append(newOutput);
}
}
if (process.state() == QProcess::NotRunning)
break;
}
if (process.exitStatus() == QProcess::NormalExit || process.exitCode() == 0)
return true;
......
......@@ -39,6 +39,8 @@ class Kit;
namespace QmlDesigner {
class PuppetBuildProgressDialog;
class PuppetCreator
{
enum Puppetype {
......@@ -73,7 +75,8 @@ protected:
bool startBuildProcess(const QString &buildDirectoryPath,
const QString &command,
const QStringList &processArguments = QStringList()) const;
const QStringList &processArguments = QStringList(),
PuppetBuildProgressDialog *progressDialog = 0) const;
static QString puppetSourceDirectoryPath();
static QString qml2puppetProjectFile();
static QString qmlpuppetProjectFile();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment