@@ -20,7 +20,9 @@
2020
2121GSettingsControllerQml* GSettingsControllerQml::s_controllerInstance = 0;
2222
23−GSettingsControllerQml::GSettingsControllerQml() {
23+GSettingsControllerQml::GSettingsControllerQml()
24+ : m_usageMode("Staged")
25+{
2426}
2527
2628GSettingsControllerQml::~GSettingsControllerQml() {
@@ -34,17 +36,29 @@ GSettingsControllerQml* GSettingsControllerQml::instance() {
3436 return s_controllerInstance;
3537}
3638
37−void GSettingsControllerQml::registerSettingsObject(GSettingsQml *obj) {
38− m_registeredGSettings.append(obj);
39+QString GSettingsControllerQml::pictureUri() const
40+{
41+ return m_pictureUri;
42+}
43+
44+void GSettingsControllerQml::setPictureUri(const QString &str)
45+{
46+ if (str != m_pictureUri) {
47+ m_pictureUri = str;
48+ Q_EMIT pictureUriChanged(m_pictureUri);
49+ }
3950}
4051
41−void GSettingsControllerQml::unRegisterSettingsObject(GSettingsQml *obj) {
42− m_registeredGSettings.removeOne(obj);
52+QString GSettingsControllerQml::usageMode() const
53+{
54+ return m_usageMode;
4355}
4456
45−void GSettingsControllerQml::setPictureUri(const QString &str) {
46− Q_FOREACH (GSettingsQml *obj, m_registeredGSettings) {
47− obj->setPictureUri(str);
57+void GSettingsControllerQml::setUsageMode(const QString &usageMode)
58+{
59+ if (usageMode != m_usageMode) {
60+ m_usageMode = usageMode;
61+ Q_EMIT usageModeChanged(m_usageMode);
4862 }
4963}
5064
@@ -56,7 +70,7 @@ QByteArray GSettingsSchemaQml::id() const {
5670}
5771
5872void GSettingsSchemaQml::setId(const QByteArray &id) {
59− if (m_id.isEmpty()) {
73+ if (!m_id.isEmpty()) {
6074 qWarning("GSettings.schema.id may only be set on construction");
6175 return;
6276 }
@@ -69,7 +83,7 @@ QByteArray GSettingsSchemaQml::path() const {
6983}
7084
7185void GSettingsSchemaQml::setPath(const QByteArray &path) {
72− if (m_path.isEmpty()) {
86+ if (!m_path.isEmpty()) {
7387 qWarning("GSettings.schema.path may only be set on construction");
7488 return;
7589 }
@@ -77,26 +91,48 @@ void GSettingsSchemaQml::setPath(const QByteArray &path) {
7791 m_path = path;
7892}
7993
80−GSettingsQml::GSettingsQml(QObject *parent): QObject(parent) {
94+GSettingsQml::GSettingsQml(QObject *parent)
95+ : QObject(parent)
96+{
8197 m_schema = new GSettingsSchemaQml(this);
82− GSettingsControllerQml::instance()->registerSettingsObject(this);
83−}
84−
85−GSettingsQml::~GSettingsQml() {
86− GSettingsControllerQml::instance()->unRegisterSettingsObject(this);
98+ connect(GSettingsControllerQml::instance(), SIGNAL(pictureUriChanged(const QString &)),
99+ this, SIGNAL(pictureUriChanged(const QString &)));
100+ connect(GSettingsControllerQml::instance(), SIGNAL(usageModeChanged(const QString &)),
101+ this, SIGNAL(usageModeChanged(const QString &)));
87102}
88103
89104GSettingsSchemaQml * GSettingsQml::schema() const {
90105 return m_schema;
91106}
92107
93−QString GSettingsQml::pictureUri() const {
94− return m_pictureUri;
108+QString GSettingsQml::pictureUri() const
109+{
110+ if (m_schema->id() == "org.gnome.desktop.background") {
111+ return GSettingsControllerQml::instance()->pictureUri();
112+ } else {
113+ return "";
114+ }
95115}
96116
97−void GSettingsQml::setPictureUri(const QString &str) {
98− if (str != m_pictureUri) {
99− m_pictureUri = str;
100− Q_EMIT pictureUriChanged(m_pictureUri);
117+void GSettingsQml::setPictureUri(const QString &str)
118+{
119+ if (m_schema->id() == "org.gnome.desktop.background") {
120+ GSettingsControllerQml::instance()->setPictureUri(str);
121+ }
122+}
123+
124+QString GSettingsQml::usageMode() const
125+{
126+ if (m_schema->id() == "com.canonical.Unity8") {
127+ return GSettingsControllerQml::instance()->usageMode();
128+ } else {
129+ return "";
130+ }
131+}
132+
133+void GSettingsQml::setUsageMode(const QString &usageMode)
134+{
135+ if (m_schema->id() == "com.canonical.Unity8") {
136+ GSettingsControllerQml::instance()->setUsageMode(usageMode);
101137 }
102138}