Improve password form look

master
Devin Lin 2021-02-28 18:38:02 +00:00 committed by Johan Ouwerkerk
parent 653e0b4b44
commit dcfa16025e
4 changed files with 91 additions and 67 deletions

View File

@ -3,6 +3,7 @@
# SPDX-FileCopyrightText: 2019 Bhushan Shah <bshah@kde.org>
# SPDX-FileCopyrightText: 2019 Friedrich W. H. Kossebau <kossebau@kde.org>
# SPDX-FileCopyrightText: 2019-2020 Johan Ouwerkerk <jm.ouwerkerk@gmail.com>
# SPDX-FileCopyrightText: 2021 Devin Lin <espidev@gmail.com>
#
# Need 3.10.X for C++17 support enabled via CMake: https://cmake.org/cmake/help/v3.10/prop_tgt/CXX_STANDARD.html#prop_tgt:CXX_STANDARD
@ -10,7 +11,7 @@ cmake_minimum_required(VERSION 3.10)
project(keysmith VERSION "0.2.1")
set(KF5_MIN_VERSION "5.62.0")
set(KF5_MIN_VERSION "5.77.0")
set(QT_MIN_VERSION "5.15.0")
set(SODIUM_MIN_VERSION "1.0.16")

View File

@ -4,6 +4,7 @@
# SPDX-FileCopyrightText: 2019 Friedrich W. H. Kossebau <kossebau@kde.org>
# SPDX-FileCopyrightText: 2019-2020 Johan Ouwerkerk <jm.ouwerkerk@gmail.com>
# SPDX-FileCopyrightText: 2020 Nicolas Fella <nicolas.fella@gmx.de>
# SPDX-FileCopyrightText: 2021 Devin Lin <espidev@gmail.com>
#
add_subdirectory(base32)
@ -41,6 +42,7 @@ if(ANDROID)
go-next
list-add
unlock
lock
)
endif()

View File

