Warning, /plasma/plasma-workspace/components/dialogs/examples/test.qml is written in an unsupported language. File is not indexed.

0001 /*
0002  *  SPDX-FileCopyrightText: 2021 Devin Lin <espidev@gmail.com>
0003  *
0004  *  SPDX-License-Identifier: LGPL-2.0-or-later
0005  */
0006 
0007 import QtQuick 2.15
0008 import QtQuick.Controls 2.15
0009 import QtQuick.Layouts 1.15
0010 import QtQuick.Window 2.15
0011 import Qt5Compat.GraphicalEffects
0012 import org.kde.kirigami 2.19 as Kirigami
0013 import org.kde.kirigamiaddons.components 1.0 as KirigamiComponents
0014 import org.kde.plasma.workspace.dialogs 1.0
0015 
0016 Kirigami.AbstractApplicationWindow {
0017     id: root
0018     
0019     width: 600
0020     height: 600
0021 
0022     SystemDialog {
0023         id: simple
0024         mainText: "Reset Data"
0025         subtitle: "This will reset all of your data."
0026         iconName: "documentinfo"
0027 
0028         standardButtons: DialogButtonBox.Ok | DialogButtonBox.Cancel
0029     }
0030 
0031     SystemDialog {
0032         id: simpleList
0033         mainText: "Reset Data"
0034         subtitle: "This will reset all of your data."
0035         iconName: "documentinfo"
0036 
0037         ListView {
0038             Layout.fillWidth: true
0039             implicitHeight: 300
0040 
0041             model: ListModel {
0042                 ListElement {
0043                     display: "banana"
0044                 }
0045                 ListElement {
0046                     display: "banana1"
0047                 }
0048                 ListElement {
0049                     display: "banana2"
0050                 }
0051                 ListElement {
0052                     display: "banana3"
0053                 }
0054             }
0055             delegate: ItemDelegate {
0056                 icon.name: "kate"
0057                 text: display
0058                 checkable: true
0059             }
0060         }
0061 
0062         standardButtons: DialogButtonBox.Ok | DialogButtonBox.Cancel
0063     }
0064 
0065     SystemDialog {
0066         id: desktopPolkit
0067         mainText: "Authentication Required"
0068         subtitle: "Authentication is needed to run `/usr/bin/ls` as the super user."
0069         iconName: "im-user-online"
0070 
0071         Kirigami.PasswordField {}
0072 
0073         standardButtons: DialogButtonBox.Ok | DialogButtonBox.Cancel
0074         actions: [
0075             Kirigami.Action {
0076                 text: "Details"
0077                 icon.name: "documentinfo"
0078                 onTriggered: desktopPolkit.close()
0079             }
0080         ]
0081     }
0082 
0083     SystemDialog {
0084         id: xdgDialog
0085         mainText: "Wallet access"
0086         subtitle: "Share your wallet with 'Somebody'."
0087         iconName: "kwallet"
0088         acceptable: false
0089 
0090         standardButtons: DialogButtonBox.Ok | DialogButtonBox.Cancel
0091         Component.onCompleted: {
0092             dialogButtonBox.standardButton(DialogButtonBox.Ok).text = "Share"
0093         }
0094         actions: [
0095             Kirigami.Action {
0096                 text: "Something Happens"
0097                 icon.name: "documentinfo"
0098                 onTriggered: xdgDialog.acceptable = true
0099             }
0100         ]
0101     }
0102 
0103     SystemDialog {
0104         id: appchooser
0105         title: "Open with..."
0106         iconName: "applications-all"
0107         ColumnLayout {
0108             Text {
0109                 text: "height: " + parent.height + " / " + xdgDialog.height
0110             }
0111 
0112             Label {
0113                 Layout.fillWidth: true
0114                 horizontalAlignment: Text.AlignHCenter
0115                 elide: Text.ElideRight
0116                 maximumLineCount: 3
0117 
0118                 text: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris at viverra mi. Maecenas volutpat et nisi ac scelerisque. Mauris pulvinar blandit dapibus. Nulla facilisi. Donec congue imperdiet maximus. Aliquam gravida velit sed mattis convallis. Nam id nisi egestas nibh ultrices varius quis at sapien."
0119                 wrapMode: Text.WordWrap
0120 
0121                 onLinkActivated: {
0122                     AppChooserData.openDiscover()
0123                 }
0124             }
0125 
0126             Frame {
0127                 id: viewBackground
0128                 Layout.fillWidth: true
0129                 Layout.fillHeight: true
0130                 Kirigami.Theme.inherit: false
0131                 Kirigami.Theme.colorSet: Kirigami.Theme.View
0132                 background: Rectangle {
0133                     color: Kirigami.Theme.backgroundColor
0134                     property color borderColor: Kirigami.Theme.textColor
0135                     border.color: Qt.rgba(borderColor.r, borderColor.g, borderColor.b, 0.3)
0136                 }
0137 
0138                 ScrollView {
0139                     anchors.fill: parent
0140                     implicitHeight: grid.cellHeight * 3
0141 
0142                     GridView {
0143                         id: grid
0144 
0145                         cellHeight: Kirigami.Units.iconSizes.huge + 50
0146                         cellWidth: Kirigami.Units.iconSizes.huge + 80
0147 
0148                         model: ListModel {
0149                             ListElement {
0150                                 display: "banana"
0151                             }
0152                             ListElement {
0153                                 display: "banana1"
0154                             }
0155                             ListElement {
0156                                 display: "banana2"
0157                             }
0158                             ListElement {
0159                                 display: "banana3"
0160                             }
0161                         }
0162                         delegate: Rectangle {
0163                             color: "blue"
0164                             height: grid.cellHeight
0165                             width: grid.cellWidth
0166 
0167                             Kirigami.Icon {
0168                                 source: "kalgebra"
0169                             }
0170                         }
0171                     }
0172                 }
0173             }
0174 
0175             Button {
0176                 id: showAllAppsButton
0177                 Layout.alignment: Qt.AlignHCenter
0178                 icon.name: "view-more-symbolic"
0179                 text: "Show More"
0180 
0181                 onClicked: {
0182                     visible = false
0183                 }
0184             }
0185 
0186             Kirigami.SearchField {
0187                 id: searchField
0188                 Layout.fillWidth: true
0189                 visible: !showAllAppsButton.visible
0190                 opacity: visible
0191             }
0192         }
0193     }
0194 
0195     SystemDialog {
0196         id: mobilePolkit
0197         mainText: "Authentication Required"
0198         subtitle: "Authentication is needed to run `/usr/bin/ls` as the super user."
0199 
0200         ColumnLayout {
0201             width: Kirigami.Units.gridUnit * 20
0202 
0203             KirigamiComponents.Avatar {
0204                 implicitHeight: Kirigami.Units.iconSizes.medium
0205                 implicitWidth: Kirigami.Units.iconSizes.medium
0206                 Layout.alignment: Qt.AlignHCenter
0207             }
0208             Kirigami.PasswordField {
0209                 Layout.fillWidth: true
0210             }
0211         }
0212 
0213         standardButtons: DialogButtonBox.Ok | DialogButtonBox.Cancel
0214         actions: [
0215             Kirigami.Action {
0216                 text: "Details"
0217                 icon.name: "documentinfo"
0218                 onTriggered: mobilePolkit.close()
0219             }
0220         ]
0221     }
0222 
0223     SystemDialog {
0224         id: sim
0225         mainText: "SIM Locked"
0226         subtitle: "Please enter your SIM PIN in order to unlock it."
0227 
0228         width: Kirigami.Units.gridUnit * 20
0229         standardButtons: DialogButtonBox.Ok | DialogButtonBox.Cancel
0230 
0231         Kirigami.PasswordField {
0232             Layout.fillWidth: true
0233         }
0234     }
0235 
0236     SystemDialog {
0237         id: device
0238         mainText: "Device Request"
0239         subtitle: "Allow <b>PureMaps</b> to access your location?"
0240 
0241         layout: Qt.Vertical
0242 
0243         actions: [
0244             Kirigami.Action {
0245                 text: "Allow all the time"
0246                 onTriggered: device.accept()
0247             },
0248             Kirigami.Action {
0249                 text: "Allow only while the app is in use"
0250                 onTriggered: device.accept()
0251             },
0252             Kirigami.Action {
0253                 text: "Deny"
0254                 onTriggered: device.accept()
0255             }
0256         ]
0257     }
0258 
0259     SystemDialog {
0260         id: wifi
0261         mainText: "eduroam"
0262 
0263         Kirigami.FormLayout {
0264             ComboBox {
0265                 model: ["PEAP"]
0266                 Layout.fillWidth: true
0267                 Kirigami.FormData.label: "EAP method:"
0268                 currentIndex: 0
0269             }
0270             ComboBox {
0271                 model: ["MSCHAPV2"]
0272                 Layout.fillWidth: true
0273                 Kirigami.FormData.label: "Phase 2 authentication:"
0274                 currentIndex: 0
0275             }
0276             TextField {
0277                 Kirigami.FormData.label: "Domain:"
0278                 Layout.fillWidth: true
0279                 text: ""
0280             }
0281             TextField {
0282                 Kirigami.FormData.label: "Identity:"
0283                 Layout.fillWidth: true
0284             }
0285             TextField {
0286                 Kirigami.FormData.label: "Username:"
0287                 Layout.fillWidth: true
0288             }
0289             Kirigami.PasswordField {
0290                 Kirigami.FormData.label: "Password:"
0291                 Layout.fillWidth: true
0292             }
0293         }
0294 
0295         standardButtons: DialogButtonBox.Ok | DialogButtonBox.Cancel
0296         Component.onCompleted: {
0297             dialogButtonBox.standardButton(DialogButtonBox.Ok).text = "Save"
0298         }
0299     }
0300     
0301     ColumnLayout {
0302         anchors.fill: parent
0303         Button {
0304             text: "Simple dialog (Desktop)"
0305             onClicked: {
0306                 simple.present()
0307             }
0308         }
0309         Button {
0310             text: "Simple List"
0311             onClicked: {
0312                 simpleList.present()
0313             }
0314         }
0315         Button {
0316             text: "Polkit dialog (Desktop)"
0317             onClicked: {
0318                 desktopPolkit.present()
0319             }
0320         }
0321         Button {
0322             text: "App Chooser(-ish)"
0323             onClicked: {
0324                 appchooser.present()
0325             }
0326         }
0327         Button {
0328             text: "XDG dialog (Desktop)"
0329             onClicked: {
0330                 xdgDialog.present()
0331             }
0332         }
0333         Button {
0334             text: "Polkit dialog (Mobile)"
0335             onClicked: {
0336                 mobilePolkit.present()
0337             }
0338         }
0339         Button {
0340             text: "SIM PIN dialog (Mobile)"
0341             onClicked: {
0342                 sim.present()
0343             }
0344         }
0345         Button {
0346             text: "Device request dialog (Mobile)"
0347             onClicked: {
0348                 device.present()
0349             }
0350         }
0351         Button {
0352             text: "Wifi Dialog (Mobile)"
0353             onClicked: {
0354                 wifi.present()
0355             }
0356         }
0357     }
0358 } 
0359