maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   SailfishOS (https://talk.maemo.org/forumdisplay.php?f=52)
-   -   Saving text input to a 'TextArea' (https://talk.maemo.org/showthread.php?t=99922)

Markkyboy 2017-10-03 23:11

Saving text input to a 'TextArea'
 
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,

MartinK 2017-10-03 23:43

Re: Saving text input to a 'TextArea'
 
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

rinigus 2017-10-04 06:44

Re: Saving text input to a 'TextArea'
 
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.

Markkyboy 2017-10-04 18:15

Re: Saving text input to a 'TextArea'
 
Thanks guys (rinigus & MartinK),

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

Regards,


All times are GMT. The time now is 09:10.

vBulletin® Version 3.8.8