From 4c746531d8be01ee58bcae721cd7618e919b7cf2 Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Wed, 20 Mar 2019 12:56:12 +0100 Subject: [PATCH] QmlDesigner: Add support for Dialog Change-Id: I8a2972f80ae79835018870eda7b11a817353bf94 Task-numbner: QTCREATORBUG-22120 Reviewed-by: Tim Jenssen --- .../qml/qmlpuppet/mockfiles/Dialog.qml | 51 +++++++++++++++++++ .../instances/objectnodeinstance.cpp | 4 +- share/qtcreator/qml/qmlpuppet/qmlpuppet.qrc | 1 + .../stateseditor/stateseditorview.cpp | 1 + .../designercore/metainfo/nodemetainfo.cpp | 1 + .../designercore/model/qmlitemnode.cpp | 3 ++ 6 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 share/qtcreator/qml/qmlpuppet/mockfiles/Dialog.qml diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/Dialog.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/Dialog.qml new file mode 100644 index 00000000000..13eed9be1e3 --- /dev/null +++ b/share/qtcreator/qml/qmlpuppet/mockfiles/Dialog.qml @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +import QtQuick 2.1 + +Rectangle { + property string title + + property var clickedButton + + property var modality + property var standardButtons + + property alias contentItem: contentArea + + property int maximumWidth: 0 + property int minimumWidth: 0 + + property int maximumHeight: 0 + property int minimumHeight: 0 + + Item { + id: contentArea + anchors.top: parent.bottom + anchors.left: parent.left + anchors.right: parent.right + anchors.bottom: parent.top + } +} diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/objectnodeinstance.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/objectnodeinstance.cpp index dd4a0adbd10..5f88683ffa2 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/objectnodeinstance.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/objectnodeinstance.cpp @@ -622,10 +622,12 @@ QObject *ObjectNodeInstance::createPrimitive(const QString &typeName, int majorN || typeName == "QtQuick.Controls/Drawer" || typeName == "QtQuick.Controls/Dialog" || typeName == "QtQuick.Controls/Menu" + || typeName == "QtQuick.Controls/Pane" || typeName == "QtQuick.Controls/ToolTip") polishTypeName = "QtQuick/Item"; - const QHash mockHash = {{"QtQuick.Controls/SwipeView","qrc:/qtquickplugin/mockfiles/SwipeView.qml"}}; + const QHash mockHash = {{"QtQuick.Controls/SwipeView","qrc:/qtquickplugin/mockfiles/SwipeView.qml"}, + {"QtQuick.Dialogs/Dialog","qrc:/qtquickplugin/mockfiles/Dialog.qml"}}; QObject *object = nullptr; diff --git a/share/qtcreator/qml/qmlpuppet/qmlpuppet.qrc b/share/qtcreator/qml/qmlpuppet/qmlpuppet.qrc index 4e02e48869e..5b4d0c39a29 100644 --- a/share/qtcreator/qml/qmlpuppet/qmlpuppet.qrc +++ b/share/qtcreator/qml/qmlpuppet/qmlpuppet.qrc @@ -6,5 +6,6 @@ mockfiles/Window.qml mockfiles/SwipeView.qml mockfiles/GenericBackend.qml + mockfiles/Dialog.qml diff --git a/src/plugins/qmldesigner/components/stateseditor/stateseditorview.cpp b/src/plugins/qmldesigner/components/stateseditor/stateseditorview.cpp index e7d930a82b1..67f20b8461f 100644 --- a/src/plugins/qmldesigner/components/stateseditor/stateseditorview.cpp +++ b/src/plugins/qmldesigner/components/stateseditor/stateseditorview.cpp @@ -204,6 +204,7 @@ void StatesEditorView::checkForWindow() { if (m_statesEditorWidget) m_statesEditorWidget->showAddNewStatesButton(!rootModelNode().metaInfo().isSubclassOf("QtQuick.Window.Window") + && !rootModelNode().metaInfo().isSubclassOf("QtQuick.Dialogs.Dialog") && !rootModelNode().metaInfo().isSubclassOf("QtQuick.Window.Popup")); } diff --git a/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp b/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp index 40d21beb1a9..7f2279ce4c7 100644 --- a/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp +++ b/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp @@ -1550,6 +1550,7 @@ bool NodeMetaInfo::isGraphicalItem() const { return isSubclassOf("QtQuick.Item") || isSubclassOf("QtQuick.Window.Window") + || isSubclassOf("QtQuick.Dialogs.Dialog") || isSubclassOf("QtQuick.Controls.Popup"); } diff --git a/src/plugins/qmldesigner/designercore/model/qmlitemnode.cpp b/src/plugins/qmldesigner/designercore/model/qmlitemnode.cpp index 6e5ed46d0f9..5ff63f1f1f3 100644 --- a/src/plugins/qmldesigner/designercore/model/qmlitemnode.cpp +++ b/src/plugins/qmldesigner/designercore/model/qmlitemnode.cpp @@ -54,6 +54,9 @@ bool QmlItemNode::isItemOrWindow(const ModelNode &modelNode) if (modelNode.metaInfo().isSubclassOf("QtQuick.Window.Window") && modelNode.isRootNode()) return true; + if (modelNode.metaInfo().isSubclassOf("QtQuick.Dialogs.Dialog") && modelNode.isRootNode()) + return true; + if (modelNode.metaInfo().isSubclassOf("QtQuick.Controls.Popup")) return true;