controlcenter: merged wireless/ethernet panes
This commit is contained in:
parent
540cebdbbd
commit
6043adf666
2 changed files with 84 additions and 122 deletions
|
|
@ -158,13 +158,8 @@ Item {
|
||||||
|
|
||||||
NavItem {
|
NavItem {
|
||||||
Layout.topMargin: Appearance.spacing.large * 2
|
Layout.topMargin: Appearance.spacing.large * 2
|
||||||
icon: "cable"
|
icon: "router"
|
||||||
label: "ethernet"
|
label: "networking"
|
||||||
}
|
|
||||||
|
|
||||||
NavItem {
|
|
||||||
icon: "wifi"
|
|
||||||
label: "wireless"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NavItem {
|
NavItem {
|
||||||
|
|
@ -191,11 +186,6 @@ Item {
|
||||||
icon: "apps"
|
icon: "apps"
|
||||||
label: "launcher"
|
label: "launcher"
|
||||||
}
|
}
|
||||||
|
|
||||||
NavItem {
|
|
||||||
icon: "router"
|
|
||||||
label: "networking"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
component NavItem: Item {
|
component NavItem: Item {
|
||||||
|
|
|
||||||
|
|
@ -90,9 +90,9 @@ RowLayout {
|
||||||
} else {
|
} else {
|
||||||
// Toggle to show settings - prefer ethernet if available, otherwise wireless
|
// Toggle to show settings - prefer ethernet if available, otherwise wireless
|
||||||
if (Nmcli.ethernetDevices.length > 0) {
|
if (Nmcli.ethernetDevices.length > 0) {
|
||||||
root.session.ethernet.active = ethernetListView.model.get(0)?.modelData ?? null;
|
root.session.ethernet.active = Nmcli.ethernetDevices[0];
|
||||||
} else if (Nmcli.networks.length > 0) {
|
} else if (Nmcli.networks.length > 0) {
|
||||||
root.session.network.active = wirelessListView.model.get(0)?.modelData ?? null;
|
root.session.network.active = Nmcli.networks[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -127,29 +127,16 @@ RowLayout {
|
||||||
color: Colours.palette.m3outline
|
color: Colours.palette.m3outline
|
||||||
}
|
}
|
||||||
|
|
||||||
Item {
|
Repeater {
|
||||||
|
id: ethernetRepeater
|
||||||
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.preferredHeight: Nmcli.ethernetDevices.length > 0 ? Math.min(400, Math.max(200, Nmcli.ethernetDevices.length * 80)) : 200
|
|
||||||
|
|
||||||
StyledListView {
|
|
||||||
id: ethernetListView
|
|
||||||
|
|
||||||
anchors.fill: parent
|
|
||||||
|
|
||||||
model: Nmcli.ethernetDevices
|
model: Nmcli.ethernetDevices
|
||||||
|
|
||||||
spacing: Appearance.spacing.small / 2
|
delegate: StyledRect {
|
||||||
clip: true
|
|
||||||
|
|
||||||
StyledScrollBar.vertical: StyledScrollBar {
|
|
||||||
flickable: ethernetListView
|
|
||||||
}
|
|
||||||
|
|
||||||
delegate: StyledRect {
|
|
||||||
required property var modelData
|
required property var modelData
|
||||||
|
|
||||||
anchors.left: parent.left
|
Layout.fillWidth: true
|
||||||
anchors.right: parent.right
|
|
||||||
|
|
||||||
color: Qt.alpha(Colours.tPalette.m3surfaceContainer, root.session.ethernet.active === modelData ? Colours.tPalette.m3surfaceContainer.a : 0)
|
color: Qt.alpha(Colours.tPalette.m3surfaceContainer, root.session.ethernet.active === modelData ? Colours.tPalette.m3surfaceContainer.a : 0)
|
||||||
radius: Appearance.rounding.normal
|
radius: Appearance.rounding.normal
|
||||||
|
|
@ -233,7 +220,6 @@ RowLayout {
|
||||||
}
|
}
|
||||||
|
|
||||||
implicitHeight: rowLayout.implicitHeight + Appearance.padding.normal * 2
|
implicitHeight: rowLayout.implicitHeight + Appearance.padding.normal * 2
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -274,123 +260,109 @@ RowLayout {
|
||||||
color: Colours.palette.m3outline
|
color: Colours.palette.m3outline
|
||||||
}
|
}
|
||||||
|
|
||||||
Item {
|
Repeater {
|
||||||
|
id: wirelessRepeater
|
||||||
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.preferredHeight: Nmcli.networks.length > 0 ? Math.min(400, Math.max(200, Nmcli.networks.length * 80)) : 200
|
model: Nmcli.networks
|
||||||
|
|
||||||
StyledListView {
|
delegate: StyledRect {
|
||||||
id: wirelessListView
|
required property var modelData
|
||||||
|
|
||||||
anchors.fill: parent
|
Layout.fillWidth: true
|
||||||
|
|
||||||
model: Nmcli.networks
|
color: Qt.alpha(Colours.tPalette.m3surfaceContainer, root.session.network.active === modelData ? Colours.tPalette.m3surfaceContainer.a : 0)
|
||||||
|
radius: Appearance.rounding.normal
|
||||||
|
border.width: root.session.network.active === modelData ? 1 : 0
|
||||||
|
border.color: Colours.palette.m3primary
|
||||||
|
|
||||||
spacing: Appearance.spacing.small / 2
|
StateLayer {
|
||||||
clip: true
|
function onClicked(): void {
|
||||||
|
root.session.network.active = modelData;
|
||||||
StyledScrollBar.vertical: StyledScrollBar {
|
// Check if we need to refresh saved connections when selecting a network
|
||||||
flickable: wirelessListView
|
if (modelData && modelData.ssid) {
|
||||||
|
checkSavedProfileForNetwork(modelData.ssid);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
delegate: StyledRect {
|
RowLayout {
|
||||||
required property var modelData
|
id: wirelessRowLayout
|
||||||
|
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
anchors.margins: Appearance.padding.normal
|
||||||
|
|
||||||
color: Qt.alpha(Colours.tPalette.m3surfaceContainer, root.session.network.active === modelData ? Colours.tPalette.m3surfaceContainer.a : 0)
|
spacing: Appearance.spacing.normal
|
||||||
radius: Appearance.rounding.normal
|
|
||||||
border.width: root.session.network.active === modelData ? 1 : 0
|
|
||||||
border.color: Colours.palette.m3primary
|
|
||||||
|
|
||||||
StateLayer {
|
StyledRect {
|
||||||
function onClicked(): void {
|
implicitWidth: implicitHeight
|
||||||
root.session.network.active = modelData;
|
implicitHeight: wirelessIcon.implicitHeight + Appearance.padding.normal * 2
|
||||||
// Check if we need to refresh saved connections when selecting a network
|
|
||||||
if (modelData && modelData.ssid) {
|
radius: Appearance.rounding.normal
|
||||||
checkSavedProfileForNetwork(modelData.ssid);
|
color: modelData.active ? Colours.palette.m3primaryContainer : Colours.tPalette.m3surfaceContainerHigh
|
||||||
}
|
|
||||||
|
MaterialIcon {
|
||||||
|
id: wirelessIcon
|
||||||
|
|
||||||
|
anchors.centerIn: parent
|
||||||
|
text: modelData.isSecure ? "lock" : "wifi"
|
||||||
|
font.pointSize: Appearance.font.size.large
|
||||||
|
fill: modelData.active ? 1 : 0
|
||||||
|
color: modelData.active ? Colours.palette.m3onPrimaryContainer : Colours.palette.m3onSurface
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RowLayout {
|
StyledText {
|
||||||
id: wirelessRowLayout
|
Layout.fillWidth: true
|
||||||
|
elide: Text.ElideRight
|
||||||
|
maximumLineCount: 1
|
||||||
|
|
||||||
anchors.left: parent.left
|
text: modelData.ssid || qsTr("Unknown")
|
||||||
anchors.right: parent.right
|
}
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
|
||||||
anchors.margins: Appearance.padding.normal
|
|
||||||
|
|
||||||
spacing: Appearance.spacing.normal
|
StyledText {
|
||||||
|
text: modelData.active ? qsTr("Connected") : (modelData.isSecure ? qsTr("Secured") : qsTr("Open"))
|
||||||
|
color: modelData.active ? Colours.palette.m3primary : Colours.palette.m3outline
|
||||||
|
font.pointSize: Appearance.font.size.small
|
||||||
|
font.weight: modelData.active ? 500 : 400
|
||||||
|
}
|
||||||
|
|
||||||
StyledRect {
|
StyledText {
|
||||||
implicitWidth: implicitHeight
|
text: qsTr("%1%").arg(modelData.strength)
|
||||||
implicitHeight: wirelessIcon.implicitHeight + Appearance.padding.normal * 2
|
color: Colours.palette.m3outline
|
||||||
|
font.pointSize: Appearance.font.size.small
|
||||||
|
}
|
||||||
|
|
||||||
radius: Appearance.rounding.normal
|
StyledRect {
|
||||||
color: modelData.active ? Colours.palette.m3primaryContainer : Colours.tPalette.m3surfaceContainerHigh
|
implicitWidth: implicitHeight
|
||||||
|
implicitHeight: wirelessConnectIcon.implicitHeight + Appearance.padding.smaller * 2
|
||||||
|
|
||||||
MaterialIcon {
|
radius: Appearance.rounding.full
|
||||||
id: wirelessIcon
|
color: Qt.alpha(Colours.palette.m3primaryContainer, modelData.active ? 1 : 0)
|
||||||
|
|
||||||
anchors.centerIn: parent
|
StateLayer {
|
||||||
text: modelData.isSecure ? "lock" : "wifi"
|
function onClicked(): void {
|
||||||
font.pointSize: Appearance.font.size.large
|
if (modelData.active) {
|
||||||
fill: modelData.active ? 1 : 0
|
Nmcli.disconnectFromNetwork();
|
||||||
color: modelData.active ? Colours.palette.m3onPrimaryContainer : Colours.palette.m3onSurface
|
} else {
|
||||||
}
|
handleWirelessConnect(modelData);
|
||||||
}
|
|
||||||
|
|
||||||
StyledText {
|
|
||||||
Layout.fillWidth: true
|
|
||||||
elide: Text.ElideRight
|
|
||||||
maximumLineCount: 1
|
|
||||||
|
|
||||||
text: modelData.ssid || qsTr("Unknown")
|
|
||||||
}
|
|
||||||
|
|
||||||
StyledText {
|
|
||||||
text: modelData.active ? qsTr("Connected") : (modelData.isSecure ? qsTr("Secured") : qsTr("Open"))
|
|
||||||
color: modelData.active ? Colours.palette.m3primary : Colours.palette.m3outline
|
|
||||||
font.pointSize: Appearance.font.size.small
|
|
||||||
font.weight: modelData.active ? 500 : 400
|
|
||||||
}
|
|
||||||
|
|
||||||
StyledText {
|
|
||||||
text: qsTr("%1%").arg(modelData.strength)
|
|
||||||
color: Colours.palette.m3outline
|
|
||||||
font.pointSize: Appearance.font.size.small
|
|
||||||
}
|
|
||||||
|
|
||||||
StyledRect {
|
|
||||||
implicitWidth: implicitHeight
|
|
||||||
implicitHeight: wirelessConnectIcon.implicitHeight + Appearance.padding.smaller * 2
|
|
||||||
|
|
||||||
radius: Appearance.rounding.full
|
|
||||||
color: Qt.alpha(Colours.palette.m3primaryContainer, modelData.active ? 1 : 0)
|
|
||||||
|
|
||||||
StateLayer {
|
|
||||||
function onClicked(): void {
|
|
||||||
if (modelData.active) {
|
|
||||||
Nmcli.disconnectFromNetwork();
|
|
||||||
} else {
|
|
||||||
handleWirelessConnect(modelData);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
MaterialIcon {
|
MaterialIcon {
|
||||||
id: wirelessConnectIcon
|
id: wirelessConnectIcon
|
||||||
|
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
text: modelData.active ? "link_off" : "link"
|
text: modelData.active ? "link_off" : "link"
|
||||||
color: modelData.active ? Colours.palette.m3onPrimaryContainer : Colours.palette.m3onSurface
|
color: modelData.active ? Colours.palette.m3onPrimaryContainer : Colours.palette.m3onSurface
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
implicitHeight: wirelessRowLayout.implicitHeight + Appearance.padding.normal * 2
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
implicitHeight: wirelessRowLayout.implicitHeight + Appearance.padding.normal * 2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue