diff --git a/app/layout/centrallayout.cpp b/app/layout/centrallayout.cpp index 2a245c173..545f110a5 100644 --- a/app/layout/centrallayout.cpp +++ b/app/layout/centrallayout.cpp @@ -188,7 +188,7 @@ const QStringList CentralLayout::appliedActivities() } else if (isForFreeActivities()) { return m_corona->layoutsManager()->synchronizer()->freeRunningActivities(); } else { - return m_activities; + return m_corona->layoutsManager()->synchronizer()->validActivities(m_activities); } } diff --git a/app/layouts/synchronizer.cpp b/app/layouts/synchronizer.cpp index 911c685a2..b2ca8713c 100644 --- a/app/layouts/synchronizer.cpp +++ b/app/layouts/synchronizer.cpp @@ -171,6 +171,20 @@ QStringList Synchronizer::freeRunningActivities() return fActivities; } +QStringList Synchronizer::validActivities(const QStringList &layoutActivities) +{ + QStringList valids; + QStringList allactivities = activities(); + + for(auto activity : layoutActivities) { + if (allactivities.contains(activity)) { + valids << activity; + } + } + + return valids; +} + QStringList Synchronizer::centralLayoutsNames() { QStringList names; @@ -490,8 +504,8 @@ void Synchronizer::initLayouts() void Synchronizer::onLayoutAdded(const QString &layout) { - CentralLayout centralLayout(this, layout); - m_layouts.insertBasedOnName(centralLayout.data()); + CentralLayout centrallayout(this, layout); + m_layouts.insertBasedOnName(centrallayout.data()); if (m_isLoaded) { emit layoutsChanged(); diff --git a/app/layouts/synchronizer.h b/app/layouts/synchronizer.h index 986470db9..e21d6d77c 100644 --- a/app/layouts/synchronizer.h +++ b/app/layouts/synchronizer.h @@ -97,6 +97,7 @@ public: QStringList freeActivities(); QStringList runningActivities(); QStringList freeRunningActivities(); //! These are activities that haven't been assigned to specific layout + QStringList validActivities(const QStringList &layoutActivities); Latte::View *viewForContainment(Plasma::Containment *containment); Latte::View *viewForContainment(uint id); diff --git a/app/settings/delegates/activitiesdelegate.cpp b/app/settings/delegates/activitiesdelegate.cpp index 04725f5dc..2dacf8cd5 100644 --- a/app/settings/delegates/activitiesdelegate.cpp +++ b/app/settings/delegates/activitiesdelegate.cpp @@ -264,10 +264,18 @@ void Activities::setModelData(QWidget *editor, QAbstractItemModel *model, const return; } - QStringList assignedActivities; + //! keep activities that are present in other computers + QStringList assignedActivities = index.data(Qt::UserRole).toStringList(); + foreach (QAction *action, button->menu()->actions()) { QString activityid = action->data().toString(); - if (action->isChecked() && activityid != Data::Layout::CURRENTACTIVITYID) { + if (activityid == Data::Layout::CURRENTACTIVITYID) { + continue; + } + + if (!action->isChecked()) { + assignedActivities.removeAll(activityid); + } else if (action->isChecked() && !assignedActivities.contains(activityid)) { assignedActivities << activityid; } }