Kirigami2

ToolBarPageHeader.qml
1/*
2 * SPDX-FileCopyrightText: 2018 Marco Martin <mart@kde.org>
3 *
4 * SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6
7import QtQuick
8import QtQml
9import QtQuick.Layouts
10import org.kde.kirigami as Kirigami
11
12AbstractPageHeader {
13 id: root
14
15 implicitWidth: layout.implicitWidth + Kirigami.Units.smallSpacing * 2
16 implicitHeight: Math.max(titleLoader.implicitHeight, toolBar.implicitHeight) + Kirigami.Units.smallSpacing * 2
17
18 onActiveFocusChanged: if (activeFocus && toolBar.actions.length > 0) {
19 toolBar.contentItem.visibleChildren[0].forceActiveFocus(Qt.TabFocusReason)
20 }
21
22 MouseArea {
23 anchors.fill: parent
24 onPressed: mouse => {
25 page.forceActiveFocus()
26 mouse.accepted = false
27 }
28 }
29
30 RowLayout {
31 id: layout
32 anchors.fill: parent
33 anchors.rightMargin: Kirigami.Units.smallSpacing
34 spacing: Kirigami.Units.smallSpacing
35
36 Loader {
37 id: titleLoader
38
39 Layout.alignment: Qt.AlignLeft | Qt.AlignVCenter
40 Layout.fillWidth: item?.Layout.fillWidth ?? false
41 Layout.minimumWidth: item?.Layout.minimumWidth ?? -1
42 Layout.preferredWidth: item?.Layout.preferredWidth ?? -1
43 Layout.maximumWidth: item?.Layout.maximumWidth ?? -1
44
45 // Don't load async to prevent jumpy behaviour on slower devices as it loads in.
46 // If the title delegate really needs to load async, it should be its responsibility to do it itself.
47 asynchronous: false
48 sourceComponent: page?.titleDelegate ?? null
49 }
50
51 Kirigami.ActionToolBar {
52 id: toolBar
53
54 Layout.alignment: Qt.AlignVCenter
55 Layout.fillWidth: true
56 Layout.fillHeight: true
57
58 visible: actions.length > 0
59 alignment: pageRow?.globalToolBar.toolbarActionAlignment ?? Qt.AlignRight
60 heightMode: pageRow?.globalToolBar.toolbarActionHeightMode ?? Kirigami.ToolBarLayout.ConstrainIfLarger
61
62 actions: page?.actions ?? []
63 }
64 }
65}
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Feb 21 2025 11:47:53 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.