@ -126,6 +126,9 @@ QtObject {
}
}
readonly property QtObject focusDialog: plasmoid . nativeInterface . focussedPlasmaDialog
onFocusDialogChanged: positionPopups ( )
/ / T h e r a w w i d t h o f t h e p o p u p ' s c o n t e n t i t e m , t h e D i a l o g i t s e l f a d d s s o m e m a r g i n s
property int popupWidth: units . gridUnit * 18
property int popupEdgeDistance: units . largeSpacing * 2
@ -212,6 +215,13 @@ QtObject {
} ) ;
}
function rectIntersect ( rect1 /*dialog*/ , rect2 /*popup*/ ) {
return rect1 . x < rect2 . x + rect2 . width
&& rect2 . x < rect1 . x + rect1 . width
&& rect1 . y < rect2 . y + rect2 . height
&& rect2 . y < rect1 . y + rect1 . height ;
}
function positionPopups ( ) {
if ( ! plasmoid ) {
return ;
@ -251,12 +261,22 @@ QtObject {
}
if ( popupLocation & Qt . AlignTop ) {
/ / W e w a n t t o c a l c u l a t e t h e n e w p o s i t i o n b a s e d o n i t s o r i g i n a l t a r g e t p o s i t i o n t o a v o i d p o s i t i o n i n g i t a n d t h e n
/ / p o s i t i o n i n g i t a g a i n , h e n c e t h e t e m p o r a r y Q t . r e c t w i t h e x p l i c i t " y " a n d n o t j u s t t h e p o p u p a s a w h o l e
if ( focusDialog && focusDialog . visible && focusDialog !== popup
&& rectIntersect ( focusDialog , Qt . rect ( popup . x , y , popup . width , popup . height ) ) ) {
y = focusDialog . y + focusDialog . height + popupEdgeDistance ;
}
popup . y = y ;
/ / I f t h e p o p u p i s n ' t r e a d y y e t , i g n o r e i t s o c c u p i e d s p a c e f o r n o w .
/ / W e ' l l r e p o s i t i o n e v e r y t h i n g i n o n H e i g h t C h a n g e d e v e n t u a l l y .
y += popup . height + ( popup . height > 0 ? popupSpacing : 0 ) ;
} else {
y -= popup . height ;
if ( focusDialog && focusDialog . visible && focusDialog !== popup
&& rectIntersect ( focusDialog , Qt . rect ( popup . x , y , popup . width , popup . height ) ) ) {
y = focusDialog . y - popup . height - popupEdgeDistance ;
}
popup . y = y ;
if ( popup . height > 0 ) {
y -= popupSpacing ;
@ -273,18 +293,7 @@ QtObject {
}
}
popup . visible = Qt . binding ( function ( ) {
const dialog = plasmoid . nativeInterface . focussedPlasmaDialog ;
if ( dialog && dialog . visible && dialog !== popup ) {
/ / I f t h e n o t i f i c a t i o n o b s c u r e s a n y o t h e r P l a s m a d i a l o g , h i d e i t
/ / N o r e c t i n t e r s e c t s i n J S . . .
if ( dialog . x < popup . x + popup . width && popup . x < dialog . x + dialog . width && dialog . y < popup . y + popup . height && popup . y < dialog . y + dialog . height ) {
return false ;
}
}
return visible ;
} ) ;
popup . visible = visible ;
}
}