Improve network

pull/11/head
cutefishd 5 years ago
parent 0ab3bc6462
commit 3c61f2ae7c

@ -1,135 +0,0 @@
import QtQuick 2.4
import QtQuick.Controls 2.4
import QtQuick.Layouts 1.3
import QtGraphicalEffects 1.0
import FishUI 1.0 as FishUI
import Cutefish.NetworkManagement 1.0 as NM
ItemPage {
id: control
headerTitle: qsTr("Network")
property var itemHeight: 50
property var settingsMap: ({})
NM.Networking {
id: networking
}
NM.NetworkModel {
id: networkModel
}
Scrollable {
anchors.fill: parent
contentHeight: mainLayout.implicitHeight
ColumnLayout {
id: mainLayout
anchors.fill: parent
// Wired connection
ColumnLayout {
id: wiredLayout
visible: networking.enabled && wiredView.count > 0
RowLayout {
Label {
text: qsTr("Wired")
color: FishUI.Theme.disabledTextColor
Layout.fillWidth: true
}
}
ListView {
id: wiredView
Layout.fillWidth: true
implicitHeight: wiredView.count * control.itemHeight
clip: true
model: NM.TechnologyProxyModel {
type: NM.TechnologyProxyModel.WiredType
sourceModel: networkModel
}
ScrollBar.vertical: ScrollBar {}
delegate: WiredItem {
height: control.itemHeight
width: wiredView.width
}
}
}
HorizontalDivider {
visible: wiredView.visible && networking.wirelessHardwareEnabled
}
// Wireless
ColumnLayout {
id: wirelessLayout
spacing: FishUI.Units.largeSpacing
RowLayout {
spacing: FishUI.Units.largeSpacing
Label {
text: qsTr("Wi-Fi")
color: FishUI.Theme.disabledTextColor
}
FishUI.BusyIndicator {
id: wlanBusyIndicator
width: wirelessSwitch.height
height: width
visible: networking.wirelessEnabled && wirelessView.count === 0
running: wlanBusyIndicator.visible
}
Item {
Layout.fillWidth: true
}
Switch {
id: wirelessSwitch
Layout.fillHeight: true
leftPadding: 0
rightPadding: 0
onCheckedChanged: networking.wirelessEnabled = checked
}
Component.onCompleted: {
wirelessSwitch.checked = networking.wirelessEnabled
}
}
ListView {
id: wirelessView
visible: networking.wirelessEnabled && networking.wirelessHardwareEnabled
Layout.fillWidth: true
implicitHeight: count * control.itemHeight
interactive: false
clip: true
model: NM.TechnologyProxyModel {
type: NM.TechnologyProxyModel.WirelessType
sourceModel: networkModel
showInactiveConnections: true
}
ScrollBar.vertical: ScrollBar {}
delegate: WirelessItem {
height: control.itemHeight
width: wirelessView.width
}
}
}
}
}
}

