2013-09-16 16:55:07 +02:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
2016-01-15 14:59:14 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2013-09-16 16:55:07 +02:00
|
|
|
**
|
|
|
|
|
** 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
|
2016-01-15 14:59:14 +01:00
|
|
|
** 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.
|
2013-09-16 16:55:07 +02:00
|
|
|
**
|
2015-09-18 11:34:48 +02:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
2016-01-15 14:59:14 +01:00
|
|
|
** 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.
|
2013-09-16 16:55:07 +02:00
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
import QtQuick 2.1
|
|
|
|
|
import QtQuick.Controls 1.0 as Controls
|
|
|
|
|
import QtQuick.Window 2.0
|
2013-11-04 14:47:56 +01:00
|
|
|
import QtQuick.Controls.Styles 1.1
|
|
|
|
|
import "Constants.js" as Constants
|
2013-09-16 16:55:07 +02:00
|
|
|
|
|
|
|
|
Item {
|
|
|
|
|
width: 14
|
|
|
|
|
height: 14
|
|
|
|
|
|
|
|
|
|
id: extendedFunctionButton
|
|
|
|
|
|
|
|
|
|
property variant backendValue
|
|
|
|
|
|
2016-07-13 16:50:31 +02:00
|
|
|
property string icon: "image://icons/placeholder"
|
|
|
|
|
property string hoverIcon: "image://icons/submenu"
|
2013-09-16 16:55:07 +02:00
|
|
|
|
|
|
|
|
property bool active: true
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function setIcon() {
|
|
|
|
|
if (backendValue == null) {
|
2016-07-13 16:50:31 +02:00
|
|
|
extendedFunctionButton.icon = "image://icons/placeholder"
|
2013-09-16 16:55:07 +02:00
|
|
|
} else if (backendValue.isBound ) {
|
|
|
|
|
if (backendValue.isTranslated) { //translations are a special case
|
2016-07-13 16:50:31 +02:00
|
|
|
extendedFunctionButton.icon = "image://icons/placeholder"
|
2013-09-16 16:55:07 +02:00
|
|
|
} else {
|
2016-07-13 16:50:31 +02:00
|
|
|
extendedFunctionButton.icon = "image://icons/expression"
|
2013-09-16 16:55:07 +02:00
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (backendValue.complexNode != null && backendValue.complexNode.exists) {
|
|
|
|
|
} else {
|
2016-07-13 16:50:31 +02:00
|
|
|
extendedFunctionButton.icon = "image://icons/placeholder"
|
2013-09-16 16:55:07 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onBackendValueChanged: {
|
|
|
|
|
setIcon();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
property bool isBoundBackend: backendValue.isBound;
|
|
|
|
|
property string backendExpression: backendValue.expression;
|
|
|
|
|
|
|
|
|
|
onActiveChanged: {
|
2013-11-04 14:47:56 +01:00
|
|
|
if (active) {
|
|
|
|
|
setIcon();
|
|
|
|
|
opacity = 1;
|
|
|
|
|
} else {
|
|
|
|
|
opacity = 0;
|
2013-09-16 16:55:07 +02:00
|
|
|
}
|
2013-11-04 14:47:56 +01:00
|
|
|
}
|
2013-09-16 16:55:07 +02:00
|
|
|
|
|
|
|
|
onIsBoundBackendChanged: {
|
|
|
|
|
setIcon();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onBackendExpressionChanged: {
|
|
|
|
|
setIcon();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Image {
|
2016-07-13 16:50:31 +02:00
|
|
|
width: 14
|
|
|
|
|
height: 14
|
2013-09-16 16:55:07 +02:00
|
|
|
source: extendedFunctionButton.icon
|
|
|
|
|
anchors.centerIn: parent
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
|
hoverEnabled: true
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
onHoveredChanged: {
|
|
|
|
|
if (containsMouse)
|
|
|
|
|
icon = hoverIcon
|
|
|
|
|
else
|
|
|
|
|
setIcon()
|
|
|
|
|
}
|
|
|
|
|
onClicked: {
|
|
|
|
|
menu.popup();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 14:47:56 +01:00
|
|
|
Controls.Menu {
|
|
|
|
|
id: menu
|
|
|
|
|
Controls.MenuItem {
|
|
|
|
|
text: "Reset"
|
|
|
|
|
onTriggered: {
|
|
|
|
|
transaction.start();
|
|
|
|
|
backendValue.resetValue();
|
|
|
|
|
backendValue.resetValue();
|
|
|
|
|
transaction.end();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Controls.MenuItem {
|
|
|
|
|
text: "Set Binding"
|
|
|
|
|
onTriggered: {
|
|
|
|
|
textField.text = backendValue.expression
|
|
|
|
|
expressionDialog.visible = true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
|
parent: itemPane
|
|
|
|
|
visible: false
|
|
|
|
|
x: 10
|
|
|
|
|
color: "#424242"
|
|
|
|
|
|
|
|
|
|
radius: 3
|
|
|
|
|
border.color: "black"
|
|
|
|
|
gradient: Gradient {
|
|
|
|
|
GradientStop {color: "#2c2c2c" ; position: 0}
|
|
|
|
|
GradientStop {color: "#343434" ; position: 0.15}
|
|
|
|
|
GradientStop {color: "#373737" ; position: 1.0}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
id: expressionDialog
|
|
|
|
|
|
|
|
|
|
onVisibleChanged: {
|
|
|
|
|
var pos = itemPane.mapFromItem(extendedFunctionButton.parent, 0, 0);
|
|
|
|
|
y = pos.y + 2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
width: parent.width - 20
|
|
|
|
|
height: 120
|
|
|
|
|
|
|
|
|
|
Controls.TextField {
|
|
|
|
|
id: textField
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
anchors.leftMargin: 4
|
|
|
|
|
anchors.rightMargin: 4
|
|
|
|
|
anchors.topMargin: 4
|
|
|
|
|
anchors.bottomMargin: 20
|
|
|
|
|
onAccepted: {
|
|
|
|
|
backendValue.expression = textField.text
|
|
|
|
|
expressionDialog.visible = false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
style: TextFieldStyle {
|
|
|
|
|
textColor: Constants.colorsDefaultText
|
|
|
|
|
padding.top: 3
|
|
|
|
|
padding.bottom: 1
|
|
|
|
|
padding.left: 16
|
|
|
|
|
placeholderTextColor: "gray"
|
|
|
|
|
background: Rectangle {
|
|
|
|
|
implicitWidth: 100
|
|
|
|
|
implicitHeight: 23
|
|
|
|
|
radius: 3
|
|
|
|
|
gradient: Gradient {
|
|
|
|
|
GradientStop {color: "#2c2c2c" ; position: 0}
|
|
|
|
|
GradientStop {color: "#343434" ; position: 0.15}
|
|
|
|
|
GradientStop {color: "#373737" ; position: 1.0}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Row {
|
|
|
|
|
spacing: 0
|
|
|
|
|
Button {
|
|
|
|
|
style: ButtonStyle {
|
|
|
|
|
background: Image {
|
|
|
|
|
source: "images/apply.png"
|
|
|
|
|
Rectangle {
|
|
|
|
|
opacity: control.pressed ? 0.5 : 0
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
gradient: Gradient {
|
|
|
|
|
GradientStop {color: "#606060" ; position: 0}
|
|
|
|
|
GradientStop {color: "#404040" ; position: 0.07}
|
|
|
|
|
GradientStop {color: "#303030" ; position: 1}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
onClicked: {
|
|
|
|
|
backendValue.expression = textField.text
|
|
|
|
|
expressionDialog.visible = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Button {
|
|
|
|
|
style: ButtonStyle {
|
|
|
|
|
background: Image {
|
|
|
|
|
source: "images/cancel.png"
|
|
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
|
opacity: control.pressed ? 0.5 : 0
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
gradient: Gradient {
|
|
|
|
|
GradientStop {color: "#606060" ; position: 0}
|
|
|
|
|
GradientStop {color: "#404040" ; position: 0.07}
|
|
|
|
|
GradientStop {color: "#303030" ; position: 1}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
onClicked: {
|
|
|
|
|
expressionDialog.visible = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-09-16 16:55:07 +02:00
|
|
|
|
|
|
|
|
}
|