diff --git a/qml/AddCredential.qml b/qml/AddCredential.qml new file mode 100644 index 00000000..3cc84a51 --- /dev/null +++ b/qml/AddCredential.qml @@ -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 + } + } + } + } + } +} diff --git a/qml/Main.qml b/qml/Main.qml index 98005469..375d7914 100644 --- a/qml/Main.qml +++ b/qml/Main.qml @@ -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