AutofillPopup.qml 931 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // Copyright (C) 2022 The Qt Company Ltd.
  2. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
  3. import QtQuick
  4. import QtQuick.Controls
  5. Popup {
  6. id: root
  7. // Let Chromium close the popup.
  8. closePolicy: Popup.NoAutoClose
  9. property variant controller: null
  10. property int itemHeight: 0
  11. signal selected(int index)
  12. signal accepted()
  13. function setCurrentIndex(index)
  14. {
  15. listView.currentIndex = index;
  16. }
  17. ListView {
  18. id: listView
  19. anchors.fill: parent
  20. clip: true
  21. model: controller.model
  22. currentIndex: -1
  23. delegate: ItemDelegate {
  24. width: listView.width
  25. height: root.itemHeight
  26. text: model.display
  27. highlighted: ListView.isCurrentItem
  28. onHoveredChanged: if (hovered) selected(index);
  29. onClicked: accepted();
  30. }
  31. }
  32. }