check active layouts also for broken state

pull/2/head
Michail Vourlakos 7 years ago
parent 4fae38ff8e
commit 7e2fc0f895

@ -325,21 +325,23 @@ bool Layout::isOriginalLayout() const
return m_layoutName != MultipleLayoutsName;
}
bool Layout::fileIsBroken() const
bool Layout::layoutIsBroken() const
{
if (m_layoutFile.isEmpty() || !QFile(m_layoutFile).exists()) {
return false;
}
QStringList ids;
QStringList conts;
QStringList applets;
KSharedConfigPtr lFile = KSharedConfig::openConfig(m_layoutFile);
KConfigGroup containmentsEntries = KConfigGroup(lFile, "Containments");
QStringList ids;
if (!m_corona) {
KConfigGroup containmentsEntries = KConfigGroup(lFile, "Containments");
ids << containmentsEntries.groupList();
QStringList conts;
conts << ids;
QStringList applets;
foreach (auto cId, containmentsEntries.groupList()) {
auto appletsEntries = containmentsEntries.group(cId).group("Applets");
@ -347,18 +349,36 @@ bool Layout::fileIsBroken() const
ids << appletsEntries.groupList();
applets << appletsEntries.groupList();
}
} else {
foreach (auto containment, m_containments) {
ids << QString::number(containment->id());
conts << ids;
foreach (auto applet, containment->applets()) {
ids << QString::number(applet->id());
applets << QString::number(applet->id());
}
}
}
QSet<QString> idsSet = QSet<QString>::fromList(ids);
/* a different way to count duplicates
QMap<QString, int> countOfStrings;
for (int i = 0; i < ids.count(); i++) {
countOfStrings[ids[i]]++;
}
}*/
if (idsSet.count() != ids.count()) {
qDebug() << " ---- ERROR - BROKEN LAYOUT :: " << m_layoutName << " ----";
if (!m_corona) {
qDebug() << " ---- file : " << m_layoutFile;
} else {
qDebug() << " ---- in multiple layouts hidden file : " << Importer::layoutFilePath(Layout::MultipleLayoutsName);
}
qDebug() << "Contaiments :: " << conts;
qDebug() << "Applets :: " << applets;
@ -378,12 +398,25 @@ bool Layout::fileIsBroken() const
qDebug() << " -- - -- - -- - -- - - -- - - - - -- - - - - ";
if (!m_corona) {
KConfigGroup containmentsEntries = KConfigGroup(lFile, "Containments");
foreach (auto cId, containmentsEntries.groupList()) {
auto appletsEntries = containmentsEntries.group(cId).group("Applets");
qDebug() << " CONTAINMENT : " << cId << " APPLETS : " << appletsEntries.groupList();
}
} else {
foreach (auto containment, m_containments) {
QStringList appletsIds;
foreach (auto applet, containment->applets()) {
appletsIds << QString::number(applet->id());
}
qDebug() << " CONTAINMENT : " << containment->id() << " APPLETS : " << appletsIds.join(",");
}
}
return true;
}

@ -58,7 +58,7 @@ public:
bool showInMenu() const;
void setShowInMenu(bool show);
bool fileIsBroken() const;
bool layoutIsBroken() const;
//!this layout is loaded and running
bool isActiveLayout() const;

@ -618,7 +618,9 @@ void LayoutConfigDialog::loadLayouts()
ui->layoutsView->selectRow(i - 1);
}
if (!(m_manager->memoryUsage() == Dock::MultipleLayouts && m_manager->activeLayout(layout)) && layoutSets->fileIsBroken()) {
Layout *activeLayout = m_manager->activeLayout(layoutSets->name());
if ((activeLayout && activeLayout->layoutIsBroken()) || (!activeLayout && layoutSets->layoutIsBroken())) {
brokenLayouts.append(layoutSets->name());
}
}

Loading…
Cancel
Save