update free activities flag from external changes

--when the user has altered the free_activities from
its context menu then settings window it must better
update its record concerning the layout that will
be responsible for free activities
pull/11/head
Michail Vourlakos 5 years ago
parent b960a8579e
commit 3246ce2447

@ -24,6 +24,7 @@
#include "../data/layoutdata.h"
#include "../../layouts/manager.h"
#include "../../layouts/synchronizer.h"
#include "../../settings/universalsettings.h"
// Qt
#include <QDebug>
@ -61,6 +62,11 @@ Layouts::Layouts(QObject *parent, Latte::Corona *corona)
connect(m_corona->layoutsManager(), &Latte::Layouts::Manager::currentLayoutNameChanged, this, &Layouts::updateActiveStates);
connect(m_corona->layoutsManager(), &Latte::Layouts::Manager::centralLayoutsChanged, this, &Layouts::updateActiveStates);
connect(m_corona->universalSettings(), &Latte::UniversalSettings::lastNonAssignedLayoutNameChanged, this, [&]() {
//FREE ACTIVITES LAYOUT changed and our model must be updated...
assignFreeActivitiesLayoutAt(m_corona->universalSettings()->lastNonAssignedLayoutName());
});
}
Layouts::~Layouts()
@ -417,6 +423,22 @@ QStringList Layouts::cleanStrings(const QStringList &original, const QStringList
}
void Layouts::assignFreeActivitiesLayoutAt(const QString &layoutName)
{
QString reqId = m_layoutsTable.idForOriginalName(layoutName);
if (reqId.isEmpty()) {
reqId = m_layoutsTable.idForCurrentName(layoutName);
if (reqId.isEmpty()) {
return;
}
}
int row = m_layoutsTable.indexOf(reqId);
setActivities(row, QStringList(Data::Layout::FREEACTIVITIESID));
setShares(row, QStringList());
}
void Layouts::autoAssignFreeActivitiesLayout()
{
QVector<int> roles;

@ -123,7 +123,9 @@ private slots:
private:
void initActivities();
void assignFreeActivitiesLayoutAt(const QString &layoutName);
void autoAssignFreeActivitiesLayout();
void setActivities(const int &row, const QStringList &activities);
void setId(const int &row, const QString &newId);
void setShares(const int &row, const QStringList &shares);

Loading…
Cancel
Save