1
0
mirror of https://github.com/KDE/latte-dock.git synced 2024-12-23 13:33:50 +03:00

check layout valid activities

This commit is contained in:
Michail Vourlakos 2020-08-30 21:28:22 +03:00
parent 567e3ab78f
commit 8448f36ed9
4 changed files with 28 additions and 5 deletions

View File

@ -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);
}
}

View File

@ -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();

View File

@ -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);

View File

@ -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;
}
}