PhoneInput.qml 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import QtQuick 2.9
  2. import QtQuick.Layouts 1.2
  3. import QtQuick.Controls 2.3
  4. InputRow {
  5. property alias number: _inputItem.text
  6. property int countryCode: parseInt(_ccModel.get(_countryCode.currentIndex).code, 10)
  7. RowLayout {
  8. anchors.fill: parent
  9. ComboBox {
  10. id: _countryCode
  11. Layout.alignment: Qt.AlignLeft | Qt.AlignBottom
  12. textRole: "name"
  13. model: CountryCodesModel {
  14. id: _ccModel
  15. }
  16. font.pointSize: 12
  17. font.weight: Font.Bold
  18. contentItem: Item {
  19. clip: true
  20. implicitHeight: comboBoxItem.implicitHeight + 20
  21. implicitWidth: 130
  22. SecondaryText {
  23. id: comboBoxItem
  24. anchors.bottom: parent.bottom
  25. anchors.bottomMargin: 10
  26. anchors.left: parent.left
  27. anchors.leftMargin: 10
  28. anchors.right: parent.right
  29. elide: Text.ElideMiddle
  30. text: _countryCode.currentText
  31. }
  32. }
  33. background: Rectangle {
  34. anchors.fill: parent
  35. color: _countryCode.pressed ? "#55ffffff" : "#00ffffff"
  36. }
  37. delegate: ItemDelegate {
  38. font.pointSize: 12
  39. text: model.name
  40. }
  41. }
  42. TextInput {
  43. id: _inputItem
  44. Layout.fillWidth: true
  45. Layout.alignment: Qt.AlignBottom
  46. font.pointSize: 12
  47. color: "#ffffff"
  48. validator: RegExpValidator {
  49. regExp:/\d*/
  50. }
  51. Rectangle {
  52. anchors.top: _inputItem.bottom
  53. width: _inputItem.width
  54. color: "#cfdfe7"
  55. height: 1
  56. }
  57. }
  58. }
  59. }