@@ -19,26 +19,57 @@ import Ubuntu.Components 1.1
1919import Ubuntu.Components.Themes 0.1
2020import "../Components"
2121
22−StyledItem {
22+import Ubuntu.Components.Themes.Ambiance 1.1 as Ambiance
23+
24+Item {
2325 id: root
2426
25− property string title: ""
26− property string image: ""
27− property bool showHeader: true
28− // mimic API of toolkit's MainView component required by MainViewStyle
29− property color backgroundColor: theme.palette.normal.background
30− property color headerColor: backgroundColor
31− property color footerColor: backgroundColor
32−
33− // FIXME: fake a Theme object as to expose the Palette corresponding to the backgroundColor (see MainViewStyle.qml)
34− property var theme: QtObject {
35− property string name: "Ambiance"
36− property Palette palette: Qt.createQmlObject("import QtQuick 2.2; import Ubuntu.Components.Themes.%1 1.1; Palette {}".arg(theme.name), root, "dynamicPalette");
27+ property color backgroundColor: d.undefinedColor
28+ property color headerColor: d.undefinedColor
29+ property color footerColor: d.undefinedColor
30+ property alias imageSource: overlaidImage.source
31+ property alias title: header.title
32+ property alias showHeader: header.visible
33+
34+ Ambiance.Palette {
35+ id: ambiancePalette
3736 }
3837
39− // FIXME: should instead use future toolkit API:
40− // style: theme.createStyleComponent("MainViewStyle.qml", root)
41− style: Component { MainViewStyle {theme: root.theme} }
38+ QtObject {
39+ id: d
40+
41+ // As specified in qtmir, it will set the color value to this for fields left undefined
42+ // This is also the default value of a color property in QML.
43+ readonly property color undefinedColor: "#00000000"
44+
45+ readonly property color defaultBackgroundColor: ambiancePalette.normal.background
46+ }
47+
48+ StyledItem {
49+ id: styledItem
50+ anchors.fill: parent
51+
52+ // mimic API of toolkit's MainView component required by MainViewStyle
53+ property color backgroundColor: Qt.colorEqual(root.backgroundColor, d.undefinedColor) ? d.defaultBackgroundColor
54+ : root.backgroundColor
55+ property color headerColor: Qt.colorEqual(root.headerColor, d.undefinedColor) ? styledItem.backgroundColor
56+ : root.headerColor
57+ property color footerColor: Qt.colorEqual(root.footerColor, d.undefinedColor) ? styledItem.backgroundColor
58+ : root.footerColor
59+
60+ // FIXME: fake a Theme object as to expose the Palette corresponding to the backgroundColor (see MainViewStyle.qml)
61+ property var theme: QtObject {
62+ property string name
63+ property Palette palette: Qt.createQmlObject("import QtQuick 2.2;\
64+ import Ubuntu.Components.Themes.%1 1.1;\
65+ Palette {}".arg(styledItem.theme.name),
66+ styledItem, "dynamicPalette");
67+ }
68+
69+ // FIXME: should instead use future toolkit API:
70+ // style: theme.createStyleComponent("MainViewStyle.qml", styledItem)
71+ style: Component { MainViewStyle {theme: styledItem.theme} }
72+ }
4273
4374 StyledItem {
4475 id: header
@@ -47,39 +78,36 @@ StyledItem {
4778 right: parent.right
4879 }
4980
50− visible: root.showHeader
51−
5281 // mimic API of toolkit's AppHeader component required by PageHeadStyle
5382 property Item pageStack
5483 property Item contents
55− property string title: root.title
84+ property string title
5685 property var tabsModel
5786 property var config: QtObject {
58− property color foregroundColor: theme.palette.selected.backgroundText
59− property var sections
87+ property color foregroundColor: styledItem.theme.palette.selected.backgroundText
88+ property var sections: QtObject {}
6089 }
6190
6291 // FIXME: should instead use future toolkit API:
6392 // style: theme.createStyleComponent("PageHeadStyle.qml", header)
64− style: Component { PageHeadStyle {theme: root.theme} }
93+ style: Component { PageHeadStyle {theme: styledItem.theme} }
6594 }
6695
6796 Image {
6897 id: overlaidImage
6998 anchors.centerIn: parent
70− anchors.verticalCenterOffset: root.showHeader ? header.height / 2 : 0
99+ anchors.verticalCenterOffset: header.visible ? header.height / 2 : 0
71100 sourceSize {
72101 width: root.width
73102 height: root.height
74103 }
75− source: root.image
76104 asynchronous: true
77105 cache: false
78106 }
79107
80108 ActivityIndicator {
81109 anchors.centerIn: parent
82− anchors.verticalCenterOffset: root.showHeader ? header.height / 2 : 0
110+ anchors.verticalCenterOffset: header.visible ? header.height / 2 : 0
83111 running: overlaidImage.status == Image.Error || overlaidImage.status == Image.Null
84112 }
85113