mirror of
https://github.com/KDE/latte-dock.git
synced 2024-12-24 17:33:50 +03:00
FIX creating and copying docks
--there were cases that during creating or copying docks the applets ids were created inconsistent by creating applets with ids already reserved. This patch fixes this by using the applet ids found in the layout file and not the one loaded in memory.
This commit is contained in:
parent
abeadb5794
commit
a85555f52c
@ -853,10 +853,8 @@ QStringList DockCorona::appletsIds()
|
||||
QStringList ids;
|
||||
|
||||
foreach (auto containment, containments()) {
|
||||
foreach (auto applet, containment->applets()) {
|
||||
ids << QString::number(applet->id());
|
||||
}
|
||||
|
||||
auto applets = containment->config().group("Applets");
|
||||
ids << applets.groupList();
|
||||
}
|
||||
|
||||
return ids;
|
||||
|
@ -67,7 +67,7 @@ Layout::~Layout()
|
||||
}
|
||||
}
|
||||
|
||||
void Layout::syncToLayoutFile()
|
||||
void Layout::syncToLayoutFile(bool removeLayoutId)
|
||||
{
|
||||
if (!m_corona || !isWritable()) {
|
||||
return;
|
||||
@ -82,9 +82,17 @@ void Layout::syncToLayoutFile()
|
||||
qDebug() << " LAYOUT :: " << m_layoutName << " is syncing its original file.";
|
||||
|
||||
foreach (auto containment, m_containments) {
|
||||
containment->config().writeEntry("layoutId", "");
|
||||
if (removeLayoutId) {
|
||||
containment->config().writeEntry("layoutId", "");
|
||||
}
|
||||
|
||||
KConfigGroup newGroup = oldContainments.group(QString::number(containment->id()));
|
||||
containment->config().copyTo(&newGroup);
|
||||
|
||||
if (!removeLayoutId) {
|
||||
newGroup.writeEntry("layoutId", "");
|
||||
newGroup.sync();
|
||||
}
|
||||
}
|
||||
|
||||
oldContainments.sync();
|
||||
@ -1547,6 +1555,11 @@ void Layout::assignToLayout(DockView *dockView, QList<Plasma::Containment *> con
|
||||
emit m_corona->availableScreenRectChanged();
|
||||
emit m_corona->availableScreenRegionChanged();
|
||||
}
|
||||
|
||||
//! sync the original layout file for integrity
|
||||
if (m_corona && m_corona->layoutManager()->memoryUsage() == Dock::MultipleLayouts) {
|
||||
syncToLayoutFile(false);
|
||||
}
|
||||
}
|
||||
|
||||
QList<Plasma::Containment *> Layout::unassignFromLayout(DockView *dockView)
|
||||
@ -1579,6 +1592,11 @@ QList<Plasma::Containment *> Layout::unassignFromLayout(DockView *dockView)
|
||||
m_dockViews.remove(dockView->containment());
|
||||
}
|
||||
|
||||
//! sync the original layout file for integrity
|
||||
if (m_corona && m_corona->layoutManager()->memoryUsage() == Dock::MultipleLayouts) {
|
||||
syncToLayoutFile(false);
|
||||
}
|
||||
|
||||
return containments;
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,7 @@ public:
|
||||
static const QString MultipleLayoutsName;
|
||||
|
||||
void initToCorona(DockCorona *corona);
|
||||
void syncToLayoutFile();
|
||||
void syncToLayoutFile(bool removeLayoutId = false);
|
||||
void unloadContainments();
|
||||
void unloadDockViews();
|
||||
|
||||
|
@ -126,7 +126,7 @@ void LayoutManager::unload()
|
||||
//! Unload all Layouts
|
||||
foreach (auto layout, m_activeLayouts) {
|
||||
if (memoryUsage() == Dock::MultipleLayouts && layout->isOriginalLayout()) {
|
||||
layout->syncToLayoutFile();
|
||||
layout->syncToLayoutFile(true);
|
||||
}
|
||||
|
||||
layout->unloadContainments();
|
||||
@ -715,7 +715,7 @@ bool LayoutManager::switchToLayout(QString layoutName, int previousMemoryUsage)
|
||||
m_activeLayouts.removeFirst();
|
||||
|
||||
if (layout->isOriginalLayout() && previousMemoryUsage == Dock::MultipleLayouts) {
|
||||
layout->syncToLayoutFile();
|
||||
layout->syncToLayoutFile(true);
|
||||
}
|
||||
|
||||
layout->unloadContainments();
|
||||
@ -870,7 +870,7 @@ void LayoutManager::syncMultipleLayoutsToActivities(QString layoutForOrphans)
|
||||
m_activeLayouts.removeAt(posLayout);
|
||||
|
||||
if (layout->isOriginalLayout()) {
|
||||
layout->syncToLayoutFile();
|
||||
layout->syncToLayoutFile(true);
|
||||
}
|
||||
|
||||
layout->unloadContainments();
|
||||
|
@ -850,6 +850,21 @@ void SettingsDialog::loadSettings()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//! Check Multiple Layouts Integrity
|
||||
/*if (m_corona->layoutManager()->memoryUsage() == Dock::MultipleLayouts) {
|
||||
m_corona->layoutManager()->syncActiveLayoutsToOriginalFiles();
|
||||
|
||||
QString multipleLayoutPath = QDir::homePath() + "/.config/latte/" + Layout::MultipleLayoutsName + ".layout.latte";
|
||||
Layout multipleHiddenLayouts(this, multipleLayoutPath, "Multiple Layouts File");
|
||||
|
||||
if (multipleHiddenLayouts.layoutIsBroken()) {
|
||||
qDebug() << "Intergrity Error ::: Multiple Layouts Hidden file is broken!!!!";
|
||||
brokenLayouts.append(multipleHiddenLayouts.name());
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
recalculateAvailableActivities();
|
||||
|
||||
m_model->setHorizontalHeaderItem(IDCOLUMN, new QStandardItem(QString("#path")));
|
||||
|
Loading…
Reference in New Issue
Block a user