8
submitted 1 year ago by fkfd@lemmy.ml to c/kde@lemmy.kde.social

I wrote an applet that makes an API call every 10 minutes, but I want it to show a message if the computer is offline. This means I need to get the network status within QML. I thought a DataEngine might be available, but there isn't.

I read the code for plasma-nm and found this ~~solution~~ hack:

import org.kde.plasma.networkmanagement 0.2 as PlasmaNM
PlasmaNM.NetworkStatus {
    id: networkStatus
}
PlasmaComponents3.Label {
    visible: networkStatus.networkStatus != "Connected"
    text: i18n("Network disconnected")
}

But I think comparing strings is a terrible way because I don't know what will happen in other locales.

Is there a better way?

Link to my code

you are viewing a single comment's thread
view the rest of the comments
[-] lecris@lemmy.kde.social 2 points 1 year ago

What about checking via dbus?

[-] fkfd@lemmy.ml 1 points 1 year ago

that would be ideal! but I can't seem to find a way to do it natively without some C++ library like this one?

[-] lecris@lemmy.kde.social 2 points 1 year ago

I need to setup notifications here. I am not familiar with how qml works, but can't ituse qt native integration, like the one documented in the kde page

this post was submitted on 07 Aug 2023
8 points (100.0% liked)

KDE

5445 readers
23 users here now

KDE is an international technology team creating user-friendly free and open source software for desktop and portable computing. KDE’s software runs on GNU/Linux, BSD and other operating systems, including Windows.

Plasma 6 Bugs

If you encounter a bug, proceed to https://bugs.kde.org, check whether it has been reported.

If it hasn't, report it yourself.

PLEASE THINK CAREFULLY BEFORE POSTING HERE.

Developers do not look for reports on social media, so they will not see it and all it does is clutter up the feed.

founded 1 year ago
MODERATORS