Skip to content
Snippets Groups Projects
Commit ef48306b authored by Kai Koehne's avatar Kai Koehne
Browse files

QmlProject: Consistently enable/disable debug & run buttons

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
parent 7f90a96f
No related branches found
No related tags found
No related merge requests found
...@@ -85,12 +85,7 @@ bool QmlProjectRunConfiguration::isEnabled(ProjectExplorer::BuildConfiguration * ...@@ -85,12 +85,7 @@ bool QmlProjectRunConfiguration::isEnabled(ProjectExplorer::BuildConfiguration *
{ {
Q_UNUSED(bc); Q_UNUSED(bc);
if (!QFile::exists(mainScript()) return m_isEnabled;
|| !Core::ICore::instance()->mimeDatabase()->findByFile(mainScript()).matchesType(QLatin1String("application/x-qml")))
{
return false;
}
return true;
} }
void QmlProjectRunConfiguration::ctor() void QmlProjectRunConfiguration::ctor()
...@@ -326,15 +321,17 @@ void QmlProjectRunConfiguration::changeCurrentFile(Core::IEditor *editor) ...@@ -326,15 +321,17 @@ void QmlProjectRunConfiguration::changeCurrentFile(Core::IEditor *editor)
bool enable = false; bool enable = false;
if (editor) { if (editor) {
m_currentFileFilename = editor->file()->fileName(); 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; 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. // 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()) { foreach(const QString& filename, m_projectTarget->qmlProject()->files()) {
const QFileInfo fi(filename); const QFileInfo fi(filename);
if (!filename.isEmpty() && fi.baseName()[0].isLower() 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; m_currentFileFilename = filename;
enable = true; enable = true;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment