diff --git a/applet/contents/ui/PopupDialog.qml b/applet/contents/ui/PopupDialog.qml index d184486d..f6844030 100644 --- a/applet/contents/ui/PopupDialog.qml +++ b/applet/contents/ui/PopupDialog.qml @@ -1,137 +1,141 @@ /* Copyright 2013-2017 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.2 import QtQuick.Layouts 1.2 import org.kde.plasma.components 2.0 as PlasmaComponents +import org.kde.plasma.components 3.0 as PlasmaComponents3 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 -FocusScope { +PlasmaComponents3.Page { id: full property alias toolbarValues: toolbar PlasmaNM.AvailableDevices { id: availableDevices } Component { id: networkModelComponent PlasmaNM.NetworkModel {} } property PlasmaNM.NetworkModel connectionModel: null PlasmaNM.AppletProxyModel { id: appletProxyModel sourceModel: full.connectionModel } - ColumnLayout { - anchors.fill: parent - + header: PlasmaExtras.PlasmoidHeading { Toolbar { id: toolbar - Layout.fillWidth: true + width: parent.width } + } + + FocusScope { + + anchors.fill: parent + anchors.topMargin: units.smallSpacing * 2 PlasmaExtras.ScrollArea { id: scrollView - Layout.fillWidth: true - Layout.fillHeight: true + anchors.fill: parent frameVisible: false PlasmaExtras.Heading { id: disabledMessage anchors.fill: parent horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter level: 3 visible: connectionView.count === 0 && text != "" enabled: false text: { if (toolbarValues.displayplaneModeMessage) { return i18n("Airplane mode is enabled") } if (toolbarValues.displayWifiMessage) { if (toolbarValues.displayWwanMessage) { return i18n("Wireless and mobile networks are deactivated") } return i18n("Wireless is deactivated") } if (toolbarValues.displayWwanMessage) { return i18n("Mobile network is deactivated") } return "" } } PlasmaExtras.Heading { id: message anchors.fill: parent horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter level: 3 opacity: connectionView.count === 0 && !disabledMessage.visible ? 0.6 : 0 // Check connectionView.count again, to avoid a small delay. visible: opacity >= 0.6 && connectionView.count === 0 Behavior on opacity { NumberAnimation { duration: 5000 } } text: i18n("No available connections") } ListView { id: connectionView property int currentVisibleButtonIndex: -1 property bool showSeparator: false spacing: units.smallSpacing clip: true model: appletProxyModel currentIndex: -1 boundsBehavior: Flickable.StopAtBounds section.property: showSeparator ? "Section" : "" section.delegate: ListItem { separator: true } highlight: PlasmaComponents.Highlight { } highlightMoveDuration: units.longDuration highlightResizeDuration: units.longDuration delegate: ConnectionItem { } } } - } - Connections { - target: plasmoid - onExpandedChanged: { - connectionView.currentVisibleButtonIndex = -1; - - if (expanded) { - handler.requestScan(); - full.connectionModel = networkModelComponent.createObject(full) - } else { - full.connectionModel.destroy() - toolbar.closeSearch(); + Connections { + target: plasmoid + onExpandedChanged: { + connectionView.currentVisibleButtonIndex = -1; + + if (expanded) { + handler.requestScan(); + full.connectionModel = networkModelComponent.createObject(full) + } else { + full.connectionModel.destroy() + toolbar.closeSearch(); + } } } } } diff --git a/applet/contents/ui/Toolbar.qml b/applet/contents/ui/Toolbar.qml index 74219991..700bb0b1 100644 --- a/applet/contents/ui/Toolbar.qml +++ b/applet/contents/ui/Toolbar.qml @@ -1,258 +1,250 @@ /* Copyright 2013-2017 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.2 import QtQuick.Layouts 1.2 import org.kde.plasma.components 2.0 as PlasmaComponents import org.kde.plasma.components 3.0 as PlasmaComponents3 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.networkmanagement 0.2 as PlasmaNM import org.kde.kquickcontrolsaddons 2.0 ColumnLayout { id: toolbar spacing: units.smallSpacing readonly property var displayWifiMessage: !wifiSwitchButton.checked && wifiSwitchButton.visible readonly property var displayWwanMessage: !wwanSwitchButton.checked && wwanSwitchButton.visible readonly property var displayplaneModeMessage: planeModeSwitchButton.checked && planeModeSwitchButton.visible function closeSearch() { searchToggleButton.checked = false } PlasmaCore.Svg { id: lineSvg imagePath: "widgets/line" } PlasmaNM.EnabledConnections { id: enabledConnections onWirelessEnabledChanged: { wifiSwitchButton.checked = wifiSwitchButton.enabled && enabled } onWirelessHwEnabledChanged: { wifiSwitchButton.enabled = enabled && availableDevices.wirelessDeviceAvailable && !planeModeSwitchButton.airplaneModeEnabled } onWwanEnabledChanged: { wwanSwitchButton.checked = wwanSwitchButton.enabled && enabled } onWwanHwEnabledChanged: { wwanSwitchButton.enabled = enabled && availableDevices.modemDeviceAvailable && !planeModeSwitchButton.airplaneModeEnabled } } PlasmaNM.Configuration { id: configuration } RowLayout { spacing: units.smallSpacing SwitchButton { id: wifiSwitchButton checked: enabled && enabledConnections.wirelessEnabled enabled: enabledConnections.wirelessHwEnabled && availableDevices.wirelessDeviceAvailable && !planeModeSwitchButton.airplaneModeEnabled tooltip: i18n("Enable wireless") icon: enabled ? "network-wireless-on" : "network-wireless-off" visible: availableDevices.wirelessDeviceAvailable onClicked: { handler.enableWireless(checked); } } SwitchButton { id: wwanSwitchButton checked: enabled && enabledConnections.wwanEnabled enabled: enabledConnections.wwanHwEnabled && availableDevices.modemDeviceAvailable && !planeModeSwitchButton.airplaneModeEnabled tooltip: i18n("Enable mobile network") icon: enabled ? "network-mobile-on" : "network-mobile-off" visible: availableDevices.modemDeviceAvailable onClicked: { handler.enableWwan(checked); } } SwitchButton { id: planeModeSwitchButton property bool initialized: false property bool airplaneModeEnabled: false checked: airplaneModeEnabled tooltip: i18n("Enable airplane mode") icon: airplaneModeEnabled ? "network-flightmode-on" : "network-flightmode-off" visible: availableDevices.modemDeviceAvailable || availableDevices.wirelessDeviceAvailable onClicked: { handler.enableAirplaneMode(checked); airplaneModeEnabled = !airplaneModeEnabled; } Binding { target: configuration property: "airplaneModeEnabled" value: planeModeSwitchButton.airplaneModeEnabled when: planeModeSwitchButton.initialized } Component.onCompleted: { airplaneModeEnabled = configuration.airplaneModeEnabled initialized = true } } Item { Layout.fillWidth: true } PlasmaComponents3.ToolButton { id: hotspotButton icon { height: units.iconSizes.small width: units.iconSizes.small name: "network-wireless-on" } checkable: true text: i18n("Hotspot") visible: handler.hotspotSupported onClicked: { if (configuration.hotspotConnectionPath) { checked = false handler.stopHotspot() } else { checked = true handler.createHotspot() } } PlasmaComponents3.ToolTip { id: tooltip } Connections { target: handler onHotspotCreated: { hotspotButton.checked = true tooltip.text = i18n("Disable Hotspot") } onHotspotDisabled: { hotspotButton.checked = false tooltip.text = i18n("Create Hotspot") } } Component.onCompleted: { checked = configuration.hotspotConnectionPath tooltip.text = configuration.hotspotConnectionPath ? i18n("Disable Hotspot") : i18n("Create Hotspot") } } PlasmaComponents3.ToolButton { id: searchToggleButton icon { height: units.iconSizes.small width: units.iconSizes.small name: "search" } checkable: true PlasmaComponents3.ToolTip { text: i18ndc("plasma-nm", "button tooltip", "Search the connections") } } PlasmaComponents3.ToolButton { id: openEditorButton icon { height: units.iconSizes.small width: units.iconSizes.small name: "configure" } visible: mainWindow.kcmAuthorized PlasmaComponents3.ToolTip { text: i18n("Configure network connections...") } onClicked: { KCMShell.open(mainWindow.kcm) } } } - PlasmaCore.SvgItem { - Layout.fillWidth: true - elementId: "horizontal-line" - Layout.leftMargin: - units.smallSpacing * 1.5 - Layout.rightMargin: - units.smallSpacing * 1.5 - svg: lineSvg - } - PlasmaComponents.TextField { id: searchTextField Layout.fillWidth: true Layout.leftMargin: units.smallSpacing Layout.rightMargin: units.smallSpacing Layout.topMargin: units.smallSpacing Layout.bottomMargin: units.smallSpacing focus: true clearButtonShown: true placeholderText: i18ndc("plasma-nm", "text field placeholder text", "Search...") visible: searchToggleButton.checked onVisibleChanged: { if (visible) { searchTextField.forceActiveFocus() } else { text = "" } } Keys.onEscapePressed: { //Check if the searchbar is actually visible before accepting the escape key. Otherwise, the escape key cannot dismiss the applet until one interacts with some other element. if (searchToggleButton.checked) { searchToggleButton.checked = false; } else { event.accepted = false; } } onTextChanged: { // Show search field when starting to type directly if (text.length && !searchToggleButton.checked) { searchToggleButton.checked = true } appletProxyModel.setFilterRegExp(text) } } }