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 18:38:09 +01:00
|
|
|
import Bauhaus 1.0
|
|
|
|
|
|
|
|
|
|
QWidget {
|
2010-02-05 15:42:31 +10:00
|
|
|
id: lineEdit
|
2010-01-27 18:38:09 +01:00
|
|
|
|
2010-04-13 11:20:39 +02:00
|
|
|
property variant backendValue
|
2010-02-05 15:42:31 +10:00
|
|
|
property alias enabled: lineEdit.enabled
|
2010-04-13 11:20:39 +02:00
|
|
|
property variant baseStateFlag
|
2010-02-26 15:20:34 +01:00
|
|
|
property alias text: lineEditWidget.text
|
2010-02-26 17:24:36 +01:00
|
|
|
property alias readOnly: lineEditWidget.readOnly
|
2011-06-21 16:11:55 +02:00
|
|
|
property alias translation: trCheckbox.visible
|
2010-01-27 18:38:09 +01:00
|
|
|
|
|
|
|
|
minimumHeight: 24;
|
|
|
|
|
|
2010-02-26 15:20:34 +01:00
|
|
|
onBaseStateFlagChanged: {
|
|
|
|
|
evaluate();
|
|
|
|
|
}
|
|
|
|
|
|
2010-04-13 11:20:39 +02:00
|
|
|
property variant isEnabled: lineEdit.enabled
|
2010-02-26 15:20:34 +01:00
|
|
|
onIsEnabledChanged: {
|
|
|
|
|
evaluate();
|
|
|
|
|
}
|
|
|
|
|
|
2010-04-16 11:28:37 +02:00
|
|
|
|
|
|
|
|
property bool isInModel: backendValue.isInModel;
|
|
|
|
|
onIsInModelChanged: {
|
|
|
|
|
evaluate();
|
|
|
|
|
}
|
|
|
|
|
property bool isInSubState: backendValue.isInSubState;
|
|
|
|
|
onIsInSubStateChanged: {
|
|
|
|
|
evaluate();
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-23 10:02:49 +01:00
|
|
|
function evaluate() {
|
|
|
|
|
if (!enabled) {
|
|
|
|
|
lineEditWidget.setStyleSheet("color: "+scheme.disabledColor);
|
|
|
|
|
} else {
|
|
|
|
|
if (baseStateFlag) {
|
|
|
|
|
if (backendValue != null && backendValue.isInModel)
|
|
|
|
|
lineEditWidget.setStyleSheet("color: "+scheme.changedBaseColor);
|
|
|
|
|
else
|
|
|
|
|
lineEditWidget.setStyleSheet("color: "+scheme.defaultColor);
|
|
|
|
|
} else {
|
|
|
|
|
if (backendValue != null && backendValue.isInSubState)
|
|
|
|
|
lineEditWidget.setStyleSheet("color: "+scheme.changedStateColor);
|
|
|
|
|
else
|
|
|
|
|
lineEditWidget.setStyleSheet("color: "+scheme.defaultColor);
|
|
|
|
|
}
|
2010-02-25 16:48:20 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ColorScheme { id:scheme; }
|
|
|
|
|
|
2010-01-27 18:38:09 +01:00
|
|
|
QLineEdit {
|
2010-04-16 11:28:37 +02:00
|
|
|
y: 2
|
2010-01-27 18:38:09 +01:00
|
|
|
id: lineEditWidget
|
2010-04-09 17:23:11 +02:00
|
|
|
styleSheet: "QLineEdit { padding-left: 32; }"
|
2010-02-05 15:42:31 +10:00
|
|
|
width: lineEdit.width
|
|
|
|
|
height: lineEdit.height
|
2010-04-29 09:51:24 +02:00
|
|
|
toolTip: backendValue.isBound ? backendValue.expression : ""
|
2010-04-21 11:28:17 +02:00
|
|
|
|
|
|
|
|
property string valueFromBackend: (backendValue === undefined || backendValue.value === undefined) ? "" : backendValue.value;
|
2010-01-27 18:38:09 +01:00
|
|
|
|
2010-04-21 11:28:17 +02:00
|
|
|
onValueFromBackendChanged: {
|
|
|
|
|
if (backendValue.value === undefined)
|
|
|
|
|
return;
|
|
|
|
|
text = backendValue.value;
|
|
|
|
|
}
|
2010-01-27 18:38:09 +01:00
|
|
|
|
2010-02-26 17:09:32 +01:00
|
|
|
onEditingFinished: {
|
2011-06-21 16:11:55 +02:00
|
|
|
if (backendValue.isTranslated) {
|
|
|
|
|
backendValue.expression = "qsTr(\"" + text + "\")"
|
|
|
|
|
} else {
|
|
|
|
|
backendValue.value = text
|
|
|
|
|
}
|
2010-02-26 15:20:34 +01:00
|
|
|
evaluate();
|
2010-01-27 18:38:09 +01:00
|
|
|
}
|
2010-02-25 16:48:20 +01:00
|
|
|
|
|
|
|
|
onFocusChanged: {
|
|
|
|
|
if (focus)
|
2010-04-16 11:28:37 +02:00
|
|
|
backendValue.lock();
|
2010-02-25 16:48:20 +01:00
|
|
|
else
|
2010-04-16 11:28:37 +02:00
|
|
|
backendValue.unlock();
|
2010-02-25 16:48:20 +01:00
|
|
|
}
|
2010-01-27 18:38:09 +01:00
|
|
|
|
|
|
|
|
|
2010-02-26 15:36:27 +01:00
|
|
|
}
|
2010-01-27 18:38:09 +01:00
|
|
|
ExtendedFunctionButton {
|
2010-02-05 15:42:31 +10:00
|
|
|
backendValue: lineEdit.backendValue
|
2010-04-16 11:28:37 +02:00
|
|
|
y: 6
|
2010-03-24 17:11:17 +01:00
|
|
|
x: 0
|
2010-02-05 15:42:31 +10:00
|
|
|
visible: lineEdit.enabled
|
2010-01-27 18:38:09 +01:00
|
|
|
}
|
2011-06-21 16:11:55 +02:00
|
|
|
QCheckBox {
|
|
|
|
|
id: trCheckbox
|
|
|
|
|
y: 2
|
|
|
|
|
styleSheetFile: "checkbox_tr.css";
|
|
|
|
|
toolTip: qsTr("Translate this string")
|
|
|
|
|
x: lineEditWidget.width - 22
|
|
|
|
|
height: lineEdit.height - 2;
|
|
|
|
|
width: 24
|
|
|
|
|
visible: false
|
|
|
|
|
checked: backendValue.isTranslated
|
|
|
|
|
onToggled: {
|
|
|
|
|
if (trCheckbox.checked) {
|
|
|
|
|
backendValue.expression = "qsTr(\"" + lineEditWidget.text + "\")"
|
|
|
|
|
} else {
|
|
|
|
|
backendValue.value = lineEditWidget.text
|
|
|
|
|
}
|
|
|
|
|
evaluate();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onVisibleChanged: {
|
|
|
|
|
if (trCheckbox.visible) {
|
|
|
|
|
trCheckbox.raise();
|
|
|
|
|
lineEditWidget.styleSheet = "QLineEdit { padding-left: 32; padding-right: 62;}"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-01-27 18:38:09 +01:00
|
|
|
}
|