move functions to service 2/3

This commit is contained in:
Turann_
2026-03-15 06:45:41 +03:00
parent 7d4b22059d
commit bd61583482
2 changed files with 4 additions and 85 deletions
+2 -42
View File
@@ -41,46 +41,6 @@ Item {
implicitWidth: pill.width
implicitHeight: pill.height
function getStatustxt() {
if (NetworkService.connecting) {
return NetworkService.connectingTo ? I18n.tr("common.connecting") + " " + NetworkService.connectingTo : I18n.tr("common.connecting");
}
let p = [];
// Ethernet
if (NetworkService.ethernetConnected) {
const eth = NetworkService.activeEthernetDetails;
const name = eth.connectionName || (NetworkService.ethernetInterfaces.length > 0 ? NetworkService.ethernetInterfaces[0].connectionName : "") || NetworkService.activeEthernetIf || "";
const speed = eth.speed || "";
const s = name ? (speed ? name + " - " + speed : name) : "";
if (s) {
p.push(s);
}
}
// Wi-Fi
if (NetworkService.activeWifiIf) {
const wl = NetworkService.activeWifiDetails;
const speed = wl.rateShort || wl.rate || "";
const connectedNet = Object.values(NetworkService.networks).find(net => net.connected);
const name = connectedNet ? connectedNet.ssid : (wl.connectionName || NetworkService.activeWifiIf || "");
const s = name ? (speed ? name + " - " + speed : name) : "";
if (s) {
p.push(s);
}
}
return p.join(isBarVertical ? "\n" : " + ");
}
function getIcon() {
if (NetworkService.ethernetConnected) {
return NetworkService.internetConnectivity ? "ethernet" : "ethernet-off";
}
const connectedNet = Object.values(NetworkService.networks).find(net => net.connected);
return connectedNet ? NetworkService.getSignalInfo(connectedNet.signal, true).icon : "wifi-off";
}
NPopupContextMenu {
id: contextMenu
@@ -123,8 +83,8 @@ Item {
oppositeDirection: BarService.getPillDirection(root)
customIconColor: Color.resolveColorKeyOptional(root.iconColorKey)
customTextColor: Color.resolveColorKeyOptional(root.textColorKey)
icon: getIcon()
text: getStatustxt()
icon: NetworkService.getIcon()
text: NetworkService.getStatustxt()
autoHide: false
forceOpen: !isBarVertical && root.displayMode === "alwaysShow"
forceClose: isBarVertical || root.displayMode === "alwaysHide" || text === ""
@@ -7,49 +7,8 @@ import qs.Widgets
NIconButtonHot {
property ShellScreen screen
function getStatustxt() {
if (NetworkService.connecting) {
return NetworkService.connectingTo ? I18n.tr("common.connecting") + " " + NetworkService.connectingTo : I18n.tr("common.connecting");
}
let p = [];
// Ethernet
if (NetworkService.ethernetConnected) {
const eth = NetworkService.activeEthernetDetails;
const name = eth.connectionName || (NetworkService.ethernetInterfaces.length > 0 ? NetworkService.ethernetInterfaces[0].connectionName : "") || NetworkService.activeEthernetIf || "";
const speed = eth.speed || "";
const s = name ? (speed ? name + " - " + speed : name) : "";
if (s) {
p.push(s);
}
}
// Wi-Fi
if (NetworkService.activeWifiIf) {
const wl = NetworkService.activeWifiDetails;
const speed = wl.rateShort || wl.rate || "";
const connectedNet = Object.values(NetworkService.networks).find(net => net.connected);
const name = connectedNet ? connectedNet.ssid : (wl.connectionName || NetworkService.activeWifiIf || "");
const s = name ? (speed ? name + " - " + speed : name) : "";
if (s) {
p.push(s);
}
}
return p.join(" + ");
}
function getIcon() {
if (NetworkService.ethernetConnected) {
return NetworkService.internetConnectivity ? "wired" : "wired-off";
}
const connectedNet = Object.values(NetworkService.networks).find(net => net.connected);
return connectedNet ? NetworkService.getSignalInfo(connectedNet.signal, true).icon : "wifi-off";
}
icon: getIcon()
tooltipText: getStatustxt()
icon: NetworkService.getIcon()
tooltipText: NetworkService.getStatustxt()
onClicked: {
var panel = PanelService.getPanel("networkPanel", screen);
panel?.toggle(this);