pax_global_header00006660000000000000000000000064134101746150014514gustar00rootroot0000000000000052 comment=fa7454abc92c63453926744138917ac977e073ea gsettings-qt-v0.2/000077500000000000000000000000001341017461500141745ustar00rootroot00000000000000gsettings-qt-v0.2/COPYING000066400000000000000000000167431341017461500152420ustar00rootroot00000000000000 GNU LESSER GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below. 0. Additional Definitions. As used herein, "this License" refers to version 3 of the GNU Lesser General Public License, and the "GNU GPL" refers to version 3 of the GNU General Public License. "The Library" refers to a covered work governed by this License, other than an Application or a Combined Work as defined below. An "Application" is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library. A "Combined Work" is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the "Linked Version". The "Minimal Corresponding Source" for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version. The "Corresponding Application Code" for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work. 1. Exception to Section 3 of the GNU GPL. You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL. 2. Conveying Modified Versions. If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version: a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy. 3. Object Code Incorporating Material from Library Header Files. The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following: a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the object code with a copy of the GNU GPL and this license document. 4. Combined Works. You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following: a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the Combined Work with a copy of the GNU GPL and this license document. c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document. d) Do one of the following: 0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source. 1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version. e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.) 5. Combined Libraries. You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License. b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 6. Revised Versions of the GNU Lesser General Public License. The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation. If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the Library. gsettings-qt-v0.2/GSettings/000077500000000000000000000000001341017461500161035ustar00rootroot00000000000000gsettings-qt-v0.2/GSettings/gsettings-qml.cpp000066400000000000000000000110721341017461500214060ustar00rootroot00000000000000/* * Copyright 2013 Canonical Ltd. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; version 3. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Author: Lars Uebernickel */ #include "gsettings-qml.h" #include struct GSettingsSchemaQmlPrivate { QByteArray id; QByteArray path; bool isValid; GSettingsSchemaQmlPrivate() : isValid(false) {} }; struct GSettingsQmlPrivate { GSettingsSchemaQml *schema; QGSettings *settings; }; GSettingsSchemaQml::GSettingsSchemaQml(QObject *parent): QObject(parent) { priv = new GSettingsSchemaQmlPrivate; } GSettingsSchemaQml::~GSettingsSchemaQml() { delete priv; } QByteArray GSettingsSchemaQml::id() const { return priv->id; } void GSettingsSchemaQml::setId(const QByteArray &id) { if (!priv->id.isEmpty()) { qWarning("GSettings.schema.id may only be set on construction"); return; } priv->id = id; } QByteArray GSettingsSchemaQml::path() const { return priv->path; } void GSettingsSchemaQml::setPath(const QByteArray &path) { if (!priv->path.isEmpty()) { qWarning("GSettings.schema.path may only be set on construction"); return; } priv->path = path; } bool GSettingsSchemaQml::isValid() const { return priv->isValid; } void GSettingsSchemaQml::setIsValid(bool valid) { if (valid != priv->isValid) { priv->isValid = valid; Q_EMIT isValidChanged(); } } QVariantList GSettingsSchemaQml::choices(const QByteArray &key) const { GSettingsQml *parent = (GSettingsQml *) this->parent(); if (parent->priv->settings == NULL) return QVariantList(); if (!parent->contains(key)) return QVariantList(); return parent->priv->settings->choices(key); } void GSettingsSchemaQml::reset(const QByteArray &key) { GSettingsQml *parent = (GSettingsQml *) this->parent(); if (parent->priv->settings != NULL) { parent->priv->settings->reset(key); // make sure this object gets the new value immediately and not on the // next main loop iteration (see updateValue) parent->settingChanged(key); } } GSettingsQml::GSettingsQml(QObject *parent): QQmlPropertyMap(this, parent) { priv = new GSettingsQmlPrivate; priv->schema = new GSettingsSchemaQml(this); priv->settings = NULL; } GSettingsQml::~GSettingsQml() { delete priv; } GSettingsSchemaQml * GSettingsQml::schema() const { return priv->schema; } void GSettingsQml::classBegin() { } void GSettingsQml::componentComplete() { bool schemaValid = QGSettings::isSchemaInstalled(priv->schema->id()); if (schemaValid) { priv->settings = new QGSettings(priv->schema->id(), priv->schema->path(), this); connect(priv->settings, SIGNAL(changed(const QString &)), this, SLOT(settingChanged(const QString &))); Q_FOREACH(const QString &key, priv->settings->keys()) this->insert(key, priv->settings->get(key)); Q_EMIT(schemaChanged()); } // emit isValid notification only once everything is setup priv->schema->setIsValid(schemaValid); } void GSettingsQml::settingChanged(const QString &key) { QVariant value = priv->settings->get(key); if (this->value(key) != value) { this->insert(key, value); Q_EMIT(changed(key, value)); } } QVariant GSettingsQml::updateValue(const QString& key, const QVariant &value) { if (priv->settings == NULL) return QVariant(); if (priv->settings->trySet(key, value)) { // due to QTBUG-32859, QGSettings doesn't dispatch its changed signal // directly, but on a new main loop iteration. At that point, this // object already has the new value set and doesn't emit its own // changed signal (see ::settingChanged). Emit it here so that it is // sent even when the setting is changed from qml. Q_EMIT(changed(key, value)); return value; } else { qWarning("unable to set key '%s' to value '%s'", key.toUtf8().constData(), value.toString().toUtf8().constData()); return priv->settings->get(key); } } gsettings-qt-v0.2/GSettings/gsettings-qml.h000066400000000000000000000042131341017461500210520ustar00rootroot00000000000000/* * Copyright 2013 Canonical Ltd. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; version 3. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Author: Lars Uebernickel */ #include #include class GSettingsSchemaQml: public QObject { Q_OBJECT Q_PROPERTY(QByteArray id READ id WRITE setId) Q_PROPERTY(QByteArray path READ path WRITE setPath) Q_PROPERTY(bool isValid READ isValid NOTIFY isValidChanged) public: GSettingsSchemaQml(QObject *parent = NULL); ~GSettingsSchemaQml(); QByteArray id() const; void setId(const QByteArray &id); QByteArray path() const; void setPath(const QByteArray &path); bool isValid() const; void setIsValid(bool valid); Q_INVOKABLE QVariantList choices(const QByteArray &key) const; Q_INVOKABLE void reset(const QByteArray &key); Q_SIGNALS: void isValidChanged(); private: struct GSettingsSchemaQmlPrivate *priv; }; class GSettingsQml: public QQmlPropertyMap, public QQmlParserStatus { Q_OBJECT Q_INTERFACES(QQmlParserStatus) Q_PROPERTY(GSettingsSchemaQml* schema READ schema NOTIFY schemaChanged) public: GSettingsQml(QObject *parent = NULL); ~GSettingsQml(); GSettingsSchemaQml * schema() const; void classBegin(); void componentComplete(); Q_SIGNALS: void schemaChanged(); void changed (const QString &key, const QVariant &value); private Q_SLOTS: void settingChanged(const QString &key); private: struct GSettingsQmlPrivate *priv; QVariant updateValue(const QString& key, const QVariant &value); friend class GSettingsSchemaQml; }; gsettings-qt-v0.2/GSettings/gsettings-qt.pro000066400000000000000000000014111341017461500212530ustar00rootroot00000000000000TEMPLATE = lib QT += qml QT -= gui CONFIG += qt plugin no_keywords link_pkgconfig PKGCONFIG += gio-2.0 INCLUDEPATH += ../src . LIBS += -L../src -lgsettings-qt TARGET = GSettingsQmlPlugin HEADERS = plugin.h gsettings-qml.h SOURCES = plugin.cpp gsettings-qml.cpp uri = GSettings API_VER = 1.0 # deployment rules for the plugin installPath = $$[QT_INSTALL_QML]/$$replace(uri, \\., /).$$API_VER target.path = $$installPath INSTALLS += target extra.path = $$installPath extra.files += qmldir INSTALLS += extra qmltypes.path = $$installPath qmltypes.files = plugins.qmltypes qmltypes.extra = export LD_PRELOAD=../src/libgsettings-qt.so.1; $$[QT_INSTALL_BINS]/qmlplugindump -notrelocatable GSettings 1.0 .. > $(INSTALL_ROOT)/$$installPath/plugins.qmltypes INSTALLS += qmltypes gsettings-qt-v0.2/GSettings/plugin.cpp000066400000000000000000000020701341017461500201040ustar00rootroot00000000000000/* * Copyright 2013 Canonical Ltd. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; version 3. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Author: Lars Uebernickel */ #include "plugin.h" #include "gsettings-qml.h" void GSettingsQmlPlugin::registerTypes(const char *uri) { qmlRegisterType(uri, 1, 0, "GSettings"); qmlRegisterUncreatableType(uri, 1, 0, "GSettingsSchema", "GSettingsSchema can only be used inside of a GSettings component"); } gsettings-qt-v0.2/GSettings/plugin.h000066400000000000000000000016051341017461500175540ustar00rootroot00000000000000/* * Copyright 2013 Canonical Ltd. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; version 3. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Author: Lars Uebernickel */ #include class GSettingsQmlPlugin: public QQmlExtensionPlugin { Q_OBJECT Q_PLUGIN_METADATA(IID "com.ubports.GSettings") public: void registerTypes(const char *uri); }; gsettings-qt-v0.2/GSettings/qmldir000066400000000000000000000001051341017461500173120ustar00rootroot00000000000000module GSettings plugin GSettingsQmlPlugin typeinfo plugins.qmltypes gsettings-qt-v0.2/Jenkinsfile000066400000000000000000000060111341017461500163560ustar00rootroot00000000000000pipeline { agent any stages { stage('Build source') { steps { sh '/usr/bin/build-source.sh' stash(name: 'source', includes: '*.gz,*.bz2,*.xz,*.deb,*.dsc,*.changes,*.buildinfo,lintian.txt') cleanWs(cleanWhenAborted: true, cleanWhenFailure: true, cleanWhenNotBuilt: true, cleanWhenSuccess: true, cleanWhenUnstable: true, deleteDirs: true) } } stage('Build binary - armhf') { steps { parallel( "Build binary - armhf": { node(label: 'arm64') { cleanWs(cleanWhenAborted: true, cleanWhenFailure: true, cleanWhenNotBuilt: true, cleanWhenSuccess: true, cleanWhenUnstable: true, deleteDirs: true) unstash 'source' sh '''export architecture="armhf" build-binary.sh''' stash(includes: '*.gz,*.bz2,*.xz,*.deb,*.dsc,*.changes,*.buildinfo,lintian.txt', name: 'build-armhf') cleanWs(cleanWhenAborted: true, cleanWhenFailure: true, cleanWhenNotBuilt: true, cleanWhenSuccess: true, cleanWhenUnstable: true, deleteDirs: true) } }, "Build binary - arm64": { node(label: 'arm64') { cleanWs(cleanWhenAborted: true, cleanWhenFailure: true, cleanWhenNotBuilt: true, cleanWhenSuccess: true, cleanWhenUnstable: true, deleteDirs: true) unstash 'source' sh '''export architecture="arm64" build-binary.sh''' stash(includes: '*.gz,*.bz2,*.xz,*.deb,*.dsc,*.changes,*.buildinfo,lintian.txt', name: 'build-arm64') cleanWs(cleanWhenAborted: true, cleanWhenFailure: true, cleanWhenNotBuilt: true, cleanWhenSuccess: true, cleanWhenUnstable: true, deleteDirs: true) } }, "Build binary - amd64": { node(label: 'amd64') { cleanWs(cleanWhenAborted: true, cleanWhenFailure: true, cleanWhenNotBuilt: true, cleanWhenSuccess: true, cleanWhenUnstable: true, deleteDirs: true) unstash 'source' sh '''export architecture="amd64" build-binary.sh''' stash(includes: '*.gz,*.bz2,*.xz,*.deb,*.dsc,*.changes,*.buildinfo,lintian.txt', name: 'build-amd64') cleanWs(cleanWhenAborted: true, cleanWhenFailure: true, cleanWhenNotBuilt: true, cleanWhenSuccess: true, cleanWhenUnstable: true, deleteDirs: true) } } ) } } stage('Results') { steps { cleanWs(cleanWhenAborted: true, cleanWhenFailure: true, cleanWhenNotBuilt: true, cleanWhenSuccess: true, cleanWhenUnstable: true, deleteDirs: true) unstash 'build-armhf' unstash 'build-arm64' unstash 'build-amd64' archiveArtifacts(artifacts: '*.gz,*.bz2,*.xz,*.deb,*.dsc,*.changes,*.buildinfo', fingerprint: true, onlyIfSuccessful: true) sh '''/usr/bin/build-repo.sh''' } } stage('Cleanup') { steps { cleanWs(cleanWhenAborted: true, cleanWhenFailure: true, cleanWhenNotBuilt: true, cleanWhenSuccess: true, cleanWhenUnstable: true, deleteDirs: true) } } } } gsettings-qt-v0.2/debian/000077500000000000000000000000001341017461500154165ustar00rootroot00000000000000gsettings-qt-v0.2/debian/changelog000066400000000000000000000300361341017461500172720ustar00rootroot00000000000000gsettings-qt (0.2+ubports) bionic; urgency=medium * Imported to UBports -- UBports auto importer Thu, 26 Oct 2017 13:41:36 +0200 gsettings-qt (0.1+17.10.20170824-0ubuntu1) artful; urgency=medium * Update debian/libgsettings-qt1.symbols with the latest symbols changes. -- Dmitry Shachnev Thu, 24 Aug 2017 17:09:31 +0000 gsettings-qt (0.1+16.04.20160329-0ubuntu3~1) zesty; urgency=medium * No change rebuild -- Timo Jyrinki Wed, 04 Jan 2017 08:53:28 +0200 gsettings-qt (0.1+16.04.20160329-0ubuntu2~4) yakkety; urgency=medium * Build against Qt 5.6. * Adjust test running to changes in Qt 5.6. * debian/control: don't use transitional package names * Update symbols. -- Timo Jyrinki Fri, 01 Apr 2016 10:12:26 +0000 gsettings-qt (0.1+16.04.20160329-0ubuntu1) xenial; urgency=medium [ Albert Astals Cid ] * Use QChar toUpper/toLower instead of C version (LP: #1556461) -- Michał Sawicz Tue, 29 Mar 2016 12:56:42 +0000 gsettings-qt (0.1+16.04.20160111-0ubuntu1) xenial; urgency=medium [ Albert Astals Cid ] * Disconnect signal handler on destruction -- Michał Sawicz Mon, 11 Jan 2016 11:26:52 +0000 gsettings-qt (0.1+16.04.20151130-0ubuntu1) xenial; urgency=medium * No-change rebuild. -- CI Train Bot Mon, 30 Nov 2015 14:50:27 +0000 gsettings-qt (0.1+16.04.20151104-0ubuntu1) xenial; urgency=medium [ Lars Uebernickel ] * qgsettings-qml: explicitly emit changed events (LP: #1503693) -- Sebastien Bacher Wed, 04 Nov 2015 17:59:13 +0000 gsettings-qt (0.1+15.04.20150810-0ubuntu1) vivid; urgency=medium [ Lukáš Tinkl ] * Force handling deferred delete events to avoid memory leaks (LP: #1460970) * Force handling deferred delete events to avoid memory leaks (LP: #1460970) -- CI Train Bot Mon, 10 Aug 2015 15:49:54 +0000 gsettings-qt (0.1+14.10.20140807-0ubuntu6~gcc5.1) wily; urgency=medium * No-change test rebuild for g++5 ABI transition -- Steve Langasek Wed, 15 Jul 2015 07:53:08 +0000 gsettings-qt (0.1+14.10.20140807-0ubuntu5) wily; urgency=medium * No-change rebuild against Qt 5.4.2. -- Timo Jyrinki Fri, 12 Jun 2015 09:21:19 +0300 gsettings-qt (0.1+14.10.20140807-0ubuntu4) vivid; urgency=medium * No-change rebuild against Qt 5.4.1. -- Timo Jyrinki Wed, 11 Mar 2015 08:25:19 +0200 gsettings-qt (0.1+14.10.20140807-0ubuntu3) vivid; urgency=medium * No-change rebuild against Qt 5.4.0. -- Timo Jyrinki Fri, 13 Feb 2015 13:57:38 +0200 gsettings-qt (0.1+14.10.20140807-0ubuntu2) vivid; urgency=medium * No-change rebuild against Qt 5.3.2. -- Timo Jyrinki Tue, 28 Oct 2014 13:40:39 +0200 gsettings-qt (0.1+14.10.20140807-0ubuntu1) utopic; urgency=low [ Ken VanDine ] * qtdeclarative5-gsettings1.0 needs to depend on the same version of libgsettings-qt1 -- Ubuntu daily release Thu, 07 Aug 2014 15:26:43 +0000 gsettings-qt (0.1+14.10.20140801.1-0ubuntu1) utopic; urgency=low [ Ubuntu daily release ] * debian/libgsettings-qt1.symbols: auto-update to released version * New rebuild forced [ Ken VanDine ] * added tests for a{ss} [ Lars Uebernickel ] * qconftypes: support a{ss} We don't support a{sv} because gsettings is typed more strictly than javascript and qvariant. (LP: #1349787) [ Łukasz 'sil2100' Zemczak ] * Work-around a symbols problem in ppc64el -- Ubuntu daily release Fri, 01 Aug 2014 17:06:59 +0000 gsettings-qt (0.1+14.10.20140624-0ubuntu1) utopic; urgency=low [ Lars Uebernickel ] * Stop using deprecated g_settings_get_range() * qml: only emit changed when the value has actually changed This cannot be done for the c++ class, because that would involve a round-trip to the dconf database. The QML component already caches all values because of the way QQmlPropertyMap works. (LP: #1330365) -- Ubuntu daily release Tue, 24 Jun 2014 10:01:54 +0000 gsettings-qt (0.1+14.10.20140607-0ubuntu1) utopic; urgency=low * New rebuild forced -- Ubuntu daily release Sat, 07 Jun 2014 10:54:33 +0000 gsettings-qt (0.1+14.10.20140606-0ubuntu1) utopic; urgency=low [ Lars Uebernickel ] * Sync settings in destructor To ensure that settings are saved to disc when an app exits. -- Ubuntu daily release Fri, 06 Jun 2014 14:31:00 +0000 gsettings-qt (0.1+14.10.20140520-0ubuntu1) utopic; urgency=low [ Iain Lane ] * Add a symbols file so that the qtdeclarative module (and other rdeps) get correctly versioned dependencies (LP: #1304611) -- Ubuntu daily release Tue, 20 May 2014 18:39:37 +0000 gsettings-qt (0.1+14.10.20140501-0ubuntu1) utopic; urgency=low [ Michal Hruby ] * Fix incorrect unref call. -- Ubuntu daily release Thu, 01 May 2014 10:29:56 +0000 gsettings-qt (0.1+14.04.20140408-0ubuntu1) trusty; urgency=medium [ Michal Hruby ] * Added API to check if a schema is installed [ CI bot ] * Added API to check if a schema is installed. (LP: #1209235) -- Ubuntu daily release Tue, 08 Apr 2014 13:44:50 +0000 gsettings-qt (0.0+13.10.20130902.1-0ubuntu2) trusty; urgency=medium * Rebuild against Qt 5.2.1 -- Timo Jyrinki Mon, 03 Mar 2014 07:46:18 +0200 gsettings-qt (0.0+13.10.20130902.1-0ubuntu1) saucy; urgency=low [ Lars Uebernickel ] * Don't write values into the QQmlPropertyMap when the write failed This makes sure that the property map doesn't get out of sync with the gsettings database. [ Ubuntu daily release ] * Automatic snapshot from revision 41 -- Ubuntu daily release Mon, 02 Sep 2013 06:12:44 +0000 gsettings-qt (0.0+13.10.20130829-0ubuntu1) saucy; urgency=low [ Lars Uebernickel ] * Add API to reset a key to its default value. (LP: #1218005) [ Ubuntu daily release ] * Automatic snapshot from revision 39 -- Ubuntu daily release Thu, 29 Aug 2013 12:29:45 +0000 gsettings-qt (0.0+13.10.20130807-0ubuntu1) saucy; urgency=low [ Ken VanDine ] * Install QML module in a versioned dir so it is really parallel installable . [ Lars Uebernickel ] * Fix crash in unqtify_name For one, stop using g_string_new_len(), which creates a string with a given length, not allocation. Also, make sure the QByteArray stays around for the duration of the loop. [ Ubuntu daily release ] * Automatic snapshot from revision 37 -- Ubuntu daily release Wed, 07 Aug 2013 07:02:05 +0000 gsettings-qt (0.0+13.10.20130802-0ubuntu1) saucy; urgency=low [ Sebastien Bacher ] * let the dev binary depends on the library. [ Ubuntu daily release ] * Automatic snapshot from revision 34 -- Ubuntu daily release Fri, 02 Aug 2013 20:16:44 +0000 gsettings-qt (0.0+13.10.20130730.1-0ubuntu1) saucy; urgency=low [ Sebastien Bacher ] * build a .qmltypes, so qtcreator knows about GSettings. [ Ubuntu daily release ] * Automatic snapshot from revision 32 -- Ubuntu daily release Tue, 30 Jul 2013 18:08:14 +0000 gsettings-qt (0.0+13.10.20130730-0ubuntu1) saucy; urgency=low [ Lars Uebernickel ] * Fix regression: GSettingsQml didn't update values on change. (LP: #1206181) [ Ubuntu daily release ] * Automatic snapshot from revision 30 -- Ubuntu daily release Tue, 30 Jul 2013 07:01:52 +0000 gsettings-qt (0.0+13.10.20130725-0ubuntu1) saucy; urgency=low [ Sebastien Bacher ] * Add a library that can be used from qt/c++ and make gsettings-qml use that. [ Lars Uebernickel ] * Add a library that can be used from qt/c++ and make gsettings-qml use that. [ Ubuntu daily release ] * Automatic snapshot from revision 28 -- Ubuntu daily release Thu, 25 Jul 2013 07:01:48 +0000 gsettings-qt (0.0+13.10.20130720-0ubuntu1) saucy; urgency=low [ Lars Uebernickel ] * Don't abort when calling schema.choices() for an unknown key. Also adds a test for accessing an unknown key from the settings object. * Clean up tests and add some more testing. [ Ubuntu daily release ] * Automatic snapshot from revision 26 -- Ubuntu daily release Sat, 20 Jul 2013 07:01:48 +0000 gsettings-qt (0.0+13.10.20130717-0ubuntu1) saucy; urgency=low [ Lars Uebernickel ] * Add GSettings.schema.choices A function that takes the name of a key and returns the possible values the key may assume. The values are returned in a QVariantList, so they can be used as qml models (with the modelData role). This breaks API: the settings schema must now be set with "schema.id" and the path with "schema.path". [ Ubuntu daily release ] * Automatic snapshot from revision 23 -- Ubuntu daily release Wed, 17 Jul 2013 16:55:56 +0000 gsettings-qt (0.0+13.10.20130716-0ubuntu1) saucy; urgency=low [ Iain Lane ] * Add a testcase for the onChanged signal. [ Ubuntu daily release ] * Automatic snapshot from revision 21 -- Ubuntu daily release Tue, 16 Jul 2013 07:01:42 +0000 gsettings-qt (0.0+13.10.20130713-0ubuntu1) saucy; urgency=low [ Lars Uebernickel ] * Add 'changed' signal There's a 'valueChanged' on QQmlPropertyMap, but that is not emitted when values are inserted via insert(). 'changed' is always emitted, except when the values are first read. [ Ubuntu daily release ] * Automatic snapshot from revision 19 -- Ubuntu daily release Sat, 13 Jul 2013 07:01:43 +0000 gsettings-qt (0.0+13.10.20130701-0ubuntu1) saucy; urgency=low * Automatic snapshot from revision 17 -- Ubuntu daily release Mon, 01 Jul 2013 07:01:01 +0000 gsettings-qt (0.0+13.10.20130630-0ubuntu1) saucy; urgency=low * Automatic snapshot from revision 16 -- Ubuntu daily release Sun, 30 Jun 2013 07:00:59 +0000 gsettings-qt (0.0+13.10.20130629-0ubuntu1) saucy; urgency=low * Automatic snapshot from revision 15 -- Ubuntu daily release Sat, 29 Jun 2013 07:01:00 +0000 gsettings-qt (0.0+13.10.20130628.1-0ubuntu1) saucy; urgency=low * Automatic snapshot from revision 14 -- Ubuntu daily release Fri, 28 Jun 2013 19:40:37 +0000 gsettings-qt (0.0+13.10.20130628-0ubuntu1) saucy; urgency=low * Automatic snapshot from revision 13 -- Ubuntu daily release Fri, 28 Jun 2013 07:01:01 +0000 gsettings-qt (0.0+13.10.20130627-0ubuntu1) saucy; urgency=low * Automatic snapshot from revision 12 -- Ubuntu daily release Thu, 27 Jun 2013 07:01:01 +0000 gsettings-qt (0.0+13.10.20130626.1-0ubuntu1) saucy; urgency=low [ Ken VanDine ] * build depend on qtdeclarative5-test-plugin . [ Lars Uebernickel ] * gsettings-qt: gsettings bindings for qml * Merge initial packaging From lp:~ken-vandine/gsettings-qt/packaging * Add basic testing * Remove QtGui dependency qmake adds this by default. Note that this does not remove the dependency from `make check`, qtquicktests depends on it. * debian: run `make check` under xvfb-run * Merge trunk * debian: run xvfb with -a * Don't install tests Merged from lp:~ken-vandine/gsettings- qt/no_install_tests [ Ubuntu daily release ] * Automatic snapshot from revision 11 -- Ubuntu daily release Wed, 26 Jun 2013 19:36:35 +0000 gsettings-qt (0.0-0ubuntu1) saucy; urgency=low * Initial package -- Ken VanDine Fri, 21 Jun 2013 14:35:13 -0400 gsettings-qt-v0.2/debian/compat000066400000000000000000000000021341017461500166140ustar00rootroot000000000000009 gsettings-qt-v0.2/debian/control000066400000000000000000000026321341017461500170240ustar00rootroot00000000000000Source: gsettings-qt Priority: extra Maintainer: UBports Developers Build-Depends: debhelper (>= 9), pkg-config, libglib2.0-dev, qtchooser, qt5-qmake, qtbase5-dev, qtdeclarative5-dev, qtdeclarative5-dev-tools, qml-module-qttest, qml-module-qtquick2, xvfb, Standards-Version: 3.9.4 Section: libs Homepage: https://gitlab.com/ubports/core-os/gsettings-qt Package: qtdeclarative5-gsettings1.0 Section: libs Architecture: any Pre-Depends: ${misc:Pre-Depends} Depends: ${shlibs:Depends}, ${misc:Depends}, libgsettings-qt1 (= ${binary:Version}), Description: QML Bindings for GSettings Expose QML bindings for GSettings Package: libgsettings-qt1 Section: libs Architecture: any Multi-Arch: same Pre-Depends: ${misc:Pre-Depends} Depends: ${shlibs:Depends}, ${misc:Depends}, Description: Library to access GSettings from Qt Library to access GSettings from Qt Package: libgsettings-qt-dev Section: libdevel Architecture: any Pre-Depends: dpkg (>= 1.15.6~) Depends: ${misc:Depends}, libgsettings-qt1 (= ${binary:Version}), Description: Library to access GSettings from Qt - devel Library to access GSettings from Qt . This package contains the development files needed to build applications using the GSettings Qt library gsettings-qt-v0.2/debian/copyright000066400000000000000000000016231341017461500173530ustar00rootroot00000000000000Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: gsettings-qt Source: https://launchpad.net/gsettings-qt Files: * Copyright: 2013 Canonical Ltd. License: LGPL-3 This package is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; version 3. . This package is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. . You should have received a copy of the GNU General Public License along with this program. If not, see . . On Debian systems, the complete text of the GNU Lesser General Public License can be found in "/usr/share/common-licenses/LGPL-3". gsettings-qt-v0.2/debian/libgsettings-qt-dev.install000066400000000000000000000001021341017461500226730ustar00rootroot00000000000000usr/lib/*/lib*.so usr/include usr/lib/*/pkgconfig/gsettings-qt.pc gsettings-qt-v0.2/debian/libgsettings-qt1.install000066400000000000000000000000241341017461500222030ustar00rootroot00000000000000usr/lib/*/lib*.so.* gsettings-qt-v0.2/debian/libgsettings-qt1.symbols000066400000000000000000000062431341017461500222360ustar00rootroot00000000000000# SymbolsHelper-Confirmed: 0.1+16.04.20160329-0ubuntu2 amd64 arm64 armhf i386 ppc64el libgsettings-qt.so.1 libgsettings-qt1 #MINVER# (c++)"QByteArray::~QByteArray()@Base" 0.1+14.04.20140408 (c++)"QGSettings::QGSettings(QByteArray const&, QByteArray const&, QObject*)@Base" 0.1+14.04.20140408 (c++)"QGSettings::changed(QString const&)@Base" 0.1+14.04.20140408 (c++)"QGSettings::choices(QString const&) const@Base" 0.1+14.04.20140408 (c++)"QGSettings::get(QString const&) const@Base" 0.1+14.04.20140408 (c++)"QGSettings::isSchemaInstalled(QByteArray const&)@Base" 0.1+14.04.20140408 (c++)"QGSettings::keys() const@Base" 0.1+14.04.20140408 (c++)"QGSettings::metaObject() const@Base" 0.1+14.04.20140408 (c++)"QGSettings::qt_metacall(QMetaObject::Call, int, void**)@Base" 0.1+14.04.20140408 (c++)"QGSettings::qt_metacast(char const*)@Base" 0.1+14.04.20140408 (c++)"QGSettings::reset(QString const&)@Base" 0.1+14.04.20140408 (c++)"QGSettings::set(QString const&, QVariant const&)@Base" 0.1+14.04.20140408 (c++)"QGSettings::staticMetaObject@Base" 0.1+14.04.20140408 (c++)"QGSettings::trySet(QString const&, QVariant const&)@Base" 0.1+14.04.20140408 (c++)"QGSettings::~QGSettings()@Base" 0.1+14.04.20140408 (c++)"QGSettingsPrivate::settingChanged(_GSettings*, char const*, void*)@Base" 0.1+14.04.20140408 (c++|optional=templinst)"QList::append(QString const&)@Base" 0.1+14.04.20140408 (c++|optional=templinst)"QList::detach_helper_grow(int, int)@Base" 0.1+14.10.20140801.1 (c++|optional=templinst)"QList::~QList()@Base" 0.1+14.04.20140408 (c++|optional=templinst|arch=!ppc64el)"QList::append(QVariant const&)@Base" 0.1+14.04.20140408 (c++|optional=templinst)"QList::detach_helper_grow(int, int)@Base" 0.1+14.04.20140408 (c++|optional=templinst)"QList::~QList()@Base" 0.1+14.04.20140408 (c++)"QMap::~QMap()@Base" 0.1+14.10.20140801.1 (c++)"QMapNode::copy(QMapData*) const@Base" 0.1+14.10.20140801.1 (c++)"QMapNode::destroySubTree()@Base" 0.1+14.10.20140801.1 (c++)"QString::~QString()@Base" 0.1+14.04.20140408 (optional=templinst)_ZN4QMapI7QString8QVariantEC1ERKS2_@Base 0.1+16.04.20160329-0ubuntu2 (optional=templinst)_ZN4QMapI7QString8QVariantEC2ERKS2_@Base 0.1+16.04.20160329-0ubuntu2 (optional=templinst)_ZN5QListI7QStringEC1ERKS1_@Base 0.1+16.04.20160329-0ubuntu2 (optional=templinst)_ZN5QListI7QStringEC2ERKS1_@Base 0.1+16.04.20160329-0ubuntu2 (optional=templinst|arch=ppc64el)_ZN5QListI8QVariantE6appendERKS0_@Base 0.1+16.04.20160329-0ubuntu2 (optional=templinst)_ZN8QMapDataI7QString8QVariantE7destroyEv@Base 0.1+16.04.20160329-0ubuntu2 (c++)"qconf_types_collect_from_variant(_GVariantType const*, QVariant const&)@Base" 0.1+14.04.20140408 (c++)"qconf_types_convert(_GVariantType const*)@Base" 0.1+14.04.20140408 (c++)"qconf_types_to_qvariant(_GVariant*)@Base" 0.1+14.04.20140408 (c++)"qtify_name(char const*)@Base" 0.1+14.04.20140408 (c++)"typeinfo for QGSettings@Base" 0.1+14.04.20140408 (c++)"typeinfo name for QGSettings@Base" 0.1+14.04.20140408 (c++)"unqtify_name(QString const&)@Base" 0.1+14.04.20140408 (c++)"vtable for QGSettings@Base" 0.1+14.04.20140408 gsettings-qt-v0.2/debian/qtdeclarative5-gsettings1.0.install000066400000000000000000000000161341017461500241440ustar00rootroot00000000000000usr/lib/*/qt5 gsettings-qt-v0.2/debian/rules000077500000000000000000000011041341017461500164720ustar00rootroot00000000000000#!/usr/bin/make -f # -*- makefile -*- # Uncomment this to turn on verbose mode. #export DH_VERBOSE=1 export QT_SELECT=qt5 # Skip tests on the archs they are known to be flaky testskip_architectures := powerpc override_dh_install: rm -rf debian/*/usr/tests dh_install --fail-missing override_dh_auto_test: ifneq ($(DEB_HOST_ARCH),$(findstring $(DEB_HOST_ARCH), $(testskip_architectures))) QT_QPA_PLATFORM=minimal LD_LIBRARY_PATH=../src GSETTINGS_BACKEND=memory GSETTINGS_SCHEMA_DIR=. xvfb-run -a dh_auto_test endif override_dh_makeshlibs: dh_makeshlibs -- -c4 %: dh $@ gsettings-qt-v0.2/examples/000077500000000000000000000000001341017461500160125ustar00rootroot00000000000000gsettings-qt-v0.2/examples/choices.qml000066400000000000000000000011731341017461500201440ustar00rootroot00000000000000 import GSettings 1.0 import QtQuick 2.0 import Ubuntu.Components 0.1 import Ubuntu.Components.ListItems 0.1 as ListItems Item { width: 400 height: 300 GSettings { id: settings schema.id: "com.ubports.Unity.Lenses" } Column { anchors.fill: parent ListItems.Standard { text: 'Dash search' control: Switch { checked: settings.remoteContentSearch == 'all' onClicked: settings.remoteContentSearch = checked ? 'all' : 'none' } } ListItems.SingleValue { text: 'Possible values' value: settings.schema.choices('remoteContentSearch').join(', ') } } } gsettings-qt-v0.2/gsettings-qt.pro000066400000000000000000000001601341017461500173440ustar00rootroot00000000000000TEMPLATE = subdirs SUBDIRS += src/gsettings-qt.pro GSettings/gsettings-qt.pro tests/tests.pro tests/cpptest.pro gsettings-qt-v0.2/src/000077500000000000000000000000001341017461500147635ustar00rootroot00000000000000gsettings-qt-v0.2/src/QGSettings000066400000000000000000000000301341017461500167270ustar00rootroot00000000000000#include "qgsettings.h" gsettings-qt-v0.2/src/gsettings-qt.pro000066400000000000000000000012741341017461500201420ustar00rootroot00000000000000TEMPLATE = lib INCLUDEPATH += . QT -= gui CONFIG += qt no_keywords link_pkgconfig create_pc create_prl no_install_prl PKGCONFIG += gio-2.0 TARGET = gsettings-qt HEADERS = qgsettings.h util.h qconftypes.h SOURCES = qgsettings.cpp util.cpp qconftypes.cpp target.path = $$[QT_INSTALL_LIBS] INSTALLS += target headers.path = $$[QT_INSTALL_HEADERS]/QGSettings headers.files = qgsettings.h QGSettings INSTALLS += headers QMAKE_PKGCONFIG_NAME = GSettingsQt QMAKE_PKGCONFIG_DESCRIPTION = Qt bindings to GSettings QMAKE_PKGCONFIG_PREFIX = $$INSTALLBASE QMAKE_PKGCONFIG_LIBDIR = $$target.path QMAKE_PKGCONFIG_INCDIR = $$headers.path QMAKE_PKGCONFIG_VERSION = $$VERSION QMAKE_PKGCONFIG_DESTDIR = pkgconfig gsettings-qt-v0.2/src/qconftypes.cpp000066400000000000000000000230121341017461500176600ustar00rootroot00000000000000/* * Copyright © 2011 Canonical Limited * * This library is free software: you can redistribute it and/or modify it under the terms of version 3 of the * GNU Lesser General Public License as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public License along with this program. If not, * see . * * Author: Ryan Lortie */ #include "qconftypes.h" #include /* This file is responsible for conversion between C++ values and GVariant *. * * We use the QVariant type system (but not QVariant) to express the types of native C++ values. This is * necessary because we must expose these types to Qt via the QMetaObject system. * * GSettings uses the GVariant type system to specify the types of the keys in a schema. * * We therefore have a non-injective, non-surjective partial function from GVariant types to QVariant types. * * The non-injectivity is mandated by the fact that the QVariant type system is less expressive than the * GVariant type system when it comes to specifying the sizes of integers. The non-surjectivity is mandated by * the fact that the GVariant type system has less breadth than the QVariant type system (no date, time, font, * etc. types). * * Due to the non-injectivity, we can only ever go in the direction from GVariant to QVariant; all native type * to GVariant conversions must be done in the presence of GVariant type information. For example, we are * unsure if 'Int' is supposed to be a 32 or 16 bit integer. * * The function is partial: not all GVariant types are handled. This can be improved in the future, but for now * it is probably sufficient to handle the common types that are used in 99% of cases. * * GVariant Type Name/Code C++ Type Name QVariant Type Name * -------------------------------------------------------------------------- * boolean b bool QVariant::Bool * byte y char QVariant::Char * int16 n int QVariant::Int * uint16 q unsigned int QVariant::UInt * int32 i int QVariant::Int * uint32 u unsigned int QVariant::UInt * int64 x long long QVariant::LongLong * uint64 t unsigned long long QVariant::ULongLong * double d double QVariant::Double * string s QString QVariant::String * string array* as QStringList QVariant::StringList * byte array ay QByteArray QVariant::ByteArray * dictionary a{ss} QVariantMap QVariant::Map * * [*] not strictly an array, but called as such for sake of * consistency with the 'a' appearing in the DBus type system * * We provide three functions here: the (one-way) mapping from GVariantType to QVariant::Type, plus two helpers * for converting GVariant to and from native C++ types. The signatures of these helpers are decided by the * fact that they always need to know the GVariant type information (as discussed above). * * The three functions should all be kept completely in sync with each other in terms of what types they support * and how they elect to map those types. Not-reached assertions are used in the two value conversion functions * in the cases that the type conversion function would have failed (ie: that could should be unreachable). */ QVariant::Type qconf_types_convert(const GVariantType *gtype) { switch (g_variant_type_peek_string(gtype)[0]) { case G_VARIANT_CLASS_BOOLEAN: return QVariant::Bool; case G_VARIANT_CLASS_BYTE: return QVariant::Char; case G_VARIANT_CLASS_INT16: return QVariant::Int; case G_VARIANT_CLASS_UINT16: return QVariant::UInt; case G_VARIANT_CLASS_INT32: return QVariant::Int; case G_VARIANT_CLASS_UINT32: return QVariant::UInt; case G_VARIANT_CLASS_INT64: return QVariant::LongLong; case G_VARIANT_CLASS_UINT64: return QVariant::ULongLong; case G_VARIANT_CLASS_DOUBLE: return QVariant::Double; case G_VARIANT_CLASS_STRING: return QVariant::String; case G_VARIANT_CLASS_ARRAY: if (g_variant_type_equal(gtype, G_VARIANT_TYPE_STRING_ARRAY)) return QVariant::StringList; else if (g_variant_type_equal(gtype, G_VARIANT_TYPE_BYTESTRING)) return QVariant::ByteArray; else if (g_variant_type_equal(gtype, G_VARIANT_TYPE ("a{ss}"))) return QVariant::Map; // fall through default: return QVariant::Invalid; } } QVariant qconf_types_to_qvariant(GVariant *value) { switch (g_variant_classify(value)) { case G_VARIANT_CLASS_BOOLEAN: return QVariant((bool) g_variant_get_boolean(value)); case G_VARIANT_CLASS_BYTE: return QVariant((char) g_variant_get_byte(value)); case G_VARIANT_CLASS_INT16: return QVariant((int) g_variant_get_int16(value)); case G_VARIANT_CLASS_UINT16: return QVariant((unsigned int) g_variant_get_uint16(value)); case G_VARIANT_CLASS_INT32: return QVariant((int) g_variant_get_int32(value)); case G_VARIANT_CLASS_UINT32: return QVariant((unsigned int) g_variant_get_uint32(value)); case G_VARIANT_CLASS_INT64: return QVariant((long long) g_variant_get_int64(value)); case G_VARIANT_CLASS_UINT64: return QVariant((unsigned long long) g_variant_get_uint64(value)); case G_VARIANT_CLASS_DOUBLE: return QVariant(g_variant_get_double(value)); case G_VARIANT_CLASS_STRING: return QVariant(g_variant_get_string(value, NULL)); case G_VARIANT_CLASS_ARRAY: if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING_ARRAY)) { GVariantIter iter; QStringList list; const gchar *str; g_variant_iter_init (&iter, value); while (g_variant_iter_next (&iter, "&s", &str)) list.append (str); return QVariant(list); } else if (g_variant_is_of_type(value, G_VARIANT_TYPE_BYTESTRING)) { return QVariant(QByteArray(g_variant_get_bytestring(value))); } else if (g_variant_is_of_type(value, G_VARIANT_TYPE("a{ss}"))) { GVariantIter iter; QMap map; const gchar *key; const gchar *val; g_variant_iter_init (&iter, value); while (g_variant_iter_next (&iter, "{&s&s}", &key, &val)) map.insert(key, QVariant(val)); return map; } // fall through default: g_assert_not_reached(); } } GVariant *qconf_types_collect_from_variant(const GVariantType *gtype, const QVariant &v) { switch (g_variant_type_peek_string(gtype)[0]) { case G_VARIANT_CLASS_BOOLEAN: return g_variant_new_boolean(v.toBool()); case G_VARIANT_CLASS_BYTE: return g_variant_new_byte(v.toChar().cell()); case G_VARIANT_CLASS_INT16: return g_variant_new_int16(v.toInt()); case G_VARIANT_CLASS_UINT16: return g_variant_new_uint16(v.toUInt()); case G_VARIANT_CLASS_INT32: return g_variant_new_int32(v.toInt()); case G_VARIANT_CLASS_UINT32: return g_variant_new_uint32(v.toUInt()); case G_VARIANT_CLASS_INT64: return g_variant_new_int64(v.toLongLong()); case G_VARIANT_CLASS_UINT64: return g_variant_new_int64(v.toULongLong()); case G_VARIANT_CLASS_DOUBLE: return g_variant_new_double(v.toDouble()); case G_VARIANT_CLASS_STRING: return g_variant_new_string(v.toString().toUtf8()); case G_VARIANT_CLASS_ARRAY: if (g_variant_type_equal(gtype, G_VARIANT_TYPE_STRING_ARRAY)) { const QStringList list = v.toStringList(); GVariantBuilder builder; g_variant_builder_init(&builder, G_VARIANT_TYPE_STRING_ARRAY); Q_FOREACH (const QString& string, list) g_variant_builder_add(&builder, "s", string.toUtf8().constData()); return g_variant_builder_end(&builder); } else if (g_variant_type_equal(gtype, G_VARIANT_TYPE_BYTESTRING)) { const QByteArray array = v.toByteArray(); gsize size = array.size(); gpointer data; data = g_memdup(array.data(), size); return g_variant_new_from_data(G_VARIANT_TYPE_BYTESTRING, data, size, TRUE, g_free, data); } else if (g_variant_type_equal(gtype, G_VARIANT_TYPE("a{ss}"))) { GVariantBuilder builder; g_variant_builder_init(&builder, G_VARIANT_TYPE ("a{ss}")); QMapIterator it(v.toMap()); while (it.hasNext()) { it.next(); QByteArray key = it.key().toUtf8(); QByteArray val = it.value().toByteArray(); g_variant_builder_add (&builder, "{ss}", key.constData(), val.constData()); } return g_variant_builder_end (&builder); } // fall through default: return NULL; } } // vim:sw=4 tw=112 gsettings-qt-v0.2/src/qconftypes.h000066400000000000000000000021761341017461500173350ustar00rootroot00000000000000/* * Copyright © 2011 Canonical Limited * * This library is free software: you can redistribute it and/or modify it under the terms of version 3 of the * GNU Lesser General Public License as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public License along with this program. If not, * see . * * Author: Ryan Lortie */ #ifndef _qconftypes_h_ #define _qconftypes_h_ #include #include QVariant::Type qconf_types_convert(const GVariantType *gtype); GVariant * qconf_types_collect(const GVariantType *gtype, const void *argument); GVariant *qconf_types_collect_from_variant(const GVariantType *gtype, const QVariant &v); void qconf_types_unpack(GVariant *value, void *argument); QVariant qconf_types_to_qvariant(GVariant *value); #endif /* _qconftypes_h_ */ gsettings-qt-v0.2/src/qgsettings.cpp000066400000000000000000000115111341017461500176560ustar00rootroot00000000000000/* * Copyright 2013 Canonical Ltd. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; version 3. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Author: Lars Uebernickel */ #include "qgsettings.h" #include "qconftypes.h" #include "util.h" #include struct QGSettingsPrivate { QByteArray schema_id; QByteArray path; GSettings *settings; GSettingsSchema *schema; gulong signal_handler_id; static void settingChanged(GSettings *settings, const gchar *key, gpointer user_data); }; void QGSettingsPrivate::settingChanged(GSettings *, const gchar *key, gpointer user_data) { QGSettings *self = (QGSettings *)user_data; // work around https://bugreports.qt.io/browse/QTBUG-32859 and http://pad.lv/1460970 QMetaObject::invokeMethod(self, "changed", Qt::QueuedConnection, Q_ARG(QString, qtify_name(key))); } QGSettings::QGSettings(const QByteArray &schema_id, const QByteArray &path, QObject *parent): QObject(parent) { priv = new QGSettingsPrivate; priv->schema_id = schema_id; priv->path = path; if (priv->path.isEmpty()) priv->settings = g_settings_new(priv->schema_id.constData()); else priv->settings = g_settings_new_with_path(priv->schema_id.constData(), priv->path.constData()); g_object_get (priv->settings, "settings-schema", &priv->schema, NULL); priv->signal_handler_id = g_signal_connect(priv->settings, "changed", G_CALLBACK(QGSettingsPrivate::settingChanged), this); } QGSettings::~QGSettings() { if (priv->schema) { g_settings_sync (); g_signal_handler_disconnect(priv->settings, priv->signal_handler_id); g_object_unref (priv->settings); g_settings_schema_unref (priv->schema); } delete priv; } QVariant QGSettings::get(const QString &key) const { gchar *gkey = unqtify_name(key); GVariant *value = g_settings_get_value(priv->settings, gkey); QVariant qvalue = qconf_types_to_qvariant(value); g_variant_unref(value); g_free(gkey); return qvalue; } void QGSettings::set(const QString &key, const QVariant &value) { if (!this->trySet(key, value)) qWarning("unable to set key '%s' to value '%s'", key.toUtf8().constData(), value.toString().toUtf8().constData()); } bool QGSettings::trySet(const QString &key, const QVariant &value) { gchar *gkey = unqtify_name(key); bool success = false; /* fetch current value to find out the exact type */ GVariant *cur = g_settings_get_value(priv->settings, gkey); GVariant *new_value = qconf_types_collect_from_variant(g_variant_get_type (cur), value); if (new_value) success = g_settings_set_value(priv->settings, gkey, new_value); g_free(gkey); g_variant_unref (cur); return success; } QStringList QGSettings::keys() const { QStringList list; gchar **keys = g_settings_list_keys(priv->settings); for (int i = 0; keys[i]; i++) list.append(qtify_name(keys[i])); g_strfreev(keys); return list; } QVariantList QGSettings::choices(const QString &qkey) const { gchar *key = unqtify_name (qkey); GSettingsSchemaKey *schema_key = g_settings_schema_get_key (priv->schema, key); GVariant *range = g_settings_schema_key_get_range(schema_key); g_settings_schema_key_unref (schema_key); g_free(key); if (range == NULL) return QVariantList(); const gchar *type; GVariant *value; g_variant_get(range, "(&sv)", &type, &value); QVariantList choices; if (g_str_equal(type, "enum")) { GVariantIter iter; GVariant *child; g_variant_iter_init (&iter, value); while ((child = g_variant_iter_next_value(&iter))) { choices.append(qconf_types_to_qvariant(child)); g_variant_unref(child); } } g_variant_unref (value); g_variant_unref (range); return choices; } void QGSettings::reset(const QString &qkey) { gchar *key = unqtify_name(qkey); g_settings_reset(priv->settings, key); g_free(key); } bool QGSettings::isSchemaInstalled(const QByteArray &schema_id) { GSettingsSchemaSource *source = g_settings_schema_source_get_default (); GSettingsSchema *schema = g_settings_schema_source_lookup (source, schema_id.constData(), TRUE); if (schema) { g_settings_schema_unref (schema); return true; } else { return false; } } gsettings-qt-v0.2/src/qgsettings.h000066400000000000000000000066571341017461500173420ustar00rootroot00000000000000/* * Copyright 2013 Canonical Ltd. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; version 3. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Author: Lars Uebernickel */ #ifndef __QGSETTINGS_H__ #define __QGSETTINGS_H__ #include #include /** * @brief QGSettings provides access to application settings stored with GSettings. * * GSettings does not allow keys to contain anything other than lower-case * characters and dashes. This class converts all keys to camelCase, to make it easier * for people used to Qt's naming convention. */ class QGSettings: public QObject { Q_OBJECT public: /** * @brief Create a QGSettings object for a given schema_id and path. * @param schema_id The id of the schema * @param path If non-empty, specifies the path for a relocatable schema */ QGSettings(const QByteArray &schema_id, const QByteArray &path = QByteArray(), QObject *parent = NULL); ~QGSettings(); /** * @brief Gets the value that is stored at key * @param key The key for which to retrieve the value (in camelCase) * * It is an error if key does not exist in the schema associated with this * QGSettings object. */ QVariant get(const QString &key) const; /** * @brief Sets the value at key to value * @key The key for which to set the value (in camelCase) * @value The value to set * * It is an error if key does not exist in the schema associated with this * QGSettings object. * * Not all values that a QVariant can hold can be serialized into a * setting. Basic types (integers, doubles, strings) and string lists are * supported. */ void set(const QString &key, const QVariant &value); /** * @brief Sets the value at key to value * @key The key for which to set the value * @value The value to set * * Behaves just like ::set(key, value), but returns false instead of * printing a warning if the key couldn't be set. * * @return whether the key was set */ bool trySet(const QString &key, const QVariant &value); /** * \brief Retrieves the list of avaliable keys */ QStringList keys() const; /** * \brief Returns the list of values that key can assume * * Returns an empty list if the schema doesn't contain that information for * the key. */ QVariantList choices(const QString &key) const; /** * @brief Resets the setting for @key to its default value. */ void reset(const QString &key); /** * @brief Checks if a schema with the given id is installed. */ static bool isSchemaInstalled(const QByteArray &schema_id); Q_SIGNALS: /** * \brief Emitted when the value associated with key has changed */ void changed(const QString &key); private: struct QGSettingsPrivate *priv; friend struct QGSettingsPrivate; }; #endif gsettings-qt-v0.2/src/util.cpp000066400000000000000000000037551341017461500164560ustar00rootroot00000000000000/* * Copyright 2013 Canonical Ltd. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; version 3. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Authors: Lars Uebernickel * Ryan Lortie */ #include #include /* convert 'some-key' to 'someKey' or 'SomeKey'. * the second form is needed for appending to 'set' for 'setSomeKey' */ QString qtify_name(const char *name) { bool next_cap = false; QString result; while (*name) { if (*name == '-') { next_cap = true; } else if (next_cap) { result.append(QChar(*name).toUpper().toLatin1()); next_cap = false; } else { result.append(*name); } name++; } return result; } /* Convert 'someKey' to 'some-key' * * This is the inverse function of qtify_name, iff qtify_name was called with a * valid gsettings key name (no capital letters, no consecutive dashes). * * Returns a newly-allocated string. */ gchar * unqtify_name(const QString &name) { const gchar *p; QByteArray bytes; GString *str; bytes = name.toUtf8(); str = g_string_new (NULL); for (p = bytes.constData(); *p; p++) { const QChar c(*p); if (c.isUpper()) { g_string_append_c (str, '-'); g_string_append_c (str, c.toLower().toLatin1()); } else { g_string_append_c (str, *p); } } return g_string_free(str, FALSE); } gsettings-qt-v0.2/src/util.h000066400000000000000000000015331341017461500161130ustar00rootroot00000000000000/* * Copyright 2013 Canonical Ltd. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; version 3. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Author: Lars Uebernickel */ #ifndef __UTIL_H__ #define __UTIL_H__ #include QString qtify_name(const char *name); gchar * unqtify_name(const QString &name); #endif gsettings-qt-v0.2/tests/000077500000000000000000000000001341017461500153365ustar00rootroot00000000000000gsettings-qt-v0.2/tests/com.ubports.gsettings.test.gschema.xml000066400000000000000000000015671341017461500247360ustar00rootroot00000000000000 42 1.5 false "hello" 'one' ['one', 'two', 'three'] {'foo': 'one', 'bar': 'two'} gsettings-qt-v0.2/tests/cpptest.cpp000066400000000000000000000017541341017461500175330ustar00rootroot00000000000000#include #include class TestDeferredDelete: public QObject { Q_OBJECT private slots: void initTestCase(); void test_deferredDelete(); private: QGSettings * settings; QPointer dummy; }; void TestDeferredDelete::initTestCase() { settings = new QGSettings("com.ubports.gsettings.Test", QByteArray(), this); dummy = new QObject; connect(settings, &QGSettings::changed, dummy.data(), &QObject::deleteLater); // delete the dummy object upon any gsettings change } void TestDeferredDelete::test_deferredDelete() { QSignalSpy spy(dummy.data(), &QObject::destroyed); // watch the dummy object get destroyed settings->set("testString", "bar"); QVERIFY(spy.wait(1)); QVERIFY(dummy.isNull()); // verify dummy got destroyed for real QCOMPARE(settings->get("testString").toString(), QStringLiteral("bar")); // also verify the setting got written by reading it back } QTEST_MAIN(TestDeferredDelete) #include "cpptest.moc" gsettings-qt-v0.2/tests/cpptest.pro000066400000000000000000000006261341017461500175460ustar00rootroot00000000000000TEMPLATE = app QT += testlib QT -= gui CONFIG += testcase link_pkgconfig TARGET = cpptest IMPORTPATH = $$PWD/.. SOURCES = cpptest.cpp INCLUDEPATH += $$(PWD)/../src LIBS += -L$$(PWD)/../src -lgsettings-qt schema.target = gschemas.compiled schema.commands = glib-compile-schemas $$PWD schema.depends = com.ubports.gsettings.test.gschema.xml QMAKE_EXTRA_TARGETS += schema PRE_TARGETDEPS = gschemas.compiled gsettings-qt-v0.2/tests/manual000066400000000000000000000013441341017461500165400ustar00rootroot00000000000000 Test-case gsettings-qt/unity8-check-setting
Open system settings with the security panel
Ensure "Dash search" is set to "Phone and Internet"
Change "Dash search" to "Phone only"
Ensure that the music and video lenses don't show online content
Test-case gsettings-qt/run-example
Download the choices example and run it with qmlscene
Ensure that the switch is synchronized with the "Dash Search" setting in the security panel of system settings
Ensure that the "Possible values" list item has a value of "all, none"
gsettings-qt-v0.2/tests/test.cpp000066400000000000000000000000771341017461500170250ustar00rootroot00000000000000#include QUICK_TEST_MAIN(GSettings) gsettings-qt-v0.2/tests/tests.pro000066400000000000000000000005431341017461500172240ustar00rootroot00000000000000TEMPLATE = app QT += qml testlib QT -= gui CONFIG += qmltestcase TARGET = test IMPORTPATH = $$PWD/.. SOURCES = test.cpp schema.target = gschemas.compiled schema.commands = glib-compile-schemas $$PWD schema.depends = com.ubports.gsettings.test.gschema.xml QMAKE_EXTRA_TARGETS += schema PRE_TARGETDEPS = gschemas.compiled OTHER_FILES += tst_GSettings.qml gsettings-qt-v0.2/tests/tst_GSettings.qml000066400000000000000000000057201341017461500206560ustar00rootroot00000000000000 import QtTest 1.0 import "../GSettings" 1.0 import QtQuick 2.0 TestCase { id: testCase property var changes: [] GSettings { id: settings schema.id: "com.ubports.gsettings.Test" // has to be "valueChanged" signal, not "changed"; the latter doesn't work reliably with the in-memory gsettings backend onValueChanged: changes.push([key, value]); } SignalSpy { id: changesSpy target: settings signalName: "changed" } GSettings { id: invalid_settings schema.id: "com.ubports.gsettings.NonExisting" } property string bindingTest: settings.testString // this test must run first (others overwrite keys), hence the 'aaa' function test_aaa_read_defaults() { compare(settings.schema.isValid, true); compare(settings.testInteger, 42); compare(settings.testDouble, 1.5); compare(settings.testBoolean, false); compare(settings.testString, 'hello'); compare(settings.testStringList, ['one', 'two', 'three']); compare(settings.testMap, {'foo': 'one', 'bar': 'two'}); compare(testCase.bindingTest, 'hello'); } function test_write() { settings.testInteger = 2; compare(settings.testInteger, 2); settings.testDouble = 2.5; compare(settings.testDouble, 2.5); settings.testBoolean = true; compare(settings.testBoolean, true); settings.testString = 'bye'; compare(settings.testString, 'bye'); compare(testCase.bindingTest, 'bye'); settings.testStringList = ['four', 'five'] compare(settings.testStringList, ['four', 'five']); settings.testStringList = ['six'] compare(settings.testStringList, ['six']); settings.testStringList = []; compare(settings.testStringList, []); settings.testMap = {'baz': 'three'} compare(settings.testMap, {'baz': 'three'}); settings.testMap = {}; compare(settings.testMap, {}); settings.testEnum = 'two'; compare(settings.testEnum, 'two'); // test whether writing an out-of-range key doesn't work settings.testEnum = 'notanumber'; compare(settings.testEnum, 'two'); } function test_changed() { changes = [] settings.testInteger = 4; settings.testDouble = 3.14 settings.testString = 'goodbye'; compare(changes, [['testInteger', 4], ['testDouble', 3.14], ['testString', 'goodbye']]); } function test_choices() { compare(settings.schema.choices('testEnum'), ['one', 'two', 'three']); compare(settings.schema.choices('testInteger'), []); } function test_non_existing() { compare(settings.schema.aKeyThatsNotInTheSchema, undefined); compare(settings.schema.choices('aKeyThatsNotInTheSchema'), []); } function test_reset() { settings.testInteger = 4; changesSpy.clear(); settings.schema.reset('testInteger'); compare(settings.testInteger, 42); tryCompare(changesSpy, "count", 1); } function test_invalid_schema() { compare(invalid_settings.schema.isValid, false); compare(invalid_settings.schema.testInteger, undefined); } }