145 lines
3.8 KiB
QML
145 lines
3.8 KiB
QML
import QtQuick
|
|
import QtQuick.Layouts
|
|
import QtQuick.Window
|
|
import QtQuick.Controls
|
|
import archpack
|
|
|
|
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
|
|
|
|
// "update" — обновление системы, "install" — установка одного пакета.
|
|
property string action: "update"
|
|
property string packageName: ""
|
|
|
|
// Диалог только сообщает введённый пароль: какое действие запускать
|
|
// и запоминать ли пароль на сеанс, решает Main.qml.
|
|
signal passwordEntered(string password)
|
|
|
|
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: 13
|
|
|
|
background: Rectangle {
|
|
color: Theme.color5
|
|
radius: 3
|
|
border.width: 1
|
|
border.color: passwordField.activeFocus ? Theme.color5 : Theme.color4
|
|
}
|
|
|
|
onAccepted: if (okButton.enabled) root.accept()
|
|
}
|
|
}
|
|
|
|
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
|
|
leftPadding: 14
|
|
rightPadding: 14
|
|
topPadding: 8
|
|
bottomPadding: 8
|
|
|
|
onClicked: root.accept()
|
|
|
|
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: passwordField.forceActiveFocus()
|
|
|
|
onAccepted: {
|
|
root.passwordEntered(passwordField.text)
|
|
}
|
|
|
|
onClosed: passwordField.text = ""
|
|
}
|