mirror of
https://github.com/KDE/latte-dock.git
synced 2024-12-23 01:33:50 +03:00
viewdialog:provide remove views functionality
This commit is contained in:
parent
585864df8c
commit
7bd55c202f
@ -431,6 +431,20 @@ int GenericLayout::screenForContainment(Plasma::Containment *containment)
|
|||||||
return containment->lastScreen();
|
return containment->lastScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool GenericLayout::containsView(const int &containmentId) const
|
||||||
|
{
|
||||||
|
if (!isActive()) {
|
||||||
|
return Layouts::Storage::self()->containsView(file(), containmentId);
|
||||||
|
}
|
||||||
|
|
||||||
|
for(auto containment : m_containments) {
|
||||||
|
if ((int)containment->id() == containmentId && Layouts::Storage::self()->isLatteContainment(containment)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
Latte::View *GenericLayout::viewForContainment(Plasma::Containment *containment) const
|
Latte::View *GenericLayout::viewForContainment(Plasma::Containment *containment) const
|
||||||
{
|
{
|
||||||
@ -1615,6 +1629,53 @@ void GenericLayout::updateView(const Latte::Data::View &viewData)
|
|||||||
syncLatteViewsToScreens();
|
syncLatteViewsToScreens();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GenericLayout::removeView(const Latte::Data::View &viewData)
|
||||||
|
{
|
||||||
|
if (!containsView(viewData.id.toInt())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isActive()) {
|
||||||
|
Layouts::Storage::self()->removeView(file(), viewData);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Latte::View *view = viewForContainment(viewData.id.toUInt());
|
||||||
|
|
||||||
|
if (view) {
|
||||||
|
//! viewMustBeDeleted
|
||||||
|
m_latteViews.remove(view->containment());
|
||||||
|
view->disconnectSensitiveSignals();
|
||||||
|
view->positioner()->hideOnExit();
|
||||||
|
delete view;
|
||||||
|
}
|
||||||
|
|
||||||
|
//! delete also the relevant containments
|
||||||
|
Plasma::Containment *viewcontainment = containmentForId(viewData.id.toUInt());
|
||||||
|
|
||||||
|
if (viewcontainment) {
|
||||||
|
m_containments.removeAll(viewcontainment);
|
||||||
|
delete viewcontainment;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i=0; i<viewData.subcontainments.rowCount(); ++i) {
|
||||||
|
Plasma::Containment *subcontainment = containmentForId(viewData.subcontainments[i].id.toUInt());
|
||||||
|
|
||||||
|
if (subcontainment) {
|
||||||
|
m_containments.removeAll(subcontainment);
|
||||||
|
delete subcontainment;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_corona->layoutsManager()->memoryUsage() == MemoryUsage::MultipleLayouts) {
|
||||||
|
QString multiplelayoutfile = Layouts::Importer::layoutUserFilePath(Layout::MULTIPLELAYOUTSHIDDENNAME);
|
||||||
|
Layouts::Storage::self()->removeView(multiplelayoutfile, viewData);
|
||||||
|
} else {
|
||||||
|
//! remove from storage
|
||||||
|
Layouts::Storage::self()->removeView(file(), viewData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void GenericLayout::importToCorona()
|
void GenericLayout::importToCorona()
|
||||||
{
|
{
|
||||||
Layouts::Storage::self()->importToCorona(this);
|
Layouts::Storage::self()->importToCorona(this);
|
||||||
|
@ -90,6 +90,7 @@ public:
|
|||||||
const QList<Plasma::Containment *> *containments() const;
|
const QList<Plasma::Containment *> *containments() const;
|
||||||
|
|
||||||
bool contains(Plasma::Containment *containment) const;
|
bool contains(Plasma::Containment *containment) const;
|
||||||
|
bool containsView(const int &containmentId) const;
|
||||||
int screenForContainment(Plasma::Containment *containment);
|
int screenForContainment(Plasma::Containment *containment);
|
||||||
|
|
||||||
Latte::View *highestPriorityView();
|
Latte::View *highestPriorityView();
|
||||||
@ -125,6 +126,7 @@ public:
|
|||||||
bool latteViewExists(Plasma::Containment *containment);
|
bool latteViewExists(Plasma::Containment *containment);
|
||||||
|
|
||||||
void updateView(const Latte::Data::View &viewData);
|
void updateView(const Latte::Data::View &viewData);
|
||||||
|
void removeView(const Latte::Data::View &viewData);
|
||||||
|
|
||||||
//! Available edges for specific view in that screen
|
//! Available edges for specific view in that screen
|
||||||
virtual QList<Plasma::Types::Location> availableEdgesForView(QScreen *scr, Latte::View *forView) const;
|
virtual QList<Plasma::Types::Location> availableEdgesForView(QScreen *scr, Latte::View *forView) const;
|
||||||
|
@ -1188,6 +1188,14 @@ Data::AppletsTable Storage::plugins(const QString &layoutfile, const int contain
|
|||||||
|
|
||||||
//! Views Data
|
//! Views Data
|
||||||
|
|
||||||
|
bool Storage::containsView(const QString &filepath, const int &viewId)
|
||||||
|
{
|
||||||
|
KSharedConfigPtr lFile = KSharedConfig::openConfig(filepath);
|
||||||
|
KConfigGroup containmentGroups = KConfigGroup(lFile, "Containments");
|
||||||
|
KConfigGroup viewGroup = containmentGroups.group(QString::number(viewId));
|
||||||
|
return viewGroup.exists() && isLatteContainment(viewGroup);
|
||||||
|
}
|
||||||
|
|
||||||
Data::GenericTable<Data::Generic> Storage::subcontainments(const Layout::GenericLayout *layout, const Plasma::Containment *lattecontainment) const
|
Data::GenericTable<Data::Generic> Storage::subcontainments(const Layout::GenericLayout *layout, const Plasma::Containment *lattecontainment) const
|
||||||
{
|
{
|
||||||
Data::GenericTable<Data::Generic> subs;
|
Data::GenericTable<Data::Generic> subs;
|
||||||
@ -1333,6 +1341,24 @@ void Storage::updateView(const Layout::GenericLayout *layout, const Data::View &
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Storage::removeView(const QString &filepath, const Data::View &viewData)
|
||||||
|
{
|
||||||
|
if (!viewData.isValid()) {
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
containmentGroups.sync();
|
||||||
|
}
|
||||||
|
|
||||||
Data::ViewsTable Storage::views(const Layout::GenericLayout *layout)
|
Data::ViewsTable Storage::views(const Layout::GenericLayout *layout)
|
||||||
{
|
{
|
||||||
Data::ViewsTable vtable;
|
Data::ViewsTable vtable;
|
||||||
|
@ -74,6 +74,8 @@ public:
|
|||||||
bool isBroken(const Layout::GenericLayout *layout, QStringList &errors) const;
|
bool isBroken(const Layout::GenericLayout *layout, QStringList &errors) const;
|
||||||
bool isSubContainment(const Layout::GenericLayout *layout, const Plasma::Applet *applet) const;
|
bool isSubContainment(const Layout::GenericLayout *layout, const Plasma::Applet *applet) const;
|
||||||
|
|
||||||
|
bool containsView(const QString &filepath, const int &viewId);
|
||||||
|
|
||||||
int subContainmentId(const KConfigGroup &appletGroup) const;
|
int subContainmentId(const KConfigGroup &appletGroup) const;
|
||||||
|
|
||||||
Plasma::Containment *subContainmentOf(const Layout::GenericLayout *layout, const Plasma::Applet *applet);
|
Plasma::Containment *subContainmentOf(const Layout::GenericLayout *layout, const Plasma::Applet *applet);
|
||||||
@ -88,6 +90,7 @@ public:
|
|||||||
|
|
||||||
void updateView(const Layout::GenericLayout *layout, const Data::View &viewData);
|
void updateView(const Layout::GenericLayout *layout, const Data::View &viewData);
|
||||||
void updateView(KConfigGroup viewGroup, const Data::View &viewData);
|
void updateView(KConfigGroup viewGroup, const Data::View &viewData);
|
||||||
|
void removeView(const QString &filepath, const Data::View &viewData);
|
||||||
|
|
||||||
bool exportTemplate(const QString &originFile, const QString &destinationFile, const Data::AppletsTable &approvedApplets);
|
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);
|
bool exportTemplate(const Layout::GenericLayout *layout, Plasma::Containment *containment, const QString &destinationFile, const Data::AppletsTable &approvedApplets);
|
||||||
|
@ -220,6 +220,7 @@ void Views::save()
|
|||||||
Latte::CentralLayout *centralActive = m_handler->isSelectedLayoutOriginal() ? m_handler->corona()->layoutsManager()->synchronizer()->centralLayout(originallayout.name) : nullptr;
|
Latte::CentralLayout *centralActive = m_handler->isSelectedLayoutOriginal() ? m_handler->corona()->layoutsManager()->synchronizer()->centralLayout(originallayout.name) : nullptr;
|
||||||
Latte::CentralLayout *central = centralActive ? centralActive : new Latte::CentralLayout(this, currentlayout.id);
|
Latte::CentralLayout *central = centralActive ? centralActive : new Latte::CentralLayout(this, currentlayout.id);
|
||||||
|
|
||||||
|
//! update altered views
|
||||||
Latte::Data::ViewsTable alteredViews = m_model->alteredViews();
|
Latte::Data::ViewsTable alteredViews = m_model->alteredViews();
|
||||||
|
|
||||||
for (int i=0; i<alteredViews.rowCount(); ++i) {
|
for (int i=0; i<alteredViews.rowCount(); ++i) {
|
||||||
@ -229,7 +230,20 @@ void Views::save()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! remove deprecated views
|
||||||
|
Latte::Data::ViewsTable originalViews = m_model->originalViewsData();
|
||||||
Latte::Data::ViewsTable currentViews = m_model->currentViewsData();
|
Latte::Data::ViewsTable currentViews = m_model->currentViewsData();
|
||||||
|
Latte::Data::ViewsTable removedViews = originalViews.subtracted(currentViews);
|
||||||
|
|
||||||
|
for (int i=0; i<removedViews.rowCount(); ++i) {
|
||||||
|
central->removeView(removedViews[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (removedViews.rowCount() > 0) {
|
||||||
|
m_handler->corona()->layoutsManager()->synchronizer()->syncActiveLayoutsToOriginalFiles();
|
||||||
|
}
|
||||||
|
|
||||||
|
//! update model original data
|
||||||
m_model->setOriginalData(currentViews);
|
m_model->setOriginalData(currentViews);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user