Warning, /plasma/plasma-nm/kcm/qml/AddConnectionDialog.qml is written in an unsupported language. File is not indexed.
0001 /*
0002 SPDX-FileCopyrightText: 2016 Jan Grulich <jgrulich@redhat.com>
0003
0004 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0005 */
0006
0007 import QtQuick
0008 import QtQuick.Window
0009 import QtQuick.Controls as QQC2
0010 import org.kde.kirigami 2 as Kirigami
0011 import org.kde.plasma.networkmanagement as PlasmaNM
0012
0013 Window {
0014 id: dialog
0015
0016 signal configurationDialogRequested()
0017
0018 title: i18nc("@title:window", "Choose a Connection Type")
0019
0020 height: 600
0021 minimumHeight: 400
0022 width: 500
0023 minimumWidth: 500
0024
0025 PlasmaNM.CreatableConnectionsModel {
0026 id: connectionModel
0027 }
0028
0029 Rectangle {
0030 id: background
0031 anchors.fill: parent
0032 focus: true
0033 color: Kirigami.Theme.backgroundColor
0034 }
0035
0036 QQC2.ScrollView {
0037 id: scrollView
0038 anchors {
0039 bottom: buttonRow.top
0040 bottomMargin: Math.round(Kirigami.Units.gridUnit / 2)
0041 left: parent.left
0042 right: parent.right
0043 top: parent.top
0044 }
0045
0046 QQC2.ScrollBar.horizontal.policy: QQC2.ScrollBar.AlwaysOff
0047
0048 ListView {
0049 id: view
0050
0051 property int currentlySelectedIndex: -1
0052 property bool connectionShared
0053 property string connectionSpecificType
0054 property int connectionType
0055 property string connectionVpnType
0056
0057 clip: true
0058 model: connectionModel
0059 currentIndex: -1
0060 boundsBehavior: Flickable.StopAtBounds
0061 section.property: "ConnectionTypeSection"
0062 section.delegate: Kirigami.ListSectionHeader {
0063 text: section
0064 width: ListView.view.width
0065 }
0066 Rectangle {
0067 id: background1
0068 z: -1
0069 anchors.fill: parent
0070 focus: true
0071 Kirigami.Theme.colorSet: Kirigami.Theme.View
0072 color: Kirigami.Theme.backgroundColor
0073 }
0074 delegate: ListItem {
0075 height: connectionTypeBase.height
0076 width: view.width
0077 checked: view.currentlySelectedIndex === index
0078
0079 onClicked: {
0080 createButton.enabled = true
0081 view.currentlySelectedIndex = index
0082 view.connectionSpecificType = ConnectionSpecificType
0083 view.connectionShared = ConnectionShared
0084 view.connectionType = ConnectionType
0085 view.connectionVpnType = ConnectionVpnType
0086 }
0087
0088 onDoubleClicked: {
0089 dialog.close()
0090 kcm.onRequestCreateConnection(view.connectionType, view.connectionVpnType, view.connectionSpecificType, view.connectionShared)
0091 }
0092
0093 Item {
0094 id: connectionTypeBase
0095
0096 anchors {
0097 left: parent.left
0098 right: parent.right
0099 top: parent.top
0100 // Reset top margin from PlasmaComponents.ListItem
0101 topMargin: -Math.round(Kirigami.Units.gridUnit / 3)
0102 }
0103 height: Math.max(Kirigami.Units.iconSizes.medium, connectionNameLabel.height + connectionDescriptionLabel.height) + Math.round(Kirigami.Units.gridUnit / 2)
0104
0105 Kirigami.Icon {
0106 id: connectionIcon
0107
0108 anchors {
0109 left: parent.left
0110 verticalCenter: parent.verticalCenter
0111 }
0112 height: Kirigami.Units.iconSizes.medium; width: height
0113 source: ConnectionIcon
0114 }
0115
0116 Text {
0117 id: connectionNameLabel
0118
0119 anchors {
0120 bottom: ConnectionType === PlasmaNM.Enums.Vpn ? connectionIcon.verticalCenter : undefined
0121 left: connectionIcon.right
0122 leftMargin: Math.round(Kirigami.Units.gridUnit / 2)
0123 right: parent.right
0124 verticalCenter: ConnectionType === PlasmaNM.Enums.Vpn ? undefined : parent.verticalCenter
0125 }
0126 color: textColor
0127 height: paintedHeight
0128 elide: Text.ElideRight
0129 text: ConnectionTypeName
0130 textFormat: Text.PlainText
0131 }
0132
0133 Text {
0134 id: connectionDescriptionLabel
0135
0136 anchors {
0137 left: connectionIcon.right
0138 leftMargin: Math.round(Kirigami.Units.gridUnit / 2)
0139 right: parent.right
0140 top: connectionNameLabel.bottom
0141 }
0142 color: textColor
0143 height: visible ? paintedHeight : 0
0144 elide: Text.ElideRight
0145 font.pointSize: Kirigami.Theme.smallFont.pointSize
0146 opacity: 0.6
0147 text: ConnectionDescription
0148 visible: ConnectionType === PlasmaNM.Enums.Vpn
0149 }
0150 }
0151 }
0152 }
0153 }
0154
0155 Row {
0156 id: buttonRow
0157 anchors {
0158 bottom: parent.bottom
0159 right: parent.right
0160 margins: Math.round(Kirigami.Units.gridUnit / 2)
0161 }
0162 spacing: Kirigami.Units.mediumSpacing
0163
0164 QQC2.Button {
0165 id: createButton
0166 icon.name: "list-add"
0167 enabled: false
0168 text: i18n("Create")
0169
0170 onClicked: {
0171 dialog.close()
0172 kcm.onRequestCreateConnection(view.connectionType, view.connectionVpnType, view.connectionSpecificType, view.connectionShared)
0173 }
0174 }
0175
0176 QQC2.Button {
0177 id: cancelButton
0178 icon.name: "dialog-cancel"
0179 text: i18n("Cancel")
0180
0181 onClicked: {
0182 dialog.close()
0183 }
0184 }
0185 }
0186
0187 QQC2.ToolButton {
0188 id: configureButton
0189 anchors {
0190 bottom: parent.bottom
0191 left: parent.left
0192 margins: Math.round(Kirigami.Units.gridUnit / 2)
0193 }
0194 icon.name: "configure"
0195
0196 QQC2.ToolTip.text: i18n("Configuration")
0197 QQC2.ToolTip.visible: hovered
0198
0199 onClicked: {
0200 dialog.configurationDialogRequested();
0201 }
0202 }
0203 }