matrixion/qml/dialogs/InputDialog.qml

63 lines
1.4 KiB
QML
Raw Normal View History

2021-05-28 18:25:46 +03:00
// SPDX-FileCopyrightText: 2021 Nheko Contributors
// SPDX-FileCopyrightText: 2022 Nheko Contributors
2021-05-28 18:25:46 +03:00
// SPDX-License-Identifier: GPL-3.0-or-later
2022-04-16 03:13:01 +03:00
import "../"
2021-06-13 02:48:11 +03:00
import QtQuick 2.12
import QtQuick.Controls 2.5
2021-05-28 18:25:46 +03:00
import QtQuick.Layouts 1.3
import im.nheko
2021-05-28 18:25:46 +03:00
ApplicationWindow {
id: inputDialog
property alias echoMode: statusInput.echoMode
2021-05-28 18:25:46 +03:00
property var onAccepted: undefined
2022-04-16 03:13:01 +03:00
property alias prompt: promptLabel.text
function forceActiveFocus() {
statusInput.forceActiveFocus();
}
2021-05-28 18:25:46 +03:00
flags: Qt.Dialog
height: fontMetrics.lineSpacing * 7
2022-04-16 03:13:01 +03:00
modality: Qt.NonModal
width: 350
2021-05-28 18:25:46 +03:00
2022-04-16 03:13:01 +03:00
footer: DialogButtonBox {
id: dbb
standardButtons: DialogButtonBox.Ok | DialogButtonBox.Cancel
onAccepted: {
if (inputDialog.onAccepted)
inputDialog.onAccepted(statusInput.text);
inputDialog.close();
}
onRejected: {
inputDialog.close();
}
}
Shortcut {
sequence: StandardKey.Cancel
2022-04-16 03:13:01 +03:00
onActivated: dbb.rejected()
}
2021-05-28 18:25:46 +03:00
ColumnLayout {
anchors.fill: parent
2022-04-16 03:13:01 +03:00
anchors.margins: Nheko.paddingMedium
spacing: Nheko.paddingMedium
2021-05-28 18:25:46 +03:00
Label {
id: promptLabel
2022-04-11 05:18:16 +03:00
color: timelineRoot.palette.text
2021-05-28 18:25:46 +03:00
}
MatrixTextField {
id: statusInput
Layout.fillWidth: true
focus: true
2021-05-28 18:25:46 +03:00
2022-04-16 03:13:01 +03:00
onAccepted: dbb.accepted()
2021-05-28 18:25:46 +03:00
}
}
}