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 --- framework/qml/Icons.qml | 2 ++ framework/qml/PasswordField.qml | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 framework/qml/PasswordField.qml (limited to 'framework/qml') 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 + } +} -- cgit v1.2.3