Compare commits
8
Commits
main
...
656bd0a54d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
656bd0a54d | ||
|
|
f01001dcfa | ||
|
|
bc6b0d50ab | ||
|
|
f27c9afc25 | ||
|
|
5962fc8354 | ||
|
|
1adcb9841c | ||
|
|
0e0f8555ed | ||
|
|
1d63e67554 |
@@ -15,3 +15,4 @@ dist/
|
|||||||
**/target/
|
**/target/
|
||||||
**/test-plugins/
|
**/test-plugins/
|
||||||
**/Charts/
|
**/Charts/
|
||||||
|
**/network-dev/
|
||||||
|
|||||||
@@ -40,10 +40,6 @@ JsonObject {
|
|||||||
id: "tray",
|
id: "tray",
|
||||||
enabled: true
|
enabled: true
|
||||||
},
|
},
|
||||||
{
|
|
||||||
id: "network",
|
|
||||||
enabled: false
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
id: "clock",
|
id: "clock",
|
||||||
enabled: true
|
enabled: true
|
||||||
|
|||||||
@@ -0,0 +1,125 @@
|
|||||||
|
pragma Singleton
|
||||||
|
|
||||||
|
import Quickshell
|
||||||
|
import Quickshell.Networking
|
||||||
|
import QtQuick
|
||||||
|
|
||||||
|
Singleton {
|
||||||
|
id: root
|
||||||
|
|
||||||
|
readonly property list<NetworkDevice> devices: Networking.devices.values
|
||||||
|
readonly property list<Network> networks: initialBuildNetworks()
|
||||||
|
property bool scanning: false
|
||||||
|
readonly property list<WifiDevice> wifiDevices: devices.filter(d => wifiDevice(d))
|
||||||
|
readonly property bool wifiEnabled: Networking.wifiEnabled
|
||||||
|
|
||||||
|
// Original code
|
||||||
|
|
||||||
|
readonly property list<NetworkDevice> netDevice: Networking.devices.values
|
||||||
|
readonly property string networkName: getNetworkName()
|
||||||
|
readonly property list<string> nicNames: networkInterfaceCardNames()
|
||||||
|
|
||||||
|
// Useless will prob remove
|
||||||
|
function getConnectedDevices() {
|
||||||
|
let connectedDevices = [];
|
||||||
|
|
||||||
|
for (var i = 0; i < netDevice.length; i++) {
|
||||||
|
if (netDevice[i].connected === true) {
|
||||||
|
connectedDevices.push(netDevice[i].name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return connectedDevices;
|
||||||
|
}
|
||||||
|
|
||||||
|
// SHOULD retrieve network names of connected devices
|
||||||
|
// Currently only gives connected nic name
|
||||||
|
function getNetworkName() {
|
||||||
|
const devices = netDevice.filter(device => device.connected === true);
|
||||||
|
for (var i = 0; i < devices.length; i++) {
|
||||||
|
return devices[i].name;
|
||||||
|
}
|
||||||
|
return "Failed network name";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Searches wired/wireless devices and sets them in a list
|
||||||
|
function networkInterfaceCardNames() {
|
||||||
|
let nicList = [];
|
||||||
|
|
||||||
|
for (let i = 0; i < netDevice.length; ++i) {
|
||||||
|
nicList.push(netDevice[i].name);
|
||||||
|
}
|
||||||
|
|
||||||
|
return nicList;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
|
||||||
|
function initialBuildNetworks(): void {
|
||||||
|
const init = [];
|
||||||
|
for (const d of wifiDevices) {
|
||||||
|
d.scannerEnabled = true;
|
||||||
|
init.push(...d.networks.values);
|
||||||
|
d.scannerEnabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
networks = init;
|
||||||
|
}
|
||||||
|
|
||||||
|
function isSecure(security): bool {
|
||||||
|
return !(security === WifiSecurityType.Open);
|
||||||
|
}
|
||||||
|
|
||||||
|
function rebuildNetworks(): void {
|
||||||
|
if (!scanning)
|
||||||
|
return;
|
||||||
|
|
||||||
|
const next = [];
|
||||||
|
for (const d of wifiDevices) {
|
||||||
|
next.push(...d.networks.values);
|
||||||
|
}
|
||||||
|
|
||||||
|
networks = next;
|
||||||
|
}
|
||||||
|
|
||||||
|
function rescanWifi(): void {
|
||||||
|
scanning = true;
|
||||||
|
setScan(true);
|
||||||
|
scanTimer.restart();
|
||||||
|
}
|
||||||
|
|
||||||
|
function setScan(value: bool): void {
|
||||||
|
for (const d of wifiDevices) {
|
||||||
|
d.scannerEnabled = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function setWifi(value: bool): void {
|
||||||
|
Networking.wifiEnabled = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
function wifiDevice(dev): bool {
|
||||||
|
return dev.type === DeviceType.Wifi;
|
||||||
|
}
|
||||||
|
|
||||||
|
Timer {
|
||||||
|
id: scanTimer
|
||||||
|
|
||||||
|
interval: 5000
|
||||||
|
repeat: false
|
||||||
|
|
||||||
|
onTriggered: {
|
||||||
|
root.rebuildNetworks();
|
||||||
|
root.setScan(false);
|
||||||
|
root.scanning = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Timer {
|
||||||
|
interval: 500
|
||||||
|
repeat: true
|
||||||
|
running: root.scanning
|
||||||
|
|
||||||
|
onTriggered: {
|
||||||
|
root.rebuildNetworks();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,7 +9,6 @@ import qs.Config
|
|||||||
import qs.Helpers
|
import qs.Helpers
|
||||||
import qs.Modules.SysTray
|
import qs.Modules.SysTray
|
||||||
import qs.Modules.SysTray.Widgets
|
import qs.Modules.SysTray.Widgets
|
||||||
import qs.Modules.Network
|
|
||||||
import qs.Modules.Updates
|
import qs.Modules.Updates
|
||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
@@ -185,15 +184,6 @@ RowLayout {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DelegateChoice {
|
|
||||||
roleValue: "network"
|
|
||||||
|
|
||||||
delegate: WrappedLoader {
|
|
||||||
sourceComponent: NetworkWidget {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
DelegateChoice {
|
DelegateChoice {
|
||||||
roleValue: "media"
|
roleValue: "media"
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import qs.Config
|
|||||||
import qs.Helpers
|
import qs.Helpers
|
||||||
import qs.Modules.SysTray
|
import qs.Modules.SysTray
|
||||||
import qs.Modules.SysTray.Widgets
|
import qs.Modules.SysTray.Widgets
|
||||||
import qs.Modules.Network
|
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: root
|
id: root
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import QtQuick
|
|||||||
import qs.Config
|
import qs.Config
|
||||||
import qs.Components
|
import qs.Components
|
||||||
import qs.Modules.WSOverview
|
import qs.Modules.WSOverview
|
||||||
import qs.Modules.Network
|
|
||||||
import qs.Modules.SysTray.Popouts
|
import qs.Modules.SysTray.Popouts
|
||||||
import qs.Modules.Updates
|
import qs.Modules.Updates
|
||||||
|
|
||||||
|
|||||||
@@ -1,36 +0,0 @@
|
|||||||
pragma ComponentBehavior: Bound
|
|
||||||
|
|
||||||
import Quickshell
|
|
||||||
import Quickshell.Networking
|
|
||||||
import QtQuick
|
|
||||||
import QtQuick.Layouts
|
|
||||||
import qs.Components
|
|
||||||
import qs.Config
|
|
||||||
import qs.Modules
|
|
||||||
import qs.Helpers as Helpers
|
|
||||||
|
|
||||||
Item {
|
|
||||||
id: root
|
|
||||||
|
|
||||||
required property var wrapper
|
|
||||||
|
|
||||||
ColumnLayout {
|
|
||||||
id: layout
|
|
||||||
|
|
||||||
spacing: 8
|
|
||||||
|
|
||||||
Repeater {
|
|
||||||
model: Helpers.Network.devices
|
|
||||||
|
|
||||||
CustomRadioButton {
|
|
||||||
id: network
|
|
||||||
|
|
||||||
required property NetworkDevice modelData
|
|
||||||
|
|
||||||
checked: Helpers.Network.activeDevice?.name === modelData.name
|
|
||||||
text: modelData.description
|
|
||||||
visible: modelData.name !== "lo"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
import Quickshell
|
|
||||||
import QtQuick
|
|
||||||
import QtQuick.Layouts
|
|
||||||
import qs.Components
|
|
||||||
import qs.Modules
|
|
||||||
|
|
||||||
Item {
|
|
||||||
id: root
|
|
||||||
|
|
||||||
anchors.bottom: parent.bottom
|
|
||||||
anchors.top: parent.top
|
|
||||||
implicitWidth: layout.implicitWidth
|
|
||||||
|
|
||||||
RowLayout {
|
|
||||||
id: layout
|
|
||||||
|
|
||||||
anchors.bottom: parent.bottom
|
|
||||||
anchors.top: parent.top
|
|
||||||
|
|
||||||
MaterialIcon {
|
|
||||||
Layout.alignment: Qt.AlignVCenter
|
|
||||||
text: "android_wifi_4_bar"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,219 @@
|
|||||||
|
pragma ComponentBehavior: Bound
|
||||||
|
|
||||||
|
import QtQuick
|
||||||
|
import QtQuick.Layouts
|
||||||
|
import Quickshell
|
||||||
|
import qs.Components
|
||||||
|
import qs.Config
|
||||||
|
import qs.Helpers
|
||||||
|
|
||||||
|
CustomClippingRect {
|
||||||
|
id: root
|
||||||
|
|
||||||
|
required property var wrapper
|
||||||
|
|
||||||
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
color: DynamicColors.tPalette.m3surfaceContainer
|
||||||
|
implicitHeight: networkPopContent.height + networks.implicitHeight + networkPopContent.anchors.margins + networks.anchors.margins * 2
|
||||||
|
implicitWidth: 500 + 8 * 2
|
||||||
|
radius: (20 - Appearance.padding.small) * Appearance.rounding.scale
|
||||||
|
|
||||||
|
ColumnLayout {
|
||||||
|
id: networkPopContent
|
||||||
|
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.margins: Appearance.padding.large
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.top: parent.top
|
||||||
|
|
||||||
|
CustomText {
|
||||||
|
Layout.preferredHeight: visible ? implicitHeight : 0
|
||||||
|
Layout.rightMargin: Appearance.padding.extraSmall
|
||||||
|
font.pointSize: Appearance.font.size.large
|
||||||
|
text: qsTr("Network")
|
||||||
|
}
|
||||||
|
|
||||||
|
Toggle {
|
||||||
|
Layout.preferredHeight: visible ? implicitHeight : 0
|
||||||
|
checked: Network.wifiEnabled
|
||||||
|
label: qsTr("WiFi enabled")
|
||||||
|
|
||||||
|
toggle.onToggled: Network.setWifi(checked)
|
||||||
|
}
|
||||||
|
|
||||||
|
CustomText {
|
||||||
|
Layout.preferredHeight: visible ? implicitHeight : 0
|
||||||
|
Layout.rightMargin: Appearance.padding.extraSmall
|
||||||
|
Layout.topMargin: visible ? Appearance.spacing.small : 0
|
||||||
|
color: DynamicColors.palette.m3onSurfaceVariant
|
||||||
|
text: qsTr("%1 networks available").arg(Network.networks.length) // qmllint disable missing-property
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ColumnLayout {
|
||||||
|
id: networks
|
||||||
|
|
||||||
|
anchors.bottom: parent.bottom
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.margins: Appearance.padding.large
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.top: networkPopContent.bottom
|
||||||
|
|
||||||
|
Repeater {
|
||||||
|
model: ScriptModel {
|
||||||
|
values: [...Network.networks]
|
||||||
|
}
|
||||||
|
|
||||||
|
RowLayout {
|
||||||
|
id: networkItem
|
||||||
|
|
||||||
|
required property var modelData
|
||||||
|
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.preferredHeight: visible ? implicitHeight : 0
|
||||||
|
Layout.rightMargin: Appearance.padding.extraSmall
|
||||||
|
opacity: 0
|
||||||
|
scale: 0.7
|
||||||
|
spacing: Appearance.spacing.small
|
||||||
|
|
||||||
|
Behavior on opacity {
|
||||||
|
Anim {
|
||||||
|
type: Anim.DefaultEffects
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Behavior on scale {
|
||||||
|
Anim {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
opacity = 1;
|
||||||
|
scale = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
MaterialIcon {
|
||||||
|
color: networkItem.modelData.active ? DynamicColors.palette.m3primary : DynamicColors.palette.m3onSurfaceVariant
|
||||||
|
text: Icons.getNetworkIcon(networkItem.modelData.signalStrength * 100, Network.isSecure(networkItem.modelData.security))
|
||||||
|
}
|
||||||
|
|
||||||
|
CustomText {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.leftMargin: Appearance.spacing.extraSmall
|
||||||
|
Layout.rightMargin: Appearance.spacing.extraSmall
|
||||||
|
color: networkItem.modelData.active ? DynamicColors.palette.m3primary : DynamicColors.palette.m3onSurface
|
||||||
|
elide: Text.ElideRight
|
||||||
|
text: networkItem.modelData.name
|
||||||
|
}
|
||||||
|
|
||||||
|
CustomRect {
|
||||||
|
color: Qt.alpha(DynamicColors.palette.m3primary, networkItem.modelData.active ? 1 : 0)
|
||||||
|
implicitHeight: wirelessConnectIcon.implicitHeight + Appearance.padding.extraSmall
|
||||||
|
implicitWidth: implicitHeight
|
||||||
|
radius: Appearance.rounding.full
|
||||||
|
|
||||||
|
// CircularIndicator {
|
||||||
|
// anchors.fill: parent
|
||||||
|
// running: networkItem.loading
|
||||||
|
// }
|
||||||
|
|
||||||
|
StateLayer {
|
||||||
|
color: networkItem.modelData.active ? DynamicColors.palette.m3onPrimary : DynamicColors.palette.m3onSurface
|
||||||
|
|
||||||
|
onClicked: {
|
||||||
|
console.log(Network.devices[1].scannerEnabled, Network.devices[2].scannerEnabled, Network.devices[3].scannerEnabled, Network.devices[4].scannerEnabled);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MaterialIcon {
|
||||||
|
id: wirelessConnectIcon
|
||||||
|
|
||||||
|
anchors.centerIn: parent
|
||||||
|
animate: true
|
||||||
|
color: networkItem.modelData.active ? DynamicColors.palette.m3onPrimary : DynamicColors.palette.m3onSurface
|
||||||
|
text: networkItem.modelData.active ? "link_off" : "link"
|
||||||
|
|
||||||
|
// opacity: networkItem.loading ? 0 : 1
|
||||||
|
|
||||||
|
Behavior on opacity {
|
||||||
|
Anim {
|
||||||
|
type: Anim.DefaultEffects
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CustomRect {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.preferredHeight: visible ? implicitHeight : 0
|
||||||
|
Layout.topMargin: visible ? Appearance.spacing.small : 0
|
||||||
|
color: DynamicColors.palette.m3primaryContainer
|
||||||
|
implicitHeight: rescanBtn.implicitHeight + Appearance.padding.small
|
||||||
|
radius: Appearance.rounding.full
|
||||||
|
|
||||||
|
StateLayer {
|
||||||
|
color: DynamicColors.palette.m3onPrimaryContainer
|
||||||
|
enabled: !Network.scanning
|
||||||
|
|
||||||
|
onClicked: Network.rescanWifi()
|
||||||
|
}
|
||||||
|
|
||||||
|
RowLayout {
|
||||||
|
id: rescanBtn
|
||||||
|
|
||||||
|
anchors.centerIn: parent
|
||||||
|
opacity: Network.scanning ? 0 : 1
|
||||||
|
spacing: Appearance.spacing.small
|
||||||
|
|
||||||
|
Behavior on opacity {
|
||||||
|
Anim {
|
||||||
|
type: Anim.DefaultEffects
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MaterialIcon {
|
||||||
|
id: scanIcon
|
||||||
|
|
||||||
|
Layout.topMargin: Math.round(fontInfo.pointSize * 0.0575)
|
||||||
|
animate: true
|
||||||
|
color: DynamicColors.palette.m3onPrimaryContainer
|
||||||
|
text: "wifi_find"
|
||||||
|
}
|
||||||
|
|
||||||
|
CustomText {
|
||||||
|
Layout.topMargin: -Math.round(scanIcon.fontInfo.pointSize * 0.0575)
|
||||||
|
color: DynamicColors.palette.m3onPrimaryContainer
|
||||||
|
text: qsTr("Rescan networks")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CircularIndicator {
|
||||||
|
anchors.centerIn: parent
|
||||||
|
bgColor: "transparent"
|
||||||
|
implicitSize: parent.implicitHeight - Appearance.padding.large
|
||||||
|
running: Network.scanning
|
||||||
|
strokeWidth: Appearance.padding.extraSmall / 2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
component Toggle: RowLayout {
|
||||||
|
property alias checked: toggle.checked
|
||||||
|
required property string label
|
||||||
|
property alias toggle: toggle
|
||||||
|
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.rightMargin: Appearance.padding.extraSmall
|
||||||
|
spacing: Appearance.spacing.small
|
||||||
|
|
||||||
|
CustomText {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
text: parent.label
|
||||||
|
}
|
||||||
|
|
||||||
|
CustomSwitch {
|
||||||
|
id: toggle
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -52,6 +52,11 @@ RowLayout {
|
|||||||
id: "audio",
|
id: "audio",
|
||||||
item: child
|
item: child
|
||||||
};
|
};
|
||||||
|
if (child.objectName === "networkWidget" && Config.bar.popouts.network)
|
||||||
|
return {
|
||||||
|
id: "network",
|
||||||
|
item: child
|
||||||
|
};
|
||||||
if (child.objectName === "upowerWidget" && Config.bar.popouts.upower)
|
if (child.objectName === "upowerWidget" && Config.bar.popouts.upower)
|
||||||
return {
|
return {
|
||||||
id: "upower",
|
id: "upower",
|
||||||
@@ -146,6 +151,10 @@ RowLayout {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NetworkWidget {
|
||||||
|
objectName: "networkWidget"
|
||||||
|
}
|
||||||
|
|
||||||
UPowerWidget {
|
UPowerWidget {
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
objectName: "upowerWidget"
|
objectName: "upowerWidget"
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
import QtQuick
|
||||||
|
import QtQuick.Layouts
|
||||||
|
import Quickshell.Io
|
||||||
|
import Quickshell.Services.Pipewire
|
||||||
|
import qs.Daemons
|
||||||
|
import qs.Modules
|
||||||
|
import qs.Config
|
||||||
|
import qs.Components
|
||||||
|
|
||||||
|
RowLayout {
|
||||||
|
id: root
|
||||||
|
|
||||||
|
// property color barColor: DynamicColors.palette.m3primary
|
||||||
|
property color textColor: DynamicColors.palette.m3onSurface
|
||||||
|
|
||||||
|
MaterialIcon {
|
||||||
|
Layout.alignment: Qt.AlignVCenter
|
||||||
|
animate: true
|
||||||
|
color: root.textColor // Network.connected ? root.textColor : DynamicColors.palette.m3error
|
||||||
|
fill: 1
|
||||||
|
font.pointSize: Appearance.font.size.larger
|
||||||
|
text: "android_wifi_4_bar"
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user