Commit de7bc1d9 authored by ck's avatar ck
Browse files

Maemo: Give more information to user about Qemu state.

Reviewed-by: kh1
parent a9645059
......@@ -34,8 +34,12 @@
#ifndef MAEMOCONSTANTS_H
#define MAEMOCONSTANTS_H
#include <QLatin1String>
namespace Qt4ProjectManager {
namespace Internal {
namespace Internal {
enum QemuStatus { QemuStarting, QemuFailedToStart, QemuFinished, QemuCrashed };
#define PREFIX "Qt4ProjectManager.MaemoRunConfiguration"
......@@ -49,7 +53,7 @@ static const QLatin1String LastDeployedKey(PREFIX ".LastDeployed");
static const QLatin1String DebuggingHelpersLastDeployedKey(PREFIX ".DebuggingHelpersLastDeployed");
static const QLatin1String ProFileKey(".ProFile");
} // namespace Internal
} // namespace Internal
} // namespace Qt4ProjectManager
#endif // MAEMOCONSTANTS_H
......@@ -51,6 +51,7 @@
#include <QtCore/QTextStream>
#include <QtGui/QAction>
#include <QtGui/QMessageBox>
namespace Qt4ProjectManager {
namespace Internal {
......@@ -187,20 +188,55 @@ MaemoManager::triggered()
}
void
MaemoManager::updateQemuSimulatorStarter(bool running)
MaemoManager::qemuStatusChanged(QemuStatus status, const QString &error)
{
if (m_qemuAction) {
QIcon::State state = QIcon::Off;
QString toolTip(tr("Start Maemo Emulator"));
if (running) {
state = QIcon::On;
toolTip = tr("Stop Maemo Emulator");
}
if (!m_qemuAction)
return;
m_qemuAction->setToolTip(toolTip);
m_qemuAction->setIcon(icon.pixmap(iconSize, QIcon::Normal, state));
bool running;
QString message;
switch (status) {
case QemuStarting:
running = true;
break;
case QemuFailedToStart:
running = false;
message = tr("Qemu failed to start: %1").arg(error);
break;
case QemuCrashed:
running = false;
message = tr("Qemu crashed");
break;
case QemuFinished:
running = false;
break;
default:
Q_ASSERT(!"Missing handling of Qemu status");
}
if (!message.isEmpty())
QMessageBox::warning(0, tr("Qemu error"), message);
updateQemuIcon(running);
}
void MaemoManager::updateQemuIcon(bool running)
{
if (!m_qemuAction)
return;
QIcon::State state;
QString toolTip;
if (running) {
state = QIcon::On;
toolTip = tr("Stop Maemo Emulator");
} else {
state = QIcon::Off;
toolTip = tr("Start Maemo Emulator");
}
m_qemuAction->setToolTip(toolTip);
m_qemuAction->setIcon(icon.pixmap(iconSize, QIcon::Normal, state));
}
} // namespace Internal
} // namespace Internal
} // namespace Qt4ProjectManager
......@@ -30,6 +30,8 @@
#ifndef MAEMOMANAGER_H
#define MAEMOMANAGER_H
#include "maemoconstants.h"
#include <QtCore/QObject>
#include <QtCore/QSet>
......@@ -69,12 +71,13 @@ public:
void removeQemuSimulatorStarter(Project *project);
void setQemuSimulatorStarterEnabled(bool state);
void updateQemuIcon(bool running);
MaemoSettingsPage *settingsPage() const { return m_settingsPage; }
public slots:
void triggered();
void updateQemuSimulatorStarter(bool running);
void qemuStatusChanged(QemuStatus status, const QString &error);
signals:
void startStopQemu();
......
......@@ -100,13 +100,16 @@ void MaemoRunConfiguration::init()
this, SLOT(proFileUpdate(Qt4ProjectManager::Internal::Qt4ProFileNode*)));
qemu = new QProcess(this);
connect(qemu, SIGNAL(error(QProcess::ProcessError)), this,
SLOT(qemuProcessError(QProcess::ProcessError)));
connect(qemu, SIGNAL(finished(int, QProcess::ExitStatus)), this,
SLOT(qemuProcessFinished()));
connect(&MaemoManager::instance(), SIGNAL(startStopQemu()), this,
SLOT(startStopQemu()));
connect(this, SIGNAL(qemuProcessStatus(bool)), &MaemoManager::instance(),
SLOT(updateQemuSimulatorStarter(bool)));
connect(this, SIGNAL(qemuProcessStatus(QemuStatus, QString)),
&MaemoManager::instance(),
SLOT(qemuStatusChanged(QemuStatus,QString)));
}
MaemoRunConfiguration::~MaemoRunConfiguration()
......@@ -475,7 +478,6 @@ void MaemoRunConfiguration::startStopQemu()
if (qemu->state() == QProcess::Running) {
qemu->terminate();
qemu->kill();
emit qemuProcessStatus(false);
}
return;
}
......@@ -505,12 +507,20 @@ void MaemoRunConfiguration::startStopQemu()
; // keep
qemu->start(app % QLatin1Char(' ') % simulatorArgs(), QIODevice::ReadWrite);
emit qemuProcessStatus(qemu->waitForStarted());
emit qemuProcessStatus(QemuStarting);
}
void MaemoRunConfiguration::qemuProcessFinished()
{
emit qemuProcessStatus(false);
const QemuStatus status
= qemu->exitStatus() == QProcess::CrashExit ? QemuCrashed : QemuFinished;
emit qemuProcessStatus(status);
}
void MaemoRunConfiguration::qemuProcessError(QProcess::ProcessError error)
{
if (error == QProcess::FailedToStart)
emit qemuProcessStatus(QemuFailedToStart, qemu->errorString());
}
void MaemoRunConfiguration::updateDeviceConfigurations()
......
......@@ -30,11 +30,13 @@
#ifndef MAEMORUNCONFIGURATION_H
#define MAEMORUNCONFIGURATION_H
#include "maemoconstants.h"
#include "maemodeviceconfigurations.h"
#include <projectexplorer/runconfiguration.h>
#include <QtCore/QDateTime>
#include <QtCore/QProcess>
#include <QtCore/QStringList>
QT_FORWARD_DECLARE_CLASS(QProcess)
......@@ -108,7 +110,7 @@ signals:
void deviceConfigurationChanged(ProjectExplorer::Target *target);
void targetInformationChanged() const;
void cachedSimulatorInformationChanged() const;
void qemuProcessStatus(bool running);
void qemuProcessStatus(QemuStatus, const QString &error = QString());
protected:
MaemoRunConfiguration(Qt4Target *parent, MaemoRunConfiguration *source);
......@@ -120,6 +122,7 @@ private slots:
void startStopQemu();
void qemuProcessFinished();
void qemuProcessError(QProcess::ProcessError error);
private:
void init();
......
......@@ -243,7 +243,7 @@ void MaemoRunConfigurationFactory::updateMaemoEmulatorStarter(Target *target) co
}
}
MaemoManager::instance().updateQemuSimulatorStarter(isRunning);
MaemoManager::instance().updateQemuIcon(isRunning);
MaemoManager::instance().setQemuSimulatorStarterEnabled(enable);
}
......
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