Inital commit of the Komplex Hub
This commit is contained in:
@@ -0,0 +1,97 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2020 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Quick Designer Components.
|
||||
**
|
||||
** $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.10
|
||||
|
||||
/*!
|
||||
\qmltype AndOperator
|
||||
\inqmlmodule QtQuick.Studio.LogicHelper
|
||||
\since QtQuick.Studio.LogicHelper 1.0
|
||||
\inherits QtObject
|
||||
|
||||
\brief Evaluates two boolean input values and provides the result as output.
|
||||
|
||||
The AndOperator type evaluates two boolean inputs, \l input01 and
|
||||
\l input02. The \l output is evaluated as \c true if both \l input01
|
||||
and \l input02 are evaluated as \c true.
|
||||
|
||||
Designers can use the And Operator type in \QDS instead of writing
|
||||
JavaScript expressions.
|
||||
|
||||
\section1 Example Usage
|
||||
|
||||
In the following example, we use the checked state of two \l CheckBox
|
||||
types to determine the checked state of a third one:
|
||||
|
||||
\code
|
||||
Rectangle {
|
||||
CheckBox {
|
||||
id: checkBox1
|
||||
text: qsTr("Check Box 1")
|
||||
checked: false
|
||||
}
|
||||
CheckBox {
|
||||
id: checkBox2
|
||||
text: qsTr("Check Box 2")
|
||||
}
|
||||
CheckBox {
|
||||
id: checkBox3
|
||||
text: qsTr("Check Box 3")
|
||||
checked: andOperator.output
|
||||
}
|
||||
AndOperator {
|
||||
id: andOperator
|
||||
input02: checkBox2.checked
|
||||
input01: checkBox1.checked
|
||||
}
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa OrOperator, NotOperator
|
||||
*/
|
||||
|
||||
QtObject {
|
||||
id: object
|
||||
|
||||
/*!
|
||||
The first value to evaluate.
|
||||
*/
|
||||
property bool input01: false
|
||||
|
||||
/*!
|
||||
The second value to evaluate.
|
||||
*/
|
||||
property bool input02: false
|
||||
|
||||
/*!
|
||||
The result of the evaluation.
|
||||
*/
|
||||
property bool output: object.input01 && object.input02
|
||||
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2020 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Quick Designer Components.
|
||||
**
|
||||
** $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.10
|
||||
|
||||
/*!
|
||||
\qmltype BidirectionalBinding
|
||||
\inqmlmodule QtQuick.Studio.LogicHelper
|
||||
\since QtQuick.Studio.LogicHelper 1.0
|
||||
\inherits QtObject
|
||||
|
||||
\brief Binds the values of two controls bi-directionally.
|
||||
|
||||
The BidirectionalBinding type binds the values of two controls
|
||||
together, so that when one value is changed, the other one follows it.
|
||||
For example, this type could be used to synchronize two sliders or a
|
||||
slider and checkbox. Typically, it is used to bind a backend value to
|
||||
a control, such as a slider.
|
||||
|
||||
The \l target01 and \l target02 properties specify the ids of the components
|
||||
to bind together. The \l property01 and \l property02 properties specify the
|
||||
names the properties to synchronize.
|
||||
|
||||
Designers can use the BidirectionalBinding type in \QDS instead of writing
|
||||
JavaScript expressions.
|
||||
|
||||
A \l StringMapper type can be used to add a text property that displays the
|
||||
value.
|
||||
|
||||
\section1 Example Usage
|
||||
|
||||
In the following example, we bind the values of two \l Slider types
|
||||
together bidirectionally:
|
||||
|
||||
\code
|
||||
Rectangle {
|
||||
Slider {
|
||||
id: slider
|
||||
value: 0.5
|
||||
}
|
||||
Slider {
|
||||
id: slider1
|
||||
value: 0.5
|
||||
}
|
||||
|
||||
BidrectionalBinding {
|
||||
id: biDirectBinding
|
||||
property02: "value"
|
||||
property01: "value"
|
||||
target02: slider1
|
||||
target01: slider
|
||||
}
|
||||
}
|
||||
\endcode
|
||||
*/
|
||||
|
||||
QtObject {
|
||||
id: object
|
||||
|
||||
/*!
|
||||
The id of the component to bind to \l target02.
|
||||
*/
|
||||
property QtObject target01
|
||||
|
||||
/*!
|
||||
The id of the component to bind to \l target01.
|
||||
*/
|
||||
property QtObject target02
|
||||
|
||||
/*!
|
||||
The name of the property to synchronize with \l property02.
|
||||
*/
|
||||
property string property01
|
||||
|
||||
/*!
|
||||
The name of the property to synchronize with \l property01.
|
||||
*/
|
||||
property string property02
|
||||
|
||||
property QtObject __internal: QtObject {
|
||||
property variant value01
|
||||
property variant value02
|
||||
|
||||
property bool block: false
|
||||
|
||||
onValue01Changed: {
|
||||
if (__internal.block)
|
||||
return;
|
||||
|
||||
__internal.block = true;
|
||||
try {
|
||||
object.target02[property02] = __internal.value01
|
||||
} catch(error) {
|
||||
}
|
||||
__internal.block = false;
|
||||
}
|
||||
|
||||
onValue02Changed: {
|
||||
if (__internal.block)
|
||||
return;
|
||||
|
||||
__internal.block = true;
|
||||
try {
|
||||
object.target01[property01] = __internal.value02
|
||||
} catch(error) {
|
||||
}
|
||||
__internal.block = false;
|
||||
}
|
||||
}
|
||||
|
||||
property Binding __b01: Binding {
|
||||
target: __internal
|
||||
property: "value01"
|
||||
value: target01 ? target01[property01] : null
|
||||
}
|
||||
|
||||
property Binding __b02: Binding {
|
||||
target: __internal
|
||||
property: "value02"
|
||||
value: target02 ? target02[property02] : null
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
qt_add_library(QuickStudioLogicHelper STATIC)
|
||||
qt6_add_qml_module(QuickStudioLogicHelper
|
||||
URI "QtQuick.Studio.LogicHelper"
|
||||
VERSION "${PROJECT_VERSION}"
|
||||
RESOURCE_PREFIX "/qt-project.org/imports"
|
||||
DESIGNER_SUPPORTED
|
||||
PAST_MAJOR_VERSIONS 1
|
||||
${qds_qml_extra_args}
|
||||
QML_FILES
|
||||
BidirectionalBinding.qml
|
||||
RangeMapper.qml
|
||||
MinMaxMapper.qml
|
||||
StringMapper.qml
|
||||
OrOperator.qml
|
||||
AndOperator.qml
|
||||
NotOperator.qml
|
||||
)
|
||||
|
||||
register_plugin(QuickStudioLogicHelper)
|
||||
@@ -0,0 +1,132 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2020 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Quick Designer Components.
|
||||
**
|
||||
** $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.10
|
||||
|
||||
/*!
|
||||
\qmltype MinMaxMapper
|
||||
\inqmlmodule QtQuick.Studio.LogicHelper
|
||||
\since QtQuick.Studio.LogicHelper 1.0
|
||||
\inherits QtObject
|
||||
|
||||
\brief Provides access to values that are out or range.
|
||||
|
||||
The MinMaxMapper type has output values even if the input value is out
|
||||
of range or too small or big. This enables applying actions to values
|
||||
even if they are out of range, such as changing a color in a state.
|
||||
|
||||
To access the values of a control, the \l input property of the
|
||||
minimum-maximum mapper is bound to that of the \c value property
|
||||
of the control.
|
||||
|
||||
For example, to restrict the maximum value of a slider to 0.60,
|
||||
regardless of the maximum value set in the slider properties,
|
||||
we bind the value of the \l input property of the mapper to
|
||||
the value of the \c value property of the slider and set the value
|
||||
of the \l maximum property to 0.60.
|
||||
|
||||
The \l outOfRange, \l aboveMaximum and \l belowMinimum properties are set to
|
||||
\c true if the value of the \l input property is out of range.
|
||||
For example, in the context of speed, \l aboveMaximum being \c true
|
||||
would mean \e {too fast}, whereas \l belowMinimum being \c true would
|
||||
mean \e {too slow}, and \l outOfRange being \c true would mean
|
||||
\e {either too fast or too slow}.
|
||||
|
||||
Designers can use the Min Max Mapper type in \QDS instead of writing
|
||||
JavaScript expressions.
|
||||
|
||||
\section1 Example Usage
|
||||
|
||||
In the following example, we use the MinMaxMapper type to restrict the
|
||||
maximum value of a \l Slider type to 0.60, regardless of the maximum
|
||||
value set in the Slider properties:
|
||||
|
||||
\code
|
||||
Rectangle {
|
||||
Slider {
|
||||
id: slider
|
||||
value: 0.5
|
||||
}
|
||||
MinMaxMapper {
|
||||
id: minMaxMapper
|
||||
input: slider.value
|
||||
maximum: 0.6
|
||||
}
|
||||
}
|
||||
\endcode
|
||||
*/
|
||||
|
||||
QtObject {
|
||||
id: object
|
||||
|
||||
/*!
|
||||
The input value.
|
||||
*/
|
||||
property real input: 0
|
||||
|
||||
/*!
|
||||
Whether \l input is less than \l minimum.
|
||||
*/
|
||||
property bool belowMinimum: object.input < object.minimum
|
||||
|
||||
/*!
|
||||
Whether \l input is larger than \l maximum.
|
||||
*/
|
||||
property bool aboveMaximum: object.input > object.maximum
|
||||
|
||||
/*!
|
||||
Whether \l input is out of range. Returns \c true if \l belowMinimum or
|
||||
\l aboveMaximum is \c true.
|
||||
*/
|
||||
property bool outOfRange: object.aboveMaximum ||object.belowMinimum
|
||||
|
||||
/*!
|
||||
The value of \l input. If \l aboveMaximum is \c true, returns the value of
|
||||
\l maximum. If \l belowMinimum is \c true, returns the value of \l minimum.
|
||||
*/
|
||||
property real output: {
|
||||
if (object.aboveMaximum)
|
||||
return object.maximum
|
||||
|
||||
if (object.belowMinimum)
|
||||
return object.minimum
|
||||
|
||||
return object.input
|
||||
}
|
||||
|
||||
/*!
|
||||
The minimum value of \l input.
|
||||
*/
|
||||
property real minimum: 0
|
||||
|
||||
/*!
|
||||
The maximum value of \l input.
|
||||
*/
|
||||
property real maximum: 100
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2020 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Quick Designer Components.
|
||||
**
|
||||
** $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.10
|
||||
|
||||
/*!
|
||||
\qmltype NotOperator
|
||||
\inqmlmodule QtQuick.Studio.LogicHelper
|
||||
\since QtQuick.Studio.LogicHelper 1.0
|
||||
\inherits QtObject
|
||||
|
||||
\brief Evaluates a boolean input value and provides the result as output.
|
||||
|
||||
The NotOperator type evaluates the boolean input \l input. The \l output
|
||||
value is evaluated as \c true if \l input is evaluated as \c false.
|
||||
|
||||
Designers can use the Not Operator type in \QDS instead of writing
|
||||
JavaScript expressions.
|
||||
|
||||
\section1 Example Usage
|
||||
|
||||
In the following example, we use the checked state of a \l CheckBox to
|
||||
determine the checked state of another one:
|
||||
|
||||
\code
|
||||
Rectangle {
|
||||
CheckBox {
|
||||
id: checkBox1
|
||||
text: qsTr("Check Box 1")
|
||||
checked: false
|
||||
}
|
||||
CheckBox {
|
||||
id: checkBox2
|
||||
text: qsTr("Check Box 2")
|
||||
checked: notOperator.output
|
||||
}
|
||||
NotOperator {
|
||||
id: notOperator
|
||||
input: checkBox1.checked
|
||||
}
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa AndOperator, OrOperator
|
||||
*/
|
||||
|
||||
QtObject {
|
||||
id: object
|
||||
|
||||
/*!
|
||||
The value to evaluate.
|
||||
*/
|
||||
property bool input: false
|
||||
|
||||
/*!
|
||||
The result of the evaluation.
|
||||
*/
|
||||
property bool output: !object.input
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2020 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Quick Designer Components.
|
||||
**
|
||||
** $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.10
|
||||
|
||||
/*!
|
||||
\qmltype OrOperator
|
||||
\inqmlmodule QtQuick.Studio.LogicHelper
|
||||
\since QtQuick.Studio.LogicHelper 1.0
|
||||
\inherits QtObject
|
||||
|
||||
\brief Evaluates two boolean input values and provides the result as output.
|
||||
|
||||
The OrOperator type evaluates two boolean inputs, \l input01 and \l input02.
|
||||
The \l output is evaluated as \c true if either \l input01 or \l input02 is
|
||||
evaluated as \c true.
|
||||
|
||||
Designers can use the Or Operator type in \QDS instead of writing
|
||||
JavaScript expressions.
|
||||
|
||||
\section1 Example Usage
|
||||
|
||||
In the following example, we use the checked state of two \l CheckBox
|
||||
types to determine the checked state of a third one:
|
||||
|
||||
\code
|
||||
Rectangle {
|
||||
CheckBox {
|
||||
id: checkBox1
|
||||
text: qsTr("Check Box 1")
|
||||
checked: false
|
||||
}
|
||||
CheckBox {
|
||||
id: checkBox2
|
||||
text: qsTr("Check Box 2")
|
||||
}
|
||||
|
||||
CheckBox {
|
||||
id: checkBox3
|
||||
text: qsTr("Check Box 3")
|
||||
checked: orOperator.output
|
||||
}
|
||||
|
||||
OrOperator {
|
||||
id: orOperator
|
||||
input02: checkBox2.checked
|
||||
input01: checkBox1.checked
|
||||
}
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa AndOperator, NotOperator
|
||||
*/
|
||||
|
||||
QtObject {
|
||||
id: object
|
||||
|
||||
/*!
|
||||
The first value to evaluate.
|
||||
*/
|
||||
property bool input01: false
|
||||
|
||||
/*!
|
||||
The second value to evaluate.
|
||||
*/
|
||||
property bool input02: false
|
||||
|
||||
/*!
|
||||
The result of the evaluation.
|
||||
*/
|
||||
property bool output: object.input01 || object.input02
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2020 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Quick Designer Components.
|
||||
**
|
||||
** $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.10
|
||||
|
||||
/*!
|
||||
\qmltype RangeMapper
|
||||
\inqmlmodule QtQuick.Studio.LogicHelper
|
||||
\since QtQuick.Studio.LogicHelper 1.0
|
||||
\inherits QtObject
|
||||
|
||||
\brief Maps a numerical range to another range, so that the output value
|
||||
of the second range follows that of the original range.
|
||||
|
||||
The minimum and maximum input and output values are specified as values of
|
||||
the \l inputMinimum, \l inputMaximum, \l outputMinimum, and \l outputMaximum properties.
|
||||
The original value is specified as the value of the \l output property.
|
||||
|
||||
For example, if you map input in the range of \c {-1,1} to output in the
|
||||
range of \c {0,1000}, and the original value changes from -1 to 1, the
|
||||
output value will change from 0 to 1000. This is useful when remapping
|
||||
the current frame on the timeline, for example.
|
||||
|
||||
Designers can use the Range Mapper type in \QDS instead of writing
|
||||
JavaScript expressions.
|
||||
|
||||
\section1 Example Usage
|
||||
|
||||
In the following example, we use a RangeMapper type to map the value range
|
||||
from -1 to 1 that is specified for a \l Slider type to a range from 10 to
|
||||
1000:
|
||||
|
||||
\code
|
||||
Rectangle {
|
||||
Slider {
|
||||
id: slider
|
||||
from: -1
|
||||
to: 1
|
||||
value: -1
|
||||
}
|
||||
RangeMapper {
|
||||
id: rangeMapper
|
||||
outputMinimum: 10
|
||||
outputMaximum: 1000
|
||||
inputMinimum: slider.from
|
||||
inputMaximum: slider.to
|
||||
input: slider.value
|
||||
}
|
||||
}
|
||||
\endcode
|
||||
*/
|
||||
|
||||
QtObject {
|
||||
id: object
|
||||
|
||||
/*!
|
||||
The input value.
|
||||
*/
|
||||
property real input: 0
|
||||
|
||||
/*!
|
||||
The output value.
|
||||
*/
|
||||
property real output: {
|
||||
var slope = (object.outputMaximum - object.outputMinimum) / (object.inputMaximum - object.inputMinimum)
|
||||
return object.outputMinimum + slope * (object.input - object.inputMinimum)
|
||||
}
|
||||
|
||||
/*!
|
||||
The minimum input value.
|
||||
*/
|
||||
property real inputMinimum: 0
|
||||
|
||||
/*!
|
||||
The maximum input value.
|
||||
*/
|
||||
property real inputMaximum: 100
|
||||
|
||||
/*!
|
||||
The minimum output value.
|
||||
*/
|
||||
property real outputMinimum: 0
|
||||
|
||||
/*!
|
||||
The maximum output value.
|
||||
*/
|
||||
property real outputMaximum: 100
|
||||
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2020 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Quick Designer Components.
|
||||
**
|
||||
** $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.10
|
||||
|
||||
/*!
|
||||
\qmltype StringMapper
|
||||
\inqmlmodule QtQuick.Studio.LogicHelper
|
||||
\since QtQuick.Studio.LogicHelper 1.0
|
||||
\inherits QtObject
|
||||
|
||||
\brief Converts numbers to strings with the defined precision.
|
||||
|
||||
The StringMapper type maps numbers to strings. The string mapper
|
||||
\l input property is bound to the \c value property of a control that
|
||||
provides the number and the \l text property of the string mapper is
|
||||
mapped to the \c text property of type that displays the string.
|
||||
|
||||
Designers can use the String Mapper type in \QDS instead of writing
|
||||
JavaScript expressions.
|
||||
|
||||
\section1 Example Usage
|
||||
|
||||
In the following example, we use \l Text type to display the numerical
|
||||
value of a \l Slider type as a string:
|
||||
|
||||
\code
|
||||
Rectangle {
|
||||
Slider {
|
||||
id: slider
|
||||
value: 0.5
|
||||
}
|
||||
Text {
|
||||
id: text1
|
||||
text: stringMapper.text
|
||||
}
|
||||
StringMapper {
|
||||
id: stringMapper
|
||||
input: slider.value
|
||||
}
|
||||
}
|
||||
\endcode
|
||||
*/
|
||||
|
||||
QtObject {
|
||||
id: object
|
||||
|
||||
/*!
|
||||
The value to convert to a string.
|
||||
*/
|
||||
property real input: 0
|
||||
|
||||
/*!
|
||||
The number of digits after the decimal separator.
|
||||
*/
|
||||
property int decimals: 2
|
||||
|
||||
/*!
|
||||
The \l input value as a string.
|
||||
*/
|
||||
property string text: object.input.toFixed(object.decimals)
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2018 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Quick Designer Components.
|
||||
**
|
||||
** $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$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <QtQml/qqmlextensionplugin.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class LogicHelperPlugin: public QQmlExtensionPlugin
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid)
|
||||
|
||||
public:
|
||||
LogicHelperPlugin(QObject *parent = nullptr);
|
||||
void registerTypes(const char *uri) override;
|
||||
};
|
||||
|
||||
LogicHelperPlugin::LogicHelperPlugin(QObject *parent)
|
||||
: QQmlExtensionPlugin(parent)
|
||||
{
|
||||
}
|
||||
|
||||
void LogicHelperPlugin::registerTypes(const char *)
|
||||
{
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#include "logichelperplugin.moc"
|
||||
@@ -0,0 +1,13 @@
|
||||
import QtQuick.tooling 1.2
|
||||
|
||||
// This file describes the plugin-supplied types contained in the library.
|
||||
// It is used for QML tooling purposes only.
|
||||
//
|
||||
// This file was auto-generated by:
|
||||
// 'qmlplugindump -nonrelocatable -dependencies dependencies.json QtQuick.Controls 2.15'
|
||||
|
||||
Module {
|
||||
dependencies: [
|
||||
"QtQuick 2.11"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
module QtQuick.Studio.LogicHelper
|
||||
linktarget QtQuickStudioLogicHelperplugin
|
||||
optional plugin QtQuickStudioLogicHelperplugin
|
||||
classname QtQuick_Studio_LogicHelperPlugin
|
||||
typeinfo QtQuickStudioLogicHelper.qmltypes
|
||||
prefer :/QtQuick/Studio/LogicHelper/
|
||||
BidirectionalBinding 1.0 BidirectionalBinding.qml
|
||||
RangeMapper 1.0 RangeMapper.qml
|
||||
MinMaxMapper 1.0 MinMaxMapper.qml
|
||||
StringMapper 1.0 StringMapper.qml
|
||||
OrOperator 1.0 OrOperator.qml
|
||||
AndOperator 1.0 AndOperator.qml
|
||||
NotOperator 1.0 NotOperator.qml
|
||||
|
||||
Reference in New Issue
Block a user