Commit 724dceb0 authored by Karel Slaný's avatar Karel Slaný

Merge branch 'input-dialog-wip' into 'develop'

QML input dialog

See merge request !59
parents e18e54e7 147b7172
......@@ -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,20 @@ ApplicationWindow {
/* Exposes nested stack to code outside the page component. */
property var nestedStack: null
/* Password/OTP input dialog, emitted from C++ */
InputDialogue {
id: inputDialog
onFinished: {
isds.returnInputDialogText(userName, accountName, pwd)
}
Connections {
target: isds
onOpenDialogRequest: {
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 }
......
......@@ -409,6 +409,13 @@ bool IsdsWrapper::changePassword(const QString &userName,
return true;
}
void IsdsWrapper::returnInputDialogText(const QString &userName,
const QString &accountName, const QString &pwd)
{
/* TODO - save password to isds context in future */
qDebug() << userName << accountName << pwd;
}
bool IsdsWrapper::isLoggedToIsdsOtp(const QString &userName)
{
qDebug("%s()", __func__);
......
......@@ -136,6 +136,17 @@ public:
bool changePassword(const QString &userName,
const QString &accountName);
/*!
* @brief Password string from QML input dialog.
*
* @param[in] userName Account username string.
* @param[in] accountName Account name string.
* @param[in] pwd Password or OTP code.
*/
Q_INVOKABLE
void returnInputDialogText(const QString &userName,
const QString &accountName, const QString &pwd);
/*!
* @brief Test if user is connected to databox via OTP.
*
......@@ -158,6 +169,19 @@ public:
void closeAllOtpConnections(void);
signals:
/*!
* @brief Send open QML input dialog request to QML.
*
* @param[in] userName Account username string.
* @param[in] accountName Account name string.
* @param[in] title Dialogue title.
* @param[in] text Dialogue text.
* @param[in] hidePwd True means the password will be hidden.
*/
void openDialogRequest(QString userName, QString accountName,
QString title, QString text, bool hidePwd);
/*!
* @brief Set new statusbar text and active busy indicator to QML.
*
......
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