summaryrefslogtreecommitdiffstats
path: root/src/webenginequick/ui/AutofillPopup.qml
blob: 0a14b6233d12e28ede344fd6c64b01c83f26519b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only

import QtQuick
import QtQuick.Controls

Popup {
    id: root
    // Let Chromium close the popup.
    closePolicy: Popup.NoAutoClose

    property variant controller: null
    property int itemHeight: 0

    signal selected(int index)
    signal accepted()

    function setCurrentIndex(index)
    {
        listView.currentIndex = index;
    }

    ListView {
        id: listView
        anchors.fill: parent
        clip: true

        model: controller.model
        currentIndex: -1

        delegate: ItemDelegate {
            width: listView.width
            height: root.itemHeight
            text: model.display
            highlighted: ListView.isCurrentItem

            onHoveredChanged: if (hovered) selected(index);
            onClicked: accepted();
        }
    }
}