tNewPasswordDialog.qml - sailfish-safe - Sailfish frontend for safe(1)
 (HTM) git clone git://git.z3bra.org/sailfish-safe.git
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
       tNewPasswordDialog.qml (2935B)
       ---
            1 /*
            2  *   Copyright (C) 2019  Daniel Vrátil <dvratil@kde.org>
            3  *
            4  *   This program is free software: you can redistribute it and/or modify
            5  *   it under the terms of the GNU General Public License as published by
            6  *   the Free Software Foundation, either version 3 of the License, or
            7  *   (at your option) any later version.
            8  *
            9  *   This program is distributed in the hope that it will be useful,
           10  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
           11  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
           12  *   GNU General Public License for more details.
           13  *
           14  *   You should have received a copy of the GNU General Public License
           15  *   along with this program.  If not, see <https://www.gnu.org/licenses/>.
           16  */
           17 
           18 import QtQuick 2.2
           19 import QtQml.Models 2.2
           20 import Sailfish.Silica 1.0
           21 import harbour.safe 0.1
           22 
           23 Dialog {
           24     id: newPasswordDialog
           25 
           26     property var model
           27     property var currentIndex
           28 
           29     canAccept: nameField.text !== "" && passwordField.text !== ""
           30 
           31     onAccepted: {
           32         model.addPassword(currentIndex, nameField.text, passwordField.text, extrasField.text)
           33     }
           34 
           35     DialogHeader {
           36         id: header
           37         width: parent.width
           38     }
           39 
           40     SilicaFlickable {
           41         id: flickable
           42 
           43         anchors {
           44             top: header.bottom
           45             left: parent.left
           46             right: parent.right
           47             bottom: parent.bottom
           48         }
           49 
           50         clip: true
           51         contentHeight: column.height
           52 
           53         Column {
           54             id: column
           55 
           56             anchors {
           57                 left: parent.left
           58                 right: parent.right
           59                 leftMargin: Theme.horizontalPageMargin
           60                 rightMargin: Theme.horizontalPageMargin
           61             }
           62 
           63             spacing: Theme.paddingMedium
           64 
           65             Label {
           66                 text: qsTr("Name:")
           67                 width: parent.width
           68             }
           69 
           70             TextField {
           71                 id: nameField
           72                 width: parent.width
           73             }
           74 
           75             Label {
           76                 text: qsTr("Password:")
           77                 width: parent.width
           78             }
           79 
           80             PasswordField {
           81                 id: passwordField
           82                 width: parent.width
           83             }
           84 
           85             Button {
           86                 id: generatePassButton
           87                 width: parent.width
           88                 text: qsTr("Generate Password")
           89 
           90                 onClicked: app.pageStack.push(genPassDialog)
           91             }
           92 
           93             Label {
           94                 text: qsTr("Additional Info:")
           95                 width: parent.width
           96             }
           97 
           98             TextArea {
           99                 id: extrasField
          100                 width: parent.width
          101             }
          102         }
          103 
          104 
          105         HorizontalScrollDecorator {
          106             flickable: parent
          107         }
          108     }
          109 
          110     Component {
          111         id: genPassDialog
          112 
          113         GeneratePasswordDialog {
          114             onAccepted: {
          115                 passwordField.text = PasswordGenerator.generate(passLen, allowSymbols)
          116             }
          117         }
          118     }
          119 }