Maemo: Give more information to user about Qemu state.

Reviewed-by: kh1
This commit is contained in:
ck
2010-05-19 11:00:43 +02:00
parent a9645059ee
commit de7bc1d9cf
6 changed files with 77 additions and 21 deletions

View File

@@ -34,8 +34,12 @@
#ifndef MAEMOCONSTANTS_H #ifndef MAEMOCONSTANTS_H
#define MAEMOCONSTANTS_H #define MAEMOCONSTANTS_H
#include <QLatin1String>
namespace Qt4ProjectManager { namespace Qt4ProjectManager {
namespace Internal { namespace Internal {
enum QemuStatus { QemuStarting, QemuFailedToStart, QemuFinished, QemuCrashed };
#define PREFIX "Qt4ProjectManager.MaemoRunConfiguration" #define PREFIX "Qt4ProjectManager.MaemoRunConfiguration"
@@ -49,7 +53,7 @@ static const QLatin1String LastDeployedKey(PREFIX ".LastDeployed");
static const QLatin1String DebuggingHelpersLastDeployedKey(PREFIX ".DebuggingHelpersLastDeployed"); static const QLatin1String DebuggingHelpersLastDeployedKey(PREFIX ".DebuggingHelpersLastDeployed");
static const QLatin1String ProFileKey(".ProFile"); static const QLatin1String ProFileKey(".ProFile");
} // namespace Internal } // namespace Internal
} // namespace Qt4ProjectManager } // namespace Qt4ProjectManager
#endif // MAEMOCONSTANTS_H #endif // MAEMOCONSTANTS_H

View File

@@ -51,6 +51,7 @@
#include <QtCore/QTextStream> #include <QtCore/QTextStream>
#include <QtGui/QAction> #include <QtGui/QAction>
#include <QtGui/QMessageBox>
namespace Qt4ProjectManager { namespace Qt4ProjectManager {
namespace Internal { namespace Internal {
@@ -187,20 +188,55 @@ MaemoManager::triggered()
} }
void void
MaemoManager::updateQemuSimulatorStarter(bool running) MaemoManager::qemuStatusChanged(QemuStatus status, const QString &error)
{ {
if (m_qemuAction) { if (!m_qemuAction)
QIcon::State state = QIcon::Off; return;
QString toolTip(tr("Start Maemo Emulator"));
if (running) {
state = QIcon::On;
toolTip = tr("Stop Maemo Emulator");
}
m_qemuAction->setToolTip(toolTip); bool running;
m_qemuAction->setIcon(icon.pixmap(iconSize, QIcon::Normal, state)); 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);
} }
} // namespace Internal 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 Qt4ProjectManager } // namespace Qt4ProjectManager

View File

@@ -30,6 +30,8 @@
#ifndef MAEMOMANAGER_H #ifndef MAEMOMANAGER_H
#define MAEMOMANAGER_H #define MAEMOMANAGER_H
#include "maemoconstants.h"
#include <QtCore/QObject> #include <QtCore/QObject>
#include <QtCore/QSet> #include <QtCore/QSet>
@@ -69,12 +71,13 @@ public:
void removeQemuSimulatorStarter(Project *project); void removeQemuSimulatorStarter(Project *project);
void setQemuSimulatorStarterEnabled(bool state); void setQemuSimulatorStarterEnabled(bool state);
void updateQemuIcon(bool running);
MaemoSettingsPage *settingsPage() const { return m_settingsPage; } MaemoSettingsPage *settingsPage() const { return m_settingsPage; }
public slots: public slots:
void triggered(); void triggered();
void updateQemuSimulatorStarter(bool running); void qemuStatusChanged(QemuStatus status, const QString &error);
signals: signals:
void startStopQemu(); void startStopQemu();

View File

@@ -100,13 +100,16 @@ void MaemoRunConfiguration::init()
this, SLOT(proFileUpdate(Qt4ProjectManager::Internal::Qt4ProFileNode*))); this, SLOT(proFileUpdate(Qt4ProjectManager::Internal::Qt4ProFileNode*)));
qemu = new QProcess(this); qemu = new QProcess(this);
connect(qemu, SIGNAL(error(QProcess::ProcessError)), this,
SLOT(qemuProcessError(QProcess::ProcessError)));
connect(qemu, SIGNAL(finished(int, QProcess::ExitStatus)), this, connect(qemu, SIGNAL(finished(int, QProcess::ExitStatus)), this,
SLOT(qemuProcessFinished())); SLOT(qemuProcessFinished()));
connect(&MaemoManager::instance(), SIGNAL(startStopQemu()), this, connect(&MaemoManager::instance(), SIGNAL(startStopQemu()), this,
SLOT(startStopQemu())); SLOT(startStopQemu()));
connect(this, SIGNAL(qemuProcessStatus(bool)), &MaemoManager::instance(), connect(this, SIGNAL(qemuProcessStatus(QemuStatus, QString)),
SLOT(updateQemuSimulatorStarter(bool))); &MaemoManager::instance(),
SLOT(qemuStatusChanged(QemuStatus,QString)));
} }
MaemoRunConfiguration::~MaemoRunConfiguration() MaemoRunConfiguration::~MaemoRunConfiguration()
@@ -475,7 +478,6 @@ void MaemoRunConfiguration::startStopQemu()
if (qemu->state() == QProcess::Running) { if (qemu->state() == QProcess::Running) {
qemu->terminate(); qemu->terminate();
qemu->kill(); qemu->kill();
emit qemuProcessStatus(false);
} }
return; return;
} }
@@ -505,12 +507,20 @@ void MaemoRunConfiguration::startStopQemu()
; // keep ; // keep
qemu->start(app % QLatin1Char(' ') % simulatorArgs(), QIODevice::ReadWrite); qemu->start(app % QLatin1Char(' ') % simulatorArgs(), QIODevice::ReadWrite);
emit qemuProcessStatus(qemu->waitForStarted()); emit qemuProcessStatus(QemuStarting);
} }
void MaemoRunConfiguration::qemuProcessFinished() 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() void MaemoRunConfiguration::updateDeviceConfigurations()

