on db15929 help sign in
unity8/qml/Components/Unity8Settings.qml
50 lines 1.8 kB history raw
1/*
2 * Copyright (C) 2015 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
17import QtQuick 2.0
18import GSettings 1.0
20QtObject {
21 id: root
23 property string usageMode: "Staged"
25 // FIXME: Works around a bug where if we change a Loader's source in response to a GSettings
26 // property change in the same event loop, the Loader's previously loaded component does not
27 // get destroyed and its bindings continue to operate!
28 //
29 // Shouldn't be needed after
30 // https://code.launchpad.net/~lukas-kde/gsettings-qt/queued-processing/+merge/259883 gets
31 // merged.
32 property var timer: Timer {
33 interval: 1
34 onTriggered: { root.usageMode = root.wrapped.usageMode; }
35 }
36 property var wrappedConnections: Connections {
37 target: root.wrapped
38 ignoreUnknownSignals: true // don't spam us
39 onUsageModeChanged: { root.timer.start(); }
40 }
41 property var wrapped: GSettings {
42 schema.id: "com.canonical.Unity8"
43 Component.onCompleted: {
44 // init the value. it's a dynamic prop, so we have to check first
45 if (root.usageMode) {
46 root.usageMode = root.wrapped.usageMode;
47 }
48 }
49 }