forked from qt-creator/qt-creator
Maemo: Give more information to user about Qemu state.
Reviewed-by: kh1
This commit is contained in:
@@ -34,9 +34,13 @@
|
||||
#ifndef MAEMOCONSTANTS_H
|
||||
#define MAEMOCONSTANTS_H
|
||||
|
||||
#include <QLatin1String>
|
||||
|
||||
namespace Qt4ProjectManager {
|
||||
namespace Internal {
|
||||
|
||||
enum QemuStatus { QemuStarting, QemuFailedToStart, QemuFinished, QemuCrashed };
|
||||
|
||||
#define PREFIX "Qt4ProjectManager.MaemoRunConfiguration"
|
||||
|
||||
static const QLatin1String MAEMO_RC_ID(PREFIX);
|
||||
|
||||
@@ -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 (!m_qemuAction)
|
||||
return;
|
||||
|
||||
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 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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user