View File

@@ -30,11 +30,13 @@
#ifndef MAEMORUNCONFIGURATION_H #ifndef MAEMORUNCONFIGURATION_H
#define MAEMORUNCONFIGURATION_H #define MAEMORUNCONFIGURATION_H
#include "maemoconstants.h"
#include "maemodeviceconfigurations.h" #include "maemodeviceconfigurations.h"
#include <projectexplorer/runconfiguration.h> #include <projectexplorer/runconfiguration.h>
#include <QtCore/QDateTime> #include <QtCore/QDateTime>
#include <QtCore/QProcess>
#include <QtCore/QStringList> #include <QtCore/QStringList>
QT_FORWARD_DECLARE_CLASS(QProcess) QT_FORWARD_DECLARE_CLASS(QProcess)
@@ -108,7 +110,7 @@ signals:
void deviceConfigurationChanged(ProjectExplorer::Target *target); void deviceConfigurationChanged(ProjectExplorer::Target *target);
void targetInformationChanged() const; void targetInformationChanged() const;
void cachedSimulatorInformationChanged() const; void cachedSimulatorInformationChanged() const;
void qemuProcessStatus(bool running); void qemuProcessStatus(QemuStatus, const QString &error = QString());
protected: protected:
MaemoRunConfiguration(Qt4Target *parent, MaemoRunConfiguration *source); MaemoRunConfiguration(Qt4Target *parent, MaemoRunConfiguration *source);
@@ -120,6 +122,7 @@ private slots:
void startStopQemu(); void startStopQemu();
void qemuProcessFinished(); void qemuProcessFinished();
void qemuProcessError(QProcess::ProcessError error);
private: private:
void init(); void init();

View File

@@ -243,7 +243,7 @@ void MaemoRunConfigurationFactory::updateMaemoEmulatorStarter(Target *target) co
} }
} }
MaemoManager::instance().updateQemuSimulatorStarter(isRunning); MaemoManager::instance().updateQemuIcon(isRunning);
MaemoManager::instance().setQemuSimulatorStarterEnabled(enable); MaemoManager::instance().setQemuSimulatorStarterEnabled(enable);
} }