PhoneInput.qml 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * MIT License
  3. *
  4. * Copyright (c) 2019 Alexey Edelev <semlanik@gmail.com>
  5. *
  6. * This file is part of QtProtobuf project https://git.semlanik.org/semlanik/qtprotobuf
  7. *
  8. * Permission is hereby granted, free of charge, to any person obtaining a copy of this
  9. * software and associated documentation files (the "Software"), to deal in the Software
  10. * without restriction, including without limitation the rights to use, copy, modify,
  11. * merge, publish, distribute, sublicense, and/or sell copies of the Software, and
  12. * to permit persons to whom the Software is furnished to do so, subject to the following
  13. * conditions:
  14. *
  15. * The above copyright notice and this permission notice shall be included in all copies
  16. * or substantial portions of the Software.
  17. *
  18. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
  19. * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  20. * PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
  21. * FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  22. * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  23. * DEALINGS IN THE SOFTWARE.
  24. */
  25. import QtQuick 2.9
  26. import QtQuick.Layouts 1.2
  27. import QtQuick.Controls 2.4
  28. InputRow {
  29. property alias number: _inputItem.text
  30. property int countryCode: parseInt(_ccModel.get(_countryCode.currentIndex).code, 10)
  31. RowLayout {
  32. anchors.fill: parent
  33. ComboBox {
  34. id: _countryCode
  35. Layout.alignment: Qt.AlignLeft | Qt.AlignBottom
  36. textRole: "name"
  37. model: CountryCodesModel {
  38. id: _ccModel
  39. }
  40. font.pointSize: 12
  41. font.weight: Font.Bold
  42. contentItem: Item {
  43. clip: true
  44. implicitHeight: comboBoxItem.implicitHeight + 20
  45. implicitWidth: 130
  46. SecondaryText {
  47. id: comboBoxItem
  48. anchors.bottom: parent.bottom
  49. anchors.bottomMargin: 10
  50. anchors.left: parent.left
  51. anchors.leftMargin: 10
  52. anchors.right: parent.right
  53. elide: Text.ElideMiddle
  54. text: _countryCode.currentText
  55. }
  56. }
  57. background: Rectangle {
  58. anchors.fill: parent
  59. color: _countryCode.pressed ? "#55ffffff" : "#00ffffff"
  60. }
  61. delegate: ItemDelegate {
  62. font.pointSize: 12
  63. text: model.name
  64. }
  65. }
  66. TextInput {
  67. id: _inputItem
  68. Layout.fillWidth: true
  69. Layout.alignment: Qt.AlignBottom
  70. font.pointSize: 12
  71. color: "#ffffff"
  72. // validator: RegularExpressionValidator {
  73. // regExp:/\d*/
  74. // }
  75. Rectangle {
  76. anchors.top: _inputItem.bottom
  77. width: _inputItem.width
  78. color: "#cfdfe7"
  79. height: 1
  80. }
  81. }
  82. }
  83. }