mirror of
https://github.com/KDE/latte-dock.git
synced 2024-12-23 01:33:50 +03:00
layout:add function to remove orphan subcontainment
This commit is contained in:
parent
b9c2560a77
commit
837842f1f1
@ -1651,12 +1651,36 @@ void GenericLayout::removeView(const Latte::Data::View &viewData)
|
||||
}
|
||||
|
||||
Plasma::Containment *viewcontainment = containmentForId(viewData.id.toUInt());
|
||||
destroyContainment(viewcontainment);
|
||||
}
|
||||
|
||||
if (viewcontainment) {
|
||||
m_containments.removeAll(viewcontainment);
|
||||
viewcontainment->setImmutability(Plasma::Types::Mutable);
|
||||
viewcontainment->destroy();
|
||||
void GenericLayout::removeOrphanedSubContainment(const int &containmentId)
|
||||
{
|
||||
Data::ViewsTable views = viewsTable();
|
||||
QString cidstr = QString::number(containmentId);
|
||||
|
||||
if (views.hasContainmentId(cidstr)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isActive()) {
|
||||
Layouts::Storage::self()->removeContainment(file(), cidstr);
|
||||
return;
|
||||
}
|
||||
|
||||
Plasma::Containment *orphanedcontainment = containmentForId(cidstr.toUInt());
|
||||
destroyContainment(orphanedcontainment);
|
||||
}
|
||||
|
||||
void GenericLayout::destroyContainment(Plasma::Containment *containment)
|
||||
{
|
||||
if (!containment) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_containments.removeAll(containment);
|
||||
containment->setImmutability(Plasma::Types::Mutable);
|
||||
containment->destroy();
|
||||
}
|
||||
|
||||
QString GenericLayout::storedView(const int &containmentId)
|
||||
|
@ -129,6 +129,7 @@ public:
|
||||
void removeView(const Latte::Data::View &viewData);
|
||||
void updateView(const Latte::Data::View &viewData);
|
||||
QString storedView(const int &containmentId); //returns temp filepath containing all view data
|
||||
void removeOrphanedSubContainment(const int &containmentId);
|
||||
|
||||
//! Available edges for specific view in that screen
|
||||
virtual QList<Plasma::Types::Location> availableEdgesForView(QScreen *scr, Latte::View *forView) const;
|
||||
@ -207,6 +208,8 @@ private:
|
||||
|
||||
QList<Latte::Data::View> sortedViewsData(const QList<Latte::Data::View> &viewsData);
|
||||
|
||||
void destroyContainment(Plasma::Containment *containment);
|
||||
|
||||
private:
|
||||
bool m_blockAutomaticLatteViewCreation{false};
|
||||
|
||||
|
@ -1582,15 +1582,27 @@ void Storage::removeView(const QString &filepath, const Data::View &viewData)
|
||||
return;
|
||||
}
|
||||
|
||||
removeContainment(filepath, viewData.id);
|
||||
|
||||
for (int i=0; i<viewData.subcontainments.rowCount(); ++i) {
|
||||
removeContainment(filepath, viewData.subcontainments[i].id);
|
||||
}
|
||||
}
|
||||
|
||||
void Storage::removeContainment(const QString &filepath, const QString &containmentId)
|
||||
{
|
||||
if (containmentId.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
KSharedConfigPtr lFile = KSharedConfig::openConfig(filepath);
|
||||
KConfigGroup containmentGroups = KConfigGroup(lFile, "Containments");
|
||||
|
||||
containmentGroups.group(viewData.id).deleteGroup();
|
||||
|
||||
for (int i=0; i<viewData.subcontainments.rowCount(); ++i) {
|
||||
containmentGroups.group(viewData.subcontainments[i].id).deleteGroup();
|
||||
if (!containmentGroups.group(containmentId).exists()) {
|
||||
return;
|
||||
}
|
||||
|
||||
containmentGroups.group(containmentId).deleteGroup();
|
||||
containmentGroups.sync();
|
||||
}
|
||||
|
||||
|
@ -86,6 +86,8 @@ public:
|
||||
void updateView(KConfigGroup viewGroup, const Data::View &viewData);
|
||||
QString storedView(const Layout::GenericLayout *layout, const int &containmentId); //returns temp filepath containing all view data
|
||||
|
||||
void removeContainment(const QString &filepath, const QString &containmentId);
|
||||
|
||||
bool exportTemplate(const QString &originFile, const QString &destinationFile, const Data::AppletsTable &approvedApplets);
|
||||
bool exportTemplate(const Layout::GenericLayout *layout, Plasma::Containment *containment, const QString &destinationFile, const Data::AppletsTable &approvedApplets);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user