OSDN Git Service

QmlProject: Consistently enable/disable debug & run buttons
authorKai Koehne <kai.koehne@nokia.com>
Thu, 10 Jun 2010 07:10:11 +0000 (09:10 +0200)
committerKai Koehne <kai.koehne@nokia.com>
Thu, 10 Jun 2010 08:26:32 +0000 (10:26 +0200)
The heuristics to find the file to run and the logic that decides
whether the show / debug button is shown weren't in sync. Also, don't
try to run .qmlproject files if open in the editor.

Reviewed-by: Lasse Holmstedt
src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp

index da51b8b..3b959f8 100644 (file)
@@ -85,12 +85,7 @@ bool QmlProjectRunConfiguration::isEnabled(ProjectExplorer::BuildConfiguration *
 {
     Q_UNUSED(bc);
 
-    if (!QFile::exists(mainScript())
-        || !Core::ICore::instance()->mimeDatabase()->findByFile(mainScript()).matchesType(QLatin1String("application/x-qml")))
-    {
-        return false;
-    }
-    return true;
+    return m_isEnabled;
 }
 
 void QmlProjectRunConfiguration::ctor()
@@ -326,15 +321,17 @@ void QmlProjectRunConfiguration::changeCurrentFile(Core::IEditor *editor)
         bool enable = false;
         if (editor) {
             m_currentFileFilename = editor->file()->fileName();
-            if (Core::ICore::instance()->mimeDatabase()->findByFile(mainScript()).matchesType(QLatin1String("application/x-qml")))
+            if (Core::ICore::instance()->mimeDatabase()->findByFile(mainScript()).type() == QLatin1String("application/x-qml"))
                 enable = true;
-        } else {
+        }
+        if (!editor
+            || Core::ICore::instance()->mimeDatabase()->findByFile(mainScript()).type() == QLatin1String("application/x-qmlproject")) {
             // find a qml file with lowercase filename. This is slow but only done in initialization/other border cases.
             foreach(const QString& filename, m_projectTarget->qmlProject()->files()) {
                 const QFileInfo fi(filename);
 
                 if (!filename.isEmpty() && fi.baseName()[0].isLower()
-                    && Core::ICore::instance()->mimeDatabase()->findByFile(fi).matchesType(QLatin1String("application/x-qml")))
+                    && Core::ICore::instance()->mimeDatabase()->findByFile(fi).type() == QLatin1String("application/x-qml"))
                 {
                     m_currentFileFilename = filename;
                     enable = true;