mirror of
https://github.com/KDE/latte-dock.git
synced 2025-03-06 16:58:17 +03:00
remove old applets config from active containments
This commit is contained in:
parent
2d2c7875e7
commit
2c0e536cf9
@ -88,11 +88,23 @@ void DockCorona::cleanConfig()
|
||||
auto containmentsEntries = config()->group("Containments");
|
||||
bool changed = false;
|
||||
|
||||
foreach (auto id, containmentsEntries.groupList()) {
|
||||
if (!containmentExists(id.toInt())) {
|
||||
containmentsEntries.group(id).deleteGroup();
|
||||
foreach (auto cId, containmentsEntries.groupList()) {
|
||||
if (!containmentExists(cId.toInt())) {
|
||||
//cleanup obsolete containments
|
||||
containmentsEntries.group(cId).deleteGroup();
|
||||
changed = true;
|
||||
qDebug() << "obsolete containment configuration deleted:" << id;
|
||||
qDebug() << "obsolete containment configuration deleted:" << cId;
|
||||
} else {
|
||||
//cleanup obsolete applets of running containments
|
||||
auto appletsEntries = containmentsEntries.group(cId).group("Applets");
|
||||
|
||||
foreach (auto appletId, appletsEntries.groupList()) {
|
||||
if (!appletExists(cId.toInt(), appletId.toInt())) {
|
||||
appletsEntries.group(appletId).deleteGroup();
|
||||
changed = true;
|
||||
qDebug() << "obsolete applet configuration deleted:" << appletId;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -113,6 +125,30 @@ bool DockCorona::containmentExists(int id) const
|
||||
return false;
|
||||
}
|
||||
|
||||
bool DockCorona::appletExists(int containmentId, int appletId) const
|
||||
{
|
||||
Plasma::Containment *containment = nullptr;
|
||||
|
||||
foreach (auto cont, containments()) {
|
||||
if (containmentId == cont->id()) {
|
||||
containment = cont;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!containment) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach (auto applet, containment->applets()) {
|
||||
if (applet->id() == appletId) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
int DockCorona::numScreens() const
|
||||
{
|
||||
return qGuiApp->screens().count();
|
||||
|
@ -71,6 +71,7 @@ private slots:
|
||||
void load();
|
||||
|
||||
private:
|
||||
bool appletExists(int containmentId, int appletId) const;
|
||||
void cleanConfig();
|
||||
bool containmentExists(int id) const;
|
||||
void qmlRegisterTypes() const;
|
||||
|
@ -529,7 +529,7 @@ DragDrop.DropArea {
|
||||
}
|
||||
|
||||
Component.onDestruction: {
|
||||
console.log("Destroying Latte Dock Containment UI...");
|
||||
console.debug("Destroying Latte Dock Containment ui...");
|
||||
}
|
||||
|
||||
Containment.onAppletAdded: {
|
||||
|
Loading…
x
Reference in New Issue
Block a user