| 1 |
/* |
| 2 |
* Copyright 2012 Canonical Ltd. |
| 3 |
* |
| 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. |
| 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 Lesser General Public License for more details. |
| 12 |
* |
| 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/>. |
| 15 |
*/ |
| 16 |
import QtQuick 2.4 |
| 17 |
import Lomiri.Components 1.2 |
| 18 |
|
| 19 |
Item { |
| 20 |
id: headerStyle |
| 21 |
/*! |
| 22 |
The height of the headercontents, which is the full height of |
| 23 |
the header minus the separators shown at the bottom of it. |
| 24 |
*/ |
| 25 |
property real contentHeight: units.gu(7.5) |
| 26 |
|
| 27 |
/*! |
| 28 |
The source of the image that separates the header from the contents of a \l MainView. |
| 29 |
The separator will be drawn over the contents. |
| 30 |
*/ |
| 31 |
property url separatorSource: Qt.resolvedUrl("../artwork/PageHeaderBaseDividerLight.sci") |
| 32 |
|
| 33 |
/*! |
| 34 |
The source of an additional image attached to the bottom of the separator. The contents |
| 35 |
of the \l MainView will be drawn on top of the separator bottom image. |
| 36 |
*/ |
| 37 |
property url separatorBottomSource: Qt.resolvedUrl("../artwork/PageHeaderBaseDividerBottom.png") |
| 38 |
|
| 39 |
property int fontWeight: Font.Light |
| 40 |
property string fontSize: "x-large" |
| 41 |
property color textColor: Theme.palette.selected.backgroundText |
| 42 |
property real textLeftMargin: units.gu(2) |
| 43 |
|
| 44 |
implicitHeight: headerStyle.contentHeight + separator.height + separatorBottom.height |
| 45 |
|
| 46 |
/*! |
| 47 |
\internal |
| 48 |
Tabs needs to call sync of the TabBar |
| 49 |
*/ |
| 50 |
property TabBar __tabBar: tabBarLoader.sourceComponent ? tabBarLoader.item : null |
| 51 |
|
| 52 |
BorderImage { |
| 53 |
id: separator |
| 54 |
anchors { |
| 55 |
bottom: parent.bottom |
| 56 |
left: parent.left |
| 57 |
right: parent.right |
| 58 |
} |
| 59 |
source: headerStyle.separatorSource |
| 60 |
} |
| 61 |
Image { |
| 62 |
id: separatorBottom |
| 63 |
anchors { |
| 64 |
top: separator.bottom |
| 65 |
left: parent.left |
| 66 |
right: parent.right |
| 67 |
} |
| 68 |
source: headerStyle.separatorBottomSource |
| 69 |
} |
| 70 |
|
| 71 |
Item { |
| 72 |
id: foreground |
| 73 |
anchors { |
| 74 |
left: parent.left |
| 75 |
right: parent.right |
| 76 |
top: parent.top |
| 77 |
} |
| 78 |
height: headerStyle.contentHeight |
| 79 |
|
| 80 |
Label { |
| 81 |
LayoutMirroring.enabled: Qt.application.layoutDirection == Qt.RightToLeft |
| 82 |
|
| 83 |
anchors { |
| 84 |
left: parent.left |
| 85 |
verticalCenter: parent.verticalCenter |
| 86 |
leftMargin: headerStyle.textLeftMargin |
| 87 |
} |
| 88 |
text: styledItem.title |
| 89 |
font.weight: headerStyle.fontWeight |
| 90 |
visible: !styledItem.tabsModel && !styledItem.contents |
| 91 |
fontSize: headerStyle.fontSize |
| 92 |
color: headerStyle.textColor |
| 93 |
} |
| 94 |
|
| 95 |
Binding { |
| 96 |
target: styledItem.contents |
| 97 |
property: "anchors.fill" |
| 98 |
value: foreground |
| 99 |
when: styledItem.contents |
| 100 |
} |
| 101 |
Binding { |
| 102 |
target: styledItem.contents |
| 103 |
property: "parent" |
| 104 |
value: foreground |
| 105 |
when: styledItem.contents |
| 106 |
} |
| 107 |
|
| 108 |
Loader { |
| 109 |
id: tabBarLoader |
| 110 |
sourceComponent: styledItem.tabsModel && !styledItem.contents ? tabBarComponent : null |
| 111 |
anchors.fill: parent |
| 112 |
} |
| 113 |
|
| 114 |
Component { |
| 115 |
id: tabBarComponent |
| 116 |
TabBar { |
| 117 |
id: tabBar |
| 118 |
anchors.fill: parent |
| 119 |
model: styledItem.tabsModel |
| 120 |
animate: styledItem.animate |
| 121 |
} |
| 122 |
} |
| 123 |
} |
| 124 |
} |