aboutsummaryrefslogtreecommitdiffstats
path: root/src/quickcontrols/windows/Menu.qml
blob: a0041a943931729d145b63854fbd0c080643ac2b (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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Copyright (C) 2024 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.Templates as T
import QtQuick.Controls.impl
import QtQuick.Window
import QtQuick.Effects

T.Menu {
    id: control

    implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
                            contentWidth + leftPadding + rightPadding)
    implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
                             contentHeight + topPadding + bottomPadding)

    leftPadding: 5
    rightPadding: 5
    topPadding: 5
    bottomPadding: 5
    margins: 0
    overlap: 4

    delegate: MenuItem { }

    contentItem: ListView {
        implicitHeight: contentHeight
        model: control.contentModel
        interactive: Window.window
                     ? contentHeight + control.topPadding + control.bottomPadding > control.height
                     : false
        currentIndex: control.currentIndex
        spacing: 2

        ScrollIndicator.vertical: ScrollIndicator {}
    }

    background: MultiEffect {
        implicitWidth: 200
        implicitHeight: 20
        source: Rectangle {
            width: control.background.width
            height: control.background.height
            radius: 8
            color: Qt.lighter(control.palette.window, 1.15)
            border.color: Qt.darker(control.palette.window, 1.12)
            visible: false
        }
        shadowScale: 1.04
        shadowOpacity: 0.1
        shadowColor: 'black'
        shadowEnabled: true
        shadowHorizontalOffset: 0
        shadowVerticalOffset: 10
    }

    T.Overlay.modal: Rectangle {
        color: "transparent"
    }

    T.Overlay.modeless: Rectangle {
        color: "transparent"
    }
}