@ -27,7 +27,17 @@ import QtQml.Models 2.2
Item {
Item {
id: windowsContainer
id: windowsContainer
property int windowsCount: 0
property int windowsCount: {
if ( isLauncher ) {
return 0 ;
}
if ( isGroupParent ) {
return windowsRepeater . count ;
}
return 1 ;
}
property bool isLauncher: IsLauncher ? true : false
property bool isLauncher: IsLauncher ? true : false
property bool isStartup: IsStartup ? true : false
property bool isStartup: IsStartup ? true : false
@ -35,44 +45,67 @@ Item{
property int lastActiveWinInGroup: - 1
property int lastActiveWinInGroup: - 1
onIsLauncherChanged: updateCounter ( ) ;
/ / o n I s S t a r t u p C h a n g e d : u p d a t e C o u n t e r ( ) ;
/ / o n I s W i n d o w C h a n g e d : u p d a t e C o u n t e r ( ) ;
/ / s t a t e s t h a t e x i s t i n w i n d o w s i n a G r o u p o f w i n d o w s
/ / s t a t e s t h a t e x i s t i n w i n d o w s i n a G r o u p o f w i n d o w s
property bool hasMinimized: false ;
property bool hasMinimized: false ;
property bool hasShown: false ;
property bool hasShown: false ;
property bool hasActive: false ;
property bool hasActive: false ;
/ / F I X M E : F o r s o m e r e a s o n t h e i n d e x i s n o t u p d a t e d c o r r e c t l y i n s o m e c a s e s ( e . g . w i n d o w d r a g g i n g , r e p o s i t i o n i n g l a u n c h e r s )
/ / a n d t h i s w a y m u c h b e a u t i f u l i n f o r m a t i o n a r e l o s t , a n a c t i v i t y c h a n g e b a c k a n d r e t u r n ,
/ / i t f i x e s t h i s s o m e t i m e s . . .
Repeater {
Repeater {
id: windowsRepeater
model: DelegateModel {
model: DelegateModel {
id: windowsLocalModel
id: windowsLocalModel
model: tasksModel
model: tasksModel
/ / ! T h i s i s a l i t t l e s u s p i c i o u s c o d e f o r c r a s h e s
/ / ! d u r i n g d r a g g i n g o r w h e n t h e d r a g g i n g e n d s . I t n e e d s
/ / ! i n v e s t i g a t i o n t o b e c o n f i r m e d o r n o t
rootIndex: tasksModel . makeModelIndex ( currentIndex >= 0 ? currentIndex : index )
property int currentIndex: - 1
delegate: Item {
delegate: Item {
readonly property string title: display !== undefined ? display : ""
readonly property string title: display !== undefined ? display : ""
readonly property bool isMinimized: IsMinimized === true ? true : false
readonly property bool isMinimized: IsMinimized === true ? true : false
readonly property bool isActive: IsActive === true ? true : false
onIsMinimizedChanged: windowsContainer . initializeStates ( ) ;
onIsMinimizedChanged: windowsContainer . updateStates ( ) ;
onIsActiveChanged: {
if ( isActive ) {
windowsContainer . lastActiveWinInGroup = ( LegacyWinIdList !== undefined ? LegacyWinIdList [ 0 ] : 0 ) ;
}
windowsContainer . updateStates ( ) ;
}
}
Component.onCompleted: {
rootIndex = mainItemContainer . modelIndex ( ) ;
}
}
}
}
}
Connections {
target: mainItemContainer
onItemIndexChanged: windowsContainer . updateStates ( ) ;
}
Connections {
target: root
onInDraggingPhaseChanged: windowsContainer . updateStates ( ) ;
}
/ / ! t r y t o g i v e t h e t i m e t o t h e m o d e l t o u p d a t e i t s s t a t e s i n o r d e r t o
/ / ! a v o i d a n y s u s p i c i o u s c r a s h e s d u r i n g d r a g g i n g g r o u p e d t a s k s t h a t
/ / ! a r e s y n c e d b e t w e e n m u l t i p l e p a n e l s / d o c k s . A t t h e s a m e t i m e i n u p d a t e S t a t e s ( )
/ / ! f u n c t i o n w e b l o c k a n y D e l e g a t e M o d e l u p d a t e s w h e n t h e u s e r i s d r a g g i n g
/ / ! a t a s k b e c a u s e t h i s c o u l d c r e a t e c r a s h e s
Timer {
id: initializeStatesTimer
interval: 200
onTriggered: windowsContainer . initializeStates ( ) ;
}
onCountChanged: {
function updateStates ( ) {
windowsContainer . updateCounter ( ) ;
if ( ! root . inDraggingPhase ) {
initializeStatesTimer . start ( ) ;
}
}
}
}
function initializeStates ( ) {
function initializeStates ( ) {
windowsLocalModel . rootIndex = mainItemContainer . modelIndex ( ) ;
hasMinimized = false ;
hasMinimized = false ;
hasShown = false ;
hasShown = false ;
hasActive = false ;
hasActive = false ;
@ -93,7 +126,6 @@ Item{
}
}
function checkInternalStates ( ) {
function checkInternalStates ( ) {
windowsLocalModel . currentIndex = index ;
var childs = windowsLocalModel . items ;
var childs = windowsLocalModel . items ;
for ( var i = 0 ; i < childs . count ; ++ i ) {
for ( var i = 0 ; i < childs . count ; ++ i ) {
@ -110,22 +142,14 @@ Item{
}
}
function windowsTitles ( ) {
function windowsTitles ( ) {
windowsLocalModel . rootIndex = mainItemContainer . modelIndex ( ) ;
var result = new Array ;
var result = new Array ;
windowsLocalModel . currentIndex = index ;
var childs = windowsLocalModel . items ;
var childs = windowsLocalModel . items ;
for ( var i = 0 ; i < childs . count ; ++ i ) {
for ( var i = 0 ; i < childs . count ; ++ i ) {
var kid = childs . get ( i ) ;
var kid = childs . get ( i ) ;
var title = kid . model . display
var title = kid . model . display
/ / c o n s o l e . l o g ( t i t l e ) ;
/ / F I X M E : w e m a y n e e d a w a y t o r e m o v e t h e a p p n a m e f r o m t h e e n d
/ * v a r l s t = t i t l e . l a s t I n d e x O f ( " - " ) ;
if ( lst > 0 ) {
title = title . substring ( 0 , lst ) ;
} * /
result . push ( title ) ;
result . push ( title ) ;
}
}
@ -135,13 +159,13 @@ Item{
/ / ! f u n c t i o n w h i c h i s u s e d t o c y c l e a c t i v a t i o n i n t o
/ / ! f u n c t i o n w h i c h i s u s e d t o c y c l e a c t i v a t i o n i n t o
/ / ! a g r o u p o f w i n d o w s
/ / ! a g r o u p o f w i n d o w s
function activateNextTask ( ) {
function activateNextTask ( ) {
windowsLocalModel . rootIndex = mainItemContainer . modelIndex ( ) ;
if ( ! mainItemContainer . isGroupParent ) {
if ( ! mainItemContainer . isGroupParent ) {
return ;
return ;
}
}
windowsLocalModel . currentIndex = index ;
var childs = windowsLocalModel . items ;
var childs = windowsLocalModel . items ;
var nextAvailableWindow = - 1 ;
var nextAvailableWindow = - 1 ;
for ( var i = 0 ; i < childs . count ; ++ i ) {
for ( var i = 0 ; i < childs . count ; ++ i ) {
@ -178,11 +202,12 @@ Item{
/ / ! f u n c t i o n w h i c h i s u s e d t o c y c l e a c t i v a t i o n i n t o
/ / ! f u n c t i o n w h i c h i s u s e d t o c y c l e a c t i v a t i o n i n t o
/ / ! a g r o u p o f w i n d o w s b a c k w i s e
/ / ! a g r o u p o f w i n d o w s b a c k w i s e
function activatePreviousTask ( ) {
function activatePreviousTask ( ) {
windowsLocalModel . rootIndex = mainItemContainer . modelIndex ( ) ;
if ( ! mainItemContainer . isGroupParent ) {
if ( ! mainItemContainer . isGroupParent ) {
return ;
return ;
}
}
windowsLocalModel . currentIndex = index ;
var childs = windowsLocalModel . items ;
var childs = windowsLocalModel . items ;
/ / i n d i c a t e s t h a n n o t h i n g w a s f o u n d
/ / i n d i c a t e s t h a n n o t h i n g w a s f o u n d
@ -218,69 +243,11 @@ Item{
tasksModel . requestActivate ( tasksModel . makeModelIndex ( index , prevAvailableWindow ) ) ;
tasksModel . requestActivate ( tasksModel . makeModelIndex ( index , prevAvailableWindow ) ) ;
}
}
/ / k e e p a r e c o r d o f t h e l a s t a c t i v e w i n d o w i n a g r o u p
Connections {
target: tasksModel
onActiveTaskChanged: {
if ( ! mainItemContainer . isGroupParent ) {
return ;
}
windowsLocalModel . currentIndex = index ;
var childs = windowsLocalModel . items ;
for ( var i = 0 ; i < childs . count ; ++ i ) {
var kid = childs . get ( i ) ;
if ( kid . model . IsActive === true ) {
windowsContainer . lastActiveWinInGroup = kid . model . LegacyWinIdList ? kid . model . LegacyWinIdList [ 0 ] : 0 ;
break ;
}
}
}
}
Component.onCompleted: {
Component.onCompleted: {
mainItemContainer . checkWindowsStates . connect ( initializeStates ) ;
mainItemContainer . checkWindowsStates . connect ( initializeStates ) ;
updateCounter ( ) ;
}
}
Component.onDestruction: {
Component.onDestruction: {
mainItemContainer . checkWindowsStates . disconnect ( initializeStates ) ;
mainItemContainer . checkWindowsStates . disconnect ( initializeStates ) ;
}
}
function updateCounter ( ) {
/ / c o n s o l e . l o g ( " - - - - - - - - - " + i n d e x + " - - - - - - - " ) ;
if ( index >= 0 ) {
if ( IsGroupParent ) {
windowsLocalModel . currentIndex = index ;
var tempC = windowsLocalModel . count ;
if ( tempC == 0 ) {
if ( isLauncher ) {
windowsCount = 0 ;
}
else if ( isWindow || isStartup ) {
windowsCount = 1 ;
}
}
else {
windowsCount = tempC ;
}
}
else {
if ( isLauncher ) {
windowsCount = 0 ;
}
else if ( isWindow || isStartup ) {
windowsCount = 1 ;
}
}
initializeStates ( ) ;
}
}
}
}