summaryrefslogtreecommitdiffstats
path: root/QtLauncher/Header.qml
blob: 64150dfca11a87fe34b898e8febb8824c5d7a97d (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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only

import QtQuick

Item {
    id: root
    required property real pageMargin
    anchors.top: parent.top
    anchors.left: parent.left
    anchors.right: parent.right
    height: root.pageMargin * 5

    Rectangle {
        anchors.fill: parent
        visible: SettingsManager.gridSelected
        gradient: Gradient {
            GradientStop { position: 0.0; color: ViewSettings.backgroundColor }
            GradientStop { position: 1.0; color: "transparent" }
        }
    }

    Item {
        anchors.fill: parent
        anchors.margins: root.pageMargin

        Item {
            id: settingsMenu
            anchors.left: parent.left
            anchors.top: parent.top
            height: parent.height
            width: opened ? parent.width - qtLogo.width : height
            clip: true

            property bool opened: false

            Behavior on width {NumberAnimation { duration: 500 } }

            function close() {
                closeTimer.stop()
                settingsMenu.opened = false
                gearAnimation.direction = RotationAnimator.Counterclockwise
                gearAnimation.restart()
            }

            function open() {
                settingsMenu.opened = true
                gearAnimation.direction = RotationAnimator.Clockwise
                gearAnimation.restart()
                closeTimer.restart()
            }

            Timer {
                id: closeTimer
                interval: 10000
                onTriggered: settingsMenu.close()
            }

            MouseArea {
                id: hoverMouseArea
                anchors.fill: parent
                hoverEnabled: true
                enabled: SettingsManager.mouseSelected
                onEntered: if (!settingsMenu.opened) settingsMenu.open()
                onExited: if (settingsMenu.opened) settingsMenu.close()
            }

            MouseArea {
                anchors.left: parent.left
                anchors.top: parent.top
                height: parent.height
                width: height

                onClicked: {
                    if (settingsMenu.opened)
                        settingsMenu.close()
                    else
                        settingsMenu.open()
                }
            }

            Image {
                id: menuIcon
                anchors.left: parent.left
                anchors.top: parent.top
                source: "icons/settings_icon.svg"
                height: parent.height
                width: height
                sourceSize: Qt.size(width, height)

                RotationAnimator {
                    id: gearAnimation
                    target: menuIcon
                    duration: 500
                    from: 0
                    to: 180
                }
            }

            Row {
                id: settingsRow
                anchors.top: parent.top
                anchors.left: menuIcon.right
                anchors.bottom: parent.bottom
                anchors.right: parent.right
                anchors.leftMargin: height * .5
                spacing: height

                Rectangle {
                    width: 2
                    height: parent.height
                    color: "white"
                }

                SettingsButton {
                    id: layoutIcon
                    source: SettingsManager.gridSelected ? "icons/grid_icon.svg" : "icons/detail_icon.svg"

                    onClicked: {
                        closeTimer.restart()
                        SettingsManager.gridSelected = !SettingsManager.gridSelected
                    }
                }

                Rectangle {
                    width: 2
                    height: parent.height
                    color: "white"
                }

                SettingsButton {
                    id: mouseIcon
                    source: SettingsManager.mouseSelected ? "icons/mouse_icon.svg" : "icons/touch_icon.svg"

                    onClicked: {
                        closeTimer.restart()
                        SettingsManager.mouseSelected = !SettingsManager.mouseSelected
                    }
                }

                Rectangle {
                    width: 2
                    height: parent.height
                    color: "white"
                }
            }
        }

        Image {
            id: qtLogo
            anchors.right: parent.right
            anchors.top: parent.top
            source: "icons/qt_logo_green_rgb.svg"
            height: parent.height
            width: height / sourceSize.height * sourceSize.width
        }
    }
}