110 lines
3.6 KiB
QML
110 lines
3.6 KiB
QML
import QtQuick
|
|
import "../services" as S
|
|
import NovaStats as NS
|
|
|
|
// NOT safe for lock screen - can toggle wifi and connect/disconnect networks
|
|
Column {
|
|
id: root
|
|
|
|
required property color accentColor
|
|
property bool active: true
|
|
onActiveChanged: if (active)
|
|
S.NetworkService.refresh()
|
|
|
|
AppletActionBar {
|
|
accentColor: root.accentColor
|
|
|
|
Item {
|
|
width: 20
|
|
height: 20
|
|
|
|
Text {
|
|
anchors.centerIn: parent
|
|
text: "\uF011"
|
|
color: S.NetworkService.wifiEnabled ? root.accentColor : NS.ThemeService.base04
|
|
font.pixelSize: NS.ThemeService.fontSize
|
|
font.family: NS.ThemeService.iconFontFamily
|
|
|
|
Behavior on color {
|
|
ColorAnimation {
|
|
duration: 100
|
|
}
|
|
}
|
|
}
|
|
|
|
HoverHandler {
|
|
cursorShape: Qt.PointingHandCursor
|
|
}
|
|
|
|
TapHandler {
|
|
onTapped: S.NetworkService.setWifi(!S.NetworkService.wifiEnabled)
|
|
}
|
|
}
|
|
}
|
|
|
|
Repeater {
|
|
model: S.NetworkService.networks
|
|
|
|
delegate: HoverableListItem {
|
|
id: entry
|
|
required property var modelData
|
|
required property int index
|
|
|
|
Text {
|
|
id: netIcon
|
|
anchors.left: parent.left
|
|
anchors.leftMargin: 12
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
text: entry.modelData.isWifi ? "\uF1EB" : "\uDB80\uDE00"
|
|
color: entry.modelData.active ? root.accentColor : NS.ThemeService.base05
|
|
font.pixelSize: NS.ThemeService.fontSize + 1
|
|
font.family: NS.ThemeService.iconFontFamily
|
|
}
|
|
|
|
Text {
|
|
anchors.left: netIcon.right
|
|
anchors.leftMargin: 8
|
|
anchors.right: sigLabel.left
|
|
anchors.rightMargin: 4
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
text: entry.modelData.name
|
|
color: entry.modelData.active ? root.accentColor : NS.ThemeService.base05
|
|
font.pixelSize: NS.ThemeService.fontSize
|
|
font.family: NS.ThemeService.fontFamily
|
|
font.bold: entry.modelData.active
|
|
elide: Text.ElideRight
|
|
}
|
|
|
|
Text {
|
|
id: sigLabel
|
|
anchors.right: parent.right
|
|
anchors.rightMargin: 12
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
text: entry.modelData.signal >= 0 ? entry.modelData.signal + "%" : ""
|
|
color: NS.ThemeService.base04
|
|
font.pixelSize: NS.ThemeService.fontSize - 1
|
|
font.family: NS.ThemeService.fontFamily
|
|
width: entry.modelData.signal >= 0 ? implicitWidth : 0
|
|
}
|
|
|
|
onTapped: {
|
|
if (entry.modelData.active)
|
|
S.NetworkService.disconnectNetwork(entry.modelData.uuid);
|
|
else
|
|
S.NetworkService.connectNetwork(entry.modelData.uuid);
|
|
}
|
|
}
|
|
}
|
|
|
|
Text {
|
|
visible: S.NetworkService.networks.length === 0
|
|
width: root.width
|
|
height: 32
|
|
horizontalAlignment: Text.AlignHCenter
|
|
verticalAlignment: Text.AlignVCenter
|
|
text: S.NetworkService.wifiEnabled ? "No networks available" : "Wi-Fi is off"
|
|
color: NS.ThemeService.base04
|
|
font.pixelSize: NS.ThemeService.fontSize
|
|
font.family: NS.ThemeService.fontFamily
|
|
}
|
|
}
|