This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Plasmoid: How to read local files?

Tags: None
(comma "," separated)
ralphb
Registered Member
Posts
16
Karma
0
OS

Plasmoid: How to read local files?

Fri May 27, 2022 8:33 am
What's the canonical way of reading a local file for a plasmoid? Do I have to use JavaScript for that?

If so, there's apparently a File class, but after reading many **** descriptions on the web I'm still not sure if File actually reads local files. I've also found suggestions of using XMLHttpRequest.

Or maybe there is some kind of Data Source that would provide the contents of a file?

In Qt4 using Python, this was obviously a piece of cake.
koffeinfriedhof
Registered Member
Posts
608
Karma
4
OS
Hi!

The usual way of reading and writing files is using a cpp-File. Depending on what you want to read, you can also use Plasma Widget Configuration which uses the KDE Frameworks read and write methods, so you don't have to implement your own.
ralphb
Registered Member
Posts
16
Karma
0
OS
koffeinfriedhof wrote:Hi!

The usual way of reading and writing files is using a cpp-File. Depending on what you want to read, you can also use Plasma Widget Configuration which uses the KDE Frameworks read and write methods, so you don't have to implement your own.


Thanks for your suggestion. I suppose you're referring to FileDialog here? I didn't mention it explicitly, but I'm looking for a way to open a file without user interaction. Right now I'm using XMLHttpRequest, but I thought there might be a better way (without using C++).
koffeinfriedhof
Registered Member
Posts
608
Karma
4
OS
Afaik there is no way of file IO in JS/QML natively, so you have to use one of the C++-backends available. Another way of data storage is Local Storage for accessing a local sqlite database.
ralphb
Registered Member
Posts
16
Karma
0
OS
koffeinfriedhof wrote:Afaik there is no way of file IO in JS/QML natively.


I see, thanks for answering.


Bookmarks



Who is online

Registered users: bartoloni, Bing [Bot], Google [Bot], Yahoo [Bot]