Commit 18817a9a authored by Thomas Hartmann's avatar Thomas Hartmann

QmlDesigner: set QT_QUICK_CONTROLS_CONF

If we have a qtquickcontrols2.conf we set QT_QUICK_CONTROLS_CONF
for the qml2puppet.

For this we have to forward the project to PuppetCreator.
I forwarded the project instead of just the path to qtquickcontrols2.conf,
because we most likely add more project specific features in the future.

Change-Id: I0a90636ca6903e28499018c8d769bb07f7be5bb6
Reviewed-by: Tim Jenssen's avatarTim Jenssen <tim.jenssen@qt.io>
parent 43afc5d1
......@@ -608,6 +608,7 @@ void DesignDocument::setEditor(Core::IEditor *editor)
this, &DesignDocument::updateFileName);
updateActiveQtVersion();
updateCurrentProject();
}
Core::IEditor *DesignDocument::editor() const
......@@ -666,6 +667,12 @@ static inline Kit *getActiveKit(DesignDocument *designDocument)
QObject::connect(currentProject, &Project::activeTargetChanged,
designDocument, &DesignDocument::updateActiveQtVersion, Qt::UniqueConnection);
QObject::connect(ProjectTree::instance(), &ProjectTree::currentProjectChanged,
designDocument, &DesignDocument::updateCurrentProject, Qt::UniqueConnection);
QObject::connect(currentProject, &Project::activeTargetChanged,
designDocument, &DesignDocument::updateCurrentProject, Qt::UniqueConnection);
Target *target = currentProject->activeTarget();
......@@ -686,6 +693,12 @@ void DesignDocument::updateActiveQtVersion()
viewManager().setNodeInstanceViewKit(m_currentKit);
}
void DesignDocument::updateCurrentProject()
{
ProjectExplorer::Project *currentProject = ProjectExplorer::SessionManager::projectForFile(fileName());
viewManager().setNodeInstanceViewProject(currentProject);
}
QString DesignDocument::contextHelpId() const
{
if (view())
......
......@@ -115,6 +115,7 @@ public slots:
void undo();
void redo();
void updateActiveQtVersion();
void updateCurrentProject();
void changeToSubComponent(const ModelNode &componentNode);
void changeToMaster();
......
......@@ -48,6 +48,7 @@ QT_END_NAMESPACE
namespace ProjectExplorer {
class Kit;
class Project;
}
namespace QmlDesigner {
......@@ -127,6 +128,7 @@ public:
QImage statePreviewImage(const ModelNode &stateNode) const;
void setKit(ProjectExplorer::Kit *kit);
void setProject(ProjectExplorer::Project *project);
void sendToken(const QString &token, int number, const QVector<ModelNode> &nodeVector);
......@@ -199,7 +201,8 @@ private: //variables
QImage m_baseStatePreviewImage;
QTime m_lastCrashTime;
NodeInstanceServerInterface::RunModus m_runModus;
ProjectExplorer::Kit *m_currentKit;
ProjectExplorer::Kit *m_currentKit = nullptr;
ProjectExplorer::Project *m_currentProject = nullptr;
int m_restartProcessTimerId;
};
......
......@@ -31,6 +31,7 @@
namespace ProjectExplorer {
class Kit;
class Project;
}
namespace QmlDesigner {
......@@ -63,6 +64,7 @@ public:
void setComponentNode(const ModelNode &componentNode);
void setComponentViewToMaster();
void setNodeInstanceViewKit(ProjectExplorer::Kit *kit);
void setNodeInstanceViewProject(ProjectExplorer::Project *project);
void resetPropertyEditorView();
......
......@@ -96,7 +96,10 @@ static void showCannotConnectToPuppetWarningAndSwitchToEditMode()
}
NodeInstanceServerProxy::NodeInstanceServerProxy(NodeInstanceView *nodeInstanceView, RunModus runModus, ProjectExplorer::Kit *kit)
NodeInstanceServerProxy::NodeInstanceServerProxy(NodeInstanceView *nodeInstanceView,
RunModus runModus,
ProjectExplorer::Kit *kit,
ProjectExplorer::Project *project)
: NodeInstanceServerInterface(nodeInstanceView),
m_localServer(new QLocalServer(this)),
m_nodeInstanceView(nodeInstanceView),
......@@ -114,7 +117,7 @@ NodeInstanceServerProxy::NodeInstanceServerProxy(NodeInstanceView *nodeInstanceV
m_localServer->listen(socketToken);
m_localServer->setMaxPendingConnections(3);
PuppetCreator puppetCreator(kit, QString(), nodeInstanceView->model());
PuppetCreator puppetCreator(kit, project, QString(), nodeInstanceView->model());
puppetCreator.setQrcMappingString(qrcMappingString());
puppetCreator.createPuppetExecutableIfMissing();
......
......@@ -40,6 +40,7 @@ QT_END_NAMESPACE
namespace ProjectExplorer {
class Kit;
class Project;
}
namespace QmlDesigner {
......@@ -59,7 +60,10 @@ public:
ThirdPuppetStream,
};
explicit NodeInstanceServerProxy(NodeInstanceView *nodeInstanceView, RunModus runModus = NormalModus, ProjectExplorer::Kit *kit = 0);
explicit NodeInstanceServerProxy(NodeInstanceView *nodeInstanceView,
RunModus runModus,
ProjectExplorer::Kit *kit,
ProjectExplorer::Project *project);
~NodeInstanceServerProxy();
void createInstances(const CreateInstancesCommand &command);
void changeFileUrl(const ChangeFileUrlCommand &command);
......
......@@ -103,7 +103,6 @@ NodeInstanceView::NodeInstanceView(QObject *parent, NodeInstanceServerInterface:
: AbstractView(parent),
m_baseStatePreviewImage(QSize(100, 100), QImage::Format_ARGB32),
m_runModus(runModus),
m_currentKit(0),
m_restartProcessTimerId(0)
{
m_baseStatePreviewImage.fill(0xFFFFFF);
......@@ -151,7 +150,7 @@ bool isSkippedNode(const ModelNode &node)
void NodeInstanceView::modelAttached(Model *model)
{
AbstractView::modelAttached(model);
m_nodeInstanceServer = new NodeInstanceServerProxy(this, m_runModus, m_currentKit);
m_nodeInstanceServer = new NodeInstanceServerProxy(this, m_runModus, m_currentKit, m_currentProject);
m_lastCrashTime.start();
connect(m_nodeInstanceServer.data(), SIGNAL(processCrashed()), this, SLOT(handleChrash()));
......@@ -203,7 +202,7 @@ void NodeInstanceView::restartProcess()
if (model()) {
delete nodeInstanceServer();
m_nodeInstanceServer = new NodeInstanceServerProxy(this, m_runModus, m_currentKit);
m_nodeInstanceServer = new NodeInstanceServerProxy(this, m_runModus, m_currentKit, m_currentProject);
connect(m_nodeInstanceServer.data(), SIGNAL(processCrashed()), this, SLOT(handleChrash()));
if (!isSkippedRootNode(rootModelNode()))
......@@ -1133,6 +1132,14 @@ void NodeInstanceView::setKit(ProjectExplorer::Kit *newKit)
}
}
void NodeInstanceView::setProject(ProjectExplorer::Project *project)
{
if (m_currentProject != project) {
m_currentProject = project;
restartProcess();
}
}
void NodeInstanceView::statePreviewImagesChanged(const StatePreviewImageChangedCommand &command)
{
if (!model())
......
......@@ -34,6 +34,7 @@
#include <projectexplorer/kit.h>
#include <projectexplorer/project.h>
#include <projectexplorer/toolchain.h>
#include <coreplugin/messagebox.h>
#include <coreplugin/icore.h>
......@@ -121,11 +122,16 @@ bool PuppetCreator::useOnlyFallbackPuppet() const
#endif
}
PuppetCreator::PuppetCreator(ProjectExplorer::Kit *kit, const QString &qtCreatorVersion, const Model *model)
PuppetCreator::PuppetCreator(ProjectExplorer::Kit *kit,
ProjectExplorer::Project *project,
const QString &qtCreatorVersion,
const Model *model)
: m_qtCreatorVersion(qtCreatorVersion)
,m_kit(kit)
,m_availablePuppetType(FallbackPuppet)
,m_model(model)
,m_kit(kit)
,m_availablePuppetType(FallbackPuppet)
,m_model(model)
,m_currentProject(project)
#ifndef QMLDESIGNER_TEST
,m_designerSettings(QmlDesignerPlugin::instance()->settings())
#endif
......@@ -141,7 +147,11 @@ void PuppetCreator::createPuppetExecutableIfMissing()
createQml2PuppetExecutableIfMissing();
}
QProcess *PuppetCreator::createPuppetProcess(const QString &puppetMode, const QString &socketToken, QObject *handlerObject, const char *outputSlot, const char *finishSlot) const
QProcess *PuppetCreator::createPuppetProcess(const QString &puppetMode,
const QString &socketToken,
QObject *handlerObject,
const char *outputSlot,
const char *finishSlot) const
{
return puppetProcess(qml2PuppetPath(m_availablePuppetType),
qmlPuppetDirectory(m_availablePuppetType),
......@@ -367,7 +377,7 @@ QProcessEnvironment PuppetCreator::processEnvironment() const
#else
const QString controlsStyle;
#endif
if (!controlsStyle.isEmpty()) {
if (!controlsStyle.isEmpty() && controlsStyle != "Default") {
environment.set(QLatin1String("QT_QUICK_CONTROLS_STYLE"), controlsStyle);
environment.set(QLatin1String("QT_LABS_CONTROLS_STYLE"), controlsStyle);
}
......@@ -388,6 +398,14 @@ QProcessEnvironment PuppetCreator::processEnvironment() const
qCInfo(puppetStart) << "Puppet import paths:" << importPaths;
qCInfo(puppetStart) << "Puppet environment:" << environment.toStringList();
if (m_currentProject) {
for (const QString &fileName : m_currentProject->files(ProjectExplorer::Project::SourceFiles)) {
QFileInfo fileInfo(fileName);
if (fileInfo.fileName() == "qtquickcontrols2.conf")
environment.appendOrSet("QT_QUICK_CONTROLS_CONF", fileName);
}
}
return environment.toProcessEnvironment();
}
......
......@@ -34,6 +34,7 @@
namespace ProjectExplorer {
class Kit;
class Project;
}
namespace QmlDesigner {
......@@ -49,7 +50,11 @@ public:
UserSpacePuppet
};
PuppetCreator(ProjectExplorer::Kit *kit, const QString &qtCreatorVersion, const Model *model);
PuppetCreator(ProjectExplorer::Kit *kit,
ProjectExplorer::Project *project,
const QString &qtCreatorVersion,
const Model *model);
~PuppetCreator();
void createPuppetExecutableIfMissing();
......@@ -118,6 +123,7 @@ private:
const DesignerSettings m_designerSettings;
#endif
QString m_qrcMapping;
ProjectExplorer::Project *m_currentProject = nullptr;
};
} // namespace QmlDesigner
......@@ -226,6 +226,11 @@ void ViewManager::setNodeInstanceViewKit(ProjectExplorer::Kit *kit)
d->nodeInstanceView.setKit(kit);
}
void QmlDesigner::ViewManager::setNodeInstanceViewProject(ProjectExplorer::Project *project)
{
d->nodeInstanceView.setProject(project);
}
QList<WidgetInfo> ViewManager::widgetInfos()
{
QList<WidgetInfo> widgetInfoList;
......
......@@ -419,6 +419,7 @@ void QmlDesignerPlugin::activateAutoSynchronization()
currentDesignDocument()->loadDocument(currentDesignDocument()->plainTextEdit());
currentDesignDocument()->updateActiveQtVersion();
currentDesignDocument()->updateCurrentProject();
currentDesignDocument()->attachRewriterToModel();
resetModelSelection();
......
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