Warning, /plasma/sddm-kcm/src/ui/Advanced.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 SPDX-FileCopyrightText: 2020 David Redondo <kde@david-redondo.de> 0003 SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0004 */ 0005 0006 import QtQuick 2.15 0007 import QtQuick.Controls 2.15 as QQC2 0008 import QtQuick.Dialogs 6.3 0009 import QtQuick.Layouts 1.15 0010 0011 import org.kde.kcmutils as KCM 0012 import org.kde.kirigami 2.14 as Kirigami 0013 import org.kde.kitemmodels 1.0 as ItemModels 0014 import org.kde.private.kcms.sddm 1.0 0015 0016 Kirigami.Page { 0017 title: i18nc("@title", "Behavior") 0018 0019 Kirigami.FormLayout { 0020 width: parent.width 0021 0022 RowLayout { 0023 Kirigami.FormData.label: i18nc("option:check", "Automatically log in:") 0024 spacing: Kirigami.Units.smallSpacing 0025 0026 QQC2.CheckBox { 0027 id: autologinBox 0028 text: i18nc("@label:listbox, the following combobox selects the user to log in automatically", "as user:") 0029 checked: kcm.sddmSettings.user != "" 0030 KCM.SettingHighlighter { 0031 highlight: (kcm.sddmSettings.user != "" && kcm.sddmSettings.defaultUser == "") || 0032 (kcm.sddmSettings.user == "" && kcm.sddmSettings.defaultUser != "") 0033 } 0034 onToggled: { 0035 // Deliberately imperative because we only want the message 0036 // to appear when the user checks the checkbox, not all the 0037 // time when the checkbox is checked. 0038 if (checked && kcm.KDEWalletAvailable()) { 0039 autologinMessage.visible = true; 0040 } 0041 } 0042 } 0043 QQC2.ComboBox { 0044 id: autologinUser 0045 model: ItemModels.KSortFilterProxyModel { 0046 sourceModel: UsersModel { 0047 id: userModel 0048 } 0049 filterRowCallback: function(sourceRow, sourceParent) { 0050 const id = userModel.data(userModel.index(sourceRow, 0, sourceParent), UsersModel.UidRole) 0051 return kcm.sddmSettings.minimumUid <= id && id <= kcm.sddmSettings.maximumUid 0052 } 0053 } 0054 textRole: "display" 0055 editable: true 0056 onActivated: kcm.sddmSettings.user = currentText 0057 onEnabledChanged: enabled ? kcm.sddmSettings.user = currentText : kcm.sddmSettings.user = "" 0058 KCM.SettingStateBinding { 0059 visible: autologinBox.checked 0060 configObject: kcm.sddmSettings 0061 settingName: "User" 0062 extraEnabledConditions: autologinBox.checked 0063 } 0064 Component.onCompleted: { 0065 updateSelectedUser(); 0066 0067 // In the initial state, comboBox sets currentIndex to 0 (the first value from the comboBox). 0068 // After component is completed currentIndex changes to the correct value using `updateSelectUser` here. 0069 // This implicit initial changing of the currentIndex (to 0) calls the onEditTextChanged handler, 0070 // which in turn saves the wrong login in kcm.sddmSettings.user (the first value from the comboBox). 0071 // So we need connect to editTextChanged signal here after the correct currentIndex was settled 0072 // thus reacting only to user input and pressing the Reset/Default buttons. 0073 autologinUser.editTextChanged.connect(setUserFromEditText); 0074 } 0075 function setUserFromEditText() { 0076 kcm.sddmSettings.user = editText; 0077 } 0078 function updateSelectedUser() { 0079 const index = find(kcm.sddmSettings.user); 0080 if (index != -1) { 0081 currentIndex = index; 0082 } 0083 editText = kcm.sddmSettings.user; 0084 } 0085 Connections { // Needed for "Reset" and "Default" buttons to work 0086 target: kcm.sddmSettings 0087 function onUserChanged() { autologinUser.updateSelectedUser(); } 0088 } 0089 } 0090 QQC2.Label { 0091 enabled: autologinBox.checked 0092 text: i18nc("@label:listbox, the following combobox selects the session that is started automatically", "with session") 0093 } 0094 QQC2.ComboBox { 0095 id: autologinSession 0096 model: SessionModel {} 0097 textRole: "name" 0098 valueRole: "file" 0099 onActivated: kcm.sddmSettings.session = currentValue 0100 onEnabledChanged: enabled ? kcm.sddmSettings.session = currentValue : kcm.sddmSettings.session = "" 0101 KCM.SettingStateBinding { 0102 visible: autologinBox.checked 0103 configObject: kcm.sddmSettings 0104 settingName: "Session" 0105 extraEnabledConditions: autologinBox.checked 0106 } 0107 Component.onCompleted: updateCurrentIndex() 0108 function updateCurrentIndex() { 0109 currentIndex = Math.max(indexOfValue(kcm.sddmSettings.session), 0); 0110 } 0111 Connections { // Needed for "Reset" and "Default" buttons to work 0112 target: kcm.sddmSettings 0113 function onSessionChanged() { autologinSession.updateCurrentIndex(); } 0114 } 0115 } 0116 } 0117 Kirigami.InlineMessage { 0118 id: autologinMessage 0119 0120 Layout.fillWidth: true 0121 0122 type: Kirigami.MessageType.Warning 0123 0124 text: xi18nc("@info", "Auto-login does not support unlocking your KDE Wallet automatically, so it will ask you to unlock it every time you log in.\ 0125 <nl/><nl/>\ 0126 To avoid this, you can change the wallet to have a blank password. Note that this is insecure and should only be done in a trusted environment.") 0127 0128 actions: Kirigami.Action { 0129 text: i18n("Open KDE Wallet Settings") 0130 icon.name: "kwalletmanager" 0131 onTriggered: kcm.openKDEWallet(); 0132 } 0133 } 0134 QQC2.CheckBox { 0135 text: i18nc("@option:check", "Log in again immediately after logging off") 0136 checked: kcm.sddmSettings.relogin 0137 onToggled: kcm.sddmSettings.relogin = checked 0138 KCM.SettingStateBinding { 0139 configObject: kcm.sddmSettings 0140 settingName: "Relogin" 0141 extraEnabledConditions: autologinBox.checked 0142 } 0143 } 0144 Item { 0145 Kirigami.FormData.isSection: true 0146 } 0147 QQC2.SpinBox { 0148 Kirigami.FormData.label: i18nc("@label:spinbox", "Minimum user UID:") 0149 id: minSpinBox 0150 from: 1000 0151 to: maxSpinBox.value 0152 value: kcm.sddmSettings.minimumUid 0153 onValueModified: kcm.sddmSettings.minimumUid = value 0154 KCM.SettingStateBinding { 0155 configObject: kcm.sddmSettings 0156 settingName: "MinimumUid" 0157 } 0158 } 0159 QQC2.SpinBox { 0160 Kirigami.FormData.label: i18nc("@label:spinbox", "Maximum user UID:") 0161 id: maxSpinBox 0162 from: minSpinBox.value 0163 to: 60513 0164 value: kcm.sddmSettings.maximumUid 0165 onValueModified: kcm.sddmSettings.maximumUid = value 0166 KCM.SettingStateBinding { 0167 configObject: kcm.sddmSettings 0168 settingName: "MaximumUid" 0169 } 0170 } 0171 Item { 0172 Kirigami.FormData.isSection: true 0173 } 0174 RowLayout { 0175 Kirigami.FormData.label: i18nc("@label:textbox", "Halt Command:") 0176 Layout.fillWidth: true 0177 spacing: Kirigami.Units.smallSpacing 0178 0179 Kirigami.ActionTextField { 0180 id: haltField 0181 Layout.fillWidth: true 0182 text: kcm.sddmSettings.haltCommand 0183 readOnly: false 0184 onTextChanged: kcm.sddmSettings.haltCommand = text 0185 rightActions: [ Kirigami.Action { 0186 icon.name: haltField.LayoutMirroring.enabled ? "edit-clear-locationbar-ltr" : "edit-clear-locationbar-rtl" 0187 visible: haltField.text.length > 0 0188 onTriggered: kcm.sddmSettings.haltCommand = "" 0189 }] 0190 KCM.SettingStateBinding { 0191 configObject: kcm.sddmSettings 0192 settingName: "HaltCommand" 0193 } 0194 } 0195 QQC2.Button { 0196 id: haltButton 0197 icon.name: "document-open-folder" 0198 enabled: haltField.enabled 0199 function selectFile() { 0200 fileDialog.handler = (url => kcm.sddmSettings.haltCommand = kcm.toLocalFile(url)) 0201 fileDialog.open() 0202 } 0203 onClicked: selectFile() 0204 } 0205 } 0206 RowLayout { 0207 Layout.fillWidth: true 0208 Kirigami.FormData.label: i18nc("@label:textbox", "Reboot Command:") 0209 spacing: Kirigami.Units.smallSpacing 0210 0211 Kirigami.ActionTextField { 0212 id: rebootField 0213 Layout.fillWidth: true 0214 text: kcm.sddmSettings.rebootCommand 0215 readOnly: false 0216 onTextChanged: kcm.sddmSettings.rebootCommand = text 0217 rightActions: [ Kirigami.Action { 0218 icon.name: rebootField.LayoutMirroring.enabled ? "edit-clear-locationbar-ltr" : "edit-clear-locationbar-rtl" 0219 visible: rebootField.text.length > 0 0220 onTriggered: kcm.sddmSettings.rebootCommand = "" 0221 }] 0222 KCM.SettingStateBinding { 0223 configObject: kcm.sddmSettings 0224 settingName: "RebootCommand" 0225 } 0226 } 0227 QQC2.Button { 0228 id: rebootButton 0229 icon.name: "document-open-folder" 0230 enabled: rebootField.enabled 0231 function selectFile() { 0232 fileDialog.handler = (url => kcm.sddmSettings.rebootCommand = kcm.toLocalFile(url)) 0233 fileDialog.open() 0234 } 0235 onClicked: selectFile() 0236 } 0237 } 0238 FileDialog { 0239 id: fileDialog 0240 property var handler 0241 onAccepted: { 0242 handler(fileUrl) 0243 } 0244 } 0245 } 0246 }