Formatting

This commit is contained in:
Dag Heyman 2017-02-28 12:08:42 +01:00
parent 79e8ca0208
commit d956aae295
No known key found for this signature in database
GPG Key ID: 06FC004369E7D338

View File

@ -21,13 +21,9 @@ ApplicationWindow {
property var hotpCoolDowns: []
property var totpCoolDowns: []
SystemPalette { id: palette }
/*******
Settings
*******/
SystemPalette {
id: palette
}
Settings {
id: settings
@ -38,13 +34,6 @@ ApplicationWindow {
property var slot2digits
}
/*******
Main menu bar
*******/
menuBar: MenuBar {
Menu {
@ -52,7 +41,7 @@ ApplicationWindow {
MenuItem {
text: qsTr('Add credential...')
onTriggered: {
addCredential.clear();
addCredential.clear()
addCredential.open()
}
shortcut: StandardKey.New
@ -96,12 +85,6 @@ ApplicationWindow {
onAccepted: refreshDependingOnMode(true)
}
/*******
Settings dialog
*******/
SettingsDialog {
id: settingsDialog
settings: settings
@ -115,13 +98,6 @@ ApplicationWindow {
}
}
/*******
Set password dialog
*******/
SetPassword {
id: setPassword
onAccepted: {
@ -155,12 +131,6 @@ ApplicationWindow {
standardButtons: StandardButton.Ok
}
/*******
Reset dialog
*******/
MessageDialog {
id: reset
icon: StandardIcon.Critical
@ -173,16 +143,9 @@ ApplicationWindow {
}
}
/*******
Device - prompt for password if needed
*******/
onHasDeviceChanged: {
if (device.hasDevice) {
if(!settings.slotMode && device.hasCCID) {
if (!settings.slotMode && device.hasCCID) {
device.promptOrSkip(passwordPrompt)
}
} else {
@ -216,8 +179,6 @@ ApplicationWindow {
}
}
Text {
visible: !device.hasDevice
id: noLoadedDeviceMessage
@ -235,17 +196,17 @@ ApplicationWindow {
anchors.verticalCenter: parent.verticalCenter
}
Text {
visible: device.hasDevice
text: if (credentials !== null && filteredCredentials(credentials).length === 0) {
qsTr("No credentials found.")
text: if (credentials !== null && filteredCredentials(
credentials).length === 0) {
qsTr("No credentials found.")
} else if (settings.slotMode && !device.hasOTP) {
qsTr("Authenticator mode is set to YubiKey slots, but the OTP connection mode is not enabled.")
} else if (!settings.slotMode && !device.hasCCID) {
qsTr("Authenticator mode is set to CCID, but the CCID connection mode is not enabled.")
} else {
""
""
}
horizontalAlignment: Text.AlignHCenter
wrapMode: Text.WordWrap
@ -254,14 +215,6 @@ ApplicationWindow {
anchors.verticalCenter: parent.verticalCenter
}
/*******
Clipboard
*******/
TextEdit {
id: clipboard
visible: false
@ -272,13 +225,6 @@ ApplicationWindow {
}
}
/*******
Right click menu for credentials
*******/
Menu {
id: credentialMenu
MenuItem {
@ -292,7 +238,8 @@ ApplicationWindow {
}
MenuItem {
visible: allowManualGenerate(repeater.selected)
enabled: allowManualGenerate(repeater.selected) && !isInCoolDown(repeater.selected.name)
enabled: allowManualGenerate(repeater.selected) && !isInCoolDown(
repeater.selected.name)
text: qsTr('Generate code')
shortcut: "Space"
onTriggered: {
@ -301,8 +248,8 @@ ApplicationWindow {
if (repeater.selected.oath_type === "hotp") {
hotpCoolDowns.push(repeater.selected.name)
hotpCoolDownTimer.restart()
} else if(repeater.selected.touch) {
totpCoolDowns.push(repeater.selected.name)
} else if (repeater.selected.touch) {
totpCoolDowns.push(repeater.selected.name)
}
}
}
@ -315,7 +262,8 @@ ApplicationWindow {
}
function allowManualGenerate(cred) {
return cred != null && (cred.oath_type === "hotp" || repeater.selected.touch)
return cred != null && (cred.oath_type === "hotp"
|| repeater.selected.touch)
}
MessageDialog {
@ -325,7 +273,7 @@ ApplicationWindow {
text: qsTr("Are you sure you want to delete the credential?")
standardButtons: StandardButton.Ok | StandardButton.Cancel
onAccepted: {
if (settings.slotMode){
if (settings.slotMode) {
device.deleteSlotCredential(getSlot(repeater.selected['name']))
} else {
device.deleteCredential(repeater.selected)
@ -342,14 +290,6 @@ ApplicationWindow {
standardButtons: StandardButton.NoButton
}
/*******
Arrow key navigation
*******/
Item {
id: arrowKeys
focus: true
@ -373,17 +313,10 @@ ApplicationWindow {
}
}
ColumnLayout {
anchors.fill: parent
spacing: 0
/*******
Time left bar
*******/
ProgressBar {
id: progressBar
visible: hasDevice
@ -420,12 +353,6 @@ ApplicationWindow {
anchors.left: appWindow.left
anchors.top: appWindow.top
/*******
Credential items
*******/
Repeater {
id: repeater
model: filteredCredentials(credentials)
@ -507,12 +434,6 @@ ApplicationWindow {
text: "[Slot mode]"
}
/*******
Search field
*******/
TextField {
id: search
visible: hasDevice
@ -521,13 +442,6 @@ ApplicationWindow {
}
}
/*******
Timers
*******/
Timer {
id: ykTimer
triggeredOnStart: true
@ -565,17 +479,11 @@ ApplicationWindow {
onTriggered: touchYourYubikey.open()
}
/*******
Utility functions
*******/
function refreshDependingOnMode(force) {
if (hasDevice) {
if (settings.slotMode && device.hasOTP) {
device.refreshSlotCredentials([settings.slot1, settings.slot2], getSlotDigitsSettings(), force)
device.refreshSlotCredentials([settings.slot1, settings.slot2],
getSlotDigitsSettings(), force)
} else if (!settings.slotMode && device.hasCCID) {
device.refreshCCIDCredentials(force)
}
@ -603,7 +511,8 @@ ApplicationWindow {
}
function isInCoolDown(name) {
return hotpCoolDowns.indexOf(name) !== -1 || totpCoolDowns.indexOf(name) !== -1
return hotpCoolDowns.indexOf(name) !== -1 || totpCoolDowns.indexOf(
name) !== -1
}
function hasIssuer(name) {
return name.indexOf(':') !== -1
@ -641,7 +550,7 @@ ApplicationWindow {
}
function getDigits(slot) {
return getSlotDigitsSettings()[slot -1]
return getSlotDigitsSettings()[slot - 1]
}
function updateExpiration() {