2 * Copyright 2014 Canonical Ltd.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
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 Lesser General Public License for more details.
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18import Lomiri.Components 1.3
19import Lomiri.Components.Themes 1.3
22import Lomiri.Components.Themes.Ambiance 1.3 as Ambiance
27 property color backgroundColor: d.undefinedColor
28 property color headerColor: d.undefinedColor
29 property color footerColor: d.undefinedColor
30 property alias imageSource: overlaidImage.source
32 property alias title: header.title
33 property alias showHeader: header.visible
35 // Set clip to prevent drawing outside the window rectangle
45 // As specified in qtmir, it will set the color value to this for fields left undefined
46 // This is also the default value of a color property in QML.
47 readonly property color undefinedColor: "#00000000"
49 readonly property color defaultBackgroundColor: header.visible ? ambiancePalette.normal.background : "black"
51 // Splash screen that shows the application icon and splashTitle
52 readonly property bool showIcon: overlaidImage.status == Image.Null && !root.showHeader
59 // mimic API of toolkit's MainView component required by MainViewStyle
60 property color backgroundColor: Qt.colorEqual(root.backgroundColor, d.undefinedColor) ? d.defaultBackgroundColor
61 : root.backgroundColor
62 property color headerColor: Qt.colorEqual(root.headerColor, d.undefinedColor) ? styledItem.backgroundColor
64 property color footerColor: Qt.colorEqual(root.footerColor, d.undefinedColor) ? styledItem.backgroundColor
67 // FIXME: fake a Theme object as to expose the Palette corresponding to the backgroundColor (see MainViewStyle.qml)
68 readonly property var fakeTheme: QtObject {
70 property Palette palette: Qt.createQmlObject("import QtQuick 2.12;\
71 import Lomiri.Components.Themes.%1 1.3;\
72 Palette {}".arg(styledItem.fakeTheme.name),
73 styledItem, "dynamicPalette");
76 // FIXME: should instead use future toolkit API:
77 // style: theme.createStyleComponent("MainViewStyle.qml", styledItem)
78 style: Component { MainViewStyle {theme: styledItem.fakeTheme} }
83 anchors { left: parent.left; right: parent.right }
85 foregroundColor: styledItem.fakeTheme.palette.normal.backgroundText
86 backgroundColor: "transparent"
87 dividerColor: styledItem.fakeTheme.palette.normal.base
93 anchors.centerIn: parent
94 anchors.verticalCenterOffset: header.visible ? header.height / 2 : 0
102 anchors.horizontalCenter: parent.horizontalCenter
103 anchors.verticalCenter: parent.verticalCenter
104 anchors.verticalCenterOffset: -units.gu(4)
106 height: units.gu(7.5)
111 aspect: LomiriShape.Flat
112 sourceFillMode: Image.PreserveAspectCrop
115 sourceSize.width: iconShape.width
116 sourceSize.height: iconShape.height
117 source: d.showIcon ? root.icon : ""
124 anchors.horizontalCenter: parent.horizontalCenter
125 anchors.top: iconShape.bottom
126 anchors.topMargin: units.gu(2)
129 color: styledItem.fakeTheme.palette.normal.backgroundText
135 onTriggered: spinner.running = true
141 anchors.centerIn: parent
142 anchors.verticalCenterOffset: header.visible ? header.height / 2 : Math.max(titleLabel.y / 2, units.gu(8))
147 enabled: parent.visible
148 // absorb all mouse events