From 184b66390302b6ed4e31d85e78884c5fc77794bd Mon Sep 17 00:00:00 2001 From: Yari Polla Date: Thu, 19 Oct 2023 19:46:54 +0200 Subject: [PATCH] dataproviders: declare SignalStrengthInfo as singleton --- components/mobileshell/mobileshellplugin.cpp | 2 +- .../qml/dataproviders/SignalStrengthInfo.qml | 2 ++ components/mobileshell/qml/statusbar/StatusBar.qml | 6 ++---- .../indicators/SignalStrengthIndicator.qml | 13 +++++-------- 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/components/mobileshell/mobileshellplugin.cpp b/components/mobileshell/mobileshellplugin.cpp index 377b1c2d..c5bc8e92 100644 --- a/components/mobileshell/mobileshellplugin.cpp +++ b/components/mobileshell/mobileshellplugin.cpp @@ -63,7 +63,7 @@ void MobileShellPlugin::registerTypes(const char *uri) qmlRegisterSingletonType(resolvePath("dataproviders/AudioInfo.qml"), uri, 1, 0, "AudioInfo"); qmlRegisterSingletonType(resolvePath("dataproviders/BatteryInfo.qml"), uri, 1, 0, "BatteryInfo"); qmlRegisterSingletonType(resolvePath("dataproviders/BluetoothInfo.qml"), uri, 1, 0, "BluetoothInfo"); - qmlRegisterType(resolvePath("dataproviders/SignalStrengthInfo.qml"), uri, 1, 0, "SignalStrengthInfo"); + qmlRegisterSingletonType(resolvePath("dataproviders/SignalStrengthInfo.qml"), uri, 1, 0, "SignalStrengthInfo"); // /homescreen qmlRegisterType(resolvePath("homescreen/HomeScreen.qml"), uri, 1, 0, "HomeScreen"); diff --git a/components/mobileshell/qml/dataproviders/SignalStrengthInfo.qml b/components/mobileshell/qml/dataproviders/SignalStrengthInfo.qml index 25c368f0..d448da21 100644 --- a/components/mobileshell/qml/dataproviders/SignalStrengthInfo.qml +++ b/components/mobileshell/qml/dataproviders/SignalStrengthInfo.qml @@ -6,6 +6,8 @@ * SPDX-License-Identifier: GPL-2.0-or-later */ +pragma Singleton + import QtQuick 2.1 import org.kde.plasma.mm 1.0 diff --git a/components/mobileshell/qml/statusbar/StatusBar.qml b/components/mobileshell/qml/statusbar/StatusBar.qml index aac83443..d5cff19a 100644 --- a/components/mobileshell/qml/statusbar/StatusBar.qml +++ b/components/mobileshell/qml/statusbar/StatusBar.qml @@ -18,9 +18,9 @@ import org.kde.plasma.core as PlasmaCore import org.kde.plasma.plasma5support 2.0 as P5Support import org.kde.plasma.components 3.0 as PlasmaComponents import org.kde.kitemmodels as KItemModels +import org.kde.plasma.private.mobileshell 1.0 as MobileShell import "indicators" as Indicators -import "../dataproviders" as DataProviders import "../components" as Components Item { @@ -210,10 +210,8 @@ Item { Item { Layout.fillWidth: true } PlasmaComponents.Label { - property var signalStrengthInfo: DataProviders.SignalStrengthInfo {} - visible: root.showTime - text: signalStrengthInfo.label + text: MobileShell.SignalStrengthInfo.label color: Kirigami.Theme.disabledTextColor font.pixelSize: root.smallerTextPixelSize horizontalAlignment: Qt.AlignRight diff --git a/components/mobileshell/qml/statusbar/indicators/SignalStrengthIndicator.qml b/components/mobileshell/qml/statusbar/indicators/SignalStrengthIndicator.qml index ceaa1f27..60ef8f14 100644 --- a/components/mobileshell/qml/statusbar/indicators/SignalStrengthIndicator.qml +++ b/components/mobileshell/qml/statusbar/indicators/SignalStrengthIndicator.qml @@ -11,14 +11,11 @@ import QtQuick.Layouts import org.kde.plasma.core as PlasmaCore import org.kde.plasma.components 3.0 as PlasmaComponents import org.kde.kirigami as Kirigami - -import "../../dataproviders" as DataProviders +import org.kde.plasma.private.mobileshell 1.0 as MobileShell Item { property InternetIndicator internetIndicator - - readonly property var provider: DataProviders.SignalStrengthInfo {} - + // check if the internet indicator icon is a mobile data related one readonly property bool isInternetIndicatorMobileData: internetIndicator && internetIndicator.icon && internetIndicator.icon.startsWith('network-mobile-') @@ -35,10 +32,10 @@ Item { width: height height: parent.height - source: provider.icon + source: MobileShell.SignalStrengthInfo.icon // don't show mobile indicator icon if the networkmanager one is already showing - visible: !isInternetIndicatorMobileData && provider.showIndicator + visible: !isInternetIndicatorMobileData && MobileShell.SignalStrengthInfo.showIndicator } PlasmaComponents.Label { @@ -49,7 +46,7 @@ Item { anchors.left: strengthIcon.right anchors.verticalCenter: parent.verticalCenter - text: provider.label + text: MobileShell.SignalStrengthInfo.label color: Kirigami.Theme.textColor font.pixelSize: textPixelSize }