forked from qt-creator/qt-creator
RemoteLinux: Make run configuration's isEnabled() function smarter.
We move some checks over from the factory's canRun() method. A a result, the disabled "run" button will show a more informative tool tip. Change-Id: I88e92c9221907ccfdc296fe13b8e8788cec865c2 Reviewed-on: http://codereview.qt.nokia.com/241 Reviewed-by: Daniel Teske <daniel.teske@nokia.com>
This commit is contained in:
@@ -43,10 +43,15 @@
|
||||
#include "qt4maemotarget.h"
|
||||
#include "maemoqtversion.h"
|
||||
|
||||
#include <analyzerbase/analyzerconstants.h>
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/messagemanager.h>
|
||||
|
||||
#include <debugger/debuggerconstants.h>
|
||||
|
||||
#include <projectexplorer/projectexplorer.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <projectexplorer/session.h>
|
||||
|
||||
#include <qtsupport/qtoutputformatter.h>
|
||||
@@ -131,14 +136,33 @@ Qt4BuildConfiguration *MaemoRunConfiguration::activeQt4BuildConfiguration() cons
|
||||
|
||||
bool MaemoRunConfiguration::isEnabled() const
|
||||
{
|
||||
return m_validParse;
|
||||
if (!m_validParse) {
|
||||
m_disabledReason = tr("The .pro file could not be parsed/");
|
||||
return false;
|
||||
}
|
||||
if (!deviceConfig()) {
|
||||
m_disabledReason = tr("No device configuration set.");
|
||||
return false;
|
||||
}
|
||||
if (!activeQt4BuildConfiguration()) {
|
||||
m_disabledReason = tr("No active build configuration.");
|
||||
return false;
|
||||
}
|
||||
if (remoteExecutableFilePath().isEmpty()) {
|
||||
m_disabledReason = tr("Don't know what to run.");
|
||||
return false;
|
||||
}
|
||||
if (!hasEnoughFreePorts(ProjectExplorer::Constants::RUNMODE)) {
|
||||
m_disabledReason = tr("Not enough free ports on the device.");
|
||||
return false;
|
||||
}
|
||||
m_disabledReason.clear();
|
||||
return true;
|
||||
}
|
||||
|
||||
QString MaemoRunConfiguration::disabledReason() const
|
||||
{
|
||||
if (!m_validParse)
|
||||
return tr("The .pro file could not be parsed");
|
||||
return QString();
|
||||
return m_disabledReason;
|
||||
}
|
||||
|
||||
QWidget *MaemoRunConfiguration::createConfigurationWidget()
|
||||
@@ -345,6 +369,23 @@ int MaemoRunConfiguration::portsUsedByDebuggers() const
|
||||
}
|
||||
}
|
||||
|
||||
bool MaemoRunConfiguration::hasEnoughFreePorts(const QString &mode) const
|
||||
{
|
||||
const int freePortCount = freePorts().count();
|
||||
const AbstractQt4MaemoTarget * const maemoTarget
|
||||
= qobject_cast<AbstractQt4MaemoTarget *>(target());
|
||||
const bool remoteMountsAllowed = maemoTarget && maemoTarget->allowsRemoteMounts();
|
||||
if (remoteMountsAllowed && freePortCount == 0)
|
||||
return false;
|
||||
const int mountDirCount = remoteMountsAllowed
|
||||
? remoteMounts()->validMountSpecificationCount() : 0;
|
||||
if (mode == Debugger::Constants::DEBUGMODE)
|
||||
return freePortCount >= mountDirCount + portsUsedByDebuggers();
|
||||
if (mode == ProjectExplorer::Constants::RUNMODE || Analyzer::Constants::MODE_ANALYZE)
|
||||
return freePortCount >= mountDirCount;
|
||||
return false;
|
||||
}
|
||||
|
||||
void MaemoRunConfiguration::updateDeviceConfigurations()
|
||||
{
|
||||
emit deviceConfigurationChanged(target());
|
||||
|
@@ -122,6 +122,7 @@ public:
|
||||
void setSystemEnvironment(const Utils::Environment &environment);
|
||||
|
||||
int portsUsedByDebuggers() const;
|
||||
bool hasEnoughFreePorts(const QString &mode) const;
|
||||
|
||||
QString proFilePath() const;
|
||||
|
||||
@@ -160,6 +161,7 @@ private:
|
||||
Utils::Environment m_systemEnvironment;
|
||||
QList<Utils::EnvironmentItem> m_userEnvironmentChanges;
|
||||
bool m_validParse;
|
||||
mutable QString m_disabledReason;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -162,29 +162,9 @@ bool MaemoRunControlFactory::canRun(RunConfiguration *runConfiguration,
|
||||
{
|
||||
const MaemoRunConfiguration * const maemoRunConfig
|
||||
= qobject_cast<MaemoRunConfiguration *>(runConfiguration);
|
||||
if (!maemoRunConfig
|
||||
|| !maemoRunConfig->deviceConfig()
|
||||
|| !maemoRunConfig->activeQt4BuildConfiguration()
|
||||
|| maemoRunConfig->remoteExecutableFilePath().isEmpty())
|
||||
if (!maemoRunConfig || !maemoRunConfig->isEnabled())
|
||||
return false;
|
||||
const int freePortCount = maemoRunConfig->freePorts().count();
|
||||
|
||||
const AbstractQt4MaemoTarget * const maemoTarget
|
||||
= qobject_cast<AbstractQt4MaemoTarget *>(maemoRunConfig->target());
|
||||
const bool remoteMountsAllowed
|
||||
= maemoTarget && maemoTarget->allowsRemoteMounts();
|
||||
if (remoteMountsAllowed && freePortCount == 0)
|
||||
return false;
|
||||
const int mountDirCount
|
||||
= remoteMountsAllowed
|
||||
? maemoRunConfig->remoteMounts()->validMountSpecificationCount()
|
||||
: 0;
|
||||
if (mode == Debugger::Constants::DEBUGMODE)
|
||||
return freePortCount >= mountDirCount + maemoRunConfig->portsUsedByDebuggers();
|
||||
if (mode == ProjectExplorer::Constants::RUNMODE
|
||||
|| Analyzer::Constants::MODE_ANALYZE)
|
||||
return freePortCount >= mountDirCount;
|
||||
return false;
|
||||
return maemoRunConfig->hasEnoughFreePorts(mode);
|
||||
}
|
||||
|
||||
RunControl* MaemoRunControlFactory::create(RunConfiguration *runConfig,
|
||||
|
Reference in New Issue
Block a user