Active Topics

 


Reply
Thread Tools
Markkyboy's Avatar
Posts: 433 | Thanked: 727 times | Joined on Oct 2012 @ Costa Blanca, Espaņa
#1
Hey all,

I have a Page in my app, the page is a search page. I have included an editable 'TextArea', basically an area at the bottom of the screen where the user can add notes on planning his/her journey.

Ultimately, saving the notes to Documents is the aim, but for now, is it possible to preserve the text input even if the app is closed?, or even if the user navigates the rest of the app, comes back to search page and notes are preserved..?

I've tried taking samples from jolla-notes and tinyedit but have achieved nothing so far or have found convoluted methods on StackExchange that don't work with Sailfish......I'm stuck!, any help appreciated.

Regards,
__________________
..oO(Don't just sit there standing around, pick up a shovel and sweep up!)Oo..
 
Posts: 1,548 | Thanked: 7,510 times | Joined on Apr 2010 @ Czech Republic
#2
Looks like QtQuick LocalStorage might work for you to persistently store user data.

Alternatively you can also use PyOtherSide to use Python to store your files to a file on the local filesystem:

PyOtherSide @ Sailfish OS docs
General PyOtherSide docs

The "notes" PyOtherSide example in particular seems to be pretty close to what you are trying to achieve - storing some string from an application persistently to a file and the loading them from the file again:

notes_example.qml
notes_example.py
__________________
modRana: a flexible GPS navigation system
Mieru: a flexible manga and comic book reader
Universal Components - a solution for native looking yet component set independent QML appliactions (QtQuick Controls 2 & Silica supported as backends)
 

The Following 3 Users Say Thank You to MartinK For This Useful Post:
Posts: 1,414 | Thanked: 7,547 times | Joined on Aug 2016 @ Estonia
#3
As MartinK explained, you can use PyOtherSide to do the magic. If you prefer to do so in C++, you could save the notes together with the other app settings using QSettings. Since you can convert between JSON and strings at your will, any complicated structure can be saved / restored from settings.

For QSettings, you probably would have to write a small wrapper that would allow to call it from QML (Q_INVOKABLE methods).

But if you use Python, its better to go with MartinK solution. Seems to be simple enough and flexible as well - you'll be able to save the notes later where you want them to be saved.
 

The Following 2 Users Say Thank You to rinigus For This Useful Post:
Markkyboy's Avatar
Posts: 433 | Thanked: 727 times | Joined on Oct 2012 @ Costa Blanca, Espaņa
#4
Thanks guys (rinigus & MartinK),

I will have a go with QtQuick LocalStorage to start with, thanks

Regards,
__________________
..oO(Don't just sit there standing around, pick up a shovel and sweep up!)Oo..
 
Reply

Thread Tools

 
Forum Jump


All times are GMT. The time now is 07:54.