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 }
|
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 {
|
ActivityButton {
|
||||||
image: "root:/icons/binoculars.svg"
|
image: "root:/icons/binoculars.svg"
|
||||||
implicitHeight: 24
|
implicitHeight: 24
|
||||||
|
|
|
||||||
|
|
@ -11,9 +11,29 @@ import qs.bar
|
||||||
ClickableIcon {
|
ClickableIcon {
|
||||||
id: root
|
id: root
|
||||||
required property var bar;
|
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 bool connected: adapter.connected
|
||||||
readonly property WifiNetwork activeNetwork: adapter.networks.values.find(network => network.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
|
property bool showMenu: false
|
||||||
|
|
||||||
|
|
@ -35,9 +55,17 @@ ClickableIcon {
|
||||||
implicitHeight: width
|
implicitHeight: width
|
||||||
fillWindowWidth: true
|
fillWindowWidth: true
|
||||||
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
||||||
image: Networking.wifiEnabled
|
image: {
|
||||||
? (connected ? `root:/icons/wifi-${Math.round(root.activeNetwork.signalStrength * 3)}.svg` : "root:/icons/wifi-x.svg")
|
if (root.eth?.network && root.eth.network.connected) {
|
||||||
: "root:/icons/wifi-slash.svg"
|
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 {
|
property var tooltip: TooltipItem {
|
||||||
tooltip: bar.tooltip
|
tooltip: bar.tooltip
|
||||||
|
|
@ -67,14 +95,51 @@ ClickableIcon {
|
||||||
SmoothedAnimation { property: "y"; velocity: 350 }
|
SmoothedAnimation { property: "y"; velocity: 350 }
|
||||||
}
|
}
|
||||||
|
|
||||||
RowLayout {
|
Loader {
|
||||||
width: parent.width
|
width: parent.width
|
||||||
|
active: root.eth != null
|
||||||
|
visible: active
|
||||||
|
sourceComponent: ColumnLayout {
|
||||||
|
RowLayout {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
|
||||||
ClickableIcon {
|
ClickableIcon {
|
||||||
image: root.image
|
image: root.ethIcon
|
||||||
implicitHeight: 40
|
implicitHeight: 40
|
||||||
implicitWidth: height
|
implicitWidth: height
|
||||||
onClicked: root.adapter.enabled = !root.adapter.enabled
|
onClicked: {
|
||||||
|
const n = root.eth.network;
|
||||||
|
if (n.connected) n.disconnect();
|
||||||
|
else n.connect();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Label {
|
||||||
|
text: `Ethernet (${root.eth?.name ?? ""})`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
implicitHeight: 1
|
||||||
|
color: ShellGlobals.colors.separator
|
||||||
|
visible: root.adapter != null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Loader {
|
||||||
|
width: parent.width
|
||||||
|
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
|
||||||
}
|
}
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
|
|
@ -83,13 +148,6 @@ ClickableIcon {
|
||||||
|
|
||||||
Item { Layout.fillWidth: true }
|
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 {
|
ActivityButton {
|
||||||
image: "root:/icons/binoculars.svg"
|
image: "root:/icons/binoculars.svg"
|
||||||
implicitHeight: 24
|
implicitHeight: 24
|
||||||
|
|
@ -101,7 +159,7 @@ ClickableIcon {
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
width: parent.width
|
Layout.fillWidth: parent
|
||||||
implicitHeight: 1
|
implicitHeight: 1
|
||||||
visible: root.adapter.networks.values.length > 0
|
visible: root.adapter.networks.values.length > 0
|
||||||
|
|
||||||
|
|
@ -121,6 +179,7 @@ ClickableIcon {
|
||||||
|
|
||||||
delegate: NetworkDelegate {
|
delegate: NetworkDelegate {
|
||||||
required property var modelData
|
required property var modelData
|
||||||
|
Layout.fillWidth: parent
|
||||||
device: root.adapter
|
device: root.adapter
|
||||||
network: modelData
|
network: modelData
|
||||||
width: parent.width
|
width: parent.width
|
||||||
|
|
@ -131,3 +190,5 @@ ClickableIcon {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -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