Commit 61ca001e authored by Lasse Holmstedt's avatar Lasse Holmstedt

QML project executable file to default to lowercase .qml file

Use a lowercase .qml file found in project tree if no current file is
selected. This way we don't have to disable run controls if there are
some files to execute.

Reviewed-by: kkoehne
parent c5d6c139
......@@ -31,6 +31,7 @@
#include "qmlprojectfile.h"
#include "qmlprojectmanagerconstants.h"
#include "fileformat/qmlprojectitem.h"
#include "qmlprojectrunconfiguration.h"
#include <coreplugin/icore.h>
#include <coreplugin/messagemanager.h>
......@@ -255,6 +256,10 @@ bool QmlProject::fromMap(const QVariantMap &map)
}
refresh(Everything);
// FIXME workaround to guarantee that run/debug actions are enabled if a valid file exists
QmlProjectRunConfiguration *runConfig = static_cast<QmlProjectRunConfiguration*>(activeTarget()->activeRunConfiguration());
runConfig->changeCurrentFile(0);
return true;
}
......
......@@ -54,6 +54,7 @@ QmlProjectRunConfiguration::QmlProjectRunConfiguration(Internal::QmlProjectTarge
ProjectExplorer::RunConfiguration(parent, QLatin1String(Constants::QML_RC_ID)),
m_debugServerAddress("127.0.0.1"),
m_debugServerPort(Constants::QML_DEFAULT_DEBUG_SERVER_PORT),
m_projectTarget(parent),
m_usingCurrentFile(false),
m_isEnabled(false)
{
......@@ -294,6 +295,20 @@ void QmlProjectRunConfiguration::changeCurrentFile(Core::IEditor *editor)
m_currentFileFilename = editor->file()->fileName();
if (Core::ICore::instance()->mimeDatabase()->findByFile(mainScript()).matchesType(QLatin1String("application/x-qml")))
enable = true;
} else {
// 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")))
{
m_currentFileFilename = filename;
enable = true;
break;
}
}
}
setEnabled(enable);
......
......@@ -72,8 +72,11 @@ public:
QVariantMap toMap() const;
private slots:
public slots:
void changeCurrentFile(Core::IEditor*);
private slots:
QString mainScript() const;
void setMainScript(const QString &scriptFile);
......@@ -102,6 +105,8 @@ private:
QString m_debugServerAddress;
uint m_debugServerPort;
Internal::QmlProjectTarget *m_projectTarget;
bool m_usingCurrentFile;
bool m_isEnabled;
......
Markdown is supported
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