Warning, /network/kdenetwork-filesharing/samba/filepropertiesplugin/qml/UserPage.qml is written in an unsupported language. File is not indexed.

0001 /*
0002     SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0003     SPDX-FileCopyrightText: 2020 Harald Sitter <sitter@kde.org>
0004 */
0005 
0006 import QtQuick 2.12
0007 import QtQuick.Controls 2.5 as QQC2
0008 import QtQuick.Layouts 1.14
0009 import org.kde.kirigami 2.12 as Kirigami
0010 import org.kde.filesharing.samba 1.0 as Samba
0011 
0012 Kirigami.ScrollablePage {
0013     background: Item {} /* this page is inside a tabbox, we want its background, not a window/page background */
0014 
0015     globalToolBarStyle: Kirigami.ApplicationHeaderStyle.None
0016 
0017     // the page it lives within already has its own
0018     leftPadding: 0
0019     rightPadding: 0
0020     topPadding: 0
0021     bottomPadding: 0
0022 
0023     Keys.onPressed: {
0024         // We need to explicitly handle some keys inside the sheet. Since the sheet is no FocusScope we will catch
0025         // them here and feed them to the sheet instead.
0026         if (!changePassword.sheetOpen) {
0027             return
0028         }
0029         changePassword.handleKeyEvent(event)
0030     }
0031 
0032     ChangePassword {
0033         // This is an overlay sheet, it requires a scrollable page to anchor on.
0034         id: changePassword
0035 
0036         function userCreated(userCreated)
0037         {
0038             enabled = true
0039             changePassword.busy = false
0040             if (userCreated) {
0041                 close()
0042                 stackReplace(pendingStack.pop())
0043             }
0044         }
0045 
0046         onAccepted: {
0047             enabled = false
0048             busy = true
0049             sambaPlugin.userManager.currentUser().addToSamba(password)
0050         }
0051     }
0052 
0053     Connections {
0054         // ChangePassword being a sheet it's being crap to use and can't even connect to nothing.
0055         target: sambaPlugin.userManager.currentUser()
0056         onInSambaChanged: changePassword.userCreated(target.inSamba)
0057         onAddToSambaError: changePassword.errorMessage = error
0058     }
0059 
0060     ColumnLayout {
0061         QQC2.Label {
0062             Layout.alignment: Qt.AlignHCenter
0063             Layout.fillWidth: true
0064             textFormat: Text.RichText // for xi18n markup
0065             text: xi18nc("@info", `
0066 <para>
0067 Samba uses a separate user database from the system one.
0068 This requires you to set a separate Samba password for every user that you want to
0069 be able to authenticate with.
0070 </para>
0071 <para>
0072 Before you can access shares with your current user account you need to set a Samba password.
0073 </para>`)
0074             wrapMode: Text.Wrap
0075         }
0076 
0077         QQC2.Button {
0078             Layout.alignment: Qt.AlignHCenter
0079             icon.name: "lock"
0080             text: i18nc("@action:button opens dialog to create new user", "Create Samba password")
0081             onClicked: changePassword.openAndClear()
0082         }
0083 
0084         QQC2.Label {
0085             Layout.alignment: Qt.AlignHCenter
0086             Layout.fillWidth: true
0087             textFormat: Text.RichText // for xi18n markup
0088             text: xi18nc("@info", `
0089 Additional user management and password management can be done using Samba's <command>smbpasswd</command>
0090 command line utility.`)
0091             wrapMode: Text.Wrap
0092         }
0093     }
0094 }