QmlDesigner: Add item layer properties

Task-number: QDS-1305
Change-Id: I0d6a390ac05f6bda9f11ecb25b461c95519d8bb3
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
Reviewed-by: Henning Gründl <henning.gruendl@qt.io>
This commit is contained in:
Henning Gruendl
2019-12-06 12:17:18 +01:00
committed by Henning Gründl
parent f4d6300b0b
commit 60f27c609a
5 changed files with 434 additions and 1 deletions

View File

@@ -615,6 +615,8 @@ Rectangle {
anchors.right: parent.right anchors.right: parent.right
AdvancedSection { AdvancedSection {
} }
LayerSection {
}
} }
} }
} }

View File

@@ -0,0 +1,319 @@
/****************************************************************************
**
** Copyright (C) 2019 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.0
import HelperWidgets 2.0
import QtQuick.Layouts 1.0
Section {
anchors.left: parent.left
anchors.right: parent.right
caption: qsTr("Layer")
SectionLayout {
columns: 2
Label {
text: qsTr("Effect")
tooltip: qsTr("Sets the effect that is applied to this layer.")
}
SecondColumnLayout {
ItemFilterComboBox {
typeFilter: "QtQuick.Item"
validator: RegExpValidator { regExp: /(^$|^[a-z_]\w*)/ }
backendValue: backendValues.layer_effect
Layout.fillWidth: true
}
ExpandingSpacer {
}
}
Label {
text: qsTr("Enabled")
tooltip: qsTr("Sets whether the item is layered or not.")
}
SecondColumnLayout {
CheckBox {
text: backendValues.layer_enabled.valueToString
backendValue: backendValues.layer_enabled
Layout.fillWidth: true
}
ExpandingSpacer {
}
}
Label {
text: qsTr("Format")
tooltip: qsTr("Defines the internal OpenGL format of the texture.")
}
SecondColumnLayout {
ComboBox {
scope: "ShaderEffectSource"
model: ["Alpha", "RGB", "RGBA"]
backendValue: backendValues.layer_format
Layout.fillWidth: true
}
ExpandingSpacer {
}
}
Label {
text: qsTr("Mipmap")
tooltip: qsTr("Enables the generation of mipmaps for the texture.")
}
SecondColumnLayout {
CheckBox {
text: backendValues.layer_mipmap.valueToString
backendValue: backendValues.layer_mipmap
Layout.fillWidth: true
}
ExpandingSpacer {
}
}
Label {
text: qsTr("Sampler name")
tooltip: qsTr("Sets the name of the effect's source texture property.")
}
SecondColumnLayout {
LineEdit {
backendValue: backendValues.layer_samplerName
text: backendValues.layer_samplerName.valueToString
Layout.fillWidth: true
showTranslateCheckBox: false
}
ExpandingSpacer {
}
}
Label {
text: qsTr("Samples")
tooltip: qsTr("Allows requesting multisampled rendering in the layer.")
}
SecondColumnLayout {
ComboBox {
id: samplesComboBox
model: [2, 4, 8, 16]
backendValue: backendValues.layer_samples
manualMapping: true
Layout.fillWidth: true
onValueFromBackendChanged: {
if (!samplesComboBox.__isCompleted)
return
samplesComboBox.syncIndexToBackendValue()
}
onCompressedActivated: {
if (!samplesComboBox.__isCompleted)
return
if (samplesComboBox.block)
return
backendValues.layer_samples.value = samplesComboBox.model[samplesComboBox.currentIndex]
}
Component.onCompleted: samplesComboBox.syncIndexToBackendValue()
function syncIndexToBackendValue() {
samplesComboBox.block = true
samplesComboBox.currentIndex = samplesComboBox.model.indexOf(backendValues.layer_samples.value)
samplesComboBox.block = false
}
}
ExpandingSpacer {
}
}
Label {
text: qsTr("Smooth")
tooltip: qsTr("Sets whether the layer is smoothly transformed.")
}
SecondColumnLayout {
CheckBox {
text: backendValues.layer_smooth.valueToString
backendValue: backendValues.layer_smooth
Layout.fillWidth: true
}
ExpandingSpacer {
}
}
/*
Label {
text: qsTr("Source rectangle")
tooltip: qsTr("TODO.")
}
SecondColumnLayout {
Label {
text: "X"
width: 12
}
SpinBox {
backendValue: backendValues.layer_sourceRect_x
maximumValue: 0xffff
minimumValue: -0xffff
decimals: 0
realDragRange: 5000
}
Item {
width: 4
height: 4
}
Label {
text: "Y"
width: 12
}
SpinBox {
backendValue: backendValues.layer_sourceRect_y
maximumValue: 0xffff
minimumValue: -0xffff
decimals: 0
realDragRange: 5000
}
ExpandingSpacer {
}
}
Item {
width: 4
height: 4
}
SecondColumnLayout {
Layout.fillWidth: true
Label {
text: "W"
width: 12
}
SpinBox {
backendValue: backendValues.layer_sourceRect_width
maximumValue: 0xffff
minimumValue: 0
decimals: 0
realDragRange: 5000
}
Item {
width: 4
height: 4
}
Label {
text: "H"
width: 12
}
SpinBox {
backendValue: backendValues.layer_sourceRect_height
maximumValue: 0xffff
minimumValue: 0
decimals: 0
realDragRange: 5000
}
ExpandingSpacer {
}
}
*/
Label {
text: qsTr("Texture mirroring")
tooltip: qsTr("Defines how the generated OpenGL texture should be mirrored.")
}
SecondColumnLayout {
ComboBox {
scope: "ShaderEffectSource"
model: ["NoMirroring", "MirrorHorizontally", "MirrorVertically"]
backendValue: backendValues.layer_textureMirroring
Layout.fillWidth: true
}
ExpandingSpacer {
}
}
Label {
text: qsTr("Texture size")
tooltip: qsTr("Sets the requested pixel size of the layers texture.")
}
SecondColumnLayout {
Label {
text: "W"
width: 12
}
SpinBox {
backendValue: backendValues.layer_textureSize_width
minimumValue: 0
maximumValue: 2000
decimals: 0
}
Item {
width: 4
height: 4
}
Label {
text: "H"
width: 12
}
SpinBox {
backendValue: backendValues.layer_textureSize_height
minimumValue: 0
maximumValue: 2000
decimals: 0
}
ExpandingSpacer {
}
}
Label {
text: qsTr("Wrap mode")
tooltip: qsTr("Defines the OpenGL wrap modes associated with the texture.")
}
SecondColumnLayout {
ComboBox {
scope: "ShaderEffectSource"
model: ["ClampToEdge", "RepeatHorizontally", "RepeatVertically", "Repeat"]
backendValue: backendValues.layer_wrapMode
Layout.fillWidth: true
}
ExpandingSpacer {
}
}
}
}

