Warning, /plasma/sddm-kcm/src/ui/main.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 
0007 import QtQuick 2.15
0008 import QtQuick.Controls 2.15 as QQC2
0009 import QtQuick.Dialogs
0010 import QtQuick.Layouts 1.15
0011 import QtQuick.Window 2.15
0012 import Qt5Compat.GraphicalEffects
0013 
0014 
0015 import org.kde.kcmutils as KCM
0016 import org.kde.kirigami 2.14 as Kirigami
0017 import org.kde.newstuff 1.81 as NewStuff
0018 import org.kde.private.kcms.sddm 1.0
0019 
0020 KCM.GridViewKCM {
0021     id: root
0022     actions: [
0023         Kirigami.Action {
0024             text: i18nc("@action:button", "Behavior…")
0025             icon.name: "settings-configure"
0026             onTriggered: { kcm.push("Advanced.qml") }
0027         },
0028         Kirigami.Action {
0029             text: i18nc("@action:button", "Apply Plasma Settings…")
0030             icon.name: "plasma"
0031             onTriggered: syncSheet.open()
0032         },
0033         Kirigami.Action {
0034             text: i18nc("@action:button", "Install From File…")
0035             icon.name: "document-import"
0036             onTriggered: themeDialog.open()
0037         },
0038         NewStuff.Action {
0039             text: i18nc("@action:button as in, \"get new SDDM themes\"", "Get New…")
0040             configFile: "sddmtheme.knsrc"
0041             onEntryEvent: function(entry, event) {
0042                 kcm.themesModel.populate();
0043             }
0044         }
0045     ]
0046     header: Kirigami.InlineMessage {
0047         id: errorMessage
0048         type: Kirigami.MessageType.Error
0049         showCloseButton: true
0050         Connections {
0051             target: kcm
0052 
0053             function onErrorOccured(untranslatedMessage) {
0054                 errorMessage.text = i18n(untranslatedMessage);
0055                 errorMessage.visible = untranslatedMessage.length > 0
0056             }
0057 
0058             function onSyncSuccessful() {
0059                 syncSheet.close()
0060             }
0061 
0062             function onResetSyncedDataSuccessful() {
0063                 syncSheet.close()
0064             }
0065         }
0066     }
0067     KCM.SettingStateBinding {
0068         configObject: kcm.sddmSettings
0069         settingName: "Current"
0070     }
0071     view.model: kcm.themesModel
0072     view.currentIndex: kcm.themesModel.currentIndex
0073     view.delegate: KCM.GridDelegate {
0074         id: delegate
0075         text: model.display
0076         subtitle: model.author
0077         thumbnailAvailable: true
0078         thumbnail: Image {
0079             anchors.fill: parent
0080             source: model.preview
0081             sourceSize: Qt.size(delegate.GridView.view.cellWidth * Screen.devicePixelRatio,
0082                                 delegate.GridView.view.cellHeight * Screen.devicePixelRatio)
0083             fillMode: Image.PreserveAspectFit
0084             smooth: true
0085         }
0086         actions: [
0087             Kirigami.Action {
0088                 icon.name: "documentinfo"
0089                 tooltip: i18nc("@info:tooltip", "View details")
0090                 onTriggered: {
0091                     detailsDialog.themeName = model.display
0092                     detailsDialog.previewPath = model.preview
0093                     detailsDialog.authorName = model.author
0094                     detailsDialog.description = model.description
0095                     detailsDialog.license = model.license
0096                     detailsDialog.email = model.email
0097                     detailsDialog.website = model.website
0098                     detailsDialog.version = model.version
0099                     detailsDialog.open()
0100                 }
0101             },
0102             Kirigami.Action {
0103                 icon.name: "games-config-background"
0104                 tooltip: i18nc("@info:tooltip", "Change Background")
0105                 onTriggered: {
0106                     backgroundSheet.modelIndex = view.model.index(index, 0)
0107                     backgroundSheet.imagePath = Qt.binding(() => model.currentBackground)
0108                     backgroundSheet.open()
0109                 }
0110             },
0111             Kirigami.Action {
0112                 icon.name: "edit-delete"
0113                 tooltip: i18nc("@info:tooltip", "Delete")
0114                 onTriggered: kcm.removeTheme(view.model.index(index, 0))
0115                 enabled: model.deletable
0116             }
0117         ]
0118         onClicked: kcm.sddmSettings.current = model.id
0119 
0120         onDoubleClicked: {
0121             kcm.save();
0122         }
0123     }
0124     FileDialog {
0125         id: themeDialog
0126         onAccepted: kcm.installTheme(selectedFile)
0127     }
0128     DetailsDialog {
0129         id: detailsDialog
0130     }
0131     Kirigami.OverlaySheet {
0132         id: syncSheet
0133         title: i18nc("@title:window", "Apply Plasma Settings")
0134         Kirigami.InlineMessage {
0135             implicitWidth: Kirigami.Units.gridUnit * 22
0136             visible: true
0137             type: Kirigami.MessageType.Information
0138             font: Kirigami.Theme.smallFont
0139             text: i18n("This will make the SDDM login screen reflect your customizations to the following Plasma settings:") +
0140                 xi18nc("@info", "<para><list><item>Color scheme,</item><item>Cursor theme,</item><item>Cursor size,</item><item>Font,</item><item>Font rendering,</item><item>NumLock preference,</item><item>Plasma theme,</item><item>Scaling DPI,</item><item>Screen configuration (Wayland only)</item></list></para>") +
0141                 i18n("Please note that theme files must be installed globally to be reflected on the SDDM login screen.")
0142         }
0143         footer: RowLayout {
0144             spacing: Kirigami.Units.smallSpacing
0145 
0146             Item {
0147                 Layout.fillWidth: true
0148             }
0149             QQC2.Button {
0150                 text: i18nc("@action:button", "Apply")
0151                 icon.name: "dialog-ok-apply"
0152                 onClicked: kcm.synchronizeSettings()
0153             }
0154             QQC2.Button {
0155                 text: i18nc("@action:button", "Reset to Default Settings")
0156                 icon.name: "edit-undo"
0157                 onClicked: kcm.resetSyncronizedSettings()
0158             }
0159         }
0160     }
0161     Kirigami.OverlaySheet {
0162         id: backgroundSheet
0163         property var modelIndex
0164         property string imagePath
0165         title: i18nc("@title:window", "Change Background")
0166         Item {
0167             implicitWidth: 0.75 * root.width
0168             implicitHeight: backgroundImage.hasImage ? backgroundImage.implicitHeight : placeHolder.implicitHeight
0169             Kirigami.PlaceholderMessage  {
0170                 id: placeHolder
0171                 anchors.fill: parent
0172                 visible: !backgroundImage.hasImage
0173                 icon.name: "view-preview"
0174                 text: i18n("No image selected")
0175             }
0176             Image {
0177                 id: backgroundImage
0178                 readonly property bool hasImage: status == Image.Ready || status == Image.Loading
0179                 width: parent.width
0180                 source: "file:" + backgroundSheet.imagePath
0181                 sourceSize.width: width
0182                 fillMode: Image.PreserveAspectFit
0183                 smooth: true
0184                 layer.enabled: true
0185                 layer.effect: DropShadow {
0186                     verticalOffset: 2
0187                     radius: 10
0188                     samples: 32
0189                     cached: true
0190                     color: Qt.rgba(0, 0, 0, 0.3)
0191                 }
0192             }
0193         }
0194         footer: RowLayout {
0195             spacing: Kirigami.Units.smallSpacing
0196 
0197             Item {
0198                 Layout.fillWidth: true
0199             }
0200             QQC2.Button {
0201                 icon.name: "document-open"
0202                 text: i18nc("@action:button", "Load From File…")
0203                 onClicked: imageDialog.open()
0204             }
0205             QQC2.Button {
0206                 icon.name: "edit-clear"
0207                 text: i18nc("@action:button", "Clear Image")
0208                 onClicked: {
0209                     view.model.setData(backgroundSheet.modelIndex, "", ThemesModel.CurrentBackgroundRole)
0210                     backgroundSheet.close()
0211                 }
0212             }
0213             FileDialog {
0214                 id: imageDialog
0215                 onAccepted: {
0216                     view.model.setData(backgroundSheet.modelIndex, kcm.toLocalFile(selectedFile), ThemesModel.CurrentBackgroundRole)
0217                     backgroundSheet.close()
0218                 }
0219             }
0220         }
0221     }
0222 }