Commit adefff60 authored by kh1's avatar kh1
Browse files

Fix broken enabled/ disabled emulator startbutton state.

Functionality depends entirely on the active start-up project, all other
projects should have the the button disabled if they have no Maemo run
config or the the run config is not the active on.

Reviewed-by: ck
parent 044ca68e
......@@ -144,7 +144,7 @@ MaemoManager::addQemuSimulatorStarter(Project *project)
m_qemuCommand = actionManager->registerAction(action, "MaemoEmulator",
QList<int>() << Core::Constants::C_GLOBAL_ID);
modeManager->addAction(m_qemuCommand, 1);
m_qemuCommand->action()->setEnabled(true);
m_qemuCommand->action()->setEnabled(false);
m_qemuCommand->setAttribute(Core::Command::CA_UpdateText);
m_qemuCommand->setAttribute(Core::Command::CA_UpdateIcon);
......@@ -154,9 +154,11 @@ MaemoManager::addQemuSimulatorStarter(Project *project)
void
MaemoManager::removeQemuSimulatorStarter(Project *project)
{
projects.remove(project);
if (projects.isEmpty() && m_qemuCommand)
m_qemuCommand->action()->setVisible(false);
if (projects.contains(project)) {
projects.remove(project);
if (projects.isEmpty() && m_qemuCommand)
m_qemuCommand->action()->setVisible(false);
}
}
void
......
......@@ -97,9 +97,6 @@ void MaemoRunConfiguration::init()
connect(qt4Target(), SIGNAL(targetInformationChanged()), this,
SLOT(invalidateCachedTargetInformation()));
connect(qt4Target(), SIGNAL(targetInformationChanged()), this,
SLOT(enabledStateChanged()));
connect(qt4Target()->qt4Project(),
SIGNAL(proFileUpdated(Qt4ProjectManager::Internal::Qt4ProFileNode*)),
this, SLOT(proFileUpdate(Qt4ProjectManager::Internal::Qt4ProFileNode*)));
......@@ -232,6 +229,7 @@ bool MaemoRunConfiguration::fileNeedsDeployment(const QString &path,
void MaemoRunConfiguration::setDeviceConfig(const MaemoDeviceConfig &devConf)
{
m_devConfig = devConf;
emit deviceConfigurationChanged(target());
}
MaemoDeviceConfig MaemoRunConfiguration::deviceConfig() const
......@@ -454,6 +452,10 @@ void MaemoRunConfiguration::updateSimulatorInformation() const
void MaemoRunConfiguration::startStopQemu()
{
const MaemoDeviceConfig &config = deviceConfig();
if (!config.isValid()|| config.type != MaemoDeviceConfig::Simulator)
return;
if (qemu->state() != QProcess::NotRunning) {
if (qemu->state() == QProcess::Running) {
qemu->terminate();
......@@ -496,11 +498,6 @@ void MaemoRunConfiguration::qemuProcessFinished()
emit qemuProcessStatus(false);
}
void MaemoRunConfiguration::enabledStateChanged()
{
MaemoManager::instance().setQemuSimulatorStarterEnabled(isEnabled());
}
void MaemoRunConfiguration::updateDeviceConfigurations()
{
qDebug("%s: Current devid = %llu", Q_FUNC_INFO, m_devConfig.internalId);
......
......@@ -64,7 +64,6 @@ public:
virtual ~MaemoRunConfiguration();
bool isEnabled(ProjectExplorer::BuildConfiguration *config) const;
using RunConfiguration::isEnabled;
QWidget *configurationWidget();
Qt4Target *qt4Target() const;
Qt4BuildConfiguration *activeQt4BuildConfiguration() const;
......@@ -102,6 +101,7 @@ public:
signals:
void deviceConfigurationsUpdated();
void deviceConfigurationChanged(ProjectExplorer::Target *target);
void targetInformationChanged() const;
void cachedSimulatorInformationChanged() const;
void qemuProcessStatus(bool running);
......@@ -118,8 +118,6 @@ private slots:
void startStopQemu();
void qemuProcessFinished();
void enabledStateChanged();
private:
void init();
void updateTarget() const;
......
......@@ -67,8 +67,9 @@ MaemoRunConfigurationFactory::MaemoRunConfigurationFactory(QObject *parent)
this, SLOT(projectAdded(ProjectExplorer::Project*)));
connect(explorer->session(), SIGNAL(projectRemoved(ProjectExplorer::Project*)),
this, SLOT(projectRemoved(ProjectExplorer::Project*)));
connect(explorer, SIGNAL(currentProjectChanged(ProjectExplorer::Project*)),
this, SLOT(currentProjectChanged(ProjectExplorer::Project*)));
connect(explorer->session(),
SIGNAL(startupProjectChanged(ProjectExplorer::Project*)), this,
SLOT(projectChanged(ProjectExplorer::Project*)));
}
MaemoRunConfigurationFactory::~MaemoRunConfigurationFactory()
......@@ -151,65 +152,100 @@ RunConfiguration *MaemoRunConfigurationFactory::clone(Target *parent,
return new MaemoRunConfiguration(static_cast<Qt4Target *>(parent), old);
}
void MaemoRunConfigurationFactory::projectAdded(
ProjectExplorer::Project *project)
void MaemoRunConfigurationFactory::projectAdded(ProjectExplorer::Project *project)
{
connect(project, SIGNAL(addedTarget(ProjectExplorer::Target*)), this,
SLOT(targetAdded(ProjectExplorer::Target*)));
connect(project, SIGNAL(removedTarget(ProjectExplorer::Target*)), this,
SLOT(targetRemoved(ProjectExplorer::Target*)));
connect(project, SIGNAL(activeTargetChanged(ProjectExplorer::Target*)),
this, SLOT(targetChanged(ProjectExplorer::Target*)));
foreach (Target *target, project->targets())
targetAdded(target);
}
void MaemoRunConfigurationFactory::projectRemoved(
ProjectExplorer::Project *project)
void MaemoRunConfigurationFactory::projectRemoved(ProjectExplorer::Project *project)
{
disconnect(project, SIGNAL(addedTarget(ProjectExplorer::Target*)), this,
SLOT(targetAdded(ProjectExplorer::Target*)));
disconnect(project, SIGNAL(removedTarget(ProjectExplorer::Target*)), this,
SLOT(targetRemoved(ProjectExplorer::Target*)));
disconnect(project, SIGNAL(activeTargetChanged(ProjectExplorer::Target*)),
this, SLOT(targetChanged(ProjectExplorer::Target*)));
foreach (Target *target, project->targets())
targetRemoved(target);
}
void MaemoRunConfigurationFactory::projectChanged(ProjectExplorer::Project *project)
{
if (project)
updateMaemoEmulatorStarter(project->target(QLatin1String(MAEMO_DEVICE_TARGET_ID)));
}
void MaemoRunConfigurationFactory::targetAdded(ProjectExplorer::Target *target)
{
if (target->id() != QLatin1String(MAEMO_DEVICE_TARGET_ID))
if (!target || target->id() != QLatin1String(MAEMO_DEVICE_TARGET_ID))
return;
MaemoManager::instance().addQemuSimulatorStarter(target->project());
foreach (RunConfiguration *runConfig, target->runConfigurations()) {
if (MaemoRunConfiguration *mrc = qobject_cast<MaemoRunConfiguration *> (runConfig)) {
connect(mrc, SIGNAL(deviceConfigurationChanged(ProjectExplorer::Target*)),
this, SLOT(targetChanged(ProjectExplorer::Target*)));
}
}
updateMaemoEmulatorStarter(target);
}
void MaemoRunConfigurationFactory::targetRemoved(ProjectExplorer::Target *target)
{
if (target->id() != QLatin1String(MAEMO_DEVICE_TARGET_ID))
if (!target || target->id() != QLatin1String(MAEMO_DEVICE_TARGET_ID))
return;
MaemoManager::instance().removeQemuSimulatorStarter(target->project());
foreach (RunConfiguration *runConfig, target->runConfigurations()) {
if (MaemoRunConfiguration *mrc = qobject_cast<MaemoRunConfiguration *> (runConfig)) {
disconnect(mrc, SIGNAL(deviceConfigurationChanged(ProjectExplorer::Target*)),
this, SLOT(targetChanged(ProjectExplorer::Target*)));
}
}
updateMaemoEmulatorStarter(target);
}
void MaemoRunConfigurationFactory::currentProjectChanged(
ProjectExplorer::Project *project)
void MaemoRunConfigurationFactory::targetChanged(ProjectExplorer::Target *target)
{
if (!project)
return;
Target *maemoTarget = project->target(QLatin1String(MAEMO_DEVICE_TARGET_ID));
MaemoManager::instance().setQemuSimulatorStarterEnabled(maemoTarget != 0);
if (target)
updateMaemoEmulatorStarter(target);
}
void MaemoRunConfigurationFactory::updateMaemoEmulatorStarter(Target *target) const
{
bool enable = false;
bool isRunning = false;
if (maemoTarget
&& project->activeTarget() == maemoTarget
&& maemoTarget->activeRunConfiguration()) {
MaemoRunConfiguration *mrc = qobject_cast<MaemoRunConfiguration *>
(maemoTarget->activeRunConfiguration());
if (mrc)
if (target) {
MaemoRunConfiguration *mrc = 0;
if (target->project()->activeTarget() == target)
mrc = qobject_cast<MaemoRunConfiguration *> (target->activeRunConfiguration());
if (mrc) {
isRunning = mrc->isQemuRunning();
const MaemoDeviceConfig &config = mrc ? mrc->deviceConfig() : MaemoDeviceConfig();
ProjectExplorerPlugin *explorer = ProjectExplorerPlugin::instance();
if (config.isValid()
&& !mrc->simulatorPath().isEmpty()
&& config.type == MaemoDeviceConfig::Simulator
&& explorer->startupProject() == target->project()) {
enable = true;
}
}
}
MaemoManager::instance().updateQemuSimulatorStarter(isRunning);
MaemoManager::instance().setQemuSimulatorStarterEnabled(enable);
}
......
......@@ -75,11 +75,14 @@ public:
private slots:
void projectAdded(ProjectExplorer::Project *project);
void projectRemoved(ProjectExplorer::Project *project);
void projectChanged(ProjectExplorer::Project *project);
void targetAdded(ProjectExplorer::Target *target);
void targetRemoved(ProjectExplorer::Target *target);
void targetChanged(ProjectExplorer::Target *target);
void currentProjectChanged(ProjectExplorer::Project *project);
private:
void updateMaemoEmulatorStarter(ProjectExplorer::Target *target) const;
};
class MaemoRunControlFactory : public IRunControlFactory
......
Supports Markdown
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