Skip to content
Snippets Groups Projects
Commit 61ca001e authored by Lasse Holmstedt's avatar Lasse Holmstedt
Browse files

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
No related merge requests found
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include "qmlprojectfile.h" #include "qmlprojectfile.h"
#include "qmlprojectmanagerconstants.h" #include "qmlprojectmanagerconstants.h"
#include "fileformat/qmlprojectitem.h" #include "fileformat/qmlprojectitem.h"
#include "qmlprojectrunconfiguration.h"
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <coreplugin/messagemanager.h> #include <coreplugin/messagemanager.h>
...@@ -255,6 +256,10 @@ bool QmlProject::fromMap(const QVariantMap &map) ...@@ -255,6 +256,10 @@ bool QmlProject::fromMap(const QVariantMap &map)
} }
refresh(Everything); 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; return true;
} }
......
...@@ -54,6 +54,7 @@ QmlProjectRunConfiguration::QmlProjectRunConfiguration(Internal::QmlProjectTarge ...@@ -54,6 +54,7 @@ QmlProjectRunConfiguration::QmlProjectRunConfiguration(Internal::QmlProjectTarge
ProjectExplorer::RunConfiguration(parent, QLatin1String(Constants::QML_RC_ID)), ProjectExplorer::RunConfiguration(parent, QLatin1String(Constants::QML_RC_ID)),
m_debugServerAddress("127.0.0.1"), m_debugServerAddress("127.0.0.1"),
m_debugServerPort(Constants::QML_DEFAULT_DEBUG_SERVER_PORT), m_debugServerPort(Constants::QML_DEFAULT_DEBUG_SERVER_PORT),
m_projectTarget(parent),
m_usingCurrentFile(false), m_usingCurrentFile(false),
m_isEnabled(false) m_isEnabled(false)
{ {
...@@ -294,6 +295,20 @@ void QmlProjectRunConfiguration::changeCurrentFile(Core::IEditor *editor) ...@@ -294,6 +295,20 @@ void QmlProjectRunConfiguration::changeCurrentFile(Core::IEditor *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()).matchesType(QLatin1String("application/x-qml")))
enable = true; 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); setEnabled(enable);
......
...@@ -72,8 +72,11 @@ public: ...@@ -72,8 +72,11 @@ public:
QVariantMap toMap() const; QVariantMap toMap() const;
private slots: public slots:
void changeCurrentFile(Core::IEditor*); void changeCurrentFile(Core::IEditor*);
private slots:
QString mainScript() const; QString mainScript() const;
void setMainScript(const QString &scriptFile); void setMainScript(const QString &scriptFile);
...@@ -102,6 +105,8 @@ private: ...@@ -102,6 +105,8 @@ private:
QString m_debugServerAddress; QString m_debugServerAddress;
uint m_debugServerPort; uint m_debugServerPort;
Internal::QmlProjectTarget *m_projectTarget;
bool m_usingCurrentFile; bool m_usingCurrentFile;
bool m_isEnabled; bool m_isEnabled;
......
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