2023-04-01 07:09:57 +00:00
|
|
|
// SPDX-FileCopyrightText: 2017 Martin Kacej <m.kacej@atlas.sk>
|
|
|
|
|
// SPDX-FileCopyrightText: 2023 Devin Lin <devin@kde.org>
|
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
|
|
2023-09-21 19:02:47 +00:00
|
|
|
import QtQuick
|
|
|
|
|
import QtQuick.Controls
|
|
|
|
|
import QtQuick.Layouts
|
2023-04-01 07:09:57 +00:00
|
|
|
|
2026-03-07 03:08:07 +00:00
|
|
|
import org.kde.kirigami as Kirigami
|
2023-09-21 19:02:47 +00:00
|
|
|
import org.kde.kirigamiaddons.formcard 1.0 as FormCard
|
2023-09-23 23:27:13 +00:00
|
|
|
import org.kde.plasma.networkmanagement as PlasmaNM
|
2023-04-01 07:09:57 +00:00
|
|
|
import org.kde.plasma.mobileinitialstart.wifi 1.0 as WiFi
|
|
|
|
|
|
2024-11-07 06:07:50 +00:00
|
|
|
import org.kde.plasma.mobileinitialstart.initialstart
|
2023-04-01 07:09:57 +00:00
|
|
|
|
2024-11-07 06:07:50 +00:00
|
|
|
InitialStartModule {
|
2024-11-10 06:35:06 +00:00
|
|
|
name: i18n("Network")
|
2024-11-07 06:07:50 +00:00
|
|
|
contentItem: Item {
|
|
|
|
|
id: root
|
2023-04-01 07:09:57 +00:00
|
|
|
|
2024-11-07 06:07:50 +00:00
|
|
|
readonly property real cardWidth: Math.min(Kirigami.Units.gridUnit * 30, root.width - Kirigami.Units.gridUnit * 2)
|
2023-04-01 07:09:57 +00:00
|
|
|
|
2024-11-07 06:07:50 +00:00
|
|
|
PlasmaNM.Handler {
|
|
|
|
|
id: handler
|
|
|
|
|
}
|
2023-04-01 07:09:57 +00:00
|
|
|
|
2024-11-07 06:07:50 +00:00
|
|
|
PlasmaNM.EnabledConnections {
|
|
|
|
|
id: enabledConnections
|
|
|
|
|
}
|
2023-04-01 07:09:57 +00:00
|
|
|
|
2024-11-07 06:07:50 +00:00
|
|
|
PlasmaNM.NetworkModel {
|
|
|
|
|
id: connectionModel
|
|
|
|
|
}
|
2023-04-01 07:09:57 +00:00
|
|
|
|
2024-11-07 06:07:50 +00:00
|
|
|
PlasmaNM.MobileProxyModel {
|
|
|
|
|
id: mobileProxyModel
|
|
|
|
|
sourceModel: connectionModel
|
|
|
|
|
showSavedMode: false
|
|
|
|
|
}
|
2023-04-01 07:09:57 +00:00
|
|
|
|
2024-11-07 06:07:50 +00:00
|
|
|
ConnectDialog {
|
|
|
|
|
id: connectionDialog
|
|
|
|
|
}
|
2023-04-01 07:09:57 +00:00
|
|
|
|
2024-11-07 06:07:50 +00:00
|
|
|
Component.onCompleted: handler.requestScan()
|
2023-04-01 07:09:57 +00:00
|
|
|
|
2024-11-07 06:07:50 +00:00
|
|
|
Timer {
|
|
|
|
|
id: scanTimer
|
|
|
|
|
interval: 10200
|
|
|
|
|
repeat: true
|
|
|
|
|
running: parent.visible
|
2023-04-01 07:09:57 +00:00
|
|
|
|
2024-11-07 06:07:50 +00:00
|
|
|
onTriggered: handler.requestScan()
|
2023-12-27 23:17:16 +00:00
|
|
|
}
|
|
|
|
|
|
2024-11-07 06:07:50 +00:00
|
|
|
ColumnLayout {
|
|
|
|
|
anchors {
|
|
|
|
|
fill: parent
|
|
|
|
|
topMargin: Kirigami.Units.gridUnit
|
|
|
|
|
bottomMargin: Kirigami.Units.largeSpacing
|
|
|
|
|
}
|
2023-04-01 07:09:57 +00:00
|
|
|
|
2024-11-07 06:07:50 +00:00
|
|
|
width: root.width
|
|
|
|
|
spacing: Kirigami.Units.gridUnit
|
2023-04-01 07:09:57 +00:00
|
|
|
|
2024-11-07 06:07:50 +00:00
|
|
|
Label {
|
|
|
|
|
Layout.leftMargin: Kirigami.Units.gridUnit
|
|
|
|
|
Layout.rightMargin: Kirigami.Units.gridUnit
|
|
|
|
|
Layout.alignment: Qt.AlignTop
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
|
|
|
|
|
wrapMode: Text.Wrap
|
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
|
text: i18n("Connect to a WiFi network for network access.")
|
|
|
|
|
}
|
2023-04-01 07:09:57 +00:00
|
|
|
|
2024-11-07 06:07:50 +00:00
|
|
|
FormCard.FormCard {
|
|
|
|
|
id: savedCard
|
|
|
|
|
maximumWidth: root.cardWidth
|
|
|
|
|
visible: enabledConnections.wirelessEnabled && count > 0
|
|
|
|
|
|
|
|
|
|
// number of visible entries
|
|
|
|
|
property int count: 0
|
|
|
|
|
function updateCount() {
|
|
|
|
|
count = 0;
|
|
|
|
|
for (let i = 0; i < connectedRepeater.count; i++) {
|
|
|
|
|
let item = connectedRepeater.itemAt(i);
|
|
|
|
|
if (item && item.shouldDisplay) {
|
|
|
|
|
count++;
|
|
|
|
|
}
|
2023-12-27 23:17:16 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-07 06:07:50 +00:00
|
|
|
Repeater {
|
|
|
|
|
id: connectedRepeater
|
|
|
|
|
model: mobileProxyModel
|
|
|
|
|
delegate: ConnectionItemDelegate {
|
|
|
|
|
editMode: false
|
2024-07-27 03:47:44 +00:00
|
|
|
|
2024-11-07 06:07:50 +00:00
|
|
|
// connected or saved
|
|
|
|
|
property bool shouldDisplay: (Uuid != "") || ConnectionState === PlasmaNM.Enums.Activated
|
|
|
|
|
onShouldDisplayChanged: savedCard.updateCount()
|
2024-07-27 03:47:44 +00:00
|
|
|
|
2024-11-07 06:07:50 +00:00
|
|
|
// separate property for visible since visible is false when the whole card is not visible
|
|
|
|
|
visible: (Uuid != "") || ConnectionState === PlasmaNM.Enums.Activated
|
|
|
|
|
}
|
2023-12-27 23:17:16 +00:00
|
|
|
}
|
|
|
|
|
}
|
2023-04-01 07:09:57 +00:00
|
|
|
|
2024-11-07 06:07:50 +00:00
|
|
|
FormCard.FormCard {
|
2023-09-21 19:02:47 +00:00
|
|
|
Layout.fillHeight: true
|
2024-11-07 06:07:50 +00:00
|
|
|
maximumWidth: root.cardWidth
|
|
|
|
|
visible: enabledConnections.wirelessEnabled
|
|
|
|
|
|
|
|
|
|
ListView {
|
|
|
|
|
id: listView
|
|
|
|
|
|
|
|
|
|
clip: true
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
Layout.fillHeight: true
|
|
|
|
|
model: mobileProxyModel
|
|
|
|
|
|
|
|
|
|
delegate: ConnectionItemDelegate {
|
|
|
|
|
width: ListView.view.width
|
|
|
|
|
editMode: false
|
|
|
|
|
height: visible ? implicitHeight : 0
|
|
|
|
|
visible: !((Uuid != "") || ConnectionState === PlasmaNM.Enums.Activated)
|
|
|
|
|
}
|
2023-04-01 07:09:57 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-03-07 03:08:07 +00:00
|
|
|
}
|