Warning, /maui/mauikit/src/controls.6/SideBarView.qml is written in an unsupported language. File is not indexed.
0001 import QtQuick 0002 import QtQuick.Controls 0003 0004 import org.mauikit.controls 1.3 as Maui 0005 import "private" as Private 0006 0007 /** 0008 * @brief A view with a collapsible sidebar. 0009 * 0010 * <a href="https://doc.qt.io/qt-6/qml-qtquick-controls-item.html">This controls inherits from QQC2 Item, to checkout its inherited properties refer to the Qt Docs.</a> 0011 * 0012 * The SideBarView is a convenient way for organizing the application contents into view alongside with a side-bar, which can be resized, collased, hidden and tweaked further. This control adapts to small screen spaces. 0013 * 0014 * @image html SideBarView/sidebar_empty.png 0015 * 0016 * @section sections Sections 0017 * The SideBarView is divided into two sections, the sidebar container and the main contents area. 0018 * 0019 * @subsection sidebar SideBar 0020 * The sidebar area can contain any number children items, and its positioning must be handled manually, either by anchoring or using the size and coordinates properties - anchoring to fill its parent is the best way to go, since the sidebar container can changed its size and positioning. 0021 * 0022 * Once a child item has been set, other properties can be visited, such as setting the sidebar preferred and minimum width, or deciding if the sidebar will be resize-able or not. Those properties can be accessed via the alias property of the sidebar. 0023 * @see sideBar 0024 * 0025 * The sidebar can be hidden at the application startup, to tweak this behaviour the auto hide properties can be set accordingly. 0026 * The sidebar can also be collapsed, and this behavior can be fine-tuned, by either deciding if when collapsing the sidebar should stay visible or not. 0027 * 0028 * Tweaking the look of the sidebar can also be achieved by changing its background and padding properties. Those all properties are accessible via the alias property `sideBar` - and a few more methods for closing or opening the sidebar. 0029 * @see SideBar 0030 * 0031 * @image html SideBarView/sidebar_collapsed.png "The sidebar is collapsed and expanded, shifting the main area content" 0032 * 0033 * @subsection maincontent Content 0034 * The position of the main content of the SideBarView has to be done by the child item. 0035 * The default behaviour of the main content is be to shifted/moved when the sidebar being collapsed is expanded. 0036 * 0037 * @code 0038 * Maui.SideBarView 0039 * { 0040 * id: _sideBar 0041 * anchors.fill: parent 0042 * 0043 * sideBarContent: Maui.Page 0044 * { 0045 * Maui.Theme.colorSet: Maui.Theme.Window 0046 * anchors.fill: parent 0047 * 0048 * headBar.leftContent: Maui.ToolButtonMenu 0049 * { 0050 * icon.name: "application-menu" 0051 * MenuItem 0052 * { 0053 * text: "About" 0054 * icon.name: "info-dialog" 0055 * onTriggered: root.about() 0056 * } 0057 * } 0058 * 0059 * Maui.Holder 0060 * { 0061 * anchors.fill: parent 0062 * title: "SideBar" 0063 * body: "Collapsable." 0064 * emoji: "folder" 0065 * } 0066 * } 0067 * 0068 * Maui.Page 0069 * { 0070 * anchors.fill: parent 0071 * Maui.Controls.showCSD: true 0072 * 0073 * headBar.leftContent: ToolButton 0074 * { 0075 * icon.name: _sideBar.sideBar.visible ? "sidebar-collapse" : "sidebar-expand" 0076 * onClicked: _sideBar.sideBar.toggle() 0077 * } 0078 * 0079 * Maui.Holder 0080 * { 0081 * anchors.fill: parent 0082 * title: "Page" 0083 * body: "Page main content." 0084 * emoji: "application-x-addon-symbolic" 0085 * } 0086 * } 0087 * } 0088 * @endcode 0089 * 0090 * @section notes Notes 0091 * 0092 * The width of the sidebar section will always be restrained to a maximum value less than the window width - by reserving a sane margin to be able to close the sidebar by clicking/pressing outside of it. 0093 * 0094 * To place an item in the sidebar, use the exposed alias property. 0095 * @see sideBarContent 0096 * 0097 * <a href="https://invent.kde.org/maui/mauikit/-/blob/qt6-2/examples/SideBarView.qml">You can find a more complete example at this link.</a> 0098 * 0099 */ 0100 Item 0101 { 0102 id: control 0103 0104 /** 0105 * @brief 0106 * All child items declared will become part of the main area section. 0107 * @property list<QtObject> SideBarView::content 0108 */ 0109 default property alias content : _content.data 0110 0111 /** 0112 * @brief Convenient property to easily add items to the sidebar section. 0113 * @property list<QtObject> SideBarView::sideBarContent 0114 */ 0115 property alias sideBarContent: _sideBar.content 0116 0117 /** 0118 * @brief This is an alias exposed to access all the sidebar section properties. 0119 * To know more about the available properties visit the control documentation. 0120 * @see SideBar 0121 * 0122 * @code 0123 * SideBarView 0124 * { 0125 * sideBar.collapsed: width < 800 0126 * sideBar.resizeable: false 0127 * sideBar.autoHide: true 0128 * } 0129 * @endcode 0130 */ 0131 readonly property alias sideBar : _sideBar 0132 0133 Private.SideBar 0134 { 0135 id: _sideBar 0136 height: parent.height 0137 collapsed: control.width < (preferredWidth * 2.5) 0138 sideBarView: control 0139 } 0140 0141 Item 0142 { 0143 anchors.fill: parent 0144 clip: true 0145 transform: Translate 0146 { 0147 x: control.sideBar.collapsed ? control.sideBar.position * (control.sideBar.width) : 0 0148 } 0149 0150 anchors.leftMargin: control.sideBar.collapsed ? 0 : control.sideBar.width * control.sideBar.position 0151 0152 Item 0153 { 0154 id: _content 0155 anchors.fill: parent 0156 } 0157 0158 Loader 0159 { 0160 anchors.fill: parent 0161 active: _sideBar.collapsed && _sideBar.position === 1 0162 // asynchronous: true 0163 0164 sourceComponent: MouseArea 0165 { 0166 onClicked: _sideBar.close() 0167 0168 Rectangle 0169 { 0170 anchors.fill: parent 0171 color: "#333" 0172 opacity : visible ? 0.5 : 0 0173 0174 Behavior on opacity 0175 { 0176 NumberAnimation 0177 { 0178 duration: 500 0179 easing.type: Easing.InOutQuad 0180 } 0181 } 0182 } 0183 } 0184 } 0185 } 0186 } 0187