forked from Shinonome/dots-hyprland
waffle: action center: wifi menu (without auth)
This commit is contained in:
@@ -0,0 +1,114 @@
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Layouts
|
||||
import Quickshell
|
||||
import qs
|
||||
import qs.services
|
||||
import qs.services.network
|
||||
import qs.modules.common
|
||||
import qs.modules.common.functions
|
||||
import qs.modules.common.widgets
|
||||
import qs.modules.waffle.looks
|
||||
import qs.modules.waffle.actionCenter
|
||||
|
||||
WChoiceButton {
|
||||
id: root
|
||||
required property WifiAccessPoint wifiNetwork
|
||||
|
||||
property bool expanded: false
|
||||
checked: expanded
|
||||
clip: true
|
||||
|
||||
horizontalPadding: 12
|
||||
verticalPadding: 6
|
||||
animateChoiceHighlight: false
|
||||
|
||||
Behavior on implicitHeight {
|
||||
animation: Looks.transition.resize.createObject(this)
|
||||
}
|
||||
|
||||
onClicked: expanded = !expanded
|
||||
|
||||
contentItem: RowLayout {
|
||||
id: contentItem
|
||||
spacing: 12
|
||||
|
||||
FluentIcon { // Duotone hack
|
||||
Layout.bottomMargin: 2
|
||||
Layout.alignment: Qt.AlignTop
|
||||
property int strength: root.wifiNetwork?.strength ?? 0
|
||||
icon: "wifi-1"
|
||||
implicitSize: 30
|
||||
color: Looks.colors.inactiveIcon
|
||||
|
||||
FluentIcon { // Signal
|
||||
property int strength: root.wifiNetwork?.strength ?? 0
|
||||
icon: WIcons.wifiIconForStrength(strength)
|
||||
implicitSize: 30
|
||||
|
||||
FluentIcon { // Security
|
||||
anchors {
|
||||
right: parent.right
|
||||
bottom: parent.bottom
|
||||
}
|
||||
visible: root?.wifiNetwork?.isSecure ?? false
|
||||
icon: "lock-closed"
|
||||
filled: true
|
||||
implicitSize: 14
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
Layout.topMargin: statusText.visible ? 4 : 7
|
||||
Layout.bottomMargin: 4
|
||||
Layout.alignment: Qt.AlignTop
|
||||
Layout.fillWidth: true
|
||||
spacing: 1
|
||||
|
||||
Behavior on Layout.topMargin {
|
||||
animation: Looks.transition.move.createObject(this)
|
||||
}
|
||||
|
||||
WText { // Network name
|
||||
Layout.fillWidth: true
|
||||
elide: Text.ElideRight
|
||||
font.pixelSize: Looks.font.pixelSize.large
|
||||
text: root.wifiNetwork?.ssid ?? Translation.tr("Unknown")
|
||||
}
|
||||
WText { // Status
|
||||
id: statusText
|
||||
Layout.fillWidth: true
|
||||
elide: Text.ElideRight
|
||||
text: root.wifiNetwork?.active ? Translation.tr("Connected") : root.wifiNetwork?.isSecure ? Translation.tr("Secured") : Translation.tr("Not secured")
|
||||
font.pixelSize: Looks.font.pixelSize.large
|
||||
color: Looks.colors.subfg
|
||||
visible: root.wifiNetwork?.active || root.expanded
|
||||
Behavior on opacity {
|
||||
animation: Looks.transition.opacity.createObject(this)
|
||||
}
|
||||
}
|
||||
|
||||
WButton {
|
||||
Layout.alignment: Qt.AlignRight
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
visible: root.expanded
|
||||
checked: !(root.wifiNetwork?.active ?? false)
|
||||
colBackgroundHover: Looks.colors.bg2Hover
|
||||
colBackgroundActive: Looks.colors.bg2Active
|
||||
inset: 0
|
||||
implicitHeight: 30
|
||||
implicitWidth: 148
|
||||
text: root.wifiNetwork?.active ? Translation.tr("Disconnect") : Translation.tr("Connect")
|
||||
|
||||
onClicked: {
|
||||
if (root.wifiNetwork?.active) {
|
||||
Network.disconnectWifiNetwork();
|
||||
} else {
|
||||
Network.connectToWifiNetwork(root.wifiNetwork);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Layouts
|
||||
import Qt5Compat.GraphicalEffects
|
||||
import Quickshell
|
||||
import qs
|
||||
import qs.services
|
||||
import qs.services.network
|
||||
import qs.modules.common
|
||||
import qs.modules.common.functions
|
||||
import qs.modules.common.widgets
|
||||
import qs.modules.waffle.looks
|
||||
import qs.modules.waffle.actionCenter
|
||||
|
||||
Item {
|
||||
id: root
|
||||
implicitWidth: 360
|
||||
implicitHeight: 352
|
||||
|
||||
Component.onCompleted: {
|
||||
Network.rescanWifi();
|
||||
}
|
||||
|
||||
PageColumn {
|
||||
anchors.fill: parent
|
||||
|
||||
BodyRectangle {
|
||||
implicitHeight: 400
|
||||
implicitWidth: 50
|
||||
|
||||
ColumnLayout {
|
||||
anchors.fill: parent
|
||||
anchors.margins: 4
|
||||
spacing: 4
|
||||
|
||||
ColumnLayout {
|
||||
implicitHeight: headerRow.implicitHeight
|
||||
Layout.fillWidth: true
|
||||
spacing: 0
|
||||
HeaderRow {
|
||||
id: headerRow
|
||||
Layout.fillWidth: true
|
||||
title: qsTr("Wi-Fi")
|
||||
}
|
||||
FadeLoader {
|
||||
Layout.leftMargin: -4
|
||||
Layout.rightMargin: -4
|
||||
Layout.fillWidth: true
|
||||
shown: Network.wifiScanning
|
||||
sourceComponent: StyledIndeterminateProgressBar {
|
||||
id: progressBar
|
||||
implicitHeight: 3
|
||||
background: null
|
||||
layer.enabled: true
|
||||
layer.effect: OpacityMask {
|
||||
maskSource: Rectangle {
|
||||
width: progressBar.width
|
||||
height: progressBar.height
|
||||
radius: progressBar.height / 2
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
StyledListView {
|
||||
id: listView
|
||||
Layout.fillHeight: true
|
||||
Layout.fillWidth: true
|
||||
animateAppearance: false
|
||||
|
||||
contentHeight: contentLayout.implicitHeight
|
||||
contentWidth: width
|
||||
clip: true
|
||||
spacing: 4
|
||||
|
||||
model: ScriptModel {
|
||||
values: Network.friendlyWifiNetworks
|
||||
}
|
||||
delegate: WWifiNetworkItem {
|
||||
required property WifiAccessPoint modelData
|
||||
wifiNetwork: modelData
|
||||
width: ListView.view.width
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Separator {}
|
||||
|
||||
FooterRectangle {
|
||||
WButton {
|
||||
id: moreSettingsButton
|
||||
anchors {
|
||||
verticalCenter: parent.verticalCenter
|
||||
left: parent.left
|
||||
}
|
||||
inset: 0
|
||||
implicitHeight: 40
|
||||
implicitWidth: contentItem.implicitWidth + 30
|
||||
color: "transparent"
|
||||
|
||||
onClicked: {
|
||||
Quickshell.execDetached(["qs", "-p", Quickshell.shellPath(""), "ipc", "call", "sidebarLeft", "toggle"]);
|
||||
Quickshell.execDetached(["bash", "-c", Config.options.apps.network]);
|
||||
}
|
||||
|
||||
contentItem: Item {
|
||||
anchors.centerIn: parent
|
||||
implicitWidth: buttonText.implicitWidth
|
||||
WText {
|
||||
id: buttonText
|
||||
anchors.centerIn: parent
|
||||
text: qsTr("More Internet settings")
|
||||
color: moreSettingsButton.pressed ? Looks.colors.fg : Looks.colors.fg1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user