import QtQuick import QtQuick.Layouts import QtQuick.Controls Dialog { id: root x: (parent.width - width) / 2 y: (parent.height - height) / 2 width: 380 padding: 16 modal: true parent: Overlay.overlay closePolicy: Popup.CloseOnEscape property string action: "update" property string packageName: "" property bool checking: false property string errorText: "" signal passwordSubmitted(string password) function submit() { if (root.checking || passwordField.text.length === 0) return; root.checking = true; root.errorText = ""; root.passwordSubmitted(passwordField.text); } background: Rectangle { color: Theme.color1 radius: 3 border.width: 1 border.color: Theme.color4 } contentItem: ColumnLayout { spacing: 10 Label { text: root.action === "install" ? "Для установки нужны права root" : root.action === "remove" ? "Для удаления нужны права root" : "Для обновления нужны права root" color: Theme.color2 font.pixelSize: 15 font.bold: true wrapMode: Text.WordWrap Layout.fillWidth: true } Label { text: "Пароль пользователя:" color: Theme.color14 font.pixelSize: 12 Layout.fillWidth: true } TextField { id: passwordField Layout.fillWidth: true placeholderText: "пароль" placeholderTextColor: Theme.color3 echoMode: TextInput.Password selectByMouse: true color: Theme.color2 font.pixelSize: 14 topPadding: 12 bottomPadding: 12 leftPadding: 12 rightPadding: 12 background: Rectangle { color: Theme.color5 radius: 3 border.width: 1 border.color: passwordField.activeFocus ? Theme.color6 : Theme.color4 } onAccepted: root.submit() } Label { text: root.errorText visible: text.length > 0 color: "#e78284" font.pixelSize: 12 wrapMode: Text.WordWrap Layout.fillWidth: true } } footer: Item { implicitHeight: footerRow.implicitHeight + 22 RowLayout { id: footerRow anchors.fill: parent anchors.rightMargin: 18 spacing: 8 Item { Layout.fillWidth: true } Button { id: cancelButton text: "✕ Отмена" leftPadding: 14 rightPadding: 14 topPadding: 8 bottomPadding: 8 onClicked: root.reject() background: Rectangle { radius: 4 color: cancelButton.down ? Theme.color4 : cancelButton.hovered ? Theme.color4 : Theme.colorTransparent border.width: 1 border.color: Theme.color4 } contentItem: Text { text: cancelButton.text font.pixelSize: 13 color: Theme.color2 horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter } } Button { id: okButton text: root.action === "install" ? "✓ Установить" : root.action === "remove" ? "✓ Удалить" : "✓ Обновить" enabled: passwordField.text.length > 0 && !root.checking leftPadding: 14 rightPadding: 14 topPadding: 8 bottomPadding: 8 onClicked: root.submit() background: Rectangle { radius: 4 color: !okButton.enabled ? Theme.color5 : okButton.down ? Theme.color11 : okButton.hovered ? Theme.color6 : Theme.color10 } contentItem: Text { text: okButton.text font.pixelSize: 13 font.bold: true color: okButton.enabled ? Theme.color8 : Theme.color12 horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter } } } } onOpened: { root.checking = false root.errorText = "" passwordField.forceActiveFocus() } onClosed: { passwordField.text = "" root.checking = false root.errorText = "" } }