From bc9c45a42a4264462089ae9c5fee0af69d33374b Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Fri, 13 Jul 2018 20:38:07 +0300 Subject: [PATCH] fix to update contents correctly between sessions --when changing Single mode to Multiple mode the latest changes from user didnt get into because the kde cache from KFileConfigPtr hadnt been updated yet. This patch fixes this by using a temp file that contains the layout in question. --- app/layout.cpp | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/app/layout.cpp b/app/layout.cpp index 242231e5a..4fcdbaec7 100644 --- a/app/layout.cpp +++ b/app/layout.cpp @@ -1128,16 +1128,29 @@ void Layout::importToCorona() //! Settting mutable for create a containment m_corona->setImmutability(Plasma::Types::Mutable); - QString temp1File = QDir::homePath() + "/.config/lattedock.copy1.bak"; + QString temp1FilePath = QDir::homePath() + "/.config/lattedock.copy1.bak"; + //! we need to copy first the layout file because the kde cache + //! may not have yet been updated (KSharedConfigPtr) + //! this way we make sure at the latest changes stored in the layout file + //! will be also available when changing to Myltiple Layouts + QString tempLayoutFilePath = QDir::homePath() + "/.config/lattedock.layout.bak"; //! WE NEED A WAY TO COPY A CONTAINMENT!!!! - QFile copyFile(temp1File); + QFile tempLayoutFile(tempLayoutFilePath); + QFile copyFile(temp1FilePath); + QFile layoutOriginalFile(m_layoutFile); + + if (tempLayoutFile.exists()) { + tempLayoutFile.remove(); + } if (copyFile.exists()) copyFile.remove(); - KSharedConfigPtr filePtr = KSharedConfig::openConfig(m_layoutFile); - KSharedConfigPtr newFile = KSharedConfig::openConfig(temp1File); + layoutOriginalFile.copy(tempLayoutFilePath); + + KSharedConfigPtr filePtr = KSharedConfig::openConfig(tempLayoutFilePath); + KSharedConfigPtr newFile = KSharedConfig::openConfig(temp1FilePath); KConfigGroup copyGroup = KConfigGroup(newFile, "Containments"); KConfigGroup current_containments = KConfigGroup(filePtr, "Containments"); @@ -1146,7 +1159,7 @@ void Layout::importToCorona() copyGroup.sync(); //! update ids to unique ones - QString temp2File = newUniqueIdsLayoutFromFile(temp1File); + QString temp2File = newUniqueIdsLayoutFromFile(temp1FilePath); //! Finally import the configuration