1import QtQuick 2.9
2import QtQuick.Controls 2.2
3import QtQuick.Layouts 1.2
4import QtQuick.Dialogs 1.2
5import QtQuick.Controls.Material 2.2
6
7ColumnLayout {
8    spacing: 0
9    width: app.width
10    function activeKeyLbl() {
11        if (!yubiKey.hasDevice || views.isShowingHomeView) {
12            return ""
13        } else {
14            if (yubiKey.serial) {
15                return yubiKey.name + " (" + yubiKey.serial + ")"
16            } else {
17                return yubiKey.name
18            }
19        }
20    }
21
22    RowLayout {
23        Layout.fillWidth: true
24        Layout.alignment: Qt.AlignRight
25        Layout.rightMargin: 10
26        Layout.topMargin: 10
27        RowLayout {
28            Layout.alignment: Qt.AlignRight
29            Layout.fillWidth: true
30            Label {
31                text: activeKeyLbl()
32                Layout.fillWidth: false
33                Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
34                color: yubicoBlue
35                font.pixelSize: constants.h4
36            }
37            CustomButton {
38                flat: true
39                text: qsTr("Help")
40                Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
41                iconSource: "../images/help.svg"
42                toolTipText: qsTr("Visit Yubico Support in your web browser")
43                onClicked: Qt.openUrlExternally("https://www.yubico.com/kb")
44                font.pixelSize: constants.h4
45            }
46            CustomButton {
47                flat: true
48                text: qsTr("About")
49                Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
50                iconSource: "../images/info.svg"
51                toolTipText: qsTr("About YubiKey Manager")
52                onClicked: aboutPage.open()
53                font.pixelSize: constants.h4
54            }
55        }
56    }
57
58    RowLayout {
59        Layout.alignment: Qt.AlignLeft | Qt.AlignBottom
60        Layout.fillWidth: true
61        Layout.leftMargin: 20
62        Image {
63            id: yubicoLogo
64            Layout.alignment: Qt.AlignLeft | Qt.AlignBottom
65            Layout.maximumWidth: 150
66            fillMode: Image.PreserveAspectFit
67            source: "../images/yubico-logo.svg"
68        }
69        TopMenuButton {
70            text: qsTr("Home")
71            onClicked: views.home()
72            enabled: yubiKey.hasDevice
73        }
74        TopMenuButton {
75            text: qsTr("Applications")
76            Layout.fillWidth: false
77            enabled: yubiKey.hasDevice
78            onClicked: applicationsMenu.open()
79
80            Menu {
81                id: applicationsMenu
82                y: parent.height
83                Material.elevation: 1
84                MenuItem {
85                    enabled: yubiKey.isEnabledOverUsb('OTP')
86                    text: qsTr("OTP")
87                    Material.foreground: yubicoBlue
88                    onClicked: views.otp()
89                    ToolTip.delay: 1000
90                    ToolTip.visible: hovered
91                    ToolTip.text: qsTr("Configure OTP Application")
92                    font.family: constants.fontFamily
93                    font.pixelSize: constants.h3
94                }
95                MenuItem {
96                    enabled: yubiKey.isEnabledOverUsb('FIDO2')
97                    text: qsTr("FIDO2")
98                    onClicked: views.fido2()
99                    Material.foreground: yubicoBlue
100                    ToolTip.delay: 1000
101                    ToolTip.visible: hovered
102                    ToolTip.text: qsTr("Configure FIDO2 Application")
103                    font.family: constants.fontFamily
104                    font.pixelSize: constants.h3
105                }
106                MenuItem {
107                    enabled: yubiKey.isEnabledOverUsb('PIV')
108                    text: qsTr("PIV")
109                    onClicked: {
110                        if (!views.isShowingPiv)
111                            views.piv()
112                    }
113                    Material.foreground: yubicoBlue
114                    ToolTip.delay: 1000
115                    ToolTip.visible: hovered
116                    ToolTip.text: qsTr("Configure PIV Application")
117                    font.family: constants.fontFamily
118                    font.pixelSize: constants.h3
119                }
120            }
121        }
122        TopMenuButton {
123            text: qsTr("Interfaces")
124            enabled: yubiKey.hasDevice && yubiKey.canChangeInterfaces()
125            onClicked: views.configureInterfaces()
126            toolTipText: qsTr("Configure what is available over different interfaces")
127        }
128    }
129    Rectangle {
130        id: headerBorder
131        Layout.minimumHeight: 4
132        Layout.maximumHeight: 4
133        Layout.fillWidth: true
134        Layout.fillHeight: true
135        color: yubicoGreen
136    }
137}
138