@ -556,7 +556,7 @@ int DockCorona::noDocksWithTasks() const
int result = 0 ;
foreach ( auto view , m_dockViews ) {
if ( view - > tasksPresent ( ) & & view - > session ( ) = = m_session ) {
if ( view - > tasksPresent ( ) ) {
result + + ;
}
}
@ -621,14 +621,13 @@ void DockCorona::syncDockViews()
bool onPrimary = cont - > config ( ) . readEntry ( " onPrimary " , true ) ;
Plasma : : Types : : Location location = static_cast < Plasma : : Types : : Location > ( ( int ) cont - > config ( ) . readEntry ( " location " , ( int ) Plasma : : Types : : BottomEdge ) ) ;
Dock : : SessionType session = static_cast < Dock : : SessionType > ( ( int ) cont - > config ( ) . readEntry ( " session " , ( int ) Dock : : DefaultSession ) ) ;
//! two main situations that a dock must be added when it is not already running
//! 1. when a dock is primary, not running and the edge for which is associated is free
//! 2. when a dock in explicit, not running and the associated screen currently exists
//! e.g. the screen has just been added
if ( ( ( onPrimary & & freeEdges ( qGuiApp - > primaryScreen ( ) ) . contains ( location ) ) | | ( ! onPrimary & & ( m_screenPool - > connector ( id ) = = scr - > name ( ) ) ) )
& & ( ! m_dockViews . contains ( cont ) ) & & session = = currentSession ( ) ) {
& & ( ! m_dockViews . contains ( cont ) ) ) {
qDebug ( ) < < " screen Count signal: view must be added... for: " < < scr - > name ( ) ;
addDock ( cont ) ;
}
@ -689,14 +688,10 @@ void DockCorona::syncDockViews()
}
}
if ( view - > session ( ) ! = currentSession ( ) ) {
qDebug ( ) < < " deleting view that does not belong in this session... " ;
auto viewToDelete = m_dockViews . take ( view - > containment ( ) ) ;
viewToDelete - > deactivateApplets ( ) ;
viewToDelete - > deleteLater ( ) ;
//! which explicit docks can be deleted
} else if ( ! found & & ! view - > onPrimary ( ) & & ( m_dockViews . size ( ) > 1 ) & & m_dockViews . contains ( view - > containment ( ) )
& & ! ( view - > tasksPresent ( ) & & noDocksWithTasks ( ) = = 1 ) ) {
//! which explicit docks can be deleted
if ( ! found & & ! view - > onPrimary ( ) & & ( m_dockViews . size ( ) > 1 ) & & m_dockViews . contains ( view - > containment ( ) )
& & ! ( view - > tasksPresent ( ) & & noDocksWithTasks ( ) = = 1 ) ) {
//do not delete last dock containing tasks
if ( dockWithTasksWillBeShown | | preserveContainmentId ! = view - > containment ( ) - > id ( ) ) {
qDebug ( ) < < " screen Count signal: view must be deleted... for: " < < view - > currentScreen ( ) ;
@ -791,50 +786,9 @@ void DockCorona::aboutApplication()
aboutDialog - > show ( ) ;
}
Dock : : SessionType DockCorona : : currentSession ( )
int DockCorona : : noOfDocks ( )
{
return m_session ;
}
void DockCorona : : setCurrentSession ( Dock : : SessionType session )
{
if ( m_session = = session ) {
return ;
}
m_session = session ;
emit currentSessionChanged ( m_session ) ; ;
}
void DockCorona : : switchToSession ( Dock : : SessionType session )
{
if ( currentSession ( ) = = session ) {
return ;
}
setCurrentSession ( session ) ;
if ( noDocksForSession ( session ) = = 0 ) {
m_waitingSessionDocksCreation = true ;
loadDefaultLayout ( ) ;
} else {
m_waitingSessionDocksCreation = false ;
syncDockViews ( ) ;
}
}
int DockCorona : : noDocksForSession ( Dock : : SessionType session )
{
int count { 0 } ;
foreach ( auto cont , containments ( ) ) {
Dock : : SessionType ses = static_cast < Dock : : SessionType > ( cont - > config ( ) . readEntry ( " session " , ( int ) Dock : : DefaultSession ) ) ;
if ( session = = ses )
count + + ;
}
return count ;
return m_dockViews . count ( ) ;
}
QList < Plasma : : Types : : Location > DockCorona : : freeEdges ( QScreen * screen ) const
@ -844,7 +798,7 @@ QList<Plasma::Types::Location> DockCorona::freeEdges(QScreen *screen) const
Types : : TopEdge , Types : : RightEdge } ;
for ( auto * view : m_dockViews ) {
if ( view & & view - > currentScreen ( ) = = screen - > name ( ) & & view - > session ( ) = = m_session ) {
if ( view & & view - > currentScreen ( ) = = screen - > name ( ) ) {
edges . removeOne ( view - > location ( ) ) ;
}
}
@ -861,7 +815,7 @@ QList<Plasma::Types::Location> DockCorona::freeEdges(int screen) const
QScreen * scr = m_screenPool - > screenForId ( screen ) ;
for ( auto * view : m_dockViews ) {
if ( view & & scr & & view - > currentScreen ( ) = = scr - > name ( ) & & view - > session ( ) = = m_session ) {
if ( view & & scr & & view - > currentScreen ( ) = = scr - > name ( ) ) {
edges . removeOne ( view - > location ( ) ) ;
}
}
@ -929,14 +883,6 @@ void DockCorona::addDock(Plasma::Containment *containment, int expDockScreen)
if ( metadata . pluginId ( ) ! = " org.kde.latte.containment " )
return ;
int session = containment - > config ( ) . readEntry ( " session " , ( int ) Dock : : DefaultSession ) ;
//! when this containment does not belong to this session
if ( session ! = currentSession ( ) & & ! m_waitingSessionDocksCreation ) {
return ;
}
for ( auto * dock : m_dockViews ) {
if ( dock - > containment ( ) = = containment )
return ;
@ -1012,8 +958,6 @@ void DockCorona::addDock(Plasma::Containment *containment, int expDockScreen)
dockView - > setOnPrimary ( true ) ;
}
dockView - > setSession ( currentSession ( ) ) ;
connect ( containment , & QObject : : destroyed , this , & DockCorona : : dockContainmentDestroyed ) ;
connect ( containment , & Plasma : : Applet : : destroyedChanged , this , & DockCorona : : destroyedChanged ) ;
connect ( containment , & Plasma : : Applet : : locationChanged , this , & DockCorona : : dockLocationChanged ) ;
@ -1029,14 +973,6 @@ void DockCorona::addDock(Plasma::Containment *containment, int expDockScreen)
m_dockViews [ containment ] = dockView ;
if ( m_waitingSessionDocksCreation ) {
m_waitingSessionDocksCreation = false ;
if ( noDocksForSession ( currentSession ( ) ) = = 1 ) {
syncDockViews ( ) ;
}
}
emit docksCountChanged ( ) ;
}
@ -1172,16 +1108,12 @@ void DockCorona::loadDefaultLayout()
defaultContainment - > restore ( config ) ;
QList < Plasma : : Types : : Location > edges = freeEdges ( defaultContainment - > screen ( ) ) ;
if ( ( edges . count ( ) > 0 ) & & ! m_waitingSessionDocksCreation ) {
if ( ( edges . count ( ) > 0 ) ) {
defaultContainment - > setLocation ( edges . at ( 0 ) ) ;
} else {
defaultContainment - > setLocation ( Plasma : : Types : : BottomEdge ) ;
}
if ( currentSession ( ) ! = Dock : : DefaultSession ) {
config . writeEntry ( " session " , ( int ) currentSession ( ) ) ;
}
defaultContainment - > updateConstraints ( Plasma : : Types : : StartupCompletedConstraint ) ;
defaultContainment - > save ( config ) ;
@ -1353,10 +1285,6 @@ void DockCorona::copyDock(Plasma::Containment *containment)
newContainment - > config ( ) . writeEntry ( " lastScreen " , dockScrId ) ;
}
if ( currentSession ( ) ! = Dock : : DefaultSession ) {
newContainment - > config ( ) . writeEntry ( " session " , ( int ) currentSession ( ) ) ;
}
newContainment - > updateConstraints ( Plasma : : Types : : StartupCompletedConstraint ) ;
newContainment - > save ( config ) ;
@ -1388,7 +1316,6 @@ bool DockCorona::heuresticForLoadingDockWithTasks()
if ( plugin = = " org.kde.latte.containment " ) {
bool onPrimary = containmentsEntries . group ( cId ) . readEntry ( " onPrimary " , true ) ;
int lastScreen = containmentsEntries . group ( cId ) . readEntry ( " lastScreen " , - 1 ) ;
Dock : : SessionType session = static_cast < Dock : : SessionType > ( containmentsEntries . group ( cId ) . readEntry ( " session " , ( int ) Dock : : DefaultSession ) ) ;
qDebug ( ) < < " containment values: " < < onPrimary < < " - " < < lastScreen ;
@ -1403,7 +1330,7 @@ bool DockCorona::heuresticForLoadingDockWithTasks()
}
}
if ( containsTasks & & session = = Dock : : DefaultSession ) {
if ( containsTasks ) {
m_firstContainmentWithTasks = cId . toInt ( ) ;
if ( onPrimary ) {