aboutsummaryrefslogtreecommitdiff
path: root/components/LineEdit.qml
diff options
context:
space:
mode:
authorxiphon <xiphon@protonmail.com>2020-04-28 12:15:18 +0000
committerxiphon <xiphon@protonmail.com>2020-04-28 20:44:53 +0000
commit2195c67f58b242d5c6be8df66b73d9731cad7a4c (patch)
treecb22810b9cf28abc64b2fd1cd86093a2b2922dd1 /components/LineEdit.qml
parent585fb2810dc0d9b79255b9bd479559b36aa087d8 (diff)
downloadmonzero-gui-2195c67f58b242d5c6be8df66b73d9731cad7a4c.tar.gz
monzero-gui-2195c67f58b242d5c6be8df66b73d9731cad7a4c.tar.xz
monzero-gui-2195c67f58b242d5c6be8df66b73d9731cad7a4c.zip
LineEdit: password mode, linking. PasswordDialog: use LineEdit
Diffstat (limited to 'components/LineEdit.qml')
-rw-r--r--components/LineEdit.qml52
1 files changed, 51 insertions, 1 deletions
diff --git a/components/LineEdit.qml b/components/LineEdit.qml
index 554140d9..8c6346d5 100644
--- a/components/LineEdit.qml
+++ b/components/LineEdit.qml
@@ -26,6 +26,7 @@
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+import FontAwesome 1.0
import QtQuick 2.9
import QtGraphicalEffects 1.0
@@ -36,6 +37,10 @@ Item {
property alias input: input
property alias text: input.text
+ property bool password: false
+ property bool passwordHidden: true
+ property var passwordLinked: null
+
property alias placeholderText: placeholderLabel.text
property bool placeholderCenter: false
property string placeholderFontFamily: MoneroComponents.Style.fontRegular.name
@@ -48,7 +53,6 @@ Item {
property alias validator: input.validator
property alias readOnly : input.readOnly
property alias cursorPosition: input.cursorPosition
- property alias echoMode: input.echoMode
property alias inlineButton: inlineButtonId
property alias inlineButtonText: inlineButtonId.text
property alias inlineIcon: inlineIcon.visible
@@ -109,6 +113,31 @@ Item {
}
}
+ function isPasswordHidden() {
+ if (password) {
+ return passwordHidden;
+ }
+ if (passwordLinked) {
+ return passwordLinked.passwordHidden;
+ }
+ return false;
+ }
+
+ function reset() {
+ text = "";
+ if (!passwordLinked) {
+ passwordHidden = true;
+ }
+ }
+
+ function passwordToggle() {
+ if (passwordLinked) {
+ passwordLinked.passwordHidden = !passwordLinked.passwordHidden;
+ } else {
+ passwordHidden = !passwordHidden;
+ }
+ }
+
MoneroComponents.TextPlain {
id: inputLabel
anchors.top: parent.top
@@ -210,6 +239,27 @@ Item {
onTextChanged: item.textUpdated()
topPadding: 10
bottomPadding: 10
+ echoMode: isPasswordHidden() ? TextInput.Password : TextInput.Normal
+
+ MoneroComponents.Label {
+ visible: password || passwordLinked
+ fontSize: 20
+ text: isPasswordHidden() ? FontAwesome.eye : FontAwesome.eyeSlash
+ opacity: eyeMouseArea.containsMouse ? 0.9 : 0.7
+ fontFamily: FontAwesome.fontFamily
+ anchors.right: parent.right
+ anchors.rightMargin: 15
+ anchors.verticalCenter: parent.verticalCenter
+ anchors.verticalCenterOffset: 1
+
+ MouseArea {
+ id: eyeMouseArea
+ anchors.fill: parent
+ cursorShape: Qt.PointingHandCursor
+ hoverEnabled: true
+ onClicked: passwordToggle()
+ }
+ }
}
MoneroComponents.InlineButton {