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
|
#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"
|
||||||
|
|
||||||
static const QLatin1String MAEMO_RC_ID(PREFIX);
|
static const QLatin1String MAEMO_RC_ID(PREFIX);
|
||||||
|
|||||||
@@ -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"));
|
|
||||||
|
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) {
|
if (running) {
|
||||||
state = QIcon::On;
|
state = QIcon::On;
|
||||||
toolTip = tr("Stop Maemo Emulator");
|
toolTip = tr("Stop Maemo Emulator");
|
||||||
|
} else {
|
||||||
|
state = QIcon::Off;
|
||||||
|
toolTip = tr("Start Maemo Emulator");
|
||||||
}
|
}
|
||||||
|
|
||||||
m_qemuAction->setToolTip(toolTip);
|
m_qemuAction->setToolTip(toolTip);
|
||||||
m_qemuAction->setIcon(icon.pixmap(iconSize, QIcon::Normal, state));
|
m_qemuAction->setIcon(icon.pixmap(iconSize, QIcon::Normal, state));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace Qt4ProjectManager
|
} // namespace Qt4ProjectManager
|
||||||
|
|||||||
@@ -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();
|
||||||
|
|||||||
@@ -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()
|
||||||
|
|||||||
@@ -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();
|
||||||
|
|||||||
@@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user