2011-07-06 15:48:52 +00:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
|
|
|
|
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
|
|
|
|
**
|
|
|
|
|
** Contact: Nokia Corporation (info@qt.nokia.com)
|
|
|
|
|
**
|
|
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
|
**
|
|
|
|
|
** This file may be used under the terms of the GNU Lesser General Public
|
|
|
|
|
** License version 2.1 as published by the Free Software Foundation and
|
|
|
|
|
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
|
|
|
|
** Please review the following information to ensure the GNU Lesser General
|
|
|
|
|
** Public License version 2.1 requirements will be met:
|
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
|
|
|
**
|
|
|
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
|
|
|
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
|
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
|
|
|
|
** Other Usage
|
|
|
|
|
**
|
|
|
|
|
** Alternatively, this file may be used in accordance with the terms and
|
|
|
|
|
** conditions contained in a signed written agreement between you and Nokia.
|
|
|
|
|
**
|
|
|
|
|
** If you have questions regarding the use of this file, please contact
|
|
|
|
|
** Nokia at info@qt.nokia.com.
|
|
|
|
|
**
|
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
2010-04-13 11:37:57 +02:00
|
|
|
import Qt 4.7
|
2010-01-27 11:48:46 +01:00
|
|
|
import Bauhaus 1.0
|
|
|
|
|
|
2010-12-16 11:03:07 +01:00
|
|
|
AnimatedToolButton {
|
2010-02-05 15:42:31 +10:00
|
|
|
id: extendedFunctionButton
|
2010-01-27 11:48:46 +01:00
|
|
|
|
2010-04-13 11:20:39 +02:00
|
|
|
property variant backendValue
|
2010-01-27 11:48:46 +01:00
|
|
|
|
2010-12-16 11:03:07 +01:00
|
|
|
hoverIconFromFile: "images/submenu.png";
|
|
|
|
|
|
2010-03-23 10:02:49 +01:00
|
|
|
function setIcon() {
|
|
|
|
|
if (backendValue == null)
|
|
|
|
|
extendedFunctionButton.iconFromFile = "images/placeholder.png"
|
2011-06-21 16:11:55 +02:00
|
|
|
else if (backendValue.isBound ) {
|
|
|
|
|
if (backendValue.isTranslated) { //translations are a special case
|
|
|
|
|
extendedFunctionButton.iconFromFile = "images/placeholder.png"
|
|
|
|
|
} else {
|
|
|
|
|
extendedFunctionButton.iconFromFile = "images/expression.png"
|
|
|
|
|
}
|
2010-03-23 10:02:49 +01:00
|
|
|
} else {
|
|
|
|
|
if (backendValue.complexNode != null && backendValue.complexNode.exists) {
|
|
|
|
|
extendedFunctionButton.iconFromFile = "images/behaivour.png"
|
2010-01-27 11:48:46 +01:00
|
|
|
} else {
|
2010-03-23 10:02:49 +01:00
|
|
|
extendedFunctionButton.iconFromFile = "images/placeholder.png"
|
2010-01-27 11:48:46 +01:00
|
|
|
}
|
2010-02-26 15:36:27 +01:00
|
|
|
}
|
2010-01-27 11:48:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onBackendValueChanged: {
|
|
|
|
|
setIcon();
|
|
|
|
|
}
|
2010-03-18 11:48:03 +01:00
|
|
|
property bool isBoundBackend: backendValue.isBound;
|
2011-06-21 16:11:55 +02:00
|
|
|
property string backendExpression: backendValue.expression;
|
2010-01-27 11:48:46 +01:00
|
|
|
|
|
|
|
|
onIsBoundBackendChanged: {
|
|
|
|
|
setIcon();
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-21 16:11:55 +02:00
|
|
|
onBackendExpressionChanged: {
|
|
|
|
|
setIcon();
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-27 11:48:46 +01:00
|
|
|
toolButtonStyle: "Qt::ToolButtonIconOnly"
|
|
|
|
|
popupMode: "QToolButton::InstantPopup";
|
|
|
|
|
property bool active: false;
|
|
|
|
|
|
|
|
|
|
iconFromFile: "images/placeholder.png";
|
|
|
|
|
width: 14;
|
|
|
|
|
height: 14;
|
|
|
|
|
focusPolicy: "Qt::NoFocus";
|
|
|
|
|
|
|
|
|
|
styleSheet: "*::down-arrow, *::menu-indicator { image: none; width: 0; height: 0; }";
|
|
|
|
|
|
|
|
|
|
onActiveChanged: {
|
|
|
|
|
if (active) {
|
|
|
|
|
setIcon();
|
|
|
|
|
opacity = 1;
|
|
|
|
|
} else {
|
|
|
|
|
opacity = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
actions: [
|
|
|
|
|
QAction {
|
2010-03-25 14:59:54 +01:00
|
|
|
text: qsTr("Reset")
|
2010-04-12 15:11:36 +02:00
|
|
|
visible: backendValue.isInSubState || backendValue.isInModel
|
2010-01-27 11:48:46 +01:00
|
|
|
onTriggered: {
|
2010-04-19 11:18:41 +02:00
|
|
|
transaction.start();
|
|
|
|
|
backendValue.resetValue();
|
|
|
|
|
backendValue.resetValue();
|
|
|
|
|
transaction.end();
|
2010-01-27 11:48:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
QAction {
|
2010-03-25 14:59:54 +01:00
|
|
|
text: qsTr("Set Expression");
|
2010-01-27 11:48:46 +01:00
|
|
|
onTriggered: {
|
2011-07-21 11:55:54 +02:00
|
|
|
expressionEdit.globalY = extendedFunctionButton.globalY - 10;
|
2010-02-05 15:42:31 +10:00
|
|
|
expressionEdit.backendValue = extendedFunctionButton.backendValue
|
2011-07-21 11:55:54 +02:00
|
|
|
|
|
|
|
|
if ((expressionEdit.y + expressionEdit.height + 20) > frame.height)
|
|
|
|
|
expressionEdit.y = frame.height - expressionEdit.height - 20
|
|
|
|
|
|
2010-01-27 11:48:46 +01:00
|
|
|
expressionEdit.show();
|
|
|
|
|
expressionEdit.raise();
|
|
|
|
|
expressionEdit.active = true;
|
|
|
|
|
}
|
2010-02-26 15:36:27 +01:00
|
|
|
}
|
2010-01-27 11:48:46 +01:00
|
|
|
]
|
|
|
|
|
}
|