Commit 056df97a authored by Aditya Mehra's avatar Aditya Mehra
Browse files

port wifi kcm to expanded tile format

parent 5021ebef
/*
* Copyright 2019 Aditya Mehra <aix.m@outlook.com>
* Copyright 2019 Marco Martin <mart@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 2.010-1301, USA.
*/
import QtQuick 2.9
import QtQuick.Layouts 1.3
import QtQuick.Controls 2.3
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 2.0 as PlasmaComponents2
import org.kde.plasma.components 3.0 as PlasmaComponents
import org.kde.kirigami 2.11 as Kirigami
import org.kde.mycroft.bigscreen 1.0 as BigScreen
import QtGraphicalEffects 1.0
import org.kde.plasma.networkmanagement 0.2 as PlasmaNM
BigScreen.AbstractDelegate {
id: delegate
property bool activating: model.ConnectionState == PlasmaNM.Enums.Activating
property bool deactivating: model.ConnectionState == PlasmaNM.Enums.Deactivating
property bool predictableWirelessPassword: !model.Uuid && model.Type == PlasmaNM.Enums.Wireless &&
(model.SecurityType == PlasmaNM.Enums.StaticWep || model.SecurityType == PlasmaNM.Enums.WpaPsk ||
model.SecurityType == PlasmaNM.Enums.Wpa2Psk || model.SecurityType == PlasmaNM.Enums.SAE)
property alias connectionStatusLabelText: connectionStatusLabel.text
checked: connectionView.currentIndex === index && connectionView.activeFocus
implicitWidth: isCurrent ? listView.cellWidth * 2 : listView.cellWidth
implicitHeight: listView.height + Kirigami.Units.largeSpacing
Behavior on implicitWidth {
NumberAnimation {
duration: Kirigami.Units.longDuration
easing.type: Easing.InOutQuad
}
}
contentItem: Item {
id: connectionItemLayout
PlasmaCore.IconItem {
id: connectionSvgIcon
width: listView.cellWidth - delegate.leftPadding - (delegate.isCurrent ? 0 : delegate.rightPadding)
height: isCurrent ? width : width - Kirigami.Units.largeSpacing * 4
source: itemSignalIcon(model.Signal)
Behavior on width {
NumberAnimation {
duration: Kirigami.Units.longDuration
easing.type: Easing.InOutQuad
}
}
}
ColumnLayout {
width: listView.cellWidth - delegate.leftPadding - delegate.rightPadding
anchors.right: parent.right
y: delegate.isCurrent ? connectionItemLayout.height / 2 - height / 2 : connectionItemLayout.height - (connectionNameLabel.height + connectionStatusLabel.height + Kirigami.Units.largeSpacing)
Kirigami.Heading {
id: connectionNameLabel
Layout.fillWidth: true
visible: text.length > 0
level: 3
elide: Text.ElideRight
wrapMode: Text.Wrap
horizontalAlignment: Text.AlignHCenter
font.weight: model.ConnectionState == PlasmaNM.Enums.Activated ? Font.DemiBold : Font.Normal
font.italic: model.ConnectionState == PlasmaNM.Enums.Activating ? true : false
text: model.ItemUniqueName
maximumLineCount: 2
color: Kirigami.Theme.textColor
textFormat: Text.PlainText
}
Kirigami.Heading {
id: connectionStatusLabel
level: 3
elide: Text.ElideRight
Layout.fillWidth: true
visible: text.length > 0
maximumLineCount: 1
wrapMode: Text.WordWrap
horizontalAlignment: Text.AlignHCenter
opacity: 0.6
text: itemText()
color: Kirigami.Theme.textColor
textFormat: Text.PlainText
}
}
}
function itemText() {
if (model.ConnectionState == PlasmaNM.Enums.Activating) {
if (model.Type == PlasmaNM.Enums.Vpn)
return model.VpnState
else
return model.DeviceState
} else if (model.ConnectionState == PlasmaNM.Enums.Deactivating) {
if (model.Type == PlasmaNM.Enums.Vpn)
return model.VpnState
else
return model.DeviceState
} else if (model.ConnectionState == PlasmaNM.Enums.Deactivated) {
var result = model.LastUsed
if (model.SecurityType > PlasmaNM.Enums.NoneSecurity)
result += ", " + model.SecurityTypeString
return result
} else if (model.ConnectionState == PlasmaNM.Enums.Activated) {
return i18n("Connected")
}
}
function itemSignalIcon(signalState) {
if (signalState <= 25){
return "network-wireless-connected-25"
} else if (signalState <= 50){
return "network-wireless-connected-50"
} else if (signalState <= 75){
return "network-wireless-connected-75"
} else if (signalState <= 100){
return "network-wireless-connected-100"
} else {
return "network-wireless-connected-00"
}
}
Keys.onReturnPressed: clicked()
onClicked: {
listView.currentIndex = index
listView.positionViewAtIndex(index, ListView.Contain)
if (!model.ConnectionPath) {
networkSelectionView.devicePath = model.DevicePath
networkSelectionView.specificPath = model.SpecificPath
networkSelectionView.connectionName = connectionNameLabel.text
networkSelectionView.securityType = model.SecurityType
if(model.SecurityType == -1 ){
console.log("Open Network")
networkSelectionView.connectToOpenNetwork()
} else {
passwordLayer.open();
passField.forceActiveFocus();
}
} else if (model.ConnectionState == PlasmaNM.Enums.Deactivated) {
handler.activateConnection(model.ConnectionPath, model.DevicePath, model.SpecificPath)
} else {
handler.deactivateConnection(model.ConnectionPath, model.DevicePath)
}
}
Keys.onMenuPressed: {
pathToRemove = model.ConnectionPath
nameToRemove = model.ItemUniqueName
networkActions.open()
}
onPressAndHold: {
pathToRemove = model.ConnectionPath
nameToRemove = model.ItemUniqueName
networkActions.open()
}
}
......@@ -40,8 +40,8 @@ BigScreen.AbstractDelegate {
checked: connectionView.currentIndex === index && connectionView.activeFocus
implicitWidth: isCurrent ? listView.cellWidth * 2 : listView.cellWidth
implicitHeight: listView.height + Kirigami.Units.largeSpacing
implicitWidth: listView.cellWidth * 2
implicitHeight: listView.height
Behavior on implicitWidth {
NumberAnimation {
......@@ -55,51 +55,50 @@ BigScreen.AbstractDelegate {
PlasmaCore.IconItem {
id: connectionSvgIcon
width: listView.cellWidth - delegate.leftPadding - (delegate.isCurrent ? 0 : delegate.rightPadding)
height: isCurrent ? width : width - Kirigami.Units.largeSpacing * 4
width: Kirigami.Units.iconSizes.huge
height: width
y: connectionItemLayout.height/2 - connectionSvgIcon.height/2
source: itemSignalIcon(model.Signal)
Behavior on width {
NumberAnimation {
duration: Kirigami.Units.longDuration
easing.type: Easing.InOutQuad
}
}
}
ColumnLayout {
width: listView.cellWidth - delegate.leftPadding - delegate.rightPadding
anchors.right: parent.right
y: delegate.isCurrent ? connectionItemLayout.height / 2 - height / 2 : connectionItemLayout.height - (connectionNameLabel.height + connectionStatusLabel.height + Kirigami.Units.largeSpacing)
id: textLayout
anchors {
left: connectionSvgIcon.right
right: connectionItemLayout.right
top: connectionSvgIcon.top
bottom: connectionSvgIcon.bottom
leftMargin: Kirigami.Units.smallSpacing
}
Kirigami.Heading {
PlasmaComponents.Label {
id: connectionNameLabel
Layout.fillWidth: true
visible: text.length > 0
level: 3
elide: Text.ElideRight
wrapMode: Text.Wrap
wrapMode: Text.WordWrap
horizontalAlignment: Text.AlignHCenter
font.weight: model.ConnectionState == PlasmaNM.Enums.Activated ? Font.DemiBold : Font.Normal
font.italic: model.ConnectionState == PlasmaNM.Enums.Activating ? true : false
text: model.ItemUniqueName
maximumLineCount: 2
color: Kirigami.Theme.textColor
textFormat: Text.PlainText
font.weight: model.ConnectionState == PlasmaNM.Enums.Activated ? Font.DemiBold : Font.Normal
font.italic: model.ConnectionState == PlasmaNM.Enums.Activating ? true : false
text: model.ItemUniqueName
}
Kirigami.Heading {
PlasmaComponents.Label {
id: connectionStatusLabel
level: 3
elide: Text.ElideRight
Layout.fillWidth: true
visible: text.length > 0
maximumLineCount: 1
elide: Text.ElideRight
wrapMode: Text.WordWrap
horizontalAlignment: Text.AlignHCenter
opacity: 0.6
text: itemText()
maximumLineCount: 3
color: Kirigami.Theme.textColor
textFormat: Text.PlainText
opacity: 0.6
text: itemText()
}
}
}
......
......@@ -120,8 +120,25 @@ KCM.SimpleKCM {
Layout.fillHeight: true
KeyNavigation.up: connectionView
KeyNavigation.right: kcmcloseButton
icon.name: "view-refresh"
text: i18n("Refresh")
background: Rectangle {
color: reloadButton.activeFocus ? Kirigami.Theme.highlightColor : Kirigami.Theme.backgroundColor
}
contentItem: Item {
RowLayout {
anchors.centerIn: parent
Kirigami.Icon {
Layout.preferredWidth: Kirigami.Units.iconSizes.small
Layout.preferredHeight: Kirigami.Units.iconSizes.small
source: "view-refresh"
}
Label {
text: i18n("Refresh")
}
}
}
onClicked: {
networkSelectionView.refreshing = true;
connectionView.contentY = -Kirigami.Units.gridUnit * 4;
......@@ -138,8 +155,25 @@ KCM.SimpleKCM {
KeyNavigation.left: reloadButton
Layout.fillWidth: true
Layout.fillHeight: true
icon.name: "window-close"
text: i18n("Exit")
background: Rectangle {
color: kcmcloseButton.activeFocus ? Kirigami.Theme.highlightColor : Kirigami.Theme.backgroundColor
}
contentItem: Item {
RowLayout {
anchors.centerIn: parent
Kirigami.Icon {
Layout.preferredWidth: Kirigami.Units.iconSizes.small
Layout.preferredHeight: Kirigami.Units.iconSizes.small
source: "window-close"
}
Label {
text: i18n("Exit")
}
}
}
onClicked: {
Window.window.close()
}
......@@ -317,14 +351,15 @@ KCM.SimpleKCM {
contentItem: FocusScope {
width: parent.width
height: parent.height - footerArea.height
anchors.top: parent.top
anchors.topMargin: Kirigami.Units.largeSpacing
ColumnLayout {
anchors.left: parent.left
anchors.top: parent.top
anchors.leftMargin: Kirigami.Units.largeSpacing
anchors.topMargin: Kirigami.Units.largeSpacing
width: parent.width
height: children.height
anchors.top: parent.top
width: parent.width - deviceConnectionView.width
height: parent.height
BigScreen.TileView {
id: connectionView
......@@ -341,7 +376,7 @@ KCM.SimpleKCM {
}
}
onCurrentItemChanged: {
onCurrentItemChanged: {
deviceConnectionView.currentIndex = connectionView.currentIndex
deviceConnectionView.positionViewAtIndex(currentIndex, ListView.Center);
}
......@@ -351,6 +386,9 @@ KCM.SimpleKCM {
Kirigami.Separator {
id: viewSept
anchors.right: deviceConnectionView.left
anchors.top: deviceConnectionView.top
anchors.bottom: deviceConnectionView.bottom
width: 1
}
ListView {
......@@ -359,8 +397,8 @@ KCM.SimpleKCM {
anchors.topMargin: -Kirigami.Units.largeSpacing
anchors.right: parent.right
anchors.rightMargin: -Kirigami.Units.largeSpacing
height: parent.height + Kirigami.Units.smallSpacing
model: connectionView.model
height: parent.height + Kirigami.Units.largeSpacing
width: parent.width / 3.5
layoutDirection: Qt.LeftToRight
orientation: ListView.Horizontal
......@@ -374,5 +412,5 @@ KCM.SimpleKCM {
currentIndex: 0
delegate: DeviceConnectionItem{}
}
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment