@ -20,6 +20,10 @@
import QtQuick 2.0
import org . kde . plasma . plasmoid 2.0
import org . kde . latte 0.1 as Latte
/ / h o l d s a l l t h e l o g i c a r o u n d p a r a b o l i c e f f e c t s i g n a l s i n t o o n e p l a c e .
/ / P a r a b o l i c M a n a g e r i s r e s p o n s i b l e f o r t r i g g e r i n g a l l t h e m e s s a g e s t o t a s k s
/ / t h a t a r e n e i g h b o u r t o t h e h o v e r e d t a s k . T h i s w i l l h e l p a l o t t o c a t c h c a s e s
@ -42,6 +46,10 @@ Item {
/ / ( l a u n c h e r U r l , i n d e x )
property variant separators: [ ]
/ / n e w l a u n c h e r s i n o r d e r t o b e m o v e d i n c o r r e c t p l a c e
/ / ( l a u n c h e r , p o s )
property variant launchersToBeMoved: [ ]
Connections {
target: root
onTasksCountChanged: parManager . updateTasksEdgesIndexes ( ) ;
@ -461,4 +469,93 @@ Item {
return "" ;
}
/ / ! l a u n c h e r s T o B e M o v e d , n e w l a u n c h e r s t o h a v e b e e n a d d e d a n d m u s t b e r e p o s i t i o n e d
function addLauncherToBeMoved ( launcherUrl , toPos ) {
if ( ! hasLauncherToBeMoved ( launcherUrl ) ) {
launchersToBeMoved . push ( { launcher: launcherUrl , pos: Math . max ( 0 , toPos ) } ) ;
/ / c o n s o l e . l o g ( " - a d d l a u n c h e r - " ) ;
/ / p r i n t L a u n c h e r s T o B e M o v e d ( )
}
}
function printLaunchersToBeMoved ( ) {
for ( var j = 0 ; j < launchersToBeMoved . length ; ++ j ) {
console . log ( launchersToBeMoved [ j ] . launcher + " - " + launchersToBeMoved [ j ] . pos ) ;
}
}
function moveLauncherToCorrectPos ( launcherUrl , from ) {
if ( hasLauncherToBeMoved ( launcherUrl ) ) {
launchersToBeMovedTimer . from = from ;
launchersToBeMovedTimer . to = posOfLauncherToBeMoved ( launcherUrl ) ;
launchersToBeMovedTimer . launcherUrl = launcherUrl
removeLauncherToBeMoved ( launcherUrl ) ;
launchersToBeMovedTimer . start ( ) ;
}
}
function removeLauncherToBeMoved ( launcherUrl ) {
if ( hasLauncherToBeMoved ( launcherUrl ) ) {
var sLength = launchersToBeMoved . length ;
var index = - 1 ;
for ( var i = 0 ; i < sLength ; ++ i ) {
/ / ! s a f e t y c h e c k e r
if ( i >= launchersToBeMoved . length )
return - 1 ;
if ( launchersToBeMoved [ i ] . launcher === launcherUrl ) {
index = i ;
break ;
}
}
if ( index > - 1 ) {
/ / c o n s o l e . l o g ( " r e m o v i n g l a u n c h e r t o b e m o v e d : : " + l a u n c h e r U r l ) ;
launchersToBeMoved . splice ( index , 1 ) ;
}
}
}
function posOfLauncherToBeMoved ( launcherUrl ) {
var sLength = launchersToBeMoved . length ;
for ( var i = 0 ; i < sLength ; ++ i ) {
/ / ! s a f e t y c h e c k e r
if ( i >= launchersToBeMoved . length )
return - 1 ;
if ( launchersToBeMoved [ i ] . launcher === launcherUrl )
return launchersToBeMoved [ i ] . pos ;
}
return - 1 ;
}
function hasLauncherToBeMoved ( launcher ) {
return ( posOfLauncherToBeMoved ( launcher ) >= 0 ) ;
}
/ / ! T r y i n g t o a v o i d a b i n d i n g l o o p i n T a s k D e l e g a t e f o r m o d e l L a u n c h e r U r l a n d
/ / ! p r o p e r u p d a t i n g i n s e p a r a t o r s i n d e x e s
Timer {
id: launchersToBeMovedTimer
interval: 50
property int from: - 1
property int to: - 1
property string launcherUrl: ""
onTriggered: {
/ / c o n s o l e . l o g ( " t o b e m o v e d : " + l a u n c h e r U r l + " - " + f r o m + " - > " + t o )
tasksModel . move ( from , to ) ;
if ( latteDock && latteDock . launchersGroup >= Latte . Dock . LayoutLaunchers ) {
latteDock . universalLayoutManager . launchersSignals . moveTask ( plasmoid . id , latteDock . launchersGroup , from , to ) ;
}
tasksModel . syncLaunchers ( ) ;
}
}
}