OSDN Git Service

QML Inspector: Disable debug actions when qml inspector is disabled
authorLasse Holmstedt <lasse.holmstedt@nokia.com>
Thu, 29 Jul 2010 14:58:12 +0000 (16:58 +0200)
committerLasse Holmstedt <lasse.holmstedt@nokia.com>
Thu, 29 Jul 2010 14:58:12 +0000 (16:58 +0200)
Reviewed-by: Thomas Hartmann
src/plugins/debugger/debuggeruiswitcher.cpp
src/plugins/debugger/debuggeruiswitcher.h
src/plugins/qmlprojectmanager/qmlprojectruncontrol.cpp

index a7db110..2c9b223 100644 (file)
@@ -153,6 +153,11 @@ DebuggerUISwitcher::~DebuggerUISwitcher()
     delete d;
 }
 
+QStringList DebuggerUISwitcher::supportedLanguages() const
+{
+    return d->m_languages;
+}
+
 void DebuggerUISwitcher::addMenuAction(Core::Command *command, const QString &langName,
                                        const QString &group)
 {
index 52a4e1c..522d5fd 100644 (file)
@@ -77,6 +77,8 @@ public:
     void addMenuAction(Core::Command *command, const QString &langName,
                        const QString &group = QString());
 
+    QStringList supportedLanguages() const;
+
     // Changes the active language UI to the one specified by langName.
     // Does nothing if automatic switching is toggled off from settings.
     void setActiveLanguage(const QString &langName);
index de6e9bb..3307df5 100644 (file)
@@ -37,7 +37,6 @@
 #include <projectexplorer/projectexplorerconstants.h>
 #include <projectexplorer/applicationlauncher.h>
 #include <utils/qtcassert.h>
-#include <debugger/debuggerconstants.h>
 
 #include <debugger/debuggerconstants.h>
 #include <debugger/debuggeruiswitcher.h>
@@ -147,8 +146,12 @@ QmlRunControlFactory::~QmlRunControlFactory()
 bool QmlRunControlFactory::canRun(RunConfiguration *runConfiguration,
                                   const QString &mode) const
 {
-    Q_UNUSED(mode);
-    return (qobject_cast<QmlProjectRunConfiguration*>(runConfiguration) != 0);
+    QmlProjectRunConfiguration *config = qobject_cast<QmlProjectRunConfiguration*>(runConfiguration);
+    if (mode == ProjectExplorer::Constants::RUNMODE) {
+        return config != 0;
+    } else {
+        return (config != 0) && Debugger::DebuggerUISwitcher::instance()->supportedLanguages().contains(Qml::Constants::LANG_QML);
+    }
 }
 
 RunControl *QmlRunControlFactory::create(RunConfiguration *runConfiguration,