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
This commit is contained in:
Lasse Holmstedt
2010-03-08 14:36:44 +01:00
parent c5d6c139c1
commit 61ca001e67
3 changed files with 26 additions and 1 deletions

View File

@@ -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);