|
|
@ -1,25 +1,31 @@ |
|
|
|
import QtQuick 2.2 |
|
|
|
import QtQuick 2.2 |
|
|
|
import QtQuick.Controls 1.2 |
|
|
|
import QtQuick.Controls 1.2 |
|
|
|
import QtQuick.Controls.Styles 1.2 |
|
|
|
import QtQuick.Controls.Styles 1.2 |
|
|
|
|
|
|
|
import QtQuick.Layouts 1.2 |
|
|
|
|
|
|
|
|
|
|
|
import QGroundControl.Palette 1.0 |
|
|
|
import QGroundControl.Palette 1.0 |
|
|
|
import QGroundControl.ScreenTools 1.0 |
|
|
|
import QGroundControl.ScreenTools 1.0 |
|
|
|
|
|
|
|
|
|
|
|
TextField { |
|
|
|
TextField { |
|
|
|
id: root |
|
|
|
id: root |
|
|
|
|
|
|
|
|
|
|
|
property bool showUnits: false |
|
|
|
property bool showUnits: false |
|
|
|
|
|
|
|
property bool showHelp: false |
|
|
|
property string unitsLabel: "" |
|
|
|
property string unitsLabel: "" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
signal helpClicked |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
property real _helpLayoutWidth: 0 |
|
|
|
|
|
|
|
|
|
|
|
Component.onCompleted: { |
|
|
|
Component.onCompleted: { |
|
|
|
if (typeof qgcTextFieldforwardKeysTo !== 'undefined') { |
|
|
|
if (typeof qgcTextFieldforwardKeysTo !== 'undefined') { |
|
|
|
root.Keys.forwardTo = [qgcTextFieldforwardKeysTo] |
|
|
|
root.Keys.forwardTo = [qgcTextFieldforwardKeysTo] |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
property var __qgcPal: QGCPalette { colorGroupEnabled: enabled } |
|
|
|
QGCPalette { id: qgcPal; colorGroupEnabled: enabled } |
|
|
|
|
|
|
|
|
|
|
|
textColor: __qgcPal.textFieldText |
|
|
|
textColor: qgcPal.textFieldText |
|
|
|
height: Math.round(Math.max(25, ScreenTools.defaultFontPixelHeight * (ScreenTools.isMobile ? 2.5 : 1.2))) |
|
|
|
height: Math.round(Math.max(25, ScreenTools.defaultFontPixelHeight * (ScreenTools.isMobile ? 2.5 : 1.2))) |
|
|
|
|
|
|
|
|
|
|
|
QGCLabel { |
|
|
|
QGCLabel { |
|
|
@ -35,6 +41,8 @@ TextField { |
|
|
|
background: Item { |
|
|
|
background: Item { |
|
|
|
id: backgroundItem |
|
|
|
id: backgroundItem |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
property bool showHelp: control.showHelp && control.activeFocus |
|
|
|
|
|
|
|
|
|
|
|
Rectangle { |
|
|
|
Rectangle { |
|
|
|
anchors.fill: parent |
|
|
|
anchors.fill: parent |
|
|
|
anchors.bottomMargin: -1 |
|
|
|
anchors.bottomMargin: -1 |
|
|
@ -44,32 +52,58 @@ TextField { |
|
|
|
Rectangle { |
|
|
|
Rectangle { |
|
|
|
anchors.fill: parent |
|
|
|
anchors.fill: parent |
|
|
|
border.color: control.activeFocus ? "#47b" : "#999" |
|
|
|
border.color: control.activeFocus ? "#47b" : "#999" |
|
|
|
color: __qgcPal.textField |
|
|
|
color: qgcPal.textField |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Text { |
|
|
|
RowLayout { |
|
|
|
id: unitsLabel |
|
|
|
id: unitsHelpLayout |
|
|
|
|
|
|
|
anchors.top: parent.top |
|
|
|
anchors.top: parent.top |
|
|
|
anchors.bottom: parent.bottom |
|
|
|
anchors.bottom: parent.bottom |
|
|
|
anchors.rightMargin: backgroundItem.showHelp ? 0 : control.__contentHeight * 0.333 |
|
|
|
|
|
|
|
anchors.right: parent.right |
|
|
|
verticalAlignment: Text.AlignVCenter |
|
|
|
spacing: 4 |
|
|
|
horizontalAlignment:Text.AlignHCenter |
|
|
|
|
|
|
|
|
|
|
|
Component.onCompleted: control._helpLayoutWidth = unitsHelpLayout.width |
|
|
|
x: parent.width - width |
|
|
|
onWidthChanged: control._helpLayoutWidth = unitsHelpLayout.width |
|
|
|
width: unitsLabelWidthGenerator.width |
|
|
|
|
|
|
|
|
|
|
|
Text { |
|
|
|
text: control.unitsLabel |
|
|
|
anchors.verticalCenter: parent.verticalCenter |
|
|
|
font.pointSize: ScreenTools.defaultFontPointSize |
|
|
|
text: control.unitsLabel |
|
|
|
font.family: ScreenTools.normalFontFamily |
|
|
|
font.pointSize: backgroundItem.showHelp ? ScreenTools.smallFontPointSize : ScreenTools.defaultFontPointSize |
|
|
|
antialiasing: true |
|
|
|
font.family: ScreenTools.normalFontFamily |
|
|
|
|
|
|
|
antialiasing: true |
|
|
|
|
|
|
|
color: control.textColor |
|
|
|
|
|
|
|
visible: control.showUnits |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Rectangle { |
|
|
|
|
|
|
|
anchors.margins: 2 |
|
|
|
|
|
|
|
anchors.top: parent.top |
|
|
|
|
|
|
|
anchors.bottom: parent.bottom |
|
|
|
|
|
|
|
anchors.right: parent.right |
|
|
|
|
|
|
|
width: height * 0.75 |
|
|
|
|
|
|
|
color: control.textColor |
|
|
|
|
|
|
|
radius: 2 |
|
|
|
|
|
|
|
visible: backgroundItem.showHelp |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QGCLabel { |
|
|
|
|
|
|
|
anchors.fill: parent |
|
|
|
|
|
|
|
verticalAlignment: Text.AlignVCenter |
|
|
|
|
|
|
|
horizontalAlignment: Text.AlignHCenter |
|
|
|
|
|
|
|
color: qgcPal.textField |
|
|
|
|
|
|
|
text: "?" |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
color: control.textColor |
|
|
|
MouseArea { |
|
|
|
visible: control.showUnits |
|
|
|
anchors.fill: unitsHelpLayout |
|
|
|
|
|
|
|
enabled: control.activeFocus |
|
|
|
|
|
|
|
onClicked: root.helpClicked() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
padding.right: control.showUnits ? unitsLabelWidthGenerator.width : control.__contentHeight * 0.333 |
|
|
|
padding.right: control._helpLayoutWidth //control.showUnits ? unitsLabelWidthGenerator.width : control.__contentHeight * 0.333 |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
onActiveFocusChanged: { |
|
|
|
onActiveFocusChanged: { |
|
|
|