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