Kirigami2

TabViewLayout.qml
1 import QtQuick 2.12
2 import QtQuick.Layouts 1.12
3 import QtQuick.Controls 2.12 as QQC2
4 import org.kde.kirigami 2.12 as Kirigami
5 
6 /**
7  * Control for dynamically moving a bar above or below a content item,
8  * e.g. to move tabs to the bottom on mobile.
9  *
10  * @inherit QtQuick.Item
11  */
12 Item {
13  id: __root
14 
15  /**
16  * @brief Position options for TabViewLayout.
17  */
18  enum Position {
19  Top,
20  Bottom
21  }
22 
23  /**
24  * @brief The position of the bar in relation to the contentItem.
25  *
26  * default: `Position.Bottom on mobile, and Position.Top otherwise`
27  *
28  * @see ::Position
29  */
30  property int position: Kirigami.Settings.isMobile ? TabViewLayout.Position.Bottom : TabViewLayout.Position.Top
31 
32  required property Item bar
33  onBarChanged: {
34  bar.parent = __grid
35  bar.Layout.row = Qt.binding(() => (__root.position === TabViewLayout.Position.Bottom) ? 1 : 0)
36  bar.Layout.fillWidth = true
37  if (bar instanceof QQC2.ToolBar) {
38  bar.position = Qt.binding(() => (__root.position === TabViewLayout.Position.Bottom) ? QQC2.ToolBar.Footer : QQC2.ToolBar.Header)
39  }
40  }
41 
42  required property Item contentItem
43  onContentItemChanged: {
44  contentItem.parent = __grid
45  contentItem.Layout.row = Qt.binding(() => (__root.position === TabViewLayout.Position.Bottom) ? 0 : 1)
46  contentItem.Layout.fillWidth = true
47  contentItem.Layout.fillHeight = true
48  }
49 
50  implicitWidth: __grid.implicitWidth
51  implicitHeight: __grid.implicitHeight
52 
53  GridLayout {
54  id: __grid
55  children: [__root.bar, __root.contentItem]
56 
57  rowSpacing: 0
58  columns: 1
59 
60  anchors.fill: parent
61  }
62 }
Control for dynamically moving a bar above or below a content item, e.g.
Position
Position options for TabViewLayout.
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Tue Nov 28 2023 04:08:25 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.