on xenial help sign in
Move common wallpaper code to BasicShell
c2da3c7Michael Terry
Components/BasicShell.qml+11−12
@@ -14,7 +14,6 @@
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
15 */
16
16
17−import GSettings 1.0
18import QtQuick 2.0
17import QtQuick 2.0
19import Ubuntu.Components 0.1
18import Ubuntu.Components 0.1
20import "../Components"
19import "../Components"
@@ -29,17 +28,12 @@ FocusScope {
29 height: tablet ? units.gu(100) : applicationArguments.hasGeometry() ? applicationArguments.height() : units.gu(71)
28 height: tablet ? units.gu(100) : applicationArguments.hasGeometry() ? applicationArguments.height() : units.gu(71)
30
29
31 property real edgeSize: units.gu(2)
30 property real edgeSize: units.gu(2)
31+
32 property url defaultBackground: shell.width >= units.gu(60) ? "../graphics/tablet_background.jpg" : "../graphics/phone_background.jpg"
32 property url defaultBackground: shell.width >= units.gu(60) ? "../graphics/tablet_background.jpg" : "../graphics/phone_background.jpg"
33 property url background
33 property url background
34−
34+ property url backgroundSource
35− GSettings {
35+ property url backgroundFinal: backgroundSource != undefined && backgroundSource != "" ? backgroundSource : shell.defaultBackground
36− id: backgroundSettings
36+ onBackgroundFinalChanged: shell.background = backgroundFinal
37− schema.id: "org.gnome.desktop.background"
38− }
39− property url gSettingsPicture: backgroundSettings.pictureUri != undefined && backgroundSettings.pictureUri.length > 0 ? backgroundSettings.pictureUri : shell.defaultBackground
40− onGSettingsPictureChanged: {
41− shell.background = gSettingsPicture
42− }
43
37
44 // This is a dummy image that is needed to determine if the picture url
38 // This is a dummy image that is needed to determine if the picture url
45 // in backgroundSettings points to a valid picture file.
39 // in backgroundSettings points to a valid picture file.
@@ -56,8 +50,13 @@ FocusScope {
56 sourceSize.height: 0
50 sourceSize.height: 0
57 sourceSize.width: 0
51 sourceSize.width: 0
58 onStatusChanged: {
52 onStatusChanged: {
53+ if (status == Image.Error) {
59− if (status == Image.Error && source != shell.defaultBackground) {
54+ if (source != shell.defaultBackground) {
60− shell.background = defaultBackground
55+ shell.background = defaultBackground
56+ } else {
57+ // In case even our default background fails to load...
58+ shell.background = "data:image/svg+xml,<svg><rect width='100%' height='100%' fill='#000'/></svg>"
59+ }
61 }
60 }
62 }
61 }
63 }
62 }
Greeter/Greeter.qml+1−1
@@ -24,7 +24,7 @@ import "../Components/Math.js" as MathLocal
24Showable {
24Showable {
25 id: greeter
25 id: greeter
26 enabled: shown
26 enabled: shown
27− created: greeterContentLoader.status == Loader.Ready && greeterContentLoader.item.ready
27+ created: greeterContentLoader.status == Loader.Ready
28
28
29 // 1 when fully shown and 0 when fully hidden
29 // 1 when fully shown and 0 when fully hidden
30 property real showProgress: MathLocal.clamp((width + x) / width, 0, 1)
30 property real showProgress: MathLocal.clamp((width + x) / width, 0, 1)
Greeter/GreeterContent.qml−32
@@ -24,7 +24,6 @@ MouseArea {
24 id: root
24 id: root
25 anchors.fill: parent
25 anchors.fill: parent
26
26
27− property bool ready: wallpaper.source == "" || wallpaper.status == Image.Ready || wallpaper.status == Image.Error
28 property bool leftTeaserPressed: teasingMouseArea.pressed &&
27 property bool leftTeaserPressed: teasingMouseArea.pressed &&
29 teasingMouseArea.mouseX < teasingMouseArea.width / 2
28 teasingMouseArea.mouseX < teasingMouseArea.width / 2
30 property bool rightTeaserPressed: teasingMouseArea.pressed &&
29 property bool rightTeaserPressed: teasingMouseArea.pressed &&
@@ -33,37 +32,6 @@ MouseArea {
33 signal selected(int uid)
32 signal selected(int uid)
34 signal unlocked(int uid)
33 signal unlocked(int uid)
35
34
36− Rectangle {
37− // In case wallpaper fails to load
38− id: wallpaperBackup
39− anchors.fill: parent
40− color: "black"
41− }
42−
43− property url backgroundValue: AccountsService.backgroundFile != undefined && AccountsService.backgroundFile.length > 0 ? AccountsService.backgroundFile : shell.defaultBackground
44− onBackgroundValueChanged: wallpaper.source = backgroundValue
45−
46− CrossFadeImage {
47− id: wallpaper
48− anchors.fill: parent
49− fadeInFirst: false
50− }
51−
52− // See Shell.qml's backgroundSettings treatment for why we need a separate
53− // Image, but it boils down to avoiding binding loop detection.
54− Image {
55− source: wallpaper.source
56− height: 0
57− width: 0
58− sourceSize.height: 0
59− sourceSize.width: 0
60− onStatusChanged: {
61− if (status == Image.Error && source != shell.defaultBackground) {
62− wallpaper.source = shell.defaultBackground
63− }
64− }
65− }
66−
67 Rectangle {
35 Rectangle {
68 anchors.fill: parent
36 anchors.fill: parent
69 color: "black"
37 color: "black"
Greeter/Lockscreen.qml−7
@@ -53,13 +53,6 @@ Showable {
53 pinPadLoader.resetting = false;
53 pinPadLoader.resetting = false;
54 }
54 }
55
55
56− Rectangle {
57− // In case wallpaper fails to load or is undefined
58− id: wallpaperBackup
59− anchors.fill: parent
60− color: "black"
61− }
62−
63 Image {
56 Image {
64 id: wallpaper
57 id: wallpaper
65 anchors.fill: parent
58 anchors.fill: parent
GreeterShell.qml+10
@@ -16,6 +16,7 @@
16
16
17import QtQuick 2.0
17import QtQuick 2.0
18import Ubuntu.Application 0.1
18import Ubuntu.Application 0.1
19+import AccountsService 0.1
19import LightDM 0.1 as LightDM
20import LightDM 0.1 as LightDM
20import SessionBroadcast 0.1
21import SessionBroadcast 0.1
21import "Greeter"
22import "Greeter"
@@ -32,6 +33,15 @@ BasicShell {
32 greeter.hide()
33 greeter.hide()
33 }
34 }
34
35
36+ backgroundSource: AccountsService.backgroundFile
37+
38+ CrossFadeImage {
39+ id: backgroundImage
40+ anchors.fill: parent
41+ fadeInFirst: false
42+ source: shell.background
43+ }
44+
35 Lockscreen {
45 Lockscreen {
36 id: lockscreen
46 id: lockscreen
37 hides: [launcher, panel.indicators]
47 hides: [launcher, panel.indicators]
Shell.qml+7
@@ -19,6 +19,7 @@ import Ubuntu.Application 0.1
19import Ubuntu.Components 0.1
19import Ubuntu.Components 0.1
20import Ubuntu.Gestures 0.1
20import Ubuntu.Gestures 0.1
21import Unity.Launcher 0.1
21import Unity.Launcher 0.1
22+import GSettings 1.0
22import Powerd 0.1
23import Powerd 0.1
23import SessionManager 0.1
24import SessionManager 0.1
24import "Dash"
25import "Dash"
@@ -111,6 +112,12 @@ BasicShell {
111 }
112 }
112 }
113 }
113
114
115+ GSettings {
116+ id: backgroundSettings
117+ schema.id: "org.gnome.desktop.background"
118+ }
119+ backgroundSource: backgroundSettings.pictureUri
120+
114 Item {
121 Item {
115 id: underlay
122 id: underlay
116 objectName: "underlay"
123 objectName: "underlay"
plugins/AccountsService/AccountsBindings.cpp+2−2
@@ -23,14 +23,14 @@
23
23
24AccountsBindings::AccountsBindings(QObject* parent)
24AccountsBindings::AccountsBindings(QObject* parent)
25 : QObject(parent),
25 : QObject(parent),
26− m_service(new AccountsService(this)),
26+ m_service(new AccountsService(this))
27− m_user(qgetenv("USER"))
28{
27{
29 connect(m_service, SIGNAL(propertiesChanged(const QString &, const QString &, const QStringList &)),
28 connect(m_service, SIGNAL(propertiesChanged(const QString &, const QString &, const QStringList &)),
30 this, SLOT(propertiesChanged(const QString &, const QString &, const QStringList &)));
29 this, SLOT(propertiesChanged(const QString &, const QString &, const QStringList &)));
31 connect(m_service, SIGNAL(maybeChanged(const QString &)),
30 connect(m_service, SIGNAL(maybeChanged(const QString &)),
32 this, SLOT(maybeChanged(const QString &)));
31 this, SLOT(maybeChanged(const QString &)));
33
32
33+ setUser(qgetenv("USER"));
34 updateDemoEdgesForCurrentUser();
34 updateDemoEdgesForCurrentUser();
35}
35}
36
36