View File

@@ -0,0 +1,111 @@
/****************************************************************************
**
** Copyright (C) 2019 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Quick 3D.
**
** $QT_BEGIN_LICENSE:GPL$
** 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 or (at your option) any later version
** approved by the KDE Free Qt Foundation. The licenses are as published by
** the Free Software Foundation and appearing in the file LICENSE.GPL3
** 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.
**
** $QT_END_LICENSE$
**
****************************************************************************/
import QtQuick 2.12
import HelperWidgets 2.0 as HelperWidgets
HelperWidgets.ComboBox {
id: comboBox
property alias typeFilter: itemFilterModel.typeFilter
manualMapping: true
editable: true
model: comboBox.addDefaultItem(itemFilterModel.itemModel)
HelperWidgets.ItemFilterModel {
id: itemFilterModel
modelNodeBackendProperty: modelNodeBackend
}
property string defaultItem: qsTr("[None]")
property string textValue: comboBox.backendValue.expression
property bool block: false
property bool dirty: true
onTextValueChanged: {
if (comboBox.block)
return
comboBox.setCurrentText(comboBox.textValue)
}
onModelChanged: comboBox.setCurrentText(comboBox.textValue)
onCompressedActivated: comboBox.handleActivate(index)
Component.onCompleted: comboBox.setCurrentText(comboBox.textValue)
onEditTextChanged: comboBox.dirty = true
onFocusChanged: {
if (comboBox.dirty)
comboBox.handleActivate(comboBox.currentIndex)
}
function handleActivate(index)
{
if (!comboBox.__isCompleted || comboBox.backendValue === undefined)
return
var cText = (index === -1) ? comboBox.editText : comboBox.textAt(index)
comboBox.block = true
comboBox.setCurrentText(cText)
comboBox.block = false
}
function setCurrentText(text)
{
if (!comboBox.__isCompleted || comboBox.backendValue === undefined)
return
comboBox.currentIndex = comboBox.find(text)
if (text === "") {
comboBox.currentIndex = 0
comboBox.editText = comboBox.defaultItem
} else {
if (comboBox.currentIndex === -1)
comboBox.editText = text
else if (comboBox.currentIndex === 0)
comboBox.editText = comboBox.defaultItem
}
if (comboBox.currentIndex === 0) {
comboBox.backendValue.resetValue()
} else {
if (comboBox.backendValue.expression !== comboBox.editText)
comboBox.backendValue.expression = comboBox.editText
}
comboBox.dirty = false
}
function addDefaultItem(arr)
{
var copy = arr.slice()
copy.unshift(comboBox.defaultItem)
return copy
}
}

View File

@@ -31,6 +31,7 @@ GradientPresetTabContent 2.0 GradientPresetTabContent.qml
GroupBox 2.0 GroupBox.qml GroupBox 2.0 GroupBox.qml
HueSlider 2.0 HueSlider.qml HueSlider 2.0 HueSlider.qml
IconLabel 2.0 IconLabel.qml IconLabel 2.0 IconLabel.qml
ItemFilterComboBox 2.0 ItemFilterComboBox.qml
ListViewComboBox 2.0 ListViewComboBox.qml ListViewComboBox 2.0 ListViewComboBox.qml
Label 2.0 Label.qml Label 2.0 Label.qml
LineEdit 2.0 LineEdit.qml LineEdit 2.0 LineEdit.qml

View File

@@ -101,7 +101,7 @@ QStringList knownEnumScopes()
{ {
static const QStringList list = { static const QStringList list = {
"TextInput", "TextEdit", "Material", "Universal", "Font", "Shape", "ShapePath", "TextInput", "TextEdit", "Material", "Universal", "Font", "Shape", "ShapePath",
"AbstractButton", "Text" "AbstractButton", "Text", "ShaderEffectSource"
}; };
return list; return list;
} }