forked from qt-creator/qt-creator
Maemo: Add progress bar (concept shamelessly copied from S60).
Reviewed-by: kh1
This commit is contained in:
@@ -36,6 +36,7 @@
|
|||||||
#include "qt4project.h"
|
#include "qt4project.h"
|
||||||
#include "qt4buildconfiguration.h"
|
#include "qt4buildconfiguration.h"
|
||||||
|
|
||||||
|
#include <coreplugin/progressmanager/progressmanager.h>
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
#include <coreplugin/messagemanager.h>
|
#include <coreplugin/messagemanager.h>
|
||||||
#include <debugger/debuggermanager.h>
|
#include <debugger/debuggermanager.h>
|
||||||
@@ -47,7 +48,7 @@
|
|||||||
#include <projectexplorer/session.h>
|
#include <projectexplorer/session.h>
|
||||||
|
|
||||||
#include <QtCore/QDebug>
|
#include <QtCore/QDebug>
|
||||||
|
#include <QtCore/QFuture>
|
||||||
#include <QtCore/QPair>
|
#include <QtCore/QPair>
|
||||||
#include <QtCore/QProcess>
|
#include <QtCore/QProcess>
|
||||||
#include <QtCore/QSharedPointer>
|
#include <QtCore/QSharedPointer>
|
||||||
@@ -116,7 +117,7 @@ protected:
|
|||||||
const QString targetCmdLinePrefix() const;
|
const QString targetCmdLinePrefix() const;
|
||||||
const QString remoteDir() const;
|
const QString remoteDir() const;
|
||||||
const QStringList options() const;
|
const QStringList options() const;
|
||||||
virtual void deploymentFinished(bool success)=0;
|
void deploymentFinished(bool success);
|
||||||
virtual bool setProcessEnvironment(QProcess &process);
|
virtual bool setProcessEnvironment(QProcess &process);
|
||||||
private slots:
|
private slots:
|
||||||
void readStandardError();
|
void readStandardError();
|
||||||
@@ -129,10 +130,20 @@ protected:
|
|||||||
const MaemoDeviceConfigurations::DeviceConfig devConfig;
|
const MaemoDeviceConfigurations::DeviceConfig devConfig;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
virtual void handleDeploymentFinished(bool success)=0;
|
||||||
|
|
||||||
|
QFutureInterface<void> m_progress;
|
||||||
QProcess deployProcess;
|
QProcess deployProcess;
|
||||||
bool deployingExecutable;
|
struct Deployable
|
||||||
bool deployingDumperLib;
|
{
|
||||||
QList<QPair<QString, QString> > deployables;
|
typedef void (MaemoRunConfiguration::*updateFunc)();
|
||||||
|
Deployable(const QString &f, const QString &d, updateFunc u)
|
||||||
|
: fileName(f), dir(d), updateTimestamp(u) {}
|
||||||
|
QString fileName;
|
||||||
|
QString dir;
|
||||||
|
updateFunc updateTimestamp;
|
||||||
|
};
|
||||||
|
QList<Deployable> deployables;
|
||||||
};
|
};
|
||||||
|
|
||||||
class MaemoRunControl : public AbstractMaemoRunControl
|
class MaemoRunControl : public AbstractMaemoRunControl
|
||||||
@@ -149,7 +160,7 @@ private slots:
|
|||||||
void executionFinished();
|
void executionFinished();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void deploymentFinished(bool success);
|
virtual void handleDeploymentFinished(bool success);
|
||||||
void startExecution();
|
void startExecution();
|
||||||
|
|
||||||
QProcess sshProcess;
|
QProcess sshProcess;
|
||||||
@@ -176,7 +187,7 @@ private slots:
|
|||||||
void debuggerOutput(const QString &output);
|
void debuggerOutput(const QString &output);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void deploymentFinished(bool success);
|
virtual void handleDeploymentFinished(bool success);
|
||||||
|
|
||||||
void startGdbServer();
|
void startGdbServer();
|
||||||
void gdbServerStartFailed(const QString &reason);
|
void gdbServerStartFailed(const QString &reason);
|
||||||
@@ -1037,24 +1048,24 @@ void AbstractMaemoRunControl::startDeployment(bool forDebugging)
|
|||||||
{
|
{
|
||||||
QTC_ASSERT(runConfig, return);
|
QTC_ASSERT(runConfig, return);
|
||||||
|
|
||||||
|
Core::ICore::instance()->progressManager()->addTask(m_progress.future(),
|
||||||
|
tr("Deploying"), QLatin1String("Maemo.Deploy"));
|
||||||
if (devConfig.isValid()) {
|
if (devConfig.isValid()) {
|
||||||
deployables.clear();
|
deployables.clear();
|
||||||
if (runConfig->currentlyNeedsDeployment()) {
|
if (runConfig->currentlyNeedsDeployment()) {
|
||||||
deployingExecutable = true;
|
deployables.append(Deployable(executableFileName(),
|
||||||
deployables.append(qMakePair(executableFileName(),
|
QFileInfo(executableOnHost()).canonicalPath(),
|
||||||
QFileInfo(executableOnHost()).canonicalPath()));
|
&MaemoRunConfiguration::wasDeployed));
|
||||||
} else {
|
|
||||||
deployingExecutable = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (forDebugging && runConfig->debuggingHelpersNeedDeployment()) {
|
if (forDebugging && runConfig->debuggingHelpersNeedDeployment()) {
|
||||||
deployingDumperLib = true;
|
|
||||||
const QFileInfo &info(runConfig->dumperLib());
|
const QFileInfo &info(runConfig->dumperLib());
|
||||||
deployables.append(qMakePair(info.fileName(), info.canonicalPath()));
|
deployables.append(Deployable(info.fileName(), info.canonicalPath(),
|
||||||
} else {
|
&MaemoRunConfiguration::debuggingHelpersDeployed));
|
||||||
deployingDumperLib = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_progress.setProgressRange(0, deployables.count());
|
||||||
|
m_progress.setProgressValue(0);
|
||||||
|
m_progress.reportStarted();
|
||||||
deploy();
|
deploy();
|
||||||
} else {
|
} else {
|
||||||
deploymentFinished(false);
|
deploymentFinished(false);
|
||||||
@@ -1064,13 +1075,13 @@ void AbstractMaemoRunControl::startDeployment(bool forDebugging)
|
|||||||
void AbstractMaemoRunControl::deploy()
|
void AbstractMaemoRunControl::deploy()
|
||||||
{
|
{
|
||||||
if (!deployables.isEmpty()) {
|
if (!deployables.isEmpty()) {
|
||||||
QPair<QString, QString> pair = deployables.first();
|
const Deployable &deployable = deployables.first();
|
||||||
emit addToOutputWindow(this, tr("File to deploy: %1.").arg(pair.first));
|
emit addToOutputWindow(this, tr("File to deploy: %1.").arg(deployable.fileName));
|
||||||
|
|
||||||
QStringList cmdArgs;
|
QStringList cmdArgs;
|
||||||
cmdArgs << "-P" << port() << options() << pair.first << (devConfig.uname
|
cmdArgs << "-P" << port() << options() << deployable.fileName
|
||||||
+ "@" + devConfig.host + ":" + remoteDir());
|
<< (devConfig.uname + "@" + devConfig.host + ":" + remoteDir());
|
||||||
deployProcess.setWorkingDirectory(pair.second);
|
deployProcess.setWorkingDirectory(deployable.dir);
|
||||||
|
|
||||||
deployProcess.start(runConfig->scpCmd(), cmdArgs);
|
deployProcess.start(runConfig->scpCmd(), cmdArgs);
|
||||||
if (!deployProcess.waitForStarted()) {
|
if (!deployProcess.waitForStarted()) {
|
||||||
@@ -1100,15 +1111,9 @@ void AbstractMaemoRunControl::deployProcessFinished()
|
|||||||
if (deployProcess.exitCode() == 0) {
|
if (deployProcess.exitCode() == 0) {
|
||||||
emit addToOutputWindow(this, tr("Target deployed."));
|
emit addToOutputWindow(this, tr("Target deployed."));
|
||||||
success = true;
|
success = true;
|
||||||
if (deployingExecutable) {
|
Deployable deployable = deployables.takeFirst();
|
||||||
runConfig->wasDeployed();
|
(runConfig->*deployable.updateTimestamp)();
|
||||||
deployingExecutable = false;
|
m_progress.setProgressValue(m_progress.progressValue() + 1);
|
||||||
}
|
|
||||||
if (deployingDumperLib) {
|
|
||||||
runConfig->debuggingHelpersDeployed();
|
|
||||||
deployingDumperLib = false;
|
|
||||||
}
|
|
||||||
deployables.removeFirst();
|
|
||||||
} else {
|
} else {
|
||||||
emit error(this, tr("Deployment failed."));
|
emit error(this, tr("Deployment failed."));
|
||||||
success = false;
|
success = false;
|
||||||
@@ -1119,6 +1124,12 @@ void AbstractMaemoRunControl::deployProcessFinished()
|
|||||||
deploy();
|
deploy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AbstractMaemoRunControl::deploymentFinished(bool success)
|
||||||
|
{
|
||||||
|
m_progress.reportFinished();
|
||||||
|
handleDeploymentFinished(success);
|
||||||
|
}
|
||||||
|
|
||||||
const QString AbstractMaemoRunControl::executableOnHost() const
|
const QString AbstractMaemoRunControl::executableOnHost() const
|
||||||
{
|
{
|
||||||
return runConfig->executable();
|
return runConfig->executable();
|
||||||
@@ -1227,7 +1238,7 @@ void MaemoRunControl::start()
|
|||||||
startDeployment(false);
|
startDeployment(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MaemoRunControl::deploymentFinished(bool success)
|
void MaemoRunControl::handleDeploymentFinished(bool success)
|
||||||
{
|
{
|
||||||
if (success)
|
if (success)
|
||||||
startExecution();
|
startExecution();
|
||||||
@@ -1336,7 +1347,7 @@ void MaemoDebugRunControl::start()
|
|||||||
startDeployment(true);
|
startDeployment(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MaemoDebugRunControl::deploymentFinished(bool success)
|
void MaemoDebugRunControl::handleDeploymentFinished(bool success)
|
||||||
{
|
{
|
||||||
if (success) {
|
if (success) {
|
||||||
startGdbServer();
|
startGdbServer();
|
||||||
|
Reference in New Issue
Block a user