Warning, /maui/mauikit/src/controls.6/TabButton.qml is written in an unsupported language. File is not indexed.

0001 
0002 import QtQuick
0003 import QtQuick.Controls 2.15 as QQC
0004 import QtQuick.Layouts
0005 
0006 import org.mauikit.controls 1.3 as Maui
0007 
0008 /**
0009  * @inherit QtQuick.Controls.TabButton
0010  * @brief A expanded implementation of the QQC2 TabButton with a predefined horizontal layout.
0011  * 
0012  * <a href="https://doc.qt.io/qt-6/qml-qtquick-controls-tabbutton.html">This control inherits from QQC2 TabButton, to checkout its inherited properties refer to the Qt Docs.</a> 
0013  * 
0014  * By default the layout of this control is divided into three sections.
0015  * Extra items can be appended to the left and right side areas, while the center area is reserved for the title text.
0016  * @see leftContent
0017  * @see rightContent 
0018  */
0019 QQC.TabButton
0020 {
0021     id: control
0022 
0023     /**
0024      * @brief An alias exposed to append more elements into the main container of this control. The container is hanlded by a RowLayout, so any children added using this property needs to be postioned using the Layout attached properties.
0025      * @property list<QtObject> TabButton::content
0026      */
0027     property alias content: _content.data
0028     
0029     /**
0030      * @brief Use this to append items to the left area of this control.
0031      * @property list<QtObject> TabButton::leftContent
0032      */
0033     property alias leftContent: _leftContent.data
0034     
0035     /**
0036      * @brief Use this to append items to the right area of this control.
0037      * @property list<QtObject> TabButton::rightContent
0038      */
0039     property alias rightContent: _rightContent.data
0040     
0041     /**
0042      * @brief Whether a close button should be shown in the far left area.
0043      * If it is visible and pressed, a signal is emitted.
0044      * @see closeClicked
0045      * By default this is set to `true`.
0046      */
0047     property bool closeButtonVisible: true
0048     
0049     /**
0050      * @brief Emitted when the close button is pressed.
0051      * @see closeButtonVisible
0052      */
0053     signal closeClicked()
0054     
0055     /**
0056      * @brief Emitted when the area of the control has been right clicked.
0057      * This can be consumed in order to open a contextual menu, for example.
0058      * @param mouse The object with information of the event.
0059      */
0060     signal rightClicked(var mouse)
0061     
0062     contentItem: MouseArea
0063     {
0064         implicitWidth: _content.implicitWidth
0065         implicitHeight: _content.implicitHeight
0066         
0067         acceptedButtons: Qt.RightButton
0068         propagateComposedEvents: true
0069         preventStealing: false
0070         
0071         onClicked:
0072         {
0073             if(mouse.button === Qt.RightButton)
0074             {
0075                 control.rightClicked(mouse)
0076             }
0077             
0078             mouse.accepted = false
0079         }
0080         
0081         RowLayout
0082         {
0083             id: _content
0084             anchors.fill: parent
0085             spacing: control.spacing
0086             
0087             Row
0088             {
0089                 id: _leftContent
0090             }
0091             
0092             Maui.IconLabel
0093             {
0094                 Layout.fillWidth: true
0095                 Layout.fillHeight: true
0096                 opacity: control.checked || control.hovered ? 1 : 0.7
0097                 
0098                 text: control.text
0099                 icon: control.icon
0100                 color: Maui.Theme.textColor
0101                 alignment: Qt.AlignHCenter
0102                 display: QQC.ToolButton.TextBesideIcon
0103                 font: control.font
0104             }
0105             
0106             Row
0107             {
0108                 id: _rightContent
0109             }
0110             
0111             Loader
0112             {
0113                 asynchronous: true
0114                 active: control.closeButtonVisible
0115                 
0116                 Layout.alignment: Qt.AlignCenter
0117                 
0118                 sourceComponent: Maui.CloseButton
0119                 {
0120                     opacity: Maui.Handy.isMobile ? 1 : (control.hovered || control.checked ? 1 : 0)
0121                     padding: 0
0122                     
0123                     implicitHeight: 16
0124                     implicitWidth: 16
0125                     
0126                     icon.width: 16
0127                     icon.height: 16
0128                     
0129                     onClicked: control.closeClicked()
0130                     
0131                     Behavior on opacity
0132                     {
0133                         NumberAnimation
0134                         {
0135                             duration: Maui.Style.units.longDuration
0136                             easing.type: Easing.InOutQuad
0137                         }
0138                     }
0139                 }
0140             }
0141         }
0142     }
0143 }
0144