on xenial help sign in
Move common wallpaper code to BasicShell
commitc2da3c7f2b882128f561adcdc300cf09adf4230f authorMichael Terry <michael.terry@canonical.com> dateFri 6 Sep 2013, 14:02 (13 years ago) parent39dc6f6
7 files changed+31−54
Components/BasicShell.qml+11−12 Greeter/Greeter.qml+1−1 Greeter/GreeterContent.qml−32 Greeter/Lockscreen.qml−7 GreeterShell.qml+10 Shell.qml+7 plugins/AccountsService/AccountsBindings.cpp+2−2
Components/BasicShell.qml+11−12
@@ -14,7 +14,6 @@
1414 * along with this program. If not, see <http://www.gnu.org/licenses/>.
1515 */
1616
17−import GSettings 1.0
1817import QtQuick 2.0
1918import Ubuntu.Components 0.1
2019import "../Components"
@@ -29,17 +28,12 @@ FocusScope {
2928 height: tablet ? units.gu(100) : applicationArguments.hasGeometry() ? applicationArguments.height() : units.gu(71)
3029
3130 property real edgeSize: units.gu(2)
31+
3232 property url defaultBackground: shell.width >= units.gu(60) ? "../graphics/tablet_background.jpg" : "../graphics/phone_background.jpg"
3333 property url background
34−
35− GSettings {
36− id: backgroundSettings
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− }
34+ property url backgroundSource
35+ property url backgroundFinal: backgroundSource != undefined && backgroundSource != "" ? backgroundSource : shell.defaultBackground
36+ onBackgroundFinalChanged: shell.background = backgroundFinal
4337
4438 // This is a dummy image that is needed to determine if the picture url
4539 // in backgroundSettings points to a valid picture file.
@@ -56,8 +50,13 @@ FocusScope {
5650 sourceSize.height: 0
5751 sourceSize.width: 0
5852 onStatusChanged: {
59− if (status == Image.Error && source != shell.defaultBackground) {
60− shell.background = defaultBackground
53+ if (status == Image.Error) {
54+ if (source != shell.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+ }
6160 }
6261 }
6362 }
Greeter/Greeter.qml+1−1
@@ -24,7 +24,7 @@ import "../Components/Math.js" as MathLocal
2424Showable {
2525 id: greeter
2626 enabled: shown
27− created: greeterContentLoader.status == Loader.Ready && greeterContentLoader.item.ready
27+ created: greeterContentLoader.status == Loader.Ready
2828
2929 // 1 when fully shown and 0 when fully hidden
3030 property real showProgress: MathLocal.clamp((width + x) / width, 0, 1)
Greeter/GreeterContent.qml−32
@@ -24,7 +24,6 @@ MouseArea {
2424 id: root
2525 anchors.fill: parent
2626
27− property bool ready: wallpaper.source == "" || wallpaper.status == Image.Ready || wallpaper.status == Image.Error
2827 property bool leftTeaserPressed: teasingMouseArea.pressed &&
2928 teasingMouseArea.mouseX < teasingMouseArea.width / 2
3029 property bool rightTeaserPressed: teasingMouseArea.pressed &&
@@ -33,37 +32,6 @@ MouseArea {
3332 signal selected(int uid)
3433 signal unlocked(int uid)
3534
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−
6735 Rectangle {
6836 anchors.fill: parent
6937 color: "black"
Greeter/Lockscreen.qml−7
@@ -53,13 +53,6 @@ Showable {
5353 pinPadLoader.resetting = false;
5454 }
5555
56− Rectangle {
57− // In case wallpaper fails to load or is undefined
58− id: wallpaperBackup
59− anchors.fill: parent
60− color: "black"
61− }
62−
6356 Image {
6457 id: wallpaper
6558 anchors.fill: parent
GreeterShell.qml+10
@@ -16,6 +16,7 @@
1616
1717import QtQuick 2.0
1818import Ubuntu.Application 0.1
19+import AccountsService 0.1
1920import LightDM 0.1 as LightDM
2021import SessionBroadcast 0.1
2122import "Greeter"
@@ -32,6 +33,15 @@ BasicShell {
3233 greeter.hide()
3334 }
3435
36+ backgroundSource: AccountsService.backgroundFile
37+
38+ CrossFadeImage {
39+ id: backgroundImage
40+ anchors.fill: parent
41+ fadeInFirst: false
42+ source: shell.background
43+ }
44+
3545 Lockscreen {
3646 id: lockscreen
3747 hides: [launcher, panel.indicators]
Shell.qml+7
@@ -19,6 +19,7 @@ import Ubuntu.Application 0.1
1919import Ubuntu.Components 0.1
2020import Ubuntu.Gestures 0.1
2121import Unity.Launcher 0.1
22+import GSettings 1.0
2223import Powerd 0.1
2324import SessionManager 0.1
2425import "Dash"
@@ -111,6 +112,12 @@ BasicShell {
111112 }
112113 }
113114
115+ GSettings {
116+ id: backgroundSettings
117+ schema.id: "org.gnome.desktop.background"
118+ }
119+ backgroundSource: backgroundSettings.pictureUri
120+
114121 Item {
115122 id: underlay
116123 objectName: "underlay"
plugins/AccountsService/AccountsBindings.cpp+2−2
@@ -23,14 +23,14 @@
2323
2424AccountsBindings::AccountsBindings(QObject* parent)
2525 : QObject(parent),
26− m_service(new AccountsService(this)),
27− m_user(qgetenv("USER"))
26+ m_service(new AccountsService(this))
2827{
2928 connect(m_service, SIGNAL(propertiesChanged(const QString &, const QString &, const QStringList &)),
3029 this, SLOT(propertiesChanged(const QString &, const QString &, const QStringList &)));
3130 connect(m_service, SIGNAL(maybeChanged(const QString &)),
3231 this, SLOT(maybeChanged(const QString &)));
3332
33+ setUser(qgetenv("USER"));
3434 updateDemoEdgesForCurrentUser();
3535}
3636