Added network properties, nicNames, netDevices, networkName < reminder I should use layouts.
This commit is contained in:
+36
-1
@@ -6,5 +6,40 @@ import Quickshell.Networking
|
|||||||
Singleton {
|
Singleton {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
readonly property list<NetworkDevice> network: Networking.devices.values
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,8 @@
|
|||||||
pragma ComponentBehavior: Bound
|
pragma ComponentBehavior: Bound
|
||||||
|
|
||||||
import Quickshell
|
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import QtQuick.Layouts
|
|
||||||
import qs.Components
|
import qs.Components
|
||||||
import qs.Config
|
import qs.Config
|
||||||
import qs.Modules
|
|
||||||
import qs.Helpers
|
import qs.Helpers
|
||||||
|
|
||||||
CustomClippingRect {
|
CustomClippingRect {
|
||||||
@@ -33,11 +30,21 @@ CustomClippingRect {
|
|||||||
text: qsTr("Network")
|
text: qsTr("Network")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CustomText {
|
||||||
|
anchors.margins: Appearance.padding.large
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.top: parent.top
|
||||||
|
font.pointSize: Appearance.font.size.large
|
||||||
|
text: Network.networkName
|
||||||
|
}
|
||||||
|
|
||||||
StateLayer {
|
StateLayer {
|
||||||
id: buttonScan
|
id: buttonScan
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
console.log(Network.network.length);
|
console.log("Network devices: " + Network.netDevice);
|
||||||
|
console.log("Network interface names: " + Network.nicNames);
|
||||||
|
console.log("Connected devices: " + Network.networkName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user