Commit 9b6ac618 authored by Devin Lin's avatar Devin Lin 🎨
Browse files

quicksettings: Make mobile data quick setting use NM API directly

parent e4ad5220
Pipeline #136264 failed with stage
in 43 seconds
......@@ -47,6 +47,7 @@ find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS
Notifications
Wayland
ModemManagerQt
NetworkManagerQt
)
find_package(KWinDBusInterface)
set_package_properties(KWinDBusInterface PROPERTIES DESCRIPTION "KWin DBus interface"
......
......@@ -10,6 +10,7 @@ target_sources(ppc-mmqmlplugin PRIVATE
target_link_libraries(ppc-mmqmlplugin
Qt5::Qml
KF5::ModemManagerQt
KF5::NetworkManagerQt
)
set_property(TARGET ppc-mmqmlplugin PROPERTY LIBRARY_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/org/kde/plasma/mm)
......
// SPDX-FileCopyrightText: 2021 Tobias Fella <fella@posteo.de>
// SPDX-FileCopyrightText: 2022 Devin Lin <devin@kde.org>
// SPDX-License-Identifier: GPL-2.0-or-later
#include <NetworkManagerQt/Manager>
#include "signalindicator.h"
SignalIndicator::SignalIndicator()
{
connect(NetworkManager::notifier(), &NetworkManager::Notifier::wwanEnabledChanged, this, [this](bool) {
Q_EMIT wwanEnabledChanged();
});
connect(ModemManager::notifier(), &ModemManager::Notifier::modemAdded, this, &SignalIndicator::updateModem);
connect(ModemManager::notifier(), &ModemManager::Notifier::modemRemoved, this, &SignalIndicator::updateModem);
updateModem();
......@@ -36,6 +43,16 @@ bool SignalIndicator::available() const
return !ModemManager::modemDevices().isEmpty();
}
bool SignalIndicator::wwanEnabled() const
{
return NetworkManager::isWwanEnabled();
}
void SignalIndicator::setWwanEnabled(bool wwanEnabled)
{
NetworkManager::setWwanEnabled(wwanEnabled);
}
void SignalIndicator::updateModem()
{
if (!available()) {
......
// SPDX-FileCopyrightText: 2021 Tobias Fella <fella@posteo.de>
// SPDX-FileCopyrightText: 2022 Devin Lin <devin@kde.org>
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <ModemManagerQt/Manager>
#include <ModemManagerQt/modem3gpp.h>
#include <QObject>
// We make the assumption that there is only one modem.
class SignalIndicator : public QObject
{
Q_OBJECT
......@@ -15,6 +18,7 @@ class SignalIndicator : public QObject
Q_PROPERTY(QString name READ name NOTIFY nameChanged)
Q_PROPERTY(bool simLocked READ simLocked NOTIFY simLockedChanged)
Q_PROPERTY(bool available READ available NOTIFY availableChanged)
Q_PROPERTY(bool wwanEnabled READ wwanEnabled WRITE setWwanEnabled NOTIFY wwanEnabledChanged)
public:
SignalIndicator();
......@@ -23,12 +27,16 @@ public:
QString name() const;
bool simLocked() const;
bool available() const;
bool wwanEnabled() const;
void setWwanEnabled(bool wwanEnabled);
Q_SIGNALS:
void strengthChanged();
void nameChanged();
void simLockedChanged();
void availableChanged();
void wwanEnabledChanged();
private:
ModemManager::Modem::Ptr m_modem;
......
......@@ -15,6 +15,7 @@ import org.kde.bluezqt 1.0 as BluezQt
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 3.0 as PC3
import org.kde.plasma.networkmanagement 0.2 as PlasmaNM
import org.kde.plasma.mm 1.0 as PlasmaMM
import org.kde.plasma.private.mobileshell 1.0 as MobileShell
MobileShell.QuickSettingsModel {
......@@ -67,9 +68,9 @@ MobileShell.QuickSettingsModel {
text: i18n("Mobile Data")
icon: "network-modem"
settingsCommand: "plasma-open-settings kcm_mobile_broadband"
enabled: enabledConnections.wwanEnabled
enabled: PlasmaMM.SignalIndicator.wwanEnabled
function toggle() {
nmHandler.enableWwan(!enabledConnections.wwanEnabled)
PlasmaMM.SignalIndicator.wwanEnabled = !PlasmaMM.SignalIndicator.wwanEnabled
}
}
MobileShell.QuickSetting {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment