[SailfishDevel] How to handle app settings?
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi, I didn't find any reference to the way application settings are to be handled in SailfishOS. Does this apply http://developer.nokia.com/Community/Wiki/How-to_create_a_persistent_settings_database_in_Qt_Quick_%28QML%29 ? Or this http://harmattan-dev.nokia.com/docs/library/html/guide/html/Developer_Library_Best_practices_for_application_development_Storing_and_managing_application_settings.html ? Or is there a new way of doing in Qt5, or a way specific to Sailfish ? What is the right way to handle settings in my applicaiton ? I probably did not look at the right palce, so any pointer would be welcome. Regards, Franck -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.14 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBAgAGBQJSvwcNAAoJEGEvoAir78RobkkIAKpXnbn1yuQ/75mBXuu0e73J mqpNIwcyMzjF5Zp8XOQWqrNzIXFyoIPDMWgTPZgcoMGOc67+vd6rn7WWEQACt+r+ du3nEsvHGcxkOKCD8/mFcJ80ts7+NYZGzZCOMJiuvD2XNifZxQHbE8EIMif4a5Ud eWalkR0XfnVOWD53RafoReuxcnambwF1TpZ0iaceJAX134uBCRbMUvX+pw1rVO+n Dsg5o7DHCBteFkMPo+TGXK1GVzs4/se2cQPBF++ZUuvXBRwVUtw0I37bDZoCNTu/ 7G0XNkxTi4z3dlEYiYhWqHHUZV0OBpyc1bR+LvtItb2+7bsY3VAb2TCb5RjSL0k= =XvB7 -END PGP SIGNATURE- ___ SailfishOS.org Devel mailing list
Re: [SailfishDevel] How to handle app settings?
use QSettings On 28.12.2013 23:14, Franck Routier (perso) wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi, I didn't find any reference to the way application settings are to be handled in SailfishOS. Does this apply http://developer.nokia.com/Community/Wiki/How-to_create_a_persistent_settings_database_in_Qt_Quick_%28QML%29 ? Or this http://harmattan-dev.nokia.com/docs/library/html/guide/html/Developer_Library_Best_practices_for_application_development_Storing_and_managing_application_settings.html ? Or is there a new way of doing in Qt5, or a way specific to Sailfish ? What is the right way to handle settings in my applicaiton ? I probably did not look at the right palce, so any pointer would be welcome. Regards, Franck -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.14 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBAgAGBQJSvwcNAAoJEGEvoAir78RobkkIAKpXnbn1yuQ/75mBXuu0e73J mqpNIwcyMzjF5Zp8XOQWqrNzIXFyoIPDMWgTPZgcoMGOc67+vd6rn7WWEQACt+r+ du3nEsvHGcxkOKCD8/mFcJ80ts7+NYZGzZCOMJiuvD2XNifZxQHbE8EIMif4a5Ud eWalkR0XfnVOWD53RafoReuxcnambwF1TpZ0iaceJAX134uBCRbMUvX+pw1rVO+n Dsg5o7DHCBteFkMPo+TGXK1GVzs4/se2cQPBF++ZUuvXBRwVUtw0I37bDZoCNTu/ 7G0XNkxTi4z3dlEYiYhWqHHUZV0OBpyc1bR+LvtItb2+7bsY3VAb2TCb5RjSL0k= =XvB7 -END PGP SIGNATURE- ___ SailfishOS.org Devel mailing list ___ SailfishOS.org Devel mailing list
Re: [SailfishDevel] How to handle app settings?
I did it like this with QSettings, it works. I don't know is it the correct way... (comments anyone?) introduce me in main() QCoreApplication::setOrganizationDomain("diibadaaba"); QCoreApplication::setOrganizationName("diibadaaba "); QCoreApplication::setApplicationName("badbreath"); QCoreApplication::setApplicationVersion("0.1-1"); read QSettings settings; m_mySetting = settings.value("mySetting", "").toString(); write QSettings settings; settings.setValue("mySetting", m_mySetting); -kimmo ___ SailfishOS.org Devel mailing list
Re: [SailfishDevel] How to handle app settings?
Hi there I believe somebody was posting to IRC a link to a QML wrapper for QSettings done as a part of some nemo project. If you want something QML that works, I use this pure QML LocalStorage approach for the last couple of years fine - https://github.com/amarchen/Wikipedia/blob/master/src/qml/components/DbDictionary.qml Nowadays I would have started with wrapping QSettings though (and pull requests to Wikipedia for changing LocalStorage use into QSettings wrapper are welcome :)) Best regards, Artem. On Sat, Dec 28, 2013 at 7:45 PM, Kimmo Lindholm wrote: > I did it like this with QSettings, it works. I don't know is it the > correct way... (comments anyone?) > > introduce me in main() > QCoreApplication::setOrganizationDomain("diibadaaba"); > QCoreApplication::setOrganizationName("diibadaaba "); > QCoreApplication::setApplicationName("badbreath"); > QCoreApplication::setApplicationVersion("0.1-1"); > > read > QSettings settings; > m_mySetting = settings.value("mySetting", "").toString(); > > write > QSettings settings; > settings.setValue("mySetting", m_mySetting); > > -kimmo > > > ___ > SailfishOS.org Devel mailing list > -- Artem Marchenko http://agilesoftwaredevelopment.com http://twitter.com/AgileArtem ___ SailfishOS.org Devel mailing list
Re: [SailfishDevel] How to handle app settings?
I use a QML-enabled QSettings wrapper created by Nokia at some point. Here’s the download link: https://dl.dropboxusercontent.com/u/10015284/qml_settings/settings.cpp and https://dl.dropboxusercontent.com/u/10015284/qml_settings/settings.h Put those into your project, then register it in your main.cpp (or PROJECTNAME.cpp) like this: Settings settings; //create the root context and set the context properties QQmlContext *rootContext = view->rootContext(); //register our c++ modules for usage in QML rootContext->setContextProperty("settings", &settings); Now you have a ”settings” object available everywhere in your QML/JS. Usage: Save an object: settings.setSetting(”name”, value); Read a saved object: settings.setting(”name”); Works like a charm ;) //b0bben On 28 Dec 2013, at 19:06, Artem Marchenko wrote: > Hi there > > I believe somebody was posting to IRC a link to a QML wrapper for QSettings > done as a part of some nemo project. > > If you want something QML that works, I use this pure QML LocalStorage > approach for the last couple of years fine - > https://github.com/amarchen/Wikipedia/blob/master/src/qml/components/DbDictionary.qml > > Nowadays I would have started with wrapping QSettings though (and pull > requests to Wikipedia for changing LocalStorage use into QSettings wrapper > are welcome :)) > > Best regards, > Artem. > > > > On Sat, Dec 28, 2013 at 7:45 PM, Kimmo Lindholm wrote: > I did it like this with QSettings, it works. I don't know is it the correct > way... (comments anyone?) > > introduce me in main() > QCoreApplication::setOrganizationDomain("diibadaaba"); > QCoreApplication::setOrganizationName("diibadaaba "); > QCoreApplication::setApplicationName("badbreath"); > QCoreApplication::setApplicationVersion("0.1-1"); > > read > QSettings settings; > m_mySetting = settings.value("mySetting", "").toString(); > > write > QSettings settings; > settings.setValue("mySetting", m_mySetting); > > -kimmo > > > ___ > SailfishOS.org Devel mailing list > > > > -- > Artem Marchenko > http://agilesoftwaredevelopment.com > http://twitter.com/AgileArtem > ___ > SailfishOS.org Devel mailing list ___ SailfishOS.org Devel mailing list
Re: [SailfishDevel] How to handle app settings?
Le 28/12/2013 19:06, Artem Marchenko a écrit : > If you want something QML that works, I use this pure QML LocalStorage > approach for the last couple of years fine > - > https://github.com/amarchen/Wikipedia/blob/master/src/qml/components/DbDictionary.qml I found inbetween that this is the approach promoted (for now) by Ubuntu Touch as well. > > Nowadays I would have started with wrapping QSettings though (and pull > requests to Wikipedia for changing LocalStorage use into QSettings > wrapper are welcome :)) > So as I understand it, QSettings might be better, but is not yet really usable from QML out of the box (needs a wrapper of some sort, some being developped by Nokia for example). But, what makes QSettings better thant LocalStorage ? Ans what makes LocalStorage better than QSettings ? here are my first bets: LocalStorage: (+) available in qml out of the box, more standard (HTML5 ??), more powerful (sql) (-) not directly human readable / editable, security concerns (all tables available to all qml apps ??) QSettings: (+) simple text files (?) (-) not directly usable from qml there must be some other points... Best regards, Franck ___ SailfishOS.org Devel mailing list
Re: [SailfishDevel] How to handle app settings?
See my previous mail. I use that in QML all the time. I guess it’s up to you, as an app developer, to decide what fits your app. In spirit with agile software development, I start of with the easies possible solution, with as little friction as possible and take it from there. The QSettings (with QML wrapper) has served me well, and I could focus my time on other parts of the app instead :) //bob On 29 dec 2013, at 10:08, Franck Routier (perso) wrote: > Le 28/12/2013 19:06, Artem Marchenko a écrit : > >> If you want something QML that works, I use this pure QML LocalStorage >> approach for the last couple of years fine >> - >> https://github.com/amarchen/Wikipedia/blob/master/src/qml/components/DbDictionary.qml > > I found inbetween that this is the approach promoted (for now) by Ubuntu > Touch as well. >> >> Nowadays I would have started with wrapping QSettings though (and pull >> requests to Wikipedia for changing LocalStorage use into QSettings >> wrapper are welcome :)) >> > So as I understand it, QSettings might be better, but is not yet really > usable from QML out of the box (needs a wrapper of some sort, some being > developped by Nokia for example). > > But, what makes QSettings better thant LocalStorage ? Ans what makes > LocalStorage better than QSettings ? > > here are my first bets: > > LocalStorage: > (+) available in qml out of the box, more standard (HTML5 ??), more > powerful (sql) > (-) not directly human readable / editable, security concerns (all > tables available to all qml apps ??) > > QSettings: > (+) simple text files (?) > (-) not directly usable from qml > > there must be some other points... > > Best regards, > > Franck > ___ > SailfishOS.org Devel mailing list ___ SailfishOS.org Devel mailing list
Re: [SailfishDevel] How to handle app settings?
On Sunday 29 December 2013 10.08.04 Franck Routier wrote: > > LocalStorage: > (+) available in qml out of the box, more standard (HTML5 ??), more > powerful (sql) > (-) not directly human readable / editable, security concerns (all > tables available to all qml apps ??) > The localestorage file is saved per app in ~/.local/share/APPNAME/QML/OfflineStorage/Databases/UNIQUE_ID_OR_SIMILAR. db QSettings also stored ~/.local/share/appname/something... So both QSettings and LocaleStorage can be readable by other apps with some hacks. So non is better on security concern. Or wait maybe SQL is bit better because its not readable from text editor atleast ;) But I agree SQL is bit annoying to work with. Would be nice with higher levcel api for insert/delete/update... -- Skickat från Lenovo Thinkpad X230 running Kubuntu desktop ___ SailfishOS.org Devel mailing list
Re: [SailfishDevel] How to handle app settings?
QSettings saved in ~/.config/organization/application.conf for privacy you can make own SQL frontend with password-locked database. On 29.12.2013 18:46, Mikael Hermansson wrote: On Sunday 29 December 2013 10.08.04 Franck Routier wrote: LocalStorage: (+) available in qml out of the box, more standard (HTML5 ??), more powerful (sql) (-) not directly human readable / editable, security concerns (all tables available to all qml apps ??) The localestorage file is saved per app in ~/.local/share/APPNAME/QML/OfflineStorage/Databases/UNIQUE_ID_OR_SIMILAR. db QSettings also stored ~/.local/share/appname/something... So both QSettings and LocaleStorage can be readable by other apps with some hacks. So non is better on security concern. Or wait maybe SQL is bit better because its not readable from text editor atleast ;) But I agree SQL is bit annoying to work with. Would be nice with higher levcel api for insert/delete/update... ___ SailfishOS.org Devel mailing list ___ SailfishOS.org Devel mailing list
Re: [SailfishDevel] How to handle app settings?
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi, I am trying to use the QSettings wrapper, as proposed by Bob Jelica. Here is what I did in my main cpp: #include #include "settings.h" int main(int argc, char *argv[]) { // SailfishApp::main() will display "qml/template.qml", if you need more // control over initialization, you can use: // // - SailfishApp::application(int, char *[]) to get the QGuiApplication * // - SailfishApp::createView() to get a new QQuickView * instance // - SailfishApp::pathTo(QString) to get a QUrl to a resource file // // To display the view, call "show()" (will show fullscreen on device). Settings settings; QQuickView *view = SailfishApp::createView(); //create the root context and set the context properties QQmlContext *rootContext = view->rootContext(); //register our c++ modules for usage in QML rootContext->setContextProperty("settings", &settings); return SailfishApp::main(argc, argv); } Everything compiles fine, but on deployment, I get these messages: [W] QCoreApplication::applicationDirPath:1906 - QCoreApplication::applicationDirPath: Please instantiate the QApplication object first [F] qt_pixmap_thread_test:76 - QPixmap: Must construct a QApplication before a QPaintDevice applicationPath is used in settings.cpp, but I just copied it as is from the download link given. I must be missing some obvious step, and would appreciate any help. Regards, Franck Le 29/12/2013 10:15, Bob Jelica a écrit : > See my previous mail. I use that in QML all the time. > > I guess it’s up to you, as an app developer, to decide what fits > your app. In spirit with agile software development, I start of > with the easies possible solution, with as little friction as > possible and take it from there. The QSettings (with QML wrapper) > has served me well, and I could focus my time on other parts of the > app instead :) > > //bob > > On 29 dec 2013, at 10:08, Franck Routier (perso) > wrote: > >> Le 28/12/2013 19:06, Artem Marchenko a écrit : >> >>> If you want something QML that works, I use this pure QML >>> LocalStorage approach for the last couple of years fine - >>> https://github.com/amarchen/Wikipedia/blob/master/src/qml/components/DbDictionary.qml >> >> >>> I found inbetween that this is the approach promoted (for now) by Ubuntu >> Touch as well. >>> >>> Nowadays I would have started with wrapping QSettings though >>> (and pull requests to Wikipedia for changing LocalStorage use >>> into QSettings wrapper are welcome :)) >>> >> So as I understand it, QSettings might be better, but is not yet >> really usable from QML out of the box (needs a wrapper of some >> sort, some being developped by Nokia for example). >> >> But, what makes QSettings better thant LocalStorage ? Ans what >> makes LocalStorage better than QSettings ? >> >> here are my first bets: >> >> LocalStorage: (+) available in qml out of the box, more standard >> (HTML5 ??), more powerful (sql) (-) not directly human readable / >> editable, security concerns (all tables available to all qml apps >> ??) >> >> QSettings: (+) simple text files (?) (-) not directly usable from >> qml >> >> there must be some other points... >> >> Best regards, >> >> Franck ___ >> SailfishOS.org Devel mailing list > > ___ SailfishOS.org > Devel mailing list > -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.14 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBAgAGBQJSwIqSAAoJEGEvoAir78RoDeUH/iVIsj1VnsW7Ku/coDF+aI0o NrsAYTRTz02KV1uCxeDhC/L8+RObvv8j8DHDCJoQsCFdbtdMWmJilaazxeM/IXfR fn/3hMfm0rNBRKLnBGAifFy3Awbfv1kR3sBpTqJUltuBI/n7SU/jEcvcsJ4TSkKC kZRDvq3DrxPk5CKE7VR+SuZSWE69MNQD3t7TRP0yVMtYeZdf2Ayus32obb0D+Lam HjJd8o+qQOu12eapo7FPQPbnFW5xZuh803492MhduTsOsAqJTsBzy8d7zvadk9b8 YmV6wGC4JhmhwXJ6zV238S5i8PoP9SD43gv2TXNStH/Ai+0PNj+xMNIWVLgg3YI= =nD/S -END PGP SIGNATURE- ___ SailfishOS.org Devel mailing list
Re: [SailfishDevel] How to handle app settings?
That’s just a warning, I have it as well, but never had problems nor time to investigate further. //bob On 29 Dec 2013, at 21:48, Franck Routier (perso) wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > Hi, > > I am trying to use the QSettings wrapper, as proposed by Bob Jelica. > Here is what I did in my main cpp: > > #include > #include "settings.h" > > int main(int argc, char *argv[]) > { >// SailfishApp::main() will display "qml/template.qml", if you > need more >// control over initialization, you can use: >// >// - SailfishApp::application(int, char *[]) to get the > QGuiApplication * >// - SailfishApp::createView() to get a new QQuickView * instance >// - SailfishApp::pathTo(QString) to get a QUrl to a resource file >// >// To display the view, call "show()" (will show fullscreen on > device). > >Settings settings; > >QQuickView *view = SailfishApp::createView(); >//create the root context and set the context properties >QQmlContext *rootContext = view->rootContext(); >//register our c++ modules for usage in QML >rootContext->setContextProperty("settings", &settings); > >return SailfishApp::main(argc, argv); > } > > > Everything compiles fine, but on deployment, I get these messages: > > [W] QCoreApplication::applicationDirPath:1906 - > QCoreApplication::applicationDirPath: Please instantiate the > QApplication object first > [F] qt_pixmap_thread_test:76 - QPixmap: Must construct a QApplication > before a QPaintDevice > > applicationPath is used in settings.cpp, but I just copied it as is > from the download link given. > > I must be missing some obvious step, and would appreciate any help. > > Regards, > Franck > > > Le 29/12/2013 10:15, Bob Jelica a écrit : >> See my previous mail. I use that in QML all the time. >> >> I guess it’s up to you, as an app developer, to decide what fits >> your app. In spirit with agile software development, I start of >> with the easies possible solution, with as little friction as >> possible and take it from there. The QSettings (with QML wrapper) >> has served me well, and I could focus my time on other parts of the >> app instead :) >> >> //bob >> >> On 29 dec 2013, at 10:08, Franck Routier (perso) >> wrote: >> >>> Le 28/12/2013 19:06, Artem Marchenko a écrit : >>> If you want something QML that works, I use this pure QML LocalStorage approach for the last couple of years fine - https://github.com/amarchen/Wikipedia/blob/master/src/qml/components/DbDictionary.qml >>> >>> > I found inbetween that this is the approach promoted (for now) by Ubuntu >>> Touch as well. Nowadays I would have started with wrapping QSettings though (and pull requests to Wikipedia for changing LocalStorage use into QSettings wrapper are welcome :)) >>> So as I understand it, QSettings might be better, but is not yet >>> really usable from QML out of the box (needs a wrapper of some >>> sort, some being developped by Nokia for example). >>> >>> But, what makes QSettings better thant LocalStorage ? Ans what >>> makes LocalStorage better than QSettings ? >>> >>> here are my first bets: >>> >>> LocalStorage: (+) available in qml out of the box, more standard >>> (HTML5 ??), more powerful (sql) (-) not directly human readable / >>> editable, security concerns (all tables available to all qml apps >>> ??) >>> >>> QSettings: (+) simple text files (?) (-) not directly usable from >>> qml >>> >>> there must be some other points... >>> >>> Best regards, >>> >>> Franck ___ >>> SailfishOS.org Devel mailing list >> >> ___ SailfishOS.org >> Devel mailing list >> > > -BEGIN PGP SIGNATURE- > Version: GnuPG v1.4.14 (GNU/Linux) > Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ > > iQEcBAEBAgAGBQJSwIqSAAoJEGEvoAir78RoDeUH/iVIsj1VnsW7Ku/coDF+aI0o > NrsAYTRTz02KV1uCxeDhC/L8+RObvv8j8DHDCJoQsCFdbtdMWmJilaazxeM/IXfR > fn/3hMfm0rNBRKLnBGAifFy3Awbfv1kR3sBpTqJUltuBI/n7SU/jEcvcsJ4TSkKC > kZRDvq3DrxPk5CKE7VR+SuZSWE69MNQD3t7TRP0yVMtYeZdf2Ayus32obb0D+Lam > HjJd8o+qQOu12eapo7FPQPbnFW5xZuh803492MhduTsOsAqJTsBzy8d7zvadk9b8 > YmV6wGC4JhmhwXJ6zV238S5i8PoP9SD43gv2TXNStH/Ai+0PNj+xMNIWVLgg3YI= > =nD/S > -END PGP SIGNATURE- > ___ > SailfishOS.org Devel mailing list ___ SailfishOS.org Devel mailing list
Re: [SailfishDevel] How to handle app settings?
Le 29/12/2013 21:53, Bob Jelica a écrit : > That’s just a warning, I have it as well, but never had problems nor time to > investigate further. Ok, thanks a lot. Franck ___ SailfishOS.org Devel mailing list
Re: [SailfishDevel] How to handle app settings?
On Sunday 29 December 2013 21:48:18 Franck Routier wrote: > Everything compiles fine, but on deployment, I get these messages: > > [W] QCoreApplication::applicationDirPath:1906 - > QCoreApplication::applicationDirPath: Please instantiate the > QApplication object first I use: int main(int argc, char *argv[]) { QGuiApplication *app = SailfishApp::application(argc, argv); QQuickView *view = SailfishApp::createView(); QmlSettings *settings = new QmlSettings(); view->rootContext()->setContextProperty("settings", settings); view->setSource(SailfishApp::pathTo("qml/net.tanghus.currencyconverter.sailfish.qml")); view->showFullScreen(); return app->exec(); } This way you don't get the warning. -- Best regards / Med venlig hilsen Thomas Tanghus ___ SailfishOS.org Devel mailing list