From ed90f285745279e91743851ae49eeccf1d95710f Mon Sep 17 00:00:00 2001 From: Michael Bohlender Date: Mon, 31 Jul 2017 18:58:39 +0200 Subject: dedicated Kube.PasswordField --- .../gmail/package/contents/ui/GmailSettings.qml | 32 +++++------------ .../package/contents/ui/ImapAccountSettings.qml | 32 +++++------------ .../contents/ui/KolabnowAccountSettings.qml | 16 +-------- framework/qml/Icons.qml | 2 ++ framework/qml/PasswordField.qml | 41 ++++++++++++++++++++++ framework/qmldir | 1 + 6 files changed, 61 insertions(+), 63 deletions(-) create mode 100644 framework/qml/PasswordField.qml diff --git a/accounts/gmail/package/contents/ui/GmailSettings.qml b/accounts/gmail/package/contents/ui/GmailSettings.qml index 40a6e1e7..0ee18bed 100644 --- a/accounts/gmail/package/contents/ui/GmailSettings.qml +++ b/accounts/gmail/package/contents/ui/GmailSettings.qml @@ -116,32 +116,16 @@ Item { text: qsTr("Password") Layout.alignment: Qt.AlignRight } - RowLayout { - Layout.fillWidth: true - - Kube.TextField { - id: pwField - Layout.fillWidth: true - - placeholderText: qsTr("Password of your email account") - text: gmailSettings.imapPassword - onTextChanged: { - gmailSettings.imapPassword = text - gmailSettings.smtpPassword = text - } - echoMode: TextInput.Password - } + Kube.PasswordField { + id: pwField + Layout.fillWidth: true - Controls.CheckBox { - text: qsTr("Show Password") - onClicked: { - if(pwField.echoMode == TextInput.Password) { - pwField.echoMode = TextInput.Normal; - } else { - pwField.echoMode = TextInput.Password; - } - } + placeholderText: qsTr("Password of your email account") + text: gmailSettings.imapPassword + onTextChanged: { + gmailSettings.imapPassword = text + gmailSettings.smtpPassword = text } } } diff --git a/accounts/imap/package/contents/ui/ImapAccountSettings.qml b/accounts/imap/package/contents/ui/ImapAccountSettings.qml index 332b2bbe..26a41541 100644 --- a/accounts/imap/package/contents/ui/ImapAccountSettings.qml +++ b/accounts/imap/package/contents/ui/ImapAccountSettings.qml @@ -102,32 +102,16 @@ Item { text: qsTr("Password") Layout.alignment: Qt.AlignRight } - RowLayout { - Layout.fillWidth: true - - Kube.TextField { - id: pwField - Layout.fillWidth: true - - placeholderText: qsTr("Password of your email account") - text: imapSettings.imapPassword - onTextChanged: { - imapSettings.imapPassword = text - imapSettings.smtpPassword = text - } - echoMode: TextInput.Password - } + Kube.PasswordField { + id: pwField + Layout.fillWidth: true - Controls.CheckBox { - text: qsTr("Show Password") - onClicked: { - if(pwField.echoMode == TextInput.Password) { - pwField.echoMode = TextInput.Normal; - } else { - pwField.echoMode = TextInput.Password; - } - } + placeholderText: qsTr("Password of your email account") + text: imapSettings.imapPassword + onTextChanged: { + imapSettings.imapPassword = text + imapSettings.smtpPassword = text } } diff --git a/accounts/kolabnow/package/contents/ui/KolabnowAccountSettings.qml b/accounts/kolabnow/package/contents/ui/KolabnowAccountSettings.qml index c691c44a..b2048827 100644 --- a/accounts/kolabnow/package/contents/ui/KolabnowAccountSettings.qml +++ b/accounts/kolabnow/package/contents/ui/KolabnowAccountSettings.qml @@ -100,7 +100,7 @@ Item { Layout.alignment: Qt.AlignRight } - Kube.TextField { + Kube.PasswordField { id: pwField Layout.fillWidth: true @@ -110,20 +110,6 @@ Item { kolabnowSettings.imapPassword = text kolabnowSettings.smtpPassword = text } - - echoMode: pwCheck.checked ? TextInput.Normal : TextInput.Password - } - - Kube.Label { - text: "" - } - RowLayout { - Kube.CheckBox { - id: pwCheck - } - Kube.Label { - text: qsTr("Show Password") - } } } } diff --git a/framework/qml/Icons.qml b/framework/qml/Icons.qml index d9612013..4d94f86a 100644 --- a/framework/qml/Icons.qml +++ b/framework/qml/Icons.qml @@ -55,6 +55,8 @@ Item { property string goDown_inverted: "go-down-inverted" property string goUp: "go-up" property string checkbox: "checkbox" + property string password_show: "password-show-on" + property string password_hide: "password-show-off" property string addNew: "list-add" property string remove: "kube-list-remove-inverted" diff --git a/framework/qml/PasswordField.qml b/framework/qml/PasswordField.qml new file mode 100644 index 00000000..786b3d46 --- /dev/null +++ b/framework/qml/PasswordField.qml @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2017 Michael Bohlender, + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +import QtQuick 2.7 +import org.kube.framework 1.0 as Kube + +Kube.TextField { + id: root + + property bool showPassword + + echoMode: showPassword ? TextInput.Normal : TextInput.Password + + Kube.IconButton { + anchors { + right: parent.right + verticalCenter: parent.verticalCenter + } + + onClicked: { + root.showPassword = !root.showPassword + } + + iconName: root.showPassword ? Kube.Icons.password_hide : Kube.Icons.password_show + } +} diff --git a/framework/qmldir b/framework/qmldir index d4ec9619..a0f58385 100644 --- a/framework/qmldir +++ b/framework/qmldir @@ -23,6 +23,7 @@ CheckBox 1.0 CheckBox.qml PositiveButton 1.0 PositiveButton.qml TextButton 1.0 TextButton.qml TextField 1.0 TextField.qml +PasswordField 1.0 PasswordField.qml TextArea 1.0 TextArea.qml TextEditor 1.0 TextEditor.qml ToolTip 1.0 ToolTip.qml -- cgit v1.2.3