Add add credential dialog

This commit is contained in:
Dag Heyman 2017-02-03 09:58:17 +01:00
parent d82f1263fd
commit e4887be6ea
No known key found for this signature in database
GPG Key ID: 06FC004369E7D338
2 changed files with 124 additions and 0 deletions

96
qml/AddCredential.qml Normal file
View File

@ -0,0 +1,96 @@
import QtQuick 2.6
import QtQuick.Controls 1.4
import QtQuick.Layouts 1.1
import QtQuick.Controls.Styles 1.4
import QtQuick.Dialogs 1.2
Dialog {
id: addCredential
title: qsTr("Add credential")
standardButtons: StandardButton.Save | StandardButton.Cancel
ColumnLayout {
GridLayout {
columns: 2
Button {
Layout.columnSpan: 2
text: qsTr("Scan a QR code")
Layout.fillWidth: true
}
Label {
text: qsTr("Name")
Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
Layout.fillWidth: false
}
TextField {
id: nameInput
Layout.fillHeight: false
Layout.fillWidth: true
}
Label {
text: qsTr("Secret key (base32)")
}
TextField {
id: secretKeyInput
Layout.fillWidth: true
}
}
GroupBox {
title: qsTr("Credential type")
ColumnLayout {
RowLayout {
Label {
text: "OATH Type"
}
ExclusiveGroup {
id: oathType
}
RadioButton {
text: qsTr("Time based (TOTP)")
checked: true
exclusiveGroup: oathType
}
RadioButton {
text: qsTr("Counter based (HOTP)")
exclusiveGroup: oathType
}
}
RowLayout {
Label {
text: "Number of digits"
}
ExclusiveGroup {
id: digits
}
RadioButton {
text: qsTr("6")
exclusiveGroup: digits
}
RadioButton {
text: qsTr("8")
checked: true
exclusiveGroup: digits
}
}
RowLayout {
Label {
text: "Algorithm"
}
ExclusiveGroup {
id: algorithm
}
RadioButton {
text: qsTr("SHA-1")
exclusiveGroup: algorithm
}
RadioButton {
text: qsTr("SHA-256")
checked: true
exclusiveGroup: algorithm
}
}
}
}
}
}

View File

@ -23,6 +23,10 @@ ApplicationWindow {
Menu {
title: qsTr("File")
MenuItem {
text: qsTr('Add...')
onTriggered: addCredential.show()
}
MenuItem {
text: qsTr("Exit")
onTriggered: Qt.quit()
@ -42,6 +46,30 @@ ApplicationWindow {
id: aboutPage
}
AddCredential {
id: addCredential
}
MouseArea {
enabled: yk.hasDevice
anchors.fill: parent
acceptedButtons: Qt.LeftButton | Qt.RightButton
onClicked: {
if (Qt.RightButton) {
contextMenu.popup()
}
}
}
Menu {
id: contextMenu
MenuItem {
text: qsTr('Add...')
onTriggered: addCredential.open()
}
}
ColumnLayout {
id: credentialsColumn
spacing: 10