2024-02-11 23:30:06 +00:00
|
|
|
// SPDX-FileCopyrightText: 2020-2024 Devin Lin <espidev@gmail.com>
|
|
|
|
|
// SPDX-License-Identifier: LGPL-2.0-or-later
|
2023-03-14 02:26:52 +00:00
|
|
|
|
|
|
|
|
import QtQuick 2.6
|
|
|
|
|
import QtQuick.Layouts 1.2
|
|
|
|
|
import QtQuick.Controls 2.2 as Controls
|
2024-02-11 23:30:06 +00:00
|
|
|
import org.kde.kirigami as Kirigami
|
2023-03-14 02:26:52 +00:00
|
|
|
|
2024-02-11 23:30:06 +00:00
|
|
|
Kirigami.PromptDialog {
|
2023-03-14 02:26:52 +00:00
|
|
|
id: dialogRoot
|
2024-02-11 23:30:06 +00:00
|
|
|
title: headingText
|
|
|
|
|
|
2023-03-14 02:26:52 +00:00
|
|
|
property int securityType
|
|
|
|
|
property string headingText
|
|
|
|
|
property string devicePath
|
|
|
|
|
property string specificPath
|
2024-07-27 03:47:44 +00:00
|
|
|
|
2023-03-14 02:26:52 +00:00
|
|
|
signal donePressed(string password)
|
2024-07-27 03:47:44 +00:00
|
|
|
|
2023-03-14 02:26:52 +00:00
|
|
|
function openAndClear() {
|
|
|
|
|
warning.visible = false;
|
|
|
|
|
this.open();
|
|
|
|
|
passwordField.text = "";
|
|
|
|
|
passwordField.focus = true;
|
|
|
|
|
}
|
2024-07-27 03:47:44 +00:00
|
|
|
|
2023-03-14 02:26:52 +00:00
|
|
|
standardButtons: Controls.Dialog.Ok | Controls.Dialog.Cancel
|
2024-07-27 03:47:44 +00:00
|
|
|
|
2023-03-14 02:26:52 +00:00
|
|
|
onOpened: passwordField.forceActiveFocus()
|
|
|
|
|
onRejected: {
|
|
|
|
|
dialogRoot.close();
|
|
|
|
|
passwordField.focus = false;
|
|
|
|
|
}
|
|
|
|
|
onAccepted: {
|
|
|
|
|
if (passwordField.acceptableInput) {
|
|
|
|
|
dialogRoot.close();
|
|
|
|
|
handler.addAndActivateConnection(devicePath, specificPath, passwordField.text);
|
|
|
|
|
} else {
|
|
|
|
|
warning.visible = true;
|
|
|
|
|
}
|
|
|
|
|
passwordField.focus = false;
|
|
|
|
|
}
|
2024-07-27 03:47:44 +00:00
|
|
|
|
2023-03-14 02:26:52 +00:00
|
|
|
ColumnLayout {
|
|
|
|
|
id: column
|
2023-11-08 17:57:27 +00:00
|
|
|
spacing: Kirigami.Units.largeSpacing
|
2024-07-27 03:47:44 +00:00
|
|
|
|
2023-03-14 02:26:52 +00:00
|
|
|
PasswordField {
|
|
|
|
|
id: passwordField
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
securityType: dialogRoot.securityType
|
|
|
|
|
onAccepted: dialogRoot.accept()
|
|
|
|
|
}
|
2024-07-27 03:47:44 +00:00
|
|
|
|
2023-03-14 02:26:52 +00:00
|
|
|
Controls.Label {
|
|
|
|
|
id: warning
|
|
|
|
|
text: i18n("Invalid input.")
|
|
|
|
|
visible: false
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-07-27 03:47:44 +00:00
|
|
|
|
2023-03-14 02:26:52 +00:00
|
|
|
}
|