Commit 7a0718ea authored by Martin Straka's avatar Martin Straka

Added QML input dialogue

parent e18e54e7
......@@ -54,6 +54,7 @@ TRANSLATIONS += res/locale/datovka_en.ts \
lupdate_only {
SOURCES += qml/*.qml \
qml/components/*.qml \
qml/dialogues/*.qml \
qml/pages/*.qml
}
......
/*
* Copyright (C) 2014-2017 CZ.NIC
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*
* In addition, as a special exception, the copyright holders give
* permission to link the code of portions of this program with the
* OpenSSL library under certain conditions as described in each
* individual source file, and distribute linked combinations including
* the two.
*/
import QtQuick 2.7
import QtQuick.Layouts 1.3
import QtQuick.Controls 2.1
/*
* Input dialog for password or OTP code.
*/
import QtQuick 2.7
import QtQuick.Controls 2.1
Dialog {
id: root
signal finished(string userName,string accountName, string pwd)
property int minimumInputSize: parent.width / 2
property int maximumInputSize: parent.width / 2
property string dUserName
property string dAccountName
function openInputDialog(userName, accountName, title, text, hidePwd) {
dUserName = userName
dAccountName = accountName
root.title = title
roottext.text = text
rootpwd.clear()
rootpwd.placeholderText = title
rootpwd.echoMode = (hidePwd) ? TextInput.Password : TextInput.Normal
root.open()
}
// center dialog
x: parent.width / 2 - width / 2
y: parent.height / 2 - height / 2
focus: true
modal: true
title: qsTr("QML input dialog")
standardButtons: Dialog.Ok | Dialog.Cancel
contentItem: ColumnLayout {
Text {
id: roottext
Layout.fillWidth: true
Layout.minimumWidth: minimumInputSize
Layout.maximumWidth: maximumInputSize
text: ""
Layout.alignment: Qt.AlignLeft | Qt.AlignBaseline
wrapMode: Text.WordWrap
}
TextField {
id: rootpwd
focus: true
Layout.fillWidth: true
Layout.minimumWidth: minimumInputSize
Layout.maximumWidth: maximumInputSize
Layout.alignment: Qt.AlignLeft | Qt.AlignBaseline
echoMode: TextInput.Normal
placeholderText: placeholderText
horizontalAlignment: TextInput.AlignHCenter
}
} // ColumnLayout
onAccepted: finished(dUserName, dAccountName, rootpwd.text.toString())
}
......@@ -111,6 +111,19 @@ ApplicationWindow {
/* Exposes nested stack to code outside the page component. */
property var nestedStack: null
InputDialogue {
id: inputDialog
onFinished: {
isds.pwdResponse(userName, accountName, pwd)
}
Connections {
target: isds
onPwdRequest: {
inputDialog.openInputDialog(userName, accountName, title, text, hidePwd)
}
}
}
StackView { // Page area.
id: mainStack
anchors.fill: parent
......
......@@ -101,6 +101,7 @@
<file>../qml/components/PageHeader.qml</file>
<file>../qml/components/ScrollContent.qml</file>
<file>../qml/components/SpinBoxZeroMax.qml</file>
<file>../qml/dialogues/InputDialogue.qml</file>
<file>../qml/dialogues/MessageDialogue.qml</file>
<file>../qml/dialogues/PasteInputDialogue.qml</file>
<file>../qml/pages/PageAboutApp.qml</file>
......
......@@ -116,6 +116,7 @@ const struct QmlTypeEntry qmlComponents[] = {
*/
static
const struct QmlTypeEntry qmlDialogues[] = {
{ "InputDialogue", 1, 0},
{ "MessageDialogue", 1, 0},
{ "PasteInputDialogue", 1, 0 },
{ NULL, 0, 0 }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment