linphone-desktop/linphone-app/ui/modules/Common/Form/Fields/HexField.qml
Julien Wadel 6f4b12c61e Backup
2021-08-01 22:48:17 +02:00

52 lines
1.2 KiB
QML

import QtQuick 2.7
import Common.Styles 1.0
// =============================================================================
Item {
id: wrapper
// ---------------------------------------------------------------------------
property alias readOnly: textField.readOnly
property string text
// ---------------------------------------------------------------------------
signal editingFinished (int value)
// ---------------------------------------------------------------------------
function _computeText (text) {
return (+text).toString(16).toUpperCase()
}
// ---------------------------------------------------------------------------
implicitHeight: textField.height
width: TextFieldStyle.normal.background.width
// ---------------------------------------------------------------------------
Binding {
property: 'text'
target: textField
value: _computeText(wrapper.text)
}
TextField {
id: textField
validator: RegExpValidator {
regExp: /[0-9A-Fa-f]*/
}
width: parent.width
onEditingFinished: {
text = _computeText('0x' + text)
wrapper.editingFinished(parseInt(text, 16))
}
}
}