qs: ethernet
This commit is contained in:
parent
b3e9b4e6be
commit
2192caf8ad
5 changed files with 115 additions and 58 deletions
|
|
@ -82,13 +82,6 @@ ClickableIcon {
|
|||
|
||||
Item { Layout.fillWidth: true }
|
||||
|
||||
ClickableIcon {
|
||||
image: root.adapter.enabled ? "root:/icons/bluetooth-slash.svg" : "root:/icons/bluetooth.svg"
|
||||
implicitHeight: 24
|
||||
implicitWidth: height
|
||||
onClicked: root.adapter.enabled = !root.adapter.enabled
|
||||
}
|
||||
|
||||
ActivityButton {
|
||||
image: "root:/icons/binoculars.svg"
|
||||
implicitHeight: 24
|
||||
|
|
|
|||
|
|
@ -11,9 +11,29 @@ import qs.bar
|
|||
ClickableIcon {
|
||||
id: root
|
||||
required property var bar;
|
||||
readonly property WifiDevice adapter: Networking.devices.values[0] ?? null
|
||||
readonly property WifiDevice adapter: Networking.devices.values.find(d => d.type === DeviceType.Wifi)
|
||||
readonly property WiredDevice eth: Networking.devices.values.find(d => d.type === DeviceType.Wired)
|
||||
readonly property bool connected: adapter.connected
|
||||
readonly property WifiNetwork activeNetwork: adapter.networks.values.find(network => network.connected)
|
||||
readonly property string wifiIcon: {
|
||||
if (root.adapter) {
|
||||
if (!Networking.wifiEnabled) return "root:/icons/wifi-slash.svg";
|
||||
if (!root.adapter.connected) return "root:/icons/wifi-x.svg";
|
||||
return `root:/icons/wifi-${Math.round(root.activeNetwork.signalStrength * 3)}.svg`
|
||||
}
|
||||
|
||||
return "root:/icons/wifi-x.svg";
|
||||
}
|
||||
|
||||
readonly property string ethIcon: {
|
||||
if (root.eth) {
|
||||
if (!root.eth.network) return "root:/icons/ethernet-x.svg";
|
||||
else if (!root.eth.network.connected) return "root:/icons/ethernet-slash.svg";
|
||||
else return "root:/icons/ethernet.svg";
|
||||
}
|
||||
|
||||
return "root:/icons/ethernet-x.svg";
|
||||
}
|
||||
|
||||
property bool showMenu: false
|
||||
|
||||
|
|
@ -35,9 +55,17 @@ ClickableIcon {
|
|||
implicitHeight: width
|
||||
fillWindowWidth: true
|
||||
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
||||
image: Networking.wifiEnabled
|
||||
? (connected ? `root:/icons/wifi-${Math.round(root.activeNetwork.signalStrength * 3)}.svg` : "root:/icons/wifi-x.svg")
|
||||
: "root:/icons/wifi-slash.svg"
|
||||
image: {
|
||||
if (root.eth?.network && root.eth.network.connected) {
|
||||
return "root:/icons/ethernet.svg";
|
||||
} else if (Networking.wifiEnabled) {
|
||||
return root.wifiIcon;
|
||||
} else if (root.eth?.network) {
|
||||
return "root:/icons/ethernet-slash.svg";
|
||||
} else {
|
||||
return "root:/icons/ethernet-x.svg";
|
||||
}
|
||||
}
|
||||
|
||||
property var tooltip: TooltipItem {
|
||||
tooltip: bar.tooltip
|
||||
|
|
@ -67,64 +95,97 @@ ClickableIcon {
|
|||
SmoothedAnimation { property: "y"; velocity: 350 }
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
Loader {
|
||||
width: parent.width
|
||||
active: root.eth != null
|
||||
visible: active
|
||||
sourceComponent: ColumnLayout {
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
|
||||
ClickableIcon {
|
||||
image: root.image
|
||||
implicitHeight: 40
|
||||
implicitWidth: height
|
||||
onClicked: root.adapter.enabled = !root.adapter.enabled
|
||||
}
|
||||
ClickableIcon {
|
||||
image: root.ethIcon
|
||||
implicitHeight: 40
|
||||
implicitWidth: height
|
||||
onClicked: {
|
||||
const n = root.eth.network;
|
||||
if (n.connected) n.disconnect();
|
||||
else n.connect();
|
||||
}
|
||||
}
|
||||
|
||||
Label {
|
||||
text: `Wifi (${root.adapter.name})`
|
||||
}
|
||||
Label {
|
||||
text: `Ethernet (${root.eth?.name ?? ""})`
|
||||
}
|
||||
}
|
||||
|
||||
Item { Layout.fillWidth: true }
|
||||
|
||||
ClickableIcon {
|
||||
image: Networking.wifiEnabled ? "root:/icons/wifi-slash.svg" : "root:/icons/wifi-x.svg"
|
||||
implicitHeight: 24
|
||||
implicitWidth: height
|
||||
onClicked: Networking.wifiEnabled = !Networking.wifiEnabled
|
||||
}
|
||||
|
||||
ActivityButton {
|
||||
image: "root:/icons/binoculars.svg"
|
||||
implicitHeight: 24
|
||||
implicitWidth: height
|
||||
onClicked: root.adapter.scannerEnabled = !root.adapter.scannerEnabled
|
||||
showAction: root.adapter.scannerEnabled
|
||||
Layout.rightMargin: 4
|
||||
Rectangle {
|
||||
Layout.fillWidth: true
|
||||
implicitHeight: 1
|
||||
color: ShellGlobals.colors.separator
|
||||
visible: root.adapter != null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
Loader {
|
||||
width: parent.width
|
||||
implicitHeight: 1
|
||||
visible: root.adapter.networks.values.length > 0
|
||||
active: root.adapter != null
|
||||
visible: active
|
||||
sourceComponent: ColumnLayout {
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
ClickableIcon {
|
||||
image: root.wifiIcon
|
||||
implicitHeight: 40
|
||||
implicitWidth: height
|
||||
onClicked: Networking.wifiEnabled = !Networking.wifiEnabled
|
||||
}
|
||||
|
||||
color: ShellGlobals.colors.separator
|
||||
}
|
||||
Label {
|
||||
text: `Wifi (${root.adapter.name})`
|
||||
}
|
||||
|
||||
Repeater {
|
||||
model: ScriptModel {
|
||||
values: [...root.adapter.networks.values].sort((a, b) => {
|
||||
if (a.connected && !b.connected) return -1;
|
||||
if (b.connected && !a.connected) return 1;
|
||||
if (a.bonded && !b.bonded) return -1;
|
||||
if (b.bonded && !a.bonded) return 1;
|
||||
return b.name - a.name;
|
||||
})
|
||||
}
|
||||
Item { Layout.fillWidth: true }
|
||||
|
||||
delegate: NetworkDelegate {
|
||||
required property var modelData
|
||||
device: root.adapter
|
||||
network: modelData
|
||||
width: parent.width
|
||||
onConnectionAttempted: root.adapter.scannerEnabled = false
|
||||
ActivityButton {
|
||||
image: "root:/icons/binoculars.svg"
|
||||
implicitHeight: 24
|
||||
implicitWidth: height
|
||||
onClicked: root.adapter.scannerEnabled = !root.adapter.scannerEnabled
|
||||
showAction: root.adapter.scannerEnabled
|
||||
Layout.rightMargin: 4
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
Layout.fillWidth: parent
|
||||
implicitHeight: 1
|
||||
visible: root.adapter.networks.values.length > 0
|
||||
|
||||
color: ShellGlobals.colors.separator
|
||||
}
|
||||
|
||||
Repeater {
|
||||
model: ScriptModel {
|
||||
values: [...root.adapter.networks.values].sort((a, b) => {
|
||||
if (a.connected && !b.connected) return -1;
|
||||
if (b.connected && !a.connected) return 1;
|
||||
if (a.bonded && !b.bonded) return -1;
|
||||
if (b.bonded && !a.bonded) return 1;
|
||||
return b.name - a.name;
|
||||
})
|
||||
}
|
||||
|
||||
delegate: NetworkDelegate {
|
||||
required property var modelData
|
||||
Layout.fillWidth: parent
|
||||
device: root.adapter
|
||||
network: modelData
|
||||
width: parent.width
|
||||
onConnectionAttempted: root.adapter.scannerEnabled = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" fill="#f0f0f0" viewBox="0 0 256 256"><path d="M96,54V40a16,16,0,0,1,16-16h32a16,16,0,0,1,16,16V72a16,16,0,0,1-16,16H127.61a8,8,0,0,1,0-16H144V40H112V54a8,8,0,0,1-16,0ZM213.92,210.62a8,8,0,1,1-11.84,10.76L117.19,128H72v32h8a16,16,0,0,1,16,16v32a16,16,0,0,1-16,16H48a16,16,0,0,1-16-16V176a16,16,0,0,1,16-16h8V128H24a8,8,0,0,1,0-16h78.64L42.08,45.38A8,8,0,1,1,53.92,34.62ZM80,176H48v32H80Zm152-64H164a8,8,0,0,0,0,16h20v22.83a8,8,0,1,0,16,0V128h32a8,8,0,0,0,0-16Z"></path></svg>
|
||||
|
After Width: | Height: | Size: 538 B |
|
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" fill="#f0f0f0" viewBox="0 0 256 256"><path d="M232,112H136V88h8a16,16,0,0,0,16-16V40a16,16,0,0,0-16-16H112A16,16,0,0,0,96,40V72a16,16,0,0,0,16,16h8v24H24a8,8,0,0,0,0,16H56v32H48a16,16,0,0,0-16,16v32a16,16,0,0,0,16,16H80a16,16,0,0,0,16-16V176a16,16,0,0,0-16-16H72V128H184v16a8,8,0,0,0,16,0V128h32a8,8,0,0,0,0-16ZM112,40h32V72H112ZM80,208H48V176H80Zm141.65-34.34L203.31,192l18.35,18.34a8,8,0,0,1-11.32,11.32L192,203.31l-18.34,18.35a8,8,0,0,1-11.32-11.32L180.69,192l-18.35-18.34a8,8,0,0,1,11.32-11.32L192,180.69l18.34-18.35a8,8,0,0,1,11.32,11.32Z"></path></svg>
|
||||
|
After Width: | Height: | Size: 622 B |
1
modules/user/modules/quickshell/shell/icons/ethernet.svg
Normal file
1
modules/user/modules/quickshell/shell/icons/ethernet.svg
Normal file
|
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" fill="#f0f0f0" viewBox="0 0 256 256"><path d="M232,112H136V88h8a16,16,0,0,0,16-16V40a16,16,0,0,0-16-16H112A16,16,0,0,0,96,40V72a16,16,0,0,0,16,16h8v24H24a8,8,0,0,0,0,16H56v32H48a16,16,0,0,0-16,16v32a16,16,0,0,0,16,16H80a16,16,0,0,0,16-16V176a16,16,0,0,0-16-16H72V128H184v32h-8a16,16,0,0,0-16,16v32a16,16,0,0,0,16,16h32a16,16,0,0,0,16-16V176a16,16,0,0,0-16-16h-8V128h32a8,8,0,0,0,0-16ZM112,40h32V72H112ZM80,208H48V176H80Zm128,0H176V176h32Z"></path></svg>
|
||||
|
After Width: | Height: | Size: 517 B |
Loading…
Add table
Add a link
Reference in a new issue