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

0001 import QtQuick 2.15
0002 import QtQml 2.14
0003 
0004 import QtQuick.Controls 2.15
0005 import QtQuick.Layouts 1.10
0006 import QtGraphicalEffects 1.0
0007 
0008 import org.mauikit.controls 1.3 as Maui
0009 
0010 Maui.TabButton
0011 {
0012     id: control
0013     
0014     autoExclusive: true
0015     
0016     readonly property int mindex : control.TabBar.index
0017     property Item tabView : control.parent
0018     
0019    readonly property var tabInfo: control.tabView.contentModel.get(mindex).Maui.TabViewInfo
0020     
0021     width: Math.max(control.tabView.mobile ? ListView.view.width : Math.max(160, implicitWidth), 80)
0022     
0023     checked: control.mindex === control.tabView.currentIndex
0024     text: tabInfo.tabTitle
0025     
0026     icon.name: tabInfo.tabIcon
0027     
0028     property color color : tabInfo.tabColor ? tabInfo.tabColor : "transparent"
0029     
0030     ToolTip.delay: 1000
0031     ToolTip.timeout: 5000
0032     ToolTip.visible: control.hovered && !Maui.Handy.isMobile && ToolTip.text.length
0033     ToolTip.text: tabInfo.tabToolTipText    
0034     
0035     Drag.active: dragArea.active
0036     Drag.source: control
0037     Drag.hotSpot.x: width / 2
0038     Drag.hotSpot.y: height / 2
0039     Drag.dragType: Drag.Automatic
0040     Drag.proposedAction: Qt.IgnoreAction
0041     
0042     Rectangle
0043     {
0044         parent: control.background
0045         color: control.color
0046         height: 2
0047         width: parent.width*0.9
0048         anchors.bottom: parent.bottom
0049         anchors.horizontalCenter: parent.horizontalCenter
0050     }
0051     
0052     DragHandler
0053     {
0054         id: dragArea
0055         enabled: !control.mobile && control.tabView.count > 1
0056         acceptedDevices: PointerDevice.Mouse | PointerDevice.Stylus | PointerDevice.GenericPointer
0057         target: null
0058         xAxis.enabled: true
0059         yAxis.enabled: false
0060         cursorShape: Qt.OpenHandCursor
0061         
0062         onActiveChanged:
0063         {
0064             if (active) 
0065             {
0066                 control.grabToImage(function(result)
0067                 {
0068                     control.Drag.imageSource = result.url;
0069                 })
0070             }
0071         }
0072     }                        
0073     
0074     Timer
0075     {
0076         id: _dropAreaTimer
0077         interval: 250
0078         onTriggered:
0079         {
0080             if(_dropArea.containsDrag)
0081             {
0082                 control.tabView.setCurrentIndex(mindex)
0083             }
0084         }
0085     }
0086     
0087     DropArea
0088     {
0089         id: _dropArea
0090         anchors.fill: parent
0091         onDropped:
0092         {                             
0093             const from = drop.source.mindex
0094             const to = control.mindex
0095             
0096             if(to === from)
0097             {
0098                 return
0099             }
0100             
0101             console.log("Move ", drop.source.mindex, control.mindex)            
0102             control.tabView.moveTab(from , to)
0103         }
0104         
0105         onEntered: 
0106         {
0107             if(drag.source &&  drag.source.mindex >= 0)
0108             {
0109                 return
0110             }
0111             _dropAreaTimer.restart()    
0112         }
0113         
0114         onExited:
0115         {
0116             _dropAreaTimer.stop()
0117         }
0118     }
0119 }