@ -38,7 +38,7 @@ import org.kde.taskmanager 0.1 as TaskManager
PlasmaExtras . ScrollArea {
id: mainToolTip
property Item parentTask
property int parentIndex: - 1
property var rootIndex
property string appName
property int pidParent
@ -62,7 +62,7 @@ PlasmaExtras.ScrollArea {
property bool isOnAllVirtualDesktopsParent
property var activitiesParent
/ /
readonly property bool isVerticalPanel: plasmoid . formFactor == PlasmaCore . Types . Vertical
readonly property bool isVerticalPanel: plasmoid . formFactor == = PlasmaCore . Types . Vertical
Layout.minimumWidth: contentItem . width
Layout.maximumWidth: Layout . minimumWidth
@ -83,19 +83,18 @@ PlasmaExtras.ScrollArea {
return isVerticalPanel ? contentItem . height > viewport.height : contentItem . width > viewport . width
} ) ;
}
Item {
width: contentItem . width
height: contentItem . height
/ / ! D r o p A r e a
DropArea {
id: dropMainArea
anchors.fill: contentItem
anchors.fill: parent
enabled: isGroup
preventStealing: true
property bool dragInside: false
property QtObject currentWindow
onDragLeave: {
@ -103,120 +102,117 @@ PlasmaExtras.ScrollArea {
}
onDragMove: {
var current = groupTask. child AtPos( event . x , event . y ) ;
var current = mainToolTip. instance AtPos( event . x , event . y ) ;
if ( current && currentWindow !== current && current . submodelIndex ) {
currentWindow = current ;
tasksModel . requestActivate ( current . submodelIndex ) ;
}
}
}
} / / ! D r o p A r e a
/ / ! U n d e r n e a t h M o u s e A r e a
MouseArea {
id: contentItem
width: childrenRect . width
height: childrenRect . height
id: contentItemMouseArea
anchors.fill: parent
hoverEnabled: true
onContainsMouseChanged: {
checkMouse Inside( ) ;
mainToolTip. mouseIs Inside( ) ;
}
} / / ! M o u s e A r e a
function checkMouseInside ( ) {
var isInside = containsMouse || childrenContainMouse ( ) || ( parentTask && parentTask . containsMouse ) ;
if ( isInside ) {
/ / r o o t . d i s a b l e R e s t o r e Z o o m = t r u e ;
mainToolTip . containsMouse = true ;
if ( ! root . latteDock )
checkListHovered . stop ( ) ;
}
else {
/ / r o o t . d i s a b l e R e s t o r e Z o o m = f a l s e ;
mainToolTip . containsMouse = false ;
if ( ! root . latteDock )
checkListHovered . startDuration ( 100 ) ;
else
root . latteDock . startCheckRestoreZoomTimer ( ) ;
}
}
Loader {
id: contentItem
active: mainToolTip . rootIndex !== undefined
asynchronous: true
sourceComponent: isGroup ? groupToolTip : singleTooltip
function childrenContainMouse ( ) {
return singleTask . containsMouse ( ) || groupTask . containsMouse ( ) ;
}
Component {
id: singleTooltip
ToolTipInstance {
id: singleTask
visible: ! isGroup
ToolTipInstance {
submodelIndex: mainToolTip . rootIndex
}
}
Grid {
id: groupTask
rows: ! isVerticalPanel
columns: isVerticalPanel
flow: isVerticalPanel ? Grid.TopToBottom : Grid . LeftToRight
spacing: units . largeSpacing
width: isGroup ? childrenRect.width : 0
height: isGroup ? childrenRect.height : 0
Component {
id: groupToolTip
visible: isGroup && parentIndex !== - 1
Grid {
rows: ! isVerticalPanel
columns: isVerticalPanel
flow: isVerticalPanel ? Grid.TopToBottom : Grid . LeftToRight
spacing: units . largeSpacing
Loader {
id: modelLoader
active: groupTask . visible
sourceComponent: Repeater {
Repeater {
id: groupRepeater
model: DelegateModel {
id: delegateModel
model: mainToolTip . rootIndex ? tasksModel : null
rootIndex: mainToolTip . rootIndex
model: parentIndex !== - 1 && isGroup ? tasksModel : undefined
rootIndex: tasksModel . makeModelIndex ( parentIndex , - 1 )
delegate: ToolTipInstance { }
}
Component.onCompleted: {
parent = groupTask
delegate: ToolTipInstance {
submodelIndex: tasksModel . makeModelIndex ( mainToolTip . rootIndex . row , index )
}
}
}
}
}
} / / ! L o a d e r
} / / ! I t e m
/ / ! C e n t r a l F u n c t i o n a l i t y
function mouseIsInside ( ) {
var isInside = contentItemMouseArea . containsMouse || instancesContainMouse ( ) || ( parentTask && parentTask . containsMouse ) ;
function containsMouse ( ) {
for ( var i = 1 ; i < children . length - 1 ; ++ i ) {
if ( children [ i ] . containsMouse ( ) )
return true ;
}
if ( isInside ) {
mainToolTip . containsMouse = true ;
return false ;
}
if ( ! root . latteDock )
checkListHovered . stop ( ) ;
} else {
mainToolTip . containsMouse = false ;
if ( ! root . latteDock )
checkListHovered . startDuration ( 100 ) ;
else
root . latteDock . startCheckRestoreZoomTimer ( ) ;
}
}
function childAtPos ( x , y ) {
var tasks = groupTask . children ;
function instancesContainMouse ( ) {
var previewInstances = isGroup ? contentItem . children [ 0 ] . children : contentItem . children ;
var instancesLength = previewInstances . length ;
for ( var i = 0 ; i < tasks . length ; ++ i ) {
var task = tasks [ i ] ;
for ( var i = instancesLength - 1 ; i >= 0 ; -- i ) {
if ( ( typeof ( previewInstances [ i ] . containsMouse ) === "function" ) / / i g n o r e u n r e l e v a n t o b j e c t s
&& previewInstances [ i ] . containsMouse ( ) )
return true ;
}
var choords = contentItem . mapFromItem ( task , 0 , 0 ) ;
return false ;
}
if ( choords . y < 0 )
choords . y = 0 ;
if ( choords . x < 0 )
choords . x = 0 ;
function instanceAtPos ( x , y ) {
var previewInstances = isGroup ? contentItem . children [ 0 ] . children : contentItem . children ;
var instancesLength = previewInstances . length ;
if ( ( x >= choords . x ) && ( x <= choords . x + task . width )
&& ( y >= choords . y ) && ( y <= choords . y + task . height ) ) {
return task ;
}
}
for ( var i = 0 ; i < instancesLength ; ++ i ) {
var instance = previewInstances [ i ] ;
var choords = contentItem . mapFromItem ( instance , 0 , 0 ) ;
return null ;
}
if ( choords . y < 0 )
choords . y = 0 ;
if ( choords . x < 0 )
choords . x = 0 ;
if ( ( x >= choords . x ) && ( x <= choords . x + instance . width )
&& ( y >= choords . y ) && ( y <= choords . y + instance . height ) ) {
return instance ;
}
}
return null ;
}
}