19import QtQuick.Layouts 1.1
20import QtQuick.Controls.Suru 2.2
21import Lomiri.Components 1.3
22import Dekko.Components 1.0
23import Dekko.Lomiri.Constants 1.0
28 property color titleColor: theme.palette.normal.foregroundText
29 property Action backAction
30 property Action primaryAction
33 property list<Action> secondaryActions
35 property list<Action> multiSelectActionList
37 property alias filterSections: filters.filterSections
39 property alias selectedIndex: filters.selectedIndex
44 property Component customComponent
47 property bool showDivider:
true
51 property bool enableSearching:
false
52 property bool searchInProgress:
false
56 property Item pageFlickable: null
57 property bool composeButtonEnabled:
false
58 property alias backgroundVisible: backgroundColor.visible
59 property alias backgroundColor: backgroundColor.color
61 readonly
property bool isDefault: state ===
"default"
62 readonly
property bool isSearchMode: state ===
"search"
63 readonly
property bool isMultiSelect: state ===
"multi-select"
64 readonly
property int dividerHeight: units.dp(1)
65 property bool extend:
false
66 readonly
property int extendHeight: extend ? units.gu(3) : 0
68 signal searchActivated(
string searchString)
70 signal searchCanceled()
72 signal multiSelectCanceled()
74 signal composeNewMessage()
77 function startMultiSelect() {
78 state =
"multi-select"
80 onPageFlickableChanged: internal.checkPageFlickableAnchors();
81 onHeightChanged: internal.checkPageFlickableAnchors()
89 height: visible ? units.gu(6) + filterColumn.height + btmMargin.height + extendHeight : 0
94 iconName:
"contextual-menu"
95 onTriggered: actionDrawer.opened =
true
101 onTriggered: dekkoHeader.state =
"search"
107 function checkPageFlickableAnchors() {
108 if (dekkoHeader.pageFlickable) {
109 pageFlickable.anchors.left = pageFlickable.parent.left
110 pageFlickable.anchors.right = pageFlickable.parent.right
111 pageFlickable.anchors.bottom = pageFlickable.parent.bottom
112 pageFlickable.anchors.top = dekkoHeader.bottom;
125 color: Suru.backgroundColor
129 id: multiSelectComponent
131 property alias button: inner_button
134 anchors.rightMargin:
Style.defaultSpacing
135 spacing:
Style.defaultSpacing
140 bottom: parent.bottom
146 dekkoHeader.state =
"default"
147 multiSelectCanceled()
152 model: multiSelectActionList
153 delegate: HeaderButton {
155 iconSize: units.gu(2.2)
159 bottom: parent.bottom
162 Layout.fillWidth:
true
170 property alias button: inner_button
173 anchors.rightMargin:
Style.defaultSpacing
180 bottom: parent.bottom
186 dekkoHeader.state =
"default"
193 onAccepted: {searchActivated(text); focus =
false}
196 if (searchTimer.running) {
197 searchTimer.restart()
206 placeholderText: qsTr(
"Enter search...")
207 Layout.fillWidth: true
208 inputMethodHints: Qt.ImhNoPredictiveText
209 Component.onCompleted: forceActiveFocus()
211 secondaryItem: ActivityIndicator {
212 running: dekkoHeader.searchInProgress
214 visible: opacity !== 0
215 width: visible ? height : 0
216 height: parent.height / 1.8
217 Behavior on opacity {
218 NumberAnimation {duration: 250}
221 NumberAnimation {duration: 250}
229 onTriggered: searchActivated(sf.text)
238 property alias button: inner_button
239 height: parent ? parent.height : undefined
242 leftMargin: backAction ? 0 : units.gu(1)
250 bottom: parent.bottom
252 implicitWidth: units.gu(4)
254 action: backAction ? backAction : null
258 height: parent.height
260 text: dekkoHeader.title
261 anchors.verticalCenter: parent.verticalCenter
262 anchors.left: parent.left
265 elide: Text.ElideRight
267 color: dekkoHeader.titleColor
268 textFormat: Qt.RichText
269 Layout.fillWidth:
true
278 bottom: parent.bottom
282 implicitHeight: height
283 visible: composeButtonEnabled
286 onTriggered: composeNewMessage()
294 bottom: parent.bottom
298 implicitHeight: height
299 visible: action ? action.visible :
false
300 action: enableSearching ? searchAction : primaryAction
307 bottom: parent.bottom
311 implicitHeight: height
312 visible: secondaryActions[0] ? secondaryActions[0].visible :
false
313 action: secondaryActions.length > 1 ? drawerAction : secondaryActions.length === 1 ? secondaryActions[0] : null
321 top: backgroundColor.bottom
324 height: filters.height
331 height: filterSections.length && !isMultiSelect ? units.gu(3) : 0
342 top: filterColumn.bottom
343 topMargin: extend ? extendHeight : 0
345 height: visible ?
Style.lineSize : 0
352 left: backgroundColor.left
353 right: backgroundColor.right
354 top: backgroundColor.top
355 bottom: backgroundColor.bottom
356 leftMargin: units.gu(1)
357 rightMargin: units.gu(1)
361 property:
"sourceComponent"
362 value: defaultHeadState
363 when: loader && dekkoHeader.state ===
"default"
367 property:
"sourceComponent"
368 value: searchComponent
369 when: loader && dekkoHeader.state ===
"search"
373 property:
"sourceComponent"
374 value: multiSelectComponent
375 when: loader && dekkoHeader.state ===
"multi-select"
379 property:
"sourceComponent"
380 value: customComponent
381 when: loader && dekkoHeader.state ===
"custom"
391 actions: secondaryActions.length > 1 ? secondaryActions : []
406 height: units.gu(6) + filterColumn.height