Warning, /maui/mauikit/src/controls.5/private/ActionGroup.qml is written in an unsupported language. File is not indexed.

0001 /*
0002  *   Copyright 2018-2020 Camilo Higuita <milo.h@aol.com>
0003  *
0004  *   This program is free software; you can redistribute it and/or modify
0005  *   it under the terms of the GNU Library General Public License as
0006  *   published by the Free Software Foundation; either version 2, or
0007  *   (at your option) any later version.
0008  *
0009  *   This program is distributed in the hope that it will be useful,
0010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
0011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0012  *   GNU General Public License for more details
0013  *
0014  *   You should have received a copy of the GNU Library General Public
0015  *   License along with this program; if not, write to the
0016  *   Free Software Foundation, Inc.,
0017  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
0018  */
0019 
0020 import QtQuick 2.15
0021 import QtQuick.Controls 2.15
0022 import QtQuick.Layouts 1.3
0023 
0024 import org.mauikit.controls 1.3 as Maui
0025 import QtQuick.Templates 2.15 as T
0026 
0027 T.Pane
0028 {
0029     id: control
0030     
0031     implicitWidth: implicitContentWidth + leftPadding + rightPadding
0032     implicitHeight: implicitContentHeight + topPadding + bottomPadding
0033 
0034     spacing: Maui.Style.space.medium
0035     padding: 0
0036     background: null
0037     /**
0038      *
0039      */
0040     default property list<QtObject> items
0041     
0042     /**
0043      *
0044      */
0045     property list<QtObject> hiddenItems
0046     
0047     /**
0048      *
0049      */
0050     property int currentIndex : 0
0051     
0052     /**
0053      *
0054      */
0055     readonly property int count : control.items.length + control.hiddenItems.length
0056     
0057     property int display: ToolButton.TextBesideIcon
0058     /**
0059      *
0060      */
0061     signal clicked(int index)
0062     
0063     /**
0064      *
0065      */
0066     signal pressAndHold(int index)
0067     
0068     /**
0069      *
0070      */
0071     signal doubleClicked(int index)
0072 
0073     Behavior on implicitWidth
0074     {
0075         NumberAnimation
0076         {
0077             duration: Maui.Style.units.shortDuration
0078             easing.type: Easing.InOutQuad
0079         }
0080     }
0081     
0082     property Component delegate : ToolButton
0083     {
0084         id: _buttonDelegate
0085         // Layout.alignment: Qt.AlignCenter
0086         autoExclusive: true
0087         visible: modelData.visible
0088         checked:  index == control.currentIndex
0089 
0090         leftPadding: Maui.Style.space.big
0091         rightPadding: Maui.Style.space.big
0092         
0093         icon.name: modelData.Maui.AppView.iconName
0094         text: modelData.Maui.AppView.title
0095 
0096         display: checked ? (!isWide ? ToolButton.IconOnly : ToolButton.TextBesideIcon) : ToolButton.IconOnly
0097         
0098         Maui.Badge
0099         {
0100             visible: modelData.Maui.AppView.badgeText
0101             text: modelData.Maui.AppView.badgeText
0102             
0103             anchors.horizontalCenter: parent.right
0104             anchors.verticalCenter: parent.top
0105             anchors.verticalCenterOffset: 10
0106             anchors.horizontalCenterOffset: -5
0107             
0108             Maui.Theme.colorSet: Maui.Theme.View
0109             Maui.Theme.backgroundColor: Maui.Theme.negativeBackgroundColor
0110             Maui.Theme.textColor: Maui.Theme.negativeTextColor
0111             border.color: Maui.Theme.textColor
0112             
0113             mouseArea.enabled: false
0114         }
0115         
0116         onClicked:
0117         {
0118             if(index == control.currentIndex )
0119             {
0120                 return
0121             }
0122 
0123             control.currentIndex = index
0124             control.clicked(index)
0125         }
0126         
0127         DropArea
0128         {
0129             anchors.fill: parent
0130             onEntered: control.currentIndex = index
0131         }
0132     }
0133 
0134     contentItem: RowLayout
0135     {
0136         id: _layout
0137         spacing: control.spacing
0138 
0139         Repeater
0140         {
0141             model: control.items
0142             delegate: control.delegate
0143         }
0144 
0145         ToolButton
0146         {
0147             // Layout.alignment: Qt.AlignCenter
0148 //             padding: Maui.Style.space.medium
0149             leftPadding: Maui.Style.space.big
0150             rightPadding: Maui.Style.space.big
0151             readonly property QtObject obj : control.currentIndex >= control.items.length && control.currentIndex < control.count? control.hiddenItems[control.currentIndex - control.items.length] : null
0152 
0153             visible: obj && obj.visible
0154             checked: visible
0155             autoExclusive: true
0156             icon.name: obj ? obj.Maui.AppView.iconName : ""
0157         
0158             //                flat: display === ToolButton.IconOnly
0159 
0160             display: checked ? (!isWide ? ToolButton.IconOnly : ToolButton.TextBesideIcon) : ToolButton.IconOnly
0161 
0162             text: obj ? obj.Maui.AppView.title : ""
0163         }
0164 
0165         Maui.ToolButtonMenu
0166         {
0167             id: _menuButton
0168             icon.name: "overflow-menu"           
0169             visible: control.hiddenItems.length > 0
0170 
0171             Layout.alignment: Qt.AlignCenter
0172             display: checked ? ToolButton.TextBesideIcon : ToolButton.IconOnly
0173 
0174             Behavior on implicitWidth
0175             {
0176                 NumberAnimation
0177                 {
0178                     duration: Maui.Style.units.shortDuration
0179                     easing.type: Easing.InOutQuad
0180                 }
0181             }
0182 
0183             Repeater
0184             {
0185                 model: control.hiddenItems
0186 
0187                 MenuItem
0188                 {
0189                     text: modelData.Maui.AppView.title
0190                     icon.name: modelData.Maui.AppView.iconName
0191                     autoExclusive: true
0192                     checkable: true
0193                     checked: control.currentIndex === control.items.length + index
0194                     showIcon: true
0195                     
0196                     onTriggered:
0197                     {
0198                         if(control.items.length + index === control.currentIndex)
0199                         {
0200                             return
0201                         }
0202 
0203                         control.currentIndex = control.items.length + index
0204                         control.clicked(control.currentIndex)
0205                     }
0206                 }
0207             }
0208         }
0209     }
0210 }