forked from qt-creator/qt-creator
QmlDesigner: Exchange pathToQt with Kit
Change-Id: If21d3c55ec62d22c3bdb623ecd21def276ef383d Reviewed-by: Thomas Hartmann <Thomas.Hartmann@digia.com>
This commit is contained in:
@@ -44,6 +44,7 @@
|
|||||||
#include <projectexplorer/project.h>
|
#include <projectexplorer/project.h>
|
||||||
#include <projectexplorer/target.h>
|
#include <projectexplorer/target.h>
|
||||||
#include <projectexplorer/session.h>
|
#include <projectexplorer/session.h>
|
||||||
|
#include <projectexplorer/kit.h>
|
||||||
#include <qtsupport/qtkitinformation.h>
|
#include <qtsupport/qtkitinformation.h>
|
||||||
#include <qtsupport/qtsupportconstants.h>
|
#include <qtsupport/qtsupportconstants.h>
|
||||||
#include <qtsupport/qtversionmanager.h>
|
#include <qtsupport/qtversionmanager.h>
|
||||||
@@ -74,7 +75,7 @@ DesignDocument::DesignDocument(QObject *parent) :
|
|||||||
m_subComponentManager(new SubComponentManager(m_documentModel.data(), this)),
|
m_subComponentManager(new SubComponentManager(m_documentModel.data(), this)),
|
||||||
m_rewriterView (new RewriterView(RewriterView::Amend, m_documentModel.data())),
|
m_rewriterView (new RewriterView(RewriterView::Amend, m_documentModel.data())),
|
||||||
m_documentLoaded(false),
|
m_documentLoaded(false),
|
||||||
m_qtVersionId(-1)
|
m_currentKit(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,17 +101,6 @@ QWidget *DesignDocument::centralWidget() const
|
|||||||
return qobject_cast<QWidget*>(parent());
|
return qobject_cast<QWidget*>(parent());
|
||||||
}
|
}
|
||||||
|
|
||||||
QString DesignDocument::pathToQt() const
|
|
||||||
{
|
|
||||||
QtSupport::BaseQtVersion *activeQtVersion = QtSupport::QtVersionManager::version(m_qtVersionId);
|
|
||||||
if (activeQtVersion && (activeQtVersion->qtVersion() >= QtSupport::QtVersionNumber(4, 7, 1))
|
|
||||||
&& (activeQtVersion->type() == QLatin1String(QtSupport::Constants::DESKTOPQT)
|
|
||||||
|| activeQtVersion->type() == QLatin1String(QtSupport::Constants::SIMULATORQT)))
|
|
||||||
return activeQtVersion->qmakeProperty("QT_INSTALL_DATA");
|
|
||||||
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
|
|
||||||
const ViewManager &DesignDocument::viewManager() const
|
const ViewManager &DesignDocument::viewManager() const
|
||||||
{
|
{
|
||||||
return QmlDesignerPlugin::instance()->viewManager();
|
return QmlDesignerPlugin::instance()->viewManager();
|
||||||
@@ -221,9 +211,9 @@ QString DesignDocument::fileName() const
|
|||||||
return editor()->document()->filePath();
|
return editor()->document()->filePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
int DesignDocument::qtVersionId() const
|
ProjectExplorer::Kit *DesignDocument::currentKit() const
|
||||||
{
|
{
|
||||||
return m_qtVersionId;
|
return m_currentKit;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DesignDocument::isDocumentLoaded() const
|
bool DesignDocument::isDocumentLoaded() const
|
||||||
@@ -646,7 +636,7 @@ static bool isFileInProject(DesignDocument *designDocument, ProjectExplorer::Pro
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline QtSupport::BaseQtVersion *getActiveQtVersion(DesignDocument *designDocument)
|
static inline ProjectExplorer::Kit *getActiveKit(DesignDocument *designDocument)
|
||||||
{
|
{
|
||||||
ProjectExplorer::ProjectExplorerPlugin *projectExplorer = ProjectExplorer::ProjectExplorerPlugin::instance();
|
ProjectExplorer::ProjectExplorerPlugin *projectExplorer = ProjectExplorer::ProjectExplorerPlugin::instance();
|
||||||
ProjectExplorer::Project *currentProject = projectExplorer->currentProject();
|
ProjectExplorer::Project *currentProject = projectExplorer->currentProject();
|
||||||
@@ -672,24 +662,14 @@ static inline QtSupport::BaseQtVersion *getActiveQtVersion(DesignDocument *desig
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
designDocument->connect(target, SIGNAL(kitChanged()), designDocument, SLOT(updateActiveQtVersion()));
|
designDocument->connect(target, SIGNAL(kitChanged()), designDocument, SLOT(updateActiveQtVersion()));
|
||||||
return QtSupport::QtKitInformation::qtVersion(target->kit());
|
|
||||||
|
return target->kit();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DesignDocument::updateActiveQtVersion()
|
void DesignDocument::updateActiveQtVersion()
|
||||||
{
|
{
|
||||||
QtSupport::BaseQtVersion *newQtVersion = getActiveQtVersion(this);
|
m_currentKit = getActiveKit(this);
|
||||||
|
viewManager().setNodeInstanceViewKit(m_currentKit);
|
||||||
if (!newQtVersion ) {
|
|
||||||
m_qtVersionId = -1;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_qtVersionId == newQtVersion->uniqueId())
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_qtVersionId = newQtVersion->uniqueId();
|
|
||||||
|
|
||||||
viewManager().setNodeInstanceViewQtPath(pathToQt());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString DesignDocument::contextHelpId() const
|
QString DesignDocument::contextHelpId() const
|
||||||
|
|||||||
@@ -50,6 +50,10 @@ class QPlainTextEdit;
|
|||||||
class QDeclarativeError;
|
class QDeclarativeError;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
namespace ProjectExplorer {
|
||||||
|
class Kit;
|
||||||
|
}
|
||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
|
|
||||||
class ModelNode;
|
class ModelNode;
|
||||||
@@ -92,7 +96,7 @@ public:
|
|||||||
TextEditor::ITextEditor *textEditor() const;
|
TextEditor::ITextEditor *textEditor() const;
|
||||||
QPlainTextEdit *plainTextEdit() const;
|
QPlainTextEdit *plainTextEdit() const;
|
||||||
QString fileName() const;
|
QString fileName() const;
|
||||||
int qtVersionId() const; // maybe that is not working, because the id should be not cached!!!
|
ProjectExplorer::Kit *currentKit() const;
|
||||||
bool isDocumentLoaded() const;
|
bool isDocumentLoaded() const;
|
||||||
|
|
||||||
void resetToDocumentModel();
|
void resetToDocumentModel();
|
||||||
@@ -151,7 +155,7 @@ private: // variables
|
|||||||
QScopedPointer<RewriterView> m_rewriterView;
|
QScopedPointer<RewriterView> m_rewriterView;
|
||||||
|
|
||||||
bool m_documentLoaded;
|
bool m_documentLoaded;
|
||||||
int m_qtVersionId;
|
ProjectExplorer::Kit *m_currentKit;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace QmlDesigner
|
} // namespace QmlDesigner
|
||||||
|
|||||||
@@ -51,6 +51,10 @@ class QFileSystemWatcher;
|
|||||||
class QPainter;
|
class QPainter;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
namespace ProjectExplorer {
|
||||||
|
class Kit;
|
||||||
|
}
|
||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
|
|
||||||
class NodeInstanceServerInterface;
|
class NodeInstanceServerInterface;
|
||||||
@@ -144,7 +148,7 @@ public:
|
|||||||
|
|
||||||
QImage statePreviewImage(const ModelNode &stateNode) const;
|
QImage statePreviewImage(const ModelNode &stateNode) const;
|
||||||
|
|
||||||
void setPathToQt(const QString &pathToQt);
|
void setKit(ProjectExplorer::Kit *kit);
|
||||||
|
|
||||||
void sendToken(const QString &token, int number, const QVector<ModelNode> &nodeVector);
|
void sendToken(const QString &token, int number, const QVector<ModelNode> &nodeVector);
|
||||||
|
|
||||||
@@ -212,7 +216,7 @@ private: //variables
|
|||||||
QImage m_baseStatePreviewImage;
|
QImage m_baseStatePreviewImage;
|
||||||
QTime m_lastCrashTime;
|
QTime m_lastCrashTime;
|
||||||
NodeInstanceServerInterface::RunModus m_runModus;
|
NodeInstanceServerInterface::RunModus m_runModus;
|
||||||
QString m_pathToQt;
|
ProjectExplorer::Kit *m_currentKit;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace ProxyNodeInstanceView
|
} // namespace ProxyNodeInstanceView
|
||||||
|
|||||||
@@ -34,6 +34,10 @@
|
|||||||
|
|
||||||
#include <QWidgetAction>
|
#include <QWidgetAction>
|
||||||
|
|
||||||
|
namespace ProjectExplorer {
|
||||||
|
class Kit;
|
||||||
|
}
|
||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
|
|
||||||
class DesignDocument;
|
class DesignDocument;
|
||||||
@@ -63,7 +67,7 @@ public:
|
|||||||
void setItemLibraryViewResourcePath(const QString &resourcePath);
|
void setItemLibraryViewResourcePath(const QString &resourcePath);
|
||||||
void setComponentNode(const ModelNode &componentNode);
|
void setComponentNode(const ModelNode &componentNode);
|
||||||
void setComponentViewToMaster();
|
void setComponentViewToMaster();
|
||||||
void setNodeInstanceViewQtPath(const QString & qtPath);
|
void setNodeInstanceViewKit(ProjectExplorer::Kit *kit);
|
||||||
|
|
||||||
void resetPropertyEditorView();
|
void resetPropertyEditorView();
|
||||||
|
|
||||||
|
|||||||
@@ -77,6 +77,10 @@
|
|||||||
|
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
#include <utils/hostosinfo.h>
|
#include <utils/hostosinfo.h>
|
||||||
|
#include <projectexplorer/kit.h>
|
||||||
|
#include <qtsupport/qtkitinformation.h>
|
||||||
|
#include <qtsupport/baseqtversion.h>
|
||||||
|
#include <qtsupport/qtsupportconstants.h>
|
||||||
|
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
|
||||||
@@ -157,7 +161,18 @@ bool NodeInstanceServerProxy::checkPuppetVersion(const QString &qmlPuppetPath)
|
|||||||
return canConvert && versionNumber == 2;
|
return canConvert && versionNumber == 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeInstanceServerProxy::NodeInstanceServerProxy(NodeInstanceView *nodeInstanceView, RunModus runModus, const QString &pathToQt)
|
static QString getPathToQt(ProjectExplorer::Kit *kit)
|
||||||
|
{
|
||||||
|
QtSupport::BaseQtVersion *currentQtVersion = QtSupport::QtKitInformation::qtVersion(kit);
|
||||||
|
if (currentQtVersion && (currentQtVersion->qtVersion() >= QtSupport::QtVersionNumber(4, 7, 1))
|
||||||
|
&& (currentQtVersion->type() == QLatin1String(QtSupport::Constants::DESKTOPQT)
|
||||||
|
|| currentQtVersion->type() == QLatin1String(QtSupport::Constants::SIMULATORQT)))
|
||||||
|
return currentQtVersion->qmakeProperty("QT_INSTALL_DATA");
|
||||||
|
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
|
||||||
|
NodeInstanceServerProxy::NodeInstanceServerProxy(NodeInstanceView *nodeInstanceView, RunModus runModus, ProjectExplorer::Kit *kit)
|
||||||
: NodeInstanceServerInterface(nodeInstanceView),
|
: NodeInstanceServerInterface(nodeInstanceView),
|
||||||
m_localServer(new QLocalServer(this)),
|
m_localServer(new QLocalServer(this)),
|
||||||
m_nodeInstanceView(nodeInstanceView),
|
m_nodeInstanceView(nodeInstanceView),
|
||||||
@@ -171,6 +186,8 @@ NodeInstanceServerProxy::NodeInstanceServerProxy(NodeInstanceView *nodeInstanceV
|
|||||||
m_runModus(runModus),
|
m_runModus(runModus),
|
||||||
m_synchronizeId(-1)
|
m_synchronizeId(-1)
|
||||||
{
|
{
|
||||||
|
QString pathToQt = getPathToQt(kit);
|
||||||
|
|
||||||
QString applicationPath = pathToQt + QLatin1String("/bin");
|
QString applicationPath = pathToQt + QLatin1String("/bin");
|
||||||
if (runModus == TestModus) {
|
if (runModus == TestModus) {
|
||||||
applicationPath = QCoreApplication::applicationDirPath()
|
applicationPath = QCoreApplication::applicationDirPath()
|
||||||
|
|||||||
@@ -42,6 +42,10 @@ class QLocalSocket;
|
|||||||
class QProcess;
|
class QProcess;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
namespace ProjectExplorer {
|
||||||
|
class Kit;
|
||||||
|
}
|
||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
|
|
||||||
class NodeInstanceClientInterface;
|
class NodeInstanceClientInterface;
|
||||||
@@ -52,7 +56,7 @@ class NodeInstanceServerProxy : public NodeInstanceServerInterface
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit NodeInstanceServerProxy(NodeInstanceView *nodeInstanceView, RunModus runModus = NormalModus, const QString &pathToQt = QString());
|
explicit NodeInstanceServerProxy(NodeInstanceView *nodeInstanceView, RunModus runModus = NormalModus, ProjectExplorer::Kit *kit = 0);
|
||||||
~NodeInstanceServerProxy();
|
~NodeInstanceServerProxy();
|
||||||
void createInstances(const CreateInstancesCommand &command);
|
void createInstances(const CreateInstancesCommand &command);
|
||||||
void changeFileUrl(const ChangeFileUrlCommand &command);
|
void changeFileUrl(const ChangeFileUrlCommand &command);
|
||||||
|
|||||||
@@ -102,7 +102,8 @@ namespace QmlDesigner {
|
|||||||
NodeInstanceView::NodeInstanceView(QObject *parent, NodeInstanceServerInterface::RunModus runModus)
|
NodeInstanceView::NodeInstanceView(QObject *parent, NodeInstanceServerInterface::RunModus runModus)
|
||||||
: AbstractView(parent),
|
: AbstractView(parent),
|
||||||
m_baseStatePreviewImage(QSize(100, 100), QImage::Format_ARGB32),
|
m_baseStatePreviewImage(QSize(100, 100), QImage::Format_ARGB32),
|
||||||
m_runModus(runModus)
|
m_runModus(runModus),
|
||||||
|
m_currentKit(0)
|
||||||
{
|
{
|
||||||
m_baseStatePreviewImage.fill(0xFFFFFF);
|
m_baseStatePreviewImage.fill(0xFFFFFF);
|
||||||
}
|
}
|
||||||
@@ -115,6 +116,7 @@ NodeInstanceView::~NodeInstanceView()
|
|||||||
{
|
{
|
||||||
removeAllInstanceNodeRelationships();
|
removeAllInstanceNodeRelationships();
|
||||||
delete nodeInstanceServer();
|
delete nodeInstanceServer();
|
||||||
|
m_currentKit = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//\{
|
//\{
|
||||||
@@ -148,7 +150,7 @@ bool isSkippedNode(const ModelNode &node)
|
|||||||
void NodeInstanceView::modelAttached(Model *model)
|
void NodeInstanceView::modelAttached(Model *model)
|
||||||
{
|
{
|
||||||
AbstractView::modelAttached(model);
|
AbstractView::modelAttached(model);
|
||||||
m_nodeInstanceServer = new NodeInstanceServerProxy(this, m_runModus, m_pathToQt);
|
m_nodeInstanceServer = new NodeInstanceServerProxy(this, m_runModus, m_currentKit);
|
||||||
m_lastCrashTime.start();
|
m_lastCrashTime.start();
|
||||||
connect(m_nodeInstanceServer.data(), SIGNAL(processCrashed()), this, SLOT(handleChrash()));
|
connect(m_nodeInstanceServer.data(), SIGNAL(processCrashed()), this, SLOT(handleChrash()));
|
||||||
|
|
||||||
@@ -193,7 +195,7 @@ void NodeInstanceView::restartProcess()
|
|||||||
if (model()) {
|
if (model()) {
|
||||||
delete nodeInstanceServer();
|
delete nodeInstanceServer();
|
||||||
|
|
||||||
m_nodeInstanceServer = new NodeInstanceServerProxy(this, m_runModus, m_pathToQt);
|
m_nodeInstanceServer = new NodeInstanceServerProxy(this, m_runModus, m_currentKit);
|
||||||
connect(m_nodeInstanceServer.data(), SIGNAL(processCrashed()), this, SLOT(handleChrash()));
|
connect(m_nodeInstanceServer.data(), SIGNAL(processCrashed()), this, SLOT(handleChrash()));
|
||||||
|
|
||||||
if (!isSkippedRootNode(rootModelNode()))
|
if (!isSkippedRootNode(rootModelNode()))
|
||||||
@@ -1111,10 +1113,10 @@ QImage NodeInstanceView::statePreviewImage(const ModelNode &stateNode) const
|
|||||||
return m_statePreviewImage.value(stateNode);
|
return m_statePreviewImage.value(stateNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NodeInstanceView::setPathToQt(const QString &pathToQt)
|
void NodeInstanceView::setKit(ProjectExplorer::Kit *newKit)
|
||||||
{
|
{
|
||||||
if (m_pathToQt != pathToQt) {
|
if (m_currentKit != newKit) {
|
||||||
m_pathToQt = pathToQt;
|
m_currentKit = newKit;
|
||||||
restartProcess();
|
restartProcess();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,8 +18,6 @@
|
|||||||
|
|
||||||
#include <qmldesigner/qmldesignerplugin.h>
|
#include <qmldesigner/qmldesignerplugin.h>
|
||||||
|
|
||||||
#include <qtsupport/qtversionmanager.h>
|
|
||||||
#include <qtsupport/qtsupportconstants.h>
|
|
||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
|
|
||||||
@@ -63,20 +61,9 @@ DesignDocument *ViewManager::currentDesignDocument() const
|
|||||||
return QmlDesignerPlugin::instance()->documentManager().currentDesignDocument();
|
return QmlDesignerPlugin::instance()->documentManager().currentDesignDocument();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ViewManager::pathToQt() const
|
|
||||||
{
|
|
||||||
QtSupport::BaseQtVersion *activeQtVersion = QtSupport::QtVersionManager::version(currentDesignDocument()->qtVersionId());
|
|
||||||
if (activeQtVersion && (activeQtVersion->qtVersion() >= QtSupport::QtVersionNumber(4, 7, 1))
|
|
||||||
&& (activeQtVersion->type() == QLatin1String(QtSupport::Constants::DESKTOPQT)
|
|
||||||
|| activeQtVersion->type() == QLatin1String(QtSupport::Constants::SIMULATORQT)))
|
|
||||||
return activeQtVersion->qmakeProperty("QT_INSTALL_DATA");
|
|
||||||
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ViewManager::attachNodeInstanceView()
|
void ViewManager::attachNodeInstanceView()
|
||||||
{
|
{
|
||||||
setNodeInstanceViewQtPath(pathToQt());
|
setNodeInstanceViewKit(currentDesignDocument()->currentKit());
|
||||||
currentModel()->setNodeInstanceView(&d->nodeInstanceView);
|
currentModel()->setNodeInstanceView(&d->nodeInstanceView);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -206,9 +193,9 @@ void ViewManager::setComponentViewToMaster()
|
|||||||
d->componentView.setComponentToMaster();
|
d->componentView.setComponentToMaster();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViewManager::setNodeInstanceViewQtPath(const QString &qtPath)
|
void ViewManager::setNodeInstanceViewKit(ProjectExplorer::Kit *kit)
|
||||||
{
|
{
|
||||||
d->nodeInstanceView.setPathToQt(qtPath);
|
d->nodeInstanceView.setKit(kit);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool widgetInfoLessThan(const WidgetInfo &firstWidgetInfo, const WidgetInfo &secondWidgetInfo)
|
static bool widgetInfoLessThan(const WidgetInfo &firstWidgetInfo, const WidgetInfo &secondWidgetInfo)
|
||||||
|
|||||||
Reference in New Issue
Block a user