@ -2,6 +2,7 @@
* SPDX-License-Identifier: GPL-3.0-or-later
* SPDX-FileCopyrightText: 2020 Johan Ouwerkerk <jm.ouwerkerk@gmail.com>
* SPDX-FileCopyrightText: 2020 Carl Schwan <carl@carlschwan.eu>
* SPDX-FileCopyrightText: 2021 Devin Lin <espidev@gmail.com>
*/
import QtQuick 2.1
@ -19,38 +20,55 @@ Kirigami.ScrollablePage {
property bool bannerTextError : false
property Models.PasswordRequestModel passwordRequest: Keysmith.passwordRequest()
// HACK remove when depends on Kirigami 5.77
Component.onCompleted: {
for (var index in form.children[0].children) {
var item = form.children[0].children[index];
if (item instanceof Text) {
item.wrapMode = item.Text.Wrap
ColumnLayout {
spacing: Kirigami.Units.largeSpacing
Kirigami.Icon {
source: "lock"
Layout.alignment: Qt.AlignHCenter
Layout.fillWidth: true
Layout.maximumWidth: Kirigami.Units.gridUnit * 10
Layout.preferredWidth: Kirigami.Units.gridUnit * 10
Layout.preferredHeight: width
Layout.leftMargin: Kirigami.Units.gridUnit * 3
Layout.rightMargin: Kirigami.Units.gridUnit * 3
}
Kirigami.Heading {
level: 3
text: i18n("Choose a password to protect your accounts")
wrapMode: Text.Wrap
Layout.fillWidth: true
horizontalAlignment: form.wideMode ? Qt.AlignHCenter : Qt.AlignLeft
}
Kirigami.FormLayout {
id: form
Layout.fillWidth: true
Kirigami.PasswordField {
id: newPassword
text: ""
enabled: !passwordRequest.passwordProvided
Kirigami.FormData.label: i18nc("@label:textbox", "New password:")
onAccepted: newPasswordCopy.forceActiveFocus()
}
Kirigami.PasswordField {
id: newPasswordCopy
text: ""
enabled: !passwordRequest.passwordProvided
Kirigami.FormData.label: i18nc("@label:textbox", "Verify password:")
onAccepted: applyAction.trigger()
}
}
Connections {
target: passwordRequest
onPasswordRejected: {
bannerTextError = true
}
item.Layout.fillWidth = true;
}
}
Kirigami.FormLayout {
id: form
Item {
Kirigami.FormData.isSection: true
Kirigami.FormData.label: i18n("Get started by choosing a password to protect your accounts")
}
Kirigami.PasswordField {
id: newPassword
text: ""
enabled: !passwordRequest.passwordProvided
Kirigami.FormData.label: i18nc("@label:textbox", "New password:")
onAccepted: newPasswordCopy.forceActiveFocus()
}
Kirigami.PasswordField {
id: newPasswordCopy
text: ""
enabled: !passwordRequest.passwordProvided
Kirigami.FormData.label: i18nc("@label:textbox", "Verify password:")
onAccepted: applyAction.trigger()
}
}
actions.main : Kirigami.Action {
id: applyAction
@ -76,11 +94,4 @@ Kirigami.ScrollablePage {
showCloseButton: true
}
}
Connections {
target: passwordRequest
onPasswordRejected: {
bannerTextError = true
}
}
}

View File

@ -2,6 +2,7 @@
* SPDX-License-Identifier: GPL-3.0-or-later
* SPDX-FileCopyrightText: 2020 Johan Ouwerkerk <jm.ouwerkerk@gmail.com>
* SPDX-FileCopyrightText: 2020 Carl Schwan <carl@carlschwan.eu>
* SPDX-FileCopyrightText: 2021 Devin Lin <espidev@gmail.com>
*/
import QtQuick 2.1
@ -30,34 +31,50 @@ Kirigami.ScrollablePage {
}
}
// HACK remove when depends on Kirigami 5.77
Component.onCompleted: {
for (var index in form.children[0].children) {
var item = form.children[0].children[index];
if (item instanceof Text) {
item.wrapMode = item.Text.Wrap
}
item.Layout.fillWidth = true;
ColumnLayout {
spacing: Kirigami.Units.largeSpacing
Kirigami.Icon {
source: "lock"
Layout.alignment: Qt.AlignHCenter
Layout.fillWidth: true
Layout.maximumWidth: Kirigami.Units.gridUnit * 10
Layout.preferredWidth: Kirigami.Units.gridUnit * 10
Layout.preferredHeight: width
Layout.leftMargin: Kirigami.Units.gridUnit * 3
Layout.rightMargin: Kirigami.Units.gridUnit * 3
}
}
Kirigami.FormLayout {
id: form
Item {
Kirigami.FormData.isSection: true
Kirigami.FormData.label: i18n("Please provide the password to unlock your accounts")
Kirigami.Heading {
level: 3
text: i18n("Please provide the password to unlock your accounts")
wrapMode: Text.Wrap
Layout.fillWidth: true
horizontalAlignment: form.wideMode ? Qt.AlignHCenter : Qt.AlignLeft
}
Kirigami.PasswordField {
id: existingPassword
text: ""
Kirigami.FormData.label: i18nc("@label:textbox", "Password:")
enabled: !passwordRequest.passwordProvided
onAccepted: {
if (unlockAction.enabled) {
unlockAction.trigger()
Kirigami.FormLayout {
id: form
Layout.fillWidth: true
Kirigami.PasswordField {
id: existingPassword
text: ""
Kirigami.FormData.label: i18nc("@label:textbox", "Password:")
enabled: !passwordRequest.passwordProvided
onAccepted: {
if (unlockAction.enabled) {
unlockAction.trigger()
}
}
}
}
Connections {
target: passwordRequest
onPasswordRejected: {
bannerTextError = true
}
}
}
actions.main : Kirigami.Action {
@ -73,11 +90,4 @@ Kirigami.ScrollablePage {
// TODO warn if not
}
}
Connections {
target: passwordRequest
onPasswordRejected: {
bannerTextError = true
}
}
}