Warning, /plasma/polkit-kde-agent-1/qml/MobileQuickAuthDialog.qml is written in an unsupported language. File is not indexed.
0001 /* This file is part of the KDE project 0002 SPDX-FileCopyrightText: 2021 Aleix Pol Gonzalez <aleixpol@kde.org> 0003 SPDX-FileCopyrightText: 2023 Devin Lin <devin@kde.org> 0004 0005 SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 0008 import QtQuick 0009 import QtQuick.Layouts 0010 import QtQuick.Controls as QQC2 0011 import org.kde.kirigami 2.19 as Kirigami 0012 import Qt5Compat.GraphicalEffects 0013 import org.kde.polkitkde 1.0 0014 0015 MobileDialogWindow { 0016 id: root 0017 title: i18n("Authentication Required") 0018 contentWidth: Kirigami.Units.gridUnit * 22 0019 0020 property alias password: passwordField.text 0021 property alias inlineMessageType: inlineMessage.type 0022 property alias inlineMessageText: inlineMessage.text 0023 property alias inlineMessageIcon: inlineMessage.icon 0024 property alias identitiesModel: identitiesCombo.model 0025 property alias identitiesCurrentIndex: identitiesCombo.currentIndex 0026 property alias selectedIdentity: identitiesCombo.currentValue 0027 0028 // passed in by QuickAuthDialog.cpp 0029 property string mainText 0030 property string subtitle 0031 property string descriptionString 0032 property string descriptionActionId 0033 property string descriptionVendorName 0034 property string descriptionVendorUrl 0035 0036 signal accept() 0037 signal reject() 0038 0039 onAccept: { 0040 // disable password field while password is being checked 0041 if (passwordField.text.length > 0) { 0042 passwordField.enabled = false; 0043 } 0044 } 0045 0046 function authenticationFailure() { 0047 inlineMessage.type = Kirigami.MessageType.Error; 0048 inlineMessage.text = i18n("Authentication failure, please try again."); 0049 passwordField.clear() 0050 passwordField.enabled = true 0051 passwordField.focus = true 0052 rejectPasswordAnim.start(); 0053 } 0054 0055 onActiveChanged: { 0056 if (active) { 0057 // immediately focus on password field when window is focused 0058 passwordField.forceActiveFocus(); 0059 } 0060 } 0061 0062 onVisibleChanged: { 0063 if (visible) { 0064 // immediately focus on password field on load 0065 passwordField.forceActiveFocus(); 0066 } else { 0067 // reject on close 0068 root.reject(); 0069 } 0070 } 0071 0072 // select user combobox, we are displaying its popup 0073 property QQC2.ComboBox selectIdentityCombobox: QQC2.ComboBox { 0074 id: identitiesCombo 0075 visible: false 0076 textRole: "display" 0077 valueRole: "userRole" 0078 enabled: count > 0 0079 model: IdentitiesModel {} 0080 } 0081 0082 RejectPasswordAnimation { 0083 id: rejectPasswordAnim 0084 target: root.contentItem 0085 } 0086 0087 // dialog content 0088 contents: ColumnLayout { 0089 id: column 0090 spacing: 0 0091 0092 Kirigami.Heading { 0093 Layout.fillWidth: true 0094 Layout.topMargin: Kirigami.Units.largeSpacing 0095 level: 3 0096 text: i18n("Authentication Required") 0097 wrapMode: Text.Wrap 0098 font.weight: Font.Bold 0099 horizontalAlignment: Text.AlignHCenter 0100 } 0101 0102 QQC2.Label { 0103 Layout.topMargin: Kirigami.Units.largeSpacing 0104 Layout.bottomMargin: Kirigami.Units.largeSpacing 0105 Layout.fillWidth: true 0106 text: root.mainText 0107 visible: text.length > 0 0108 wrapMode: Text.Wrap 0109 horizontalAlignment: Text.AlignHCenter 0110 } 0111 0112 Kirigami.Icon { 0113 Layout.bottomMargin: Kirigami.Units.gridUnit 0114 Layout.alignment: Qt.AlignCenter 0115 source: "lock" 0116 implicitWidth: Kirigami.Units.iconSizes.large 0117 implicitHeight: Kirigami.Units.iconSizes.large 0118 } 0119 0120 // user information, only shown if there is more than one user to select from 0121 RowLayout { 0122 visible: identitiesCombo.count > 1 0123 spacing: Kirigami.Units.smallSpacing 0124 Layout.alignment: Qt.AlignHCenter 0125 Layout.bottomMargin: Kirigami.Units.largeSpacing 0126 0127 QQC2.Label { 0128 color: Kirigami.Theme.disabledTextColor 0129 text: i18n("User: %1", identitiesCombo.currentText) 0130 wrapMode: Text.Wrap 0131 } 0132 Kirigami.LinkButton { 0133 id: switchButton 0134 text: i18n("Switch…") 0135 onClicked: { 0136 identitiesCombo.popup.parent = switchButton; 0137 identitiesCombo.popup.open(); 0138 } 0139 } 0140 } 0141 0142 Kirigami.InlineMessage { 0143 id: inlineMessage 0144 Layout.fillWidth: true 0145 Layout.bottomMargin: Kirigami.Units.smallSpacing 0146 showCloseButton: true 0147 visible: text.length !== 0 0148 } 0149 0150 Kirigami.PasswordField { 0151 id: passwordField 0152 Layout.bottomMargin: Kirigami.Units.largeSpacing 0153 Layout.fillWidth: true 0154 onAccepted: root.accept() 0155 placeholderText: i18n("Password…") 0156 } 0157 0158 RowLayout { 0159 Layout.fillWidth: true 0160 0161 QQC2.Button { 0162 id: details 0163 text: i18n("Details") 0164 icon.name: "documentinfo" 0165 checkable: true 0166 checked: false 0167 } 0168 0169 Item { Layout.fillWidth: true } 0170 0171 // TODO: I'm not using a DialogButtonBox right now since there is weird extra padding right on the component, is there a way to fix that? 0172 QQC2.Button { 0173 text: i18n("OK") 0174 icon.name: "dialog-ok" 0175 onClicked: root.accept() 0176 } 0177 0178 QQC2.Button { 0179 text: i18n("Cancel") 0180 icon.name: "dialog-cancel" 0181 onClicked: root.reject() 0182 } 0183 } 0184 0185 Kirigami.FormLayout { 0186 visible: details.checked 0187 Layout.bottomMargin: Kirigami.Units.largeSpacing 0188 QQC2.Label { 0189 Kirigami.FormData.label: i18n("Action:") 0190 text: descriptionString 0191 } 0192 QQC2.Label { 0193 Kirigami.FormData.label: i18n("ID:") 0194 text: descriptionActionId 0195 } 0196 Kirigami.UrlButton { 0197 Kirigami.FormData.label: i18n("Vendor:") 0198 text: descriptionVendorName 0199 url: descriptionVendorUrl 0200 } 0201 } 0202 } 0203 }