@ -6,13 +6,14 @@ import QtQuick.Window 2.3
import FishUI 1.0 as FishUI import FishUI 1.0 as FishUI
import Cutefish.NetworkManagement 1.0 as NM import Cutefish.NetworkManagement 1.0 as NM
import "../"
Item { Item {
id: control id: control
property bool passwordIsStatic: (model.securityType === NM.NetworkModel.StaticWep || model.securityType === NM.NetworkModel.WpaPsk || property bool passwordIsStatic: (model.securityType === NM.Enums.StaticWep || model.securityType === NM.Enums.WpaPsk ||
model.securityType === NM.NetworkModel.Wpa2Psk || model.securityType === NM.NetworkModel.SAE) model.securityType === NM.Enums.Wpa2Psk || model.securityType === NM.Enums.SAE)
property bool predictableWirelessPassword: !model.uuid && model.type === NM.NetworkModel.Wireless && passwordIsStatic property bool predictableWirelessPassword: !model.uuid && model.type === NM.Enums.Wireless && passwordIsStatic
Rectangle { Rectangle {
anchors.fill: parent anchors.fill: parent
@ -38,14 +39,14 @@ Item {
onClicked: { onClicked: {
if (model.uuid || !predictableWirelessPassword) { if (model.uuid || !predictableWirelessPassword) {
if (connectionState === NM.NetworkModel.Deactivated) { if (connectionState === NM.Enums.Deactivated) {
if (!predictableWirelessPassword && !model.uuid) { if (!predictableWirelessPassword && !model.uuid) {
networking.addAndActivateConnection(model.devicePath, model.specificPath); handler.addAndActivateConnection(model.devicePath, model.specificPath);
} else { } else {
networking.activateConnection(model.connectionPath, model.devicePath, model.specificPath); handler.activateConnection(model.connectionPath, model.devicePath, model.specificPath);
} }
} else { } else {
networking.deactivateConnection(model.connectionPath, model.devicePath); handler.deactivateConnection(model.connectionPath, model.devicePath);
} }
} else if (predictableWirelessPassword) { } else if (predictableWirelessPassword) {
passwordDialog.show() passwordDialog.show()
@ -77,8 +78,8 @@ Item {
id: busyIndicator id: busyIndicator
width: 22 width: 22
height: width height: width
visible: connectionState === NM.NetworkModel.Activating || visible: connectionState === NM.Enums.Activating ||
connectionState === NM.NetworkModel.Deactivating connectionState === NM.Enums.Deactivating
running: busyIndicator.visible running: busyIndicator.visible
} }
@ -88,7 +89,7 @@ Item {
height: width height: width
sourceSize: Qt.size(width, height) sourceSize: Qt.size(width, height)
source: "qrc:/images/checked.svg" source: "qrc:/images/checked.svg"
visible: model.connectionState === NM.NetworkModel.Activated visible: model.connectionState === NM.Enums.Activated
ColorOverlay { ColorOverlay {
anchors.fill: parent anchors.fill: parent
@ -105,7 +106,7 @@ Item {
height: width height: width
sourceSize: Qt.size(width, height) sourceSize: Qt.size(width, height)
source: "qrc:/images/locked.svg" source: "qrc:/images/locked.svg"
visible: model.securityType !== -1 && model.securityType !== 0 visible: (model.securityType === -1 | model.securityType === 0) ? false : true
ColorOverlay { ColorOverlay {
anchors.fill: parent anchors.fill: parent
@ -150,7 +151,7 @@ Item {
} }
onAccept: { onAccept: {
networking.addAndActivateConnection(model.devicePath, model.specificPath, passwordField.text) handler.addAndActivateConnection(model.devicePath, model.specificPath, passwordField.text)
passwordDialog.close() passwordDialog.close()
} }
@ -172,7 +173,7 @@ Item {
placeholderText: qsTr("Password") placeholderText: qsTr("Password")
validator: RegExpValidator { validator: RegExpValidator {
regExp: { regExp: {
if (model.securityType === NM.NetworkModel.StaticWep) if (model.securityType === NM.Enums.StaticWep)
return /^(?:[\x20-\x7F]{5}|[0-9a-fA-F]{10}|[\x20-\x7F]{13}|[0-9a-fA-F]{26}){1}$/; return /^(?:[\x20-\x7F]{5}|[0-9a-fA-F]{10}|[\x20-\x7F]{13}|[0-9a-fA-F]{26}){1}$/;
return /^(?:[\x20-\x7F]{8,64}){1}$/; return /^(?:[\x20-\x7F]{8,64}){1}$/;
} }

@ -0,0 +1,72 @@
import QtQuick 2.12
import QtQuick.Controls 2.12
import QtQuick.Layouts 1.12
import FishUI 1.0 as FishUI
Item {
implicitHeight: _contentLayout.implicitHeight + FishUI.Theme.mediumRadius * 2
ColumnLayout {
id: _contentLayout
anchors.fill: parent
spacing: FishUI.Units.smallSpacing
RowLayout {
Label {
id: wlanLabel
text: qsTr("WLAN")
}
FishUI.BusyIndicator {
id: wlanBusyIndicator
width: wirelessSwitch.height
height: width
visible: enabledConnections.wirelessEnabled && wirelessView.count === 0
running: wlanBusyIndicator.visible
}
Item {
Layout.fillWidth: true
}
Switch {
id: wirelessSwitch
height: wlanLabel.implicitHeight
leftPadding: 0
rightPadding: 0
checked: enabledConnections.wirelessEnabled
onCheckedChanged: {
if (checked) {
if (!enabledConnections.wirelessEnabled) {
handler.enableWireless(checked)
handler.requestScan()
}
} else {
if (enabledConnections.wirelessEnabled) {
handler.enableWireless(checked)
}
}
}
}
}
ListView {
id: wirelessView
Layout.fillWidth: true
Layout.preferredHeight: itemHeight * count
clip: true
model: appletProxyModel
interactive: false
visible: enabledConnections.wirelessEnabled
property var itemHeight: 45
delegate: WifiItem {
width: ListView.view.width
height: ListView.view.itemHeight
}
}
}
}

@ -164,7 +164,8 @@ Dialog {
Layout.fillWidth: true Layout.fillWidth: true
flat: true flat: true
onClicked: { onClicked: {
networking.removeConnection(model.connectionPath) handler.removeConnection(model.connectionPath)
control.reject()
} }
} }
} }

@ -0,0 +1,106 @@
import QtQuick 2.4
import QtQuick.Controls 2.4
import QtQuick.Layouts 1.3
import QtGraphicalEffects 1.0
import FishUI 1.0 as FishUI
import Cutefish.NetworkManagement 1.0 as NM
import "../"
ItemPage {
id: control
headerTitle: qsTr("Network")
property var itemHeight: 50
property var settingsMap: ({})
NM.Handler {
id: handler
}
NM.WifiSettings {
id: wifiSettings
}
NM.NetworkModel {
id: networkModel
}
NM.EnabledConnections {
id: enabledConnections
}
NM.IdentityModel {
id: connectionModel
}
NM.AppletProxyModel {
id: appletProxyModel
sourceModel: connectionModel
}
Component.onCompleted: handler.requestScan()
Timer {
id: scanTimer
interval: 10200
repeat: true
running: control.visible
onTriggered: handler.requestScan()
}
Scrollable {
anchors.fill: parent
contentHeight: mainLayout.implicitHeight
ColumnLayout {
id: mainLayout
anchors.fill: parent
// Wired connection
ColumnLayout {
id: wiredLayout
visible: enabledConnections.wwanEnabled && wiredView.count > 0
RowLayout {
Label {
text: qsTr("Wired")
color: FishUI.Theme.disabledTextColor
Layout.fillWidth: true
}
}
ListView {
id: wiredView
Layout.fillWidth: true
implicitHeight: wiredView.count * control.itemHeight
clip: true
model: NM.TechnologyProxyModel {
type: NM.TechnologyProxyModel.WiredType
sourceModel: networkModel
}
ScrollBar.vertical: ScrollBar {}
delegate: WiredItem {
height: control.itemHeight
width: wiredView.width
}
}
}
HorizontalDivider {
visible: wiredView.visible && enabledConnections.wirelessHwEnabled
}
WifiView {
Layout.fillWidth: true
visible: enabledConnections.wirelessHwEnabled
}
}
}
}

@ -45,7 +45,7 @@ Item {
ListElement { ListElement {
title: qsTr("Network") title: qsTr("Network")
name: "network" name: "network"
page: "qrc:/qml/NetworkPage.qml" page: "qrc:/qml/NetworkPage/main.qml"
iconSource: "network.svg" iconSource: "network.svg"
} }

@ -57,125 +57,123 @@ ItemPage {
} }
} }
Loader { GridView {
Layout.fillWidth: true id: _view
height: item.height
sourceComponent: background.backgroundType === 0 ? imageView : colorView
}
}
}
Component {
id: imageView
GridView { property int rowCount: _view.width / itemWidth
id: _view
// spacing: FishUI.Units.smallSpacing
// orientation: Qt.Horizontal
property int rowCount: _view.width / itemWidth Layout.fillWidth: true
implicitHeight: Math.ceil(_view.count / rowCount) * cellHeight + FishUI.Units.largeSpacing
implicitHeight: Math.ceil(_view.count / rowCount) * (itemHeight + FishUI.Units.largeSpacing * 2) visible: background.backgroundType === 0
clip: true clip: true
model: background.backgrounds model: background.backgrounds
currentIndex: -1 currentIndex: -1
interactive: false interactive: false
cellHeight: calcExtraSpacing(itemHeight, _view.height) + itemHeight cellHeight: itemHeight
cellWidth: calcExtraSpacing(itemWidth, _view.width) + itemWidth cellWidth: calcExtraSpacing(itemWidth, _view.width) + itemWidth
property int itemWidth: 250 property int itemWidth: 250
property int itemHeight: 170 property int itemHeight: 170
delegate: Item { delegate: Item {
id: item id: item
property bool isSelected: modelData === background.currentBackgroundPath property bool isSelected: modelData === background.currentBackgroundPath
width: GridView.view.cellWidth width: GridView.view.cellWidth
height: GridView.view.cellHeight height: GridView.view.cellHeight
scale: 1.0 scale: 1.0
Behavior on scale { Behavior on scale {
NumberAnimation { NumberAnimation {
duration: 100 duration: 100
}
} }
}
Rectangle {
anchors.fill: parent
anchors.margins: FishUI.Units.smallSpacing
color: "transparent"
radius: FishUI.Theme.bigRadius + FishUI.Units.smallSpacing / 2
border.color: FishUI.Theme.highlightColor
border.width: image.status == Image.Ready & isSelected ? 3 : 0
Image { Rectangle {
id: image
anchors.fill: parent anchors.fill: parent
anchors.margins: FishUI.Units.smallSpacing anchors.margins: FishUI.Units.smallSpacing
source: "file://" + modelData color: "transparent"
sourceSize: Qt.size(width, height) radius: FishUI.Theme.bigRadius + FishUI.Units.smallSpacing / 2
fillMode: Image.PreserveAspectCrop
asynchronous: true border.color: FishUI.Theme.highlightColor
mipmap: true border.width: image.status == Image.Ready & isSelected ? 3 : 0
cache: true
opacity: 1.0 Image {
smooth: false id: image
anchors.fill: parent
Behavior on opacity { anchors.margins: FishUI.Units.smallSpacing
NumberAnimation { source: "file://" + modelData
duration: 100 sourceSize: Qt.size(width, height)
easing.type: Easing.InOutCubic fillMode: Image.PreserveAspectCrop
asynchronous: true
mipmap: true
cache: true
smooth: true
opacity: 1.0
Behavior on opacity {
NumberAnimation {
duration: 100
easing.type: Easing.InOutCubic
}
} }
}
layer.enabled: true layer.enabled: true
layer.effect: OpacityMask { layer.effect: OpacityMask {
maskSource: Item { maskSource: Item {
width: image.width width: image.width
height: image.height height: image.height
Rectangle { Rectangle {
anchors.fill: parent anchors.fill: parent
radius: FishUI.Theme.bigRadius radius: FishUI.Theme.bigRadius
}
} }
} }
} }
}
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent
acceptedButtons: Qt.LeftButton acceptedButtons: Qt.LeftButton
hoverEnabled: true hoverEnabled: true
onClicked: { onClicked: {
background.setBackground(modelData) background.setBackground(modelData)
} }
onEntered: function() { onEntered: function() {
image.opacity = 0.7 image.opacity = 0.7
} }
onExited: function() { onExited: function() {
image.opacity = 1.0 image.opacity = 1.0
}
onPressedChanged: item.scale = pressed ? 0.97 : 1.0
} }
}
}
onPressedChanged: item.scale = pressed ? 0.97 : 1.0 function calcExtraSpacing(cellSize, containerSize) {
var availableColumns = Math.floor(containerSize / cellSize)
var extraSpacing = 0
if (availableColumns > 0) {
var allColumnSize = availableColumns * cellSize
var extraSpace = Math.max(containerSize - allColumnSize, FishUI.Units.largeSpacing)
extraSpacing = extraSpace / availableColumns
} }
return Math.floor(extraSpacing)
} }
} }
function calcExtraSpacing(cellSize, containerSize) { Loader {
var availableColumns = Math.floor(containerSize / cellSize) Layout.fillWidth: true
var extraSpacing = 0 height: item.height
if (availableColumns > 0) { visible: background.backgroundType === 1
var allColumnSize = availableColumns * cellSize sourceComponent: colorView
var extraSpace = Math.max(containerSize - allColumnSize, FishUI.Units.largeSpacing)
extraSpacing = extraSpace / availableColumns
}
return Math.floor(extraSpacing)
} }
} }
} }

@ -24,7 +24,6 @@
<file>qml/HorizontalDivider.qml</file> <file>qml/HorizontalDivider.qml</file>
<file>qml/DockPage.qml</file> <file>qml/DockPage.qml</file>
<file>qml/LanguagePage.qml</file> <file>qml/LanguagePage.qml</file>
<file>qml/NetworkPage.qml</file>
<file>images/locked.svg</file> <file>images/locked.svg</file>
<file>images/checked.svg</file> <file>images/checked.svg</file>
<file>images/light/network-wired.svg</file> <file>images/light/network-wired.svg</file>
@ -42,10 +41,7 @@
<file>images/view-refresh.svg</file> <file>images/view-refresh.svg</file>
<file>images/info.svg</file> <file>images/info.svg</file>
<file>qml/IconButton.qml</file> <file>qml/IconButton.qml</file>
<file>qml/WirelessItem.qml</file>
<file>images/go-previous.svg</file> <file>images/go-previous.svg</file>
<file>qml/WirelessDetailsDialog.qml</file>
<file>qml/WiredItem.qml</file>
<file>qml/AccountsPage.qml</file> <file>qml/AccountsPage.qml</file>
<file>qml/Hideable.qml</file> <file>qml/Hideable.qml</file>
<file>qml/AddUserDialog.qml</file> <file>qml/AddUserDialog.qml</file>
@ -85,5 +81,10 @@
<file>images/sidebar/light/language.svg</file> <file>images/sidebar/light/language.svg</file>
<file>images/sidebar/light/network.svg</file> <file>images/sidebar/light/network.svg</file>
<file>images/sidebar/light/wallpaper.svg</file> <file>images/sidebar/light/wallpaper.svg</file>
<file>qml/NetworkPage/WifiView.qml</file>
<file>qml/NetworkPage/main.qml</file>
<file>qml/NetworkPage/WifiItem.qml</file>
<file>qml/NetworkPage/WirelessDetailsDialog.qml</file>
<file>qml/NetworkPage/WiredItem.qml</file>
</qresource> </qresource>
</RCC> </RCC>

Loading…
Cancel
Save