| 1 |
// SPDX-FileCopyrightText: Nheko Contributors |
| 2 |
// |
| 3 |
// SPDX-License-Identifier: GPL-3.0-or-later |
| 4 |
|
| 5 |
import ".." |
| 6 |
import QtQuick 2.12 |
| 7 |
import QtQuick.Controls 2.5 |
| 8 |
import QtQuick.Layouts 1.3 |
| 9 |
import im.nheko 1.0 |
| 10 |
|
| 11 |
ApplicationWindow { |
| 12 |
id: inputDialog |
| 13 |
|
| 14 |
property alias prompt: promptLabel.text |
| 15 |
property alias echoMode: statusInput.echoMode |
| 16 |
property alias text: statusInput.text |
| 17 |
|
| 18 |
signal accepted(text: string) |
| 19 |
|
| 20 |
modality: Qt.NonModal |
| 21 |
flags: Qt.Dialog |
| 22 |
width: 350 |
| 23 |
height: fontMetrics.lineSpacing * 7 |
| 24 |
|
| 25 |
function forceActiveFocus() { |
| 26 |
statusInput.forceActiveFocus(); |
| 27 |
} |
| 28 |
|
| 29 |
Shortcut { |
| 30 |
sequences: [StandardKey.Cancel] |
| 31 |
onActivated: dbb.rejected() |
| 32 |
} |
| 33 |
|
| 34 |
ColumnLayout { |
| 35 |
spacing: Nheko.paddingMedium |
| 36 |
anchors.margins: Nheko.paddingMedium |
| 37 |
anchors.fill: parent |
| 38 |
|
| 39 |
Label { |
| 40 |
id: promptLabel |
| 41 |
|
| 42 |
color: palette.text |
| 43 |
} |
| 44 |
|
| 45 |
MatrixTextField { |
| 46 |
id: statusInput |
| 47 |
|
| 48 |
Layout.fillWidth: true |
| 49 |
onAccepted: dbb.accepted() |
| 50 |
focus: true |
| 51 |
} |
| 52 |
|
| 53 |
} |
| 54 |
|
| 55 |
footer: DialogButtonBox { |
| 56 |
id: dbb |
| 57 |
|
| 58 |
standardButtons: DialogButtonBox.Ok | DialogButtonBox.Cancel |
| 59 |
onAccepted: { |
| 60 |
inputDialog.accepted(statusInput.text); |
| 61 |
|
| 62 |
inputDialog.close(); |
| 63 |
} |
| 64 |
onRejected: { |
| 65 |
inputDialog.close(); |
| 66 |
} |
| 67 |
} |
| 68 |
|
| 69 |
} |