diff --git a/kcm/package/contents/ui/AddConnectionDialog.qml b/kcm/package/contents/ui/AddConnectionDialog.qml deleted file mode 100644 index 367f1eb5..00000000 --- a/kcm/package/contents/ui/AddConnectionDialog.qml +++ /dev/null @@ -1,182 +0,0 @@ -/* - Copyright 2016-2018 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -import QtQuick 2.3 -import QtQuick.Dialogs 1.2 -import QtQuick.Layouts 1.2 -import QtQuick.Controls 2.2 as QtControls - -import org.kde.kirigami 2.3 as Kirigami - -import org.kde.plasma.networkmanagement 0.2 as PlasmaNM - -Dialog { - id: addConnectionDialog - title: i18nc("@title:window", "Choose a Connection Type") - - signal requestCreateConnection(int type, string vpnType, string specificType, bool shared) - - contentItem: Item { - implicitHeight: 600 - implicitWidth: 500 - - PlasmaNM.CreatableConnectionsModel { - id: connectionModel - } - - Kirigami.Theme.colorSet: Kirigami.Theme.View - - Rectangle { - anchors.fill: parent - focus: true - color: Kirigami.Theme.backgroundColor - } - - ColumnLayout { - anchors.fill: parent - spacing: Kirigami.Units.smallSpacing - - Kirigami.ScrollablePage { - Layout.fillHeight: true - - ListView { - id: view - - property int currentlySelectedIndex: -1 - property bool connectionShared - property string connectionSpecificType - property int connectionType - property string connectionVpnType - - clip: true - model: connectionModel - currentIndex: -1 - boundsBehavior: Flickable.StopAtBounds - - section { - property: "ConnectionTypeSection" - delegate: Kirigami.AbstractListItem { - supportsMouseEvents: false - background: Rectangle { - color: palette.window - } - QtControls.Label { - id: headerLabel - anchors.centerIn: parent - font.weight: Font.DemiBold - text: section - } - } - } - - delegate: Kirigami.AbstractListItem { - checked: view.currentlySelectedIndex == index - highlighted: hovered - - - RowLayout { - anchors { - left: parent.left - right: parent.right - verticalCenter: parent.verticalCenter - leftMargin: Kirigami.Units.largeSpacing - } - spacing: Kirigami.Units.largeSpacing - - Kirigami.Icon { - Layout.minimumHeight: Kirigami.Units.iconSizes.smallMedium - Layout.maximumHeight: Layout.minimumHeight - Layout.minimumWidth: height - source: ConnectionIcon - } - - ColumnLayout { - spacing: 0 - - QtControls.Label { - id: nameLabel - Layout.fillWidth: true - height: paintedHeight - elide: Text.ElideRight - text: ConnectionTypeName - textFormat: Text.PlainText - } - - QtControls.Label { - id: statusLabel - Layout.fillWidth: true - height: paintedHeight - elide: Text.ElideRight - font.pointSize: theme.smallestFont.pointSize - text: ConnectionDescription - textFormat: Text.PlainText - opacity: 0.6 - visible: ConnectionType == 11 // VPN - } - } - } - - onClicked: { - createConnectionButton.enabled = true - view.currentlySelectedIndex = index - view.connectionSpecificType = ConnectionSpecificType - view.connectionShared = ConnectionShared - view.connectionType = ConnectionType - view.connectionVpnType = ConnectionVpnType - } - - onDoubleClicked: { - addConnectionDialog.close() - addConnectionDialog.requestCreateConnection(view.connectionType, view.connectionVpnType, view.connectionSpecificType, view.connectionShared) - } - } - } - } - - RowLayout { - spacing: Kirigami.Units.smallSpacing - - Layout.fillWidth: true - Layout.alignment: Qt.AlignRight - Layout.bottomMargin: Kirigami.Units.smallSpacing - Layout.rightMargin: Kirigami.Units.smallSpacing - - QtControls.Button { - id: createConnectionButton - enabled: false - text: i18n("Create") - - onClicked: { - addConnectionDialog.close() - addConnectionDialog.requestCreateConnection(view.connectionType, view.connectionVpnType, view.connectionSpecificType, view.connectionShared) - } - } - - QtControls.Button { - text: i18n("Cancel") - - onClicked: { - addConnectionDialog.close() - } - } - } - } - } -} diff --git a/kcm/package/contents/ui/AddConnectionSheet.qml b/kcm/package/contents/ui/AddConnectionSheet.qml new file mode 100644 index 00000000..3beee10d --- /dev/null +++ b/kcm/package/contents/ui/AddConnectionSheet.qml @@ -0,0 +1,83 @@ +/* + Copyright 2016-2018 Jan Grulich + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) version 3, or any + later version accepted by the membership of KDE e.V. (or its + successor approved by the membership of KDE e.V.), which shall + act as a proxy defined in Section 6 of version 3 of the license. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library. If not, see . +*/ + +import QtQuick 2.3 +import QtQuick.Dialogs 1.2 +import QtQuick.Layouts 1.2 +import QtQuick.Controls 2.2 as QtControls + +import org.kde.kirigami 2.12 as Kirigami + +import org.kde.plasma.networkmanagement 0.2 as PlasmaNM + +Kirigami.OverlaySheet { + id: addConnectionDialog + + objectName: "sheety" + + signal requestCreateConnection(int type, string vpnType, string specificType, bool shared) + + header: Kirigami.Heading { + text: i18nc("@title:window", "Choose a Connection Type") + } + + ListView { + id: view + + property int currentlySelectedIndex: -1 + property bool connectionShared + property string connectionSpecificType + property int connectionType + property string connectionVpnType + + Layout.preferredWidth: Kirigami.Units.gridUnit*10 + + clip: true + model: connectionModel + currentIndex: -1 + boundsBehavior: Flickable.StopAtBounds + + section { + property: "ConnectionTypeSection" + delegate: Kirigami.ListSectionHeader { + text: section + } + } + + delegate: Kirigami.BasicListItem { + checked: view.currentlySelectedIndex == index + highlighted: hovered + + icon: model.ConnectionIcon + label: model.ConnectionTypeName + subtitle: model.ConnectionDescription || "" + + onClicked: { + view.currentlySelectedIndex = index + view.connectionSpecificType = model.ConnectionSpecificType + view.connectionShared = model.ConnectionShared + view.connectionType = model.ConnectionType + view.connectionVpnType = model.ConnectionVpnType + addConnectionDialog.close() + addConnectionDialog.requestCreateConnection(view.connectionType, view.connectionVpnType, view.connectionSpecificType, view.connectionShared) + } + } + } +} diff --git a/kcm/package/contents/ui/ConfigurationDialog.qml b/kcm/package/contents/ui/ConfigurationDialog.qml index a1c98505..17fd490c 100644 --- a/kcm/package/contents/ui/ConfigurationDialog.qml +++ b/kcm/package/contents/ui/ConfigurationDialog.qml @@ -1,163 +1,99 @@ /* Copyright 2019 Jan Grulich This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) version 3, or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 6 of version 3 of the license. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . */ import QtQuick 2.5 import QtQuick.Dialogs 1.2 import QtQuick.Controls 2.5 as QQC2 import org.kde.kirigami 2.5 as Kirigami import org.kde.plasma.networkmanagement 0.2 as PlasmaNM Dialog { id: configurationDialog standardButtons: Dialog.Ok | Dialog.Cancel title: i18nc("@title:window", "Configuration") - PlasmaNM.Configuration { - id: configuration - } - contentItem: Item { implicitHeight: 200 implicitWidth: 400 Rectangle { id: background anchors.fill: parent focus: true color: baseColor } - Kirigami.FormLayout { - anchors.left: parent.left - anchors.right: parent.right - anchors.topMargin: units.gridUnit - - Kirigami.Heading { - id: generalLabel - level: 2 - text: i18n("General") - } - - QQC2.CheckBox { - id: unlockModem - text: i18n("Ask for PIN on modem detection") - onClicked: configurationChanged() - Component.onCompleted: checked = configuration.unlockModemOnDetection - } - - QQC2.CheckBox { - id: manageVirtualConnections - text: i18n("Show virtual connections") - onClicked: configurationChanged() - Component.onCompleted: checked = configuration.manageVirtualConnections - } - - Kirigami.Heading { - id: hotspotLabel - level: 2 - text: i18n("Hotspot") - Component.onCompleted: visible = handler.hotspotSupported - } - - QQC2.TextField { - id: hotspotName - Kirigami.FormData.label: i18n("Hotspot name:") - onTextChanged: configurationChanged() - Component.onCompleted: { - text = configuration.hotspotName - visible = handler.hotspotSupported - } - } - QQC2.TextField { - id: hotspotPassword - Kirigami.FormData.label: i18n("Hotspot password:") - validator: RegExpValidator { - regExp: if (useApMode) { - /^$|^(?:.{8,64}){1}$/ - } else { - /^$|^(?:.{5}|[0-9a-fA-F]{10}|.{13}|[0-9a-fA-F]{26}){1}$/ - } - } - - onAcceptableInputChanged: configurationChanged() - - Component.onCompleted: { - text = configuration.hotspotPassword - visible = handler.hotspotSupported - } - } - } Row { id: buttonRow anchors { bottom: parent.bottom right: parent.right margins: units.smallSpacing } spacing: units.smallSpacing QQC2.Button { id: okButton enabled: false text: i18n("Ok") onClicked: { configurationDialog.accept() } } QQC2.Button { id: cancelButton text: i18n("Cancel") onClicked: { configurationDialog.close() } } } } function configurationChanged() { if (handler.hotspotSupported) { okButton.enabled = hotspotPassword.acceptableInput && hotspotName.text } else { okButton.enabled = true } } onVisibleChanged: { if (visible) { unlockModem.checked = configuration.unlockModemOnDetection manageVirtualConnections.checked = configuration.manageVirtualConnections hotspotName.text = configuration.hotspotName hotspotPassword.text = configuration.hotspotPassword } } onAccepted: { configuration.unlockModemOnDetection = unlockModem.checked configuration.manageVirtualConnections = manageVirtualConnections.checked configuration.hotspotName = hotspotName.text configuration.hotspotPassword = hotspotPassword.text } } diff --git a/kcm/package/contents/ui/HotspotPage.qml b/kcm/package/contents/ui/HotspotPage.qml new file mode 100644 index 00000000..b0dbe90e --- /dev/null +++ b/kcm/package/contents/ui/HotspotPage.qml @@ -0,0 +1,64 @@ +/* + Copyright 2020 Carson Black + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) version 3, or any + later version accepted by the membership of KDE e.V. (or its + successor approved by the membership of KDE e.V.), which shall + act as a proxy defined in Section 6 of version 3 of the license. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library. If not, see . +*/ + +import QtQuick 2.6 +import QtQuick.Dialogs 1.1 +import QtQuick.Layouts 1.3 +import QtQuick.Controls 2.5 as QQC2 + +import org.kde.kcm 1.2 +import org.kde.plasma.core 2.0 as PlasmaCore +import org.kde.plasma.extras 2.0 as PlasmaExtras +import org.kde.plasma.networkmanagement 0.2 as PlasmaNM +import org.kde.kirigami 2.9 as Kirigami + +SimpleKCM { + id: root + + title: i18n("Hotspot") + + PlasmaNM.Configuration { + id: configuration + } + + Kirigami.FormLayout { + QQC2.TextField { + id: hotspotName + Kirigami.FormData.label: i18n("Hotspot name:") + onTextChanged: configuration.hotspotName = hotspotName.text + Component.onCompleted: text = configuration.hotspotName + } + + QQC2.TextField { + id: hotspotPassword + Kirigami.FormData.label: i18n("Hotspot password:") + validator: RegExpValidator { + regExp: if (useApMode) { + /^$|^(?:.{8,64}){1}$/ + } else { + /^$|^(?:.{5}|[0-9a-fA-F]{10}|.{13}|[0-9a-fA-F]{26}){1}$/ + } + } + + onAcceptableInputChanged: configuration.hotspotPassword = hotspotPassword.text + Component.onCompleted: text = configuration.hotspotPassword + } + } +} \ No newline at end of file diff --git a/kcm/package/contents/ui/main.qml b/kcm/package/contents/ui/main.qml index a3014c10..8a8ce746 100755 --- a/kcm/package/contents/ui/main.qml +++ b/kcm/package/contents/ui/main.qml @@ -1,342 +1,325 @@ /* Copyright 2016-2018 Jan Grulich This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) version 3, or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 6 of version 3 of the license. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . */ import "editor" import QtQuick 2.6 import QtQuick.Dialogs 1.1 import QtQuick.Layouts 1.3 import QtQuick.Controls 2.5 as QQC2 import org.kde.kcm 1.2 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.extras 2.0 as PlasmaExtras import org.kde.plasma.networkmanagement 0.2 as PlasmaNM -import org.kde.kirigami 2.9 as Kirigami +import org.kde.kirigami 2.12 as Kirigami ScrollViewKCM { id: root ConfigModule.quickHelp: i18n("Connections") title: i18n("Edit your Network Connections") property bool currentConnectionExportable: false property string currentConnectionName property string currentConnectionPath property QtObject connectionSettingsObject: kcm.connectionSettings LayoutMirroring.enabled: Qt.application.layoutDirection === Qt.RightToLeft LayoutMirroring.childrenInherit: true SystemPalette { id: palette colorGroup: SystemPalette.Active } PlasmaNM.Handler { id: handler } PlasmaNM.KcmIdentityModel { id: connectionModel } PlasmaNM.EditorProxyModel { id: editorProxyModel sourceModel: connectionModel } - header: QQC2.TextField { + header: Kirigami.SearchField { id: searchField focus: true - placeholderText: i18n("Type here to search connection...") - onTextChanged: { editorProxyModel.setFilterRegExp(text) } - - MouseArea { - anchors { - right: parent.right - verticalCenter: parent.verticalCenter - rightMargin: y - } - - opacity: searchField.text.length > 0 ? 1 : 0 - width: Kirigami.Units.iconSizes.small - height: width - - onClicked: { - searchField.text = "" - } - - Kirigami.Icon { - anchors.fill: parent - source: LayoutMirroring.enabled ? "edit-clear-rtl" : "edit-clear" - } - - Behavior on opacity { - OpacityAnimator { - duration: Kirigami.Units.longDuration - easing.type: Easing.InOutQuad - } - } - } } view: ListView { id: connectionView model: editorProxyModel currentIndex: -1 activeFocusOnTab: true keyNavigationWraps: true Accessible.role: Accessible.List Keys.onTabPressed: { if (applicationWindow().wideScreen && root.pageStack.depth > 1) { connectionEditor.focus = true; } } section { property: "KcmConnectionType" - delegate: Kirigami.AbstractListItem { - width: connectionView.width - supportsMouseEvents: false - background: Rectangle { - color: palette.window - } - QQC2.Label { - id: headerLabel - anchors.centerIn: parent - font.weight: Font.DemiBold - text: section - } + delegate: Kirigami.ListSectionHeader { + text: section } } delegate: ConnectionItemDelegate { width: connectionView.width onAboutToChangeConnection: { // Shouldn't be problem to set this in advance root.currentConnectionExportable = exportable if (kcm.needsSave) { confirmSaveDialog.connectionName = name confirmSaveDialog.connectionPath = path confirmSaveDialog.open() } else { selectConnectionInView(name, path) } } onAboutToExportConnection: { requestExportConnection(path) } onAboutToRemoveConnection: { deleteConfirmationDialog.connectionName = name deleteConfirmationDialog.connectionPath = path deleteConfirmationDialog.open() } } } footer: RowLayout { spacing: Kirigami.Units.largeSpacing + QQC2.Button { + id: configureButton + + icon.name: "configure" + + Layout.alignment: Qt.AlignLeft + + QQC2.ToolTip.text: i18n("Configuration") + QQC2.ToolTip.visible: hovered + + onClicked: { + configPopup.open() + } + + PlasmaNM.Configuration { + id: configuration + } + + QQC2.Popup { + id: configPopup + x: 0 + y: -height + modal: true + focus: true + + Kirigami.FormLayout { + QQC2.CheckBox { + text: i18n("Ask for PIN on modem detection") + onToggled: configuration.unlockModemOnDetection = checked + Component.onCompleted: checked = configuration.unlockModemOnDetection + } + + QQC2.CheckBox { + text: i18n("Show virtual connections") + onToggled: configuration.manageVirtualConnections = checked + Component.onCompleted: checked = configuration.manageVirtualConnections + } + } + } + } + QQC2.CheckBox { id: expertModeCheckbox Layout.alignment: Qt.AlignLeft Layout.fillWidth: true text: i18n("Enable expert mode") } QQC2.Button { id: exportConnectionButton Layout.alignment: Qt.AlignRight enabled: root.currentConnectionExportable icon.name: "document-export" QQC2.ToolTip.text: i18n("Export selected connection") QQC2.ToolTip.visible: hovered onClicked: { kcm.requestExportConnection(root.currentConnectionPath) } } QQC2.Button { id: removeConnectionButton Layout.alignment: Qt.AlignRight enabled: root.currentConnectionPath && root.currentConnectionPath.length icon.name: "list-remove" QQC2.ToolTip.text: i18n("Remove selected connection") QQC2.ToolTip.visible: hovered onClicked: { deleteConfirmationDialog.connectionName = root.currentConnectionName deleteConfirmationDialog.connectionPath = root.currentConnectionPath deleteConfirmationDialog.open() } } QQC2.Button { id: addConnectionButton Layout.alignment: Qt.AlignRight icon.name: "list-add" QQC2.ToolTip.text: i18n("Add new connection") QQC2.ToolTip.visible: hovered - onClicked: { - addNewConnectionDialog.open() - } + onClicked: addNewConnectionSheet.open() } - } - - ConnectionEditor { - id: connectionEditor - visible: false - } - - Row { - id: leftButtonRow - - anchors { - bottom: parent.bottom - left: parent.left - margins: units.smallSpacing - } - spacing: units.smallSpacing - - QQC2.ToolButton { - id: configureButton - icon.name: "configure" + QQC2.Button { + visible: handler.hotspotSupported + icon.name: "network-wireless-hotspot" - QQC2.ToolTip.text: i18n("Configuration") + QQC2.ToolTip.text: i18n("Configure Hotspot") QQC2.ToolTip.visible: hovered - onClicked: { - configurationDialog.open() - } + Layout.alignment: Qt.AlignRight + + onClicked: kcm.push("HotspotPage.qml") } } + ConnectionEditor { + id: connectionEditor + visible: false + } + MessageDialog { id: deleteConfirmationDialog property string connectionName property string connectionPath /* Like QString::toHtmlEscaped */ function toHtmlEscaped(s) { return s.replace(/[&<>]/g, function (tag) { return { '&': '&', '<': '<', '>': '>' }[tag] || tag }); } icon: StandardIcon.Question standardButtons: StandardButton.Ok | StandardButton.Cancel title: i18nc("@title:window", "Remove Connection") text: i18n("Do you want to remove the connection '%1'?", toHtmlEscaped(connectionName)) onAccepted: { if (connectionPath == root.currentConnectionPath) { // Deselect now non-existing connection deselectConnectionsInView() } handler.removeConnection(connectionPath) } onRejected: selectConnectionInView(connectionName, connectionPath) } MessageDialog { id: confirmSaveDialog property string connectionName property string connectionPath icon: StandardIcon.Question standardButtons: StandardButton.Ok | StandardButton.Cancel title: i18nc("@title:window", "Save Connection") text: i18n("Do you want to save changes made to the connection '%1'?", root.currentConnectionName) onAccepted: { kcm.save() selectConnectionInView(connectionName, connectionPath) } onRejected: selectConnectionInView(connectionName, connectionPath) } - AddConnectionDialog { - id: addNewConnectionDialog + AddConnectionSheet { + id: addNewConnectionSheet onRequestCreateConnection: { root.requestCreateConnection(type, vpnType, specificType, shared) } } - ConfigurationDialog { - id: configurationDialog - } - onCurrentConnectionPathChanged: { if (currentConnectionPath) { if (kcm.depth < 2) { kcm.push(connectionEditor) } else { kcm.currentIndex = 1 } kcm.selectConnection(root.currentConnectionPath) } } Component.onCompleted: { kcm.columnWidth = Kirigami.Units.gridUnit * 18 } function loadConnectionSetting() { connectionEditor.loadConnectionSettings() } function deselectConnectionsInView() { root.currentConnectionPath = "" } function selectConnectionInView(connectionName, connectionPath) { root.currentConnectionName = connectionName root.currentConnectionPath = connectionPath } }