mirror of
https://github.com/KDE/latte-dock.git
synced 2025-03-10 20:58:18 +03:00
Introduce storage TMP directory for layouts
--all storage functions are now taking place into the same Latte TMP directory that is introduced for layouts. So no more .bak files are needed from ~/.config folder.
This commit is contained in:
parent
ca5cc6015d
commit
383d762f11
@ -942,6 +942,7 @@ bool GenericLayout::initToCorona(Latte::Corona *corona)
|
||||
}
|
||||
|
||||
m_corona = corona;
|
||||
m_storage->setStorageTmpDir(m_corona->layoutsManager()->importer()->storageTmpDir());
|
||||
|
||||
for (const auto containment : m_corona->containments()) {
|
||||
if (m_corona->layoutsManager()->memoryUsage() == MemoryUsage::SingleLayout) {
|
||||
|
@ -101,6 +101,11 @@ void Storage::unlock()
|
||||
}
|
||||
}
|
||||
|
||||
void Storage::setStorageTmpDir(const QString &tmpDir)
|
||||
{
|
||||
m_storageTmpDir = tmpDir;
|
||||
}
|
||||
|
||||
void Storage::importToCorona()
|
||||
{
|
||||
if (!m_layout->corona()) {
|
||||
@ -110,12 +115,12 @@ void Storage::importToCorona()
|
||||
//! Setting mutable for create a containment
|
||||
m_layout->corona()->setImmutability(Plasma::Types::Mutable);
|
||||
|
||||
QString temp1FilePath = QDir::homePath() + "/.config/lattedock.copy1.bak";
|
||||
QString temp1FilePath = m_storageTmpDir + "/" + m_layout->name() + ".multiple.views";
|
||||
//! 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 Multiple Layouts
|
||||
QString tempLayoutFilePath = QDir::homePath() + "/.config/lattedock.layout.bak";
|
||||
QString tempLayoutFilePath = m_storageTmpDir + "/" + m_layout->name() + ".multiple.tmplayout";
|
||||
|
||||
//! WE NEED A WAY TO COPY A CONTAINMENT!!!!
|
||||
QFile tempLayoutFile(tempLayoutFilePath);
|
||||
@ -187,7 +192,7 @@ void Storage::copyView(Plasma::Containment *containment)
|
||||
//! Setting mutable for create a containment
|
||||
m_layout->corona()->setImmutability(Plasma::Types::Mutable);
|
||||
|
||||
QString temp1File = QDir::homePath() + "/.config/lattedock.copy1.bak";
|
||||
QString temp1File = m_storageTmpDir + "/" + m_layout->name() + ".copy.view";
|
||||
|
||||
//! WE NEED A WAY TO COPY A CONTAINMENT!!!!
|
||||
QFile copyFile(temp1File);
|
||||
@ -462,7 +467,7 @@ QString Storage::newUniqueIdsLayoutFromFile(QString file)
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString tempFile = QDir::homePath() + "/.config/lattedock.copy2.bak";
|
||||
QString tempFile = m_storageTmpDir + "/" + m_layout->name() + ".views.newids";
|
||||
|
||||
QFile copyFile(tempFile);
|
||||
|
||||
|
@ -52,6 +52,8 @@ public:
|
||||
void copyView(Plasma::Containment *containment);
|
||||
void syncToLayoutFile(bool removeLayoutId);
|
||||
|
||||
void setStorageTmpDir(const QString &tmpDir);
|
||||
|
||||
/// STATIC
|
||||
//! Check if an applet config group is valid or belongs to removed applet
|
||||
static bool appletGroupIsValid(KConfigGroup appletGroup);
|
||||
@ -76,6 +78,8 @@ private:
|
||||
|
||||
private:
|
||||
GenericLayout *m_layout;
|
||||
|
||||
QString m_storageTmpDir;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -30,7 +30,6 @@
|
||||
|
||||
// Qt
|
||||
#include <QFile>
|
||||
#include <QTemporaryDir>
|
||||
|
||||
// KDE
|
||||
#include <KArchive/KTar>
|
||||
@ -54,6 +53,8 @@ Importer::Importer(QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
m_manager = qobject_cast<Layouts::Manager *>(parent);
|
||||
|
||||
qDebug() << " IMPORTER, STORAGE TEMP DIR ::: " << m_storageTmpDir.path();
|
||||
}
|
||||
|
||||
Importer::~Importer()
|
||||
@ -222,7 +223,6 @@ QStringList Importer::standardPathsFor(QString subPath, bool localfirst)
|
||||
return paths;
|
||||
}
|
||||
|
||||
|
||||
QString Importer::standardPath(QString subPath, bool localfirst)
|
||||
{
|
||||
QStringList paths = standardPaths(localfirst);
|
||||
@ -242,6 +242,11 @@ QString Importer::standardPath(QString subPath, bool localfirst)
|
||||
return "";
|
||||
}
|
||||
|
||||
QString Importer::storageTmpDir() const
|
||||
{
|
||||
return m_storageTmpDir.path();
|
||||
}
|
||||
|
||||
QString Importer::layoutCanBeImported(QString oldAppletsPath, QString newName, QString exportDirectory)
|
||||
{
|
||||
QFile oldAppletsrc(oldAppletsPath);
|
||||
|
@ -23,6 +23,7 @@
|
||||
|
||||
// Qt
|
||||
#include <QObject>
|
||||
#include <QTemporaryDir>
|
||||
|
||||
namespace Latte {
|
||||
namespace Layouts {
|
||||
@ -70,6 +71,8 @@ public:
|
||||
|
||||
bool exportFullConfiguration(QString file);
|
||||
|
||||
QString storageTmpDir() const;
|
||||
|
||||
static Importer::LatteFileVersion fileVersion(QString file);
|
||||
|
||||
static bool importHelper(QString fileName);
|
||||
@ -80,7 +83,7 @@ public:
|
||||
//! returns all application data standard paths
|
||||
//! local paths have higher priority by default
|
||||
static QStringList standardPaths(bool localfirst = true);
|
||||
static QStringList standardPathsFor(QString subPath, bool localfirst = true);
|
||||
static QStringList standardPathsFor(QString subPath, bool localfirst = true);
|
||||
|
||||
//! check if this layout exists already in the latte directory
|
||||
static bool layoutExists(QString layoutName);
|
||||
@ -105,6 +108,8 @@ private:
|
||||
//! the new layout path and an empty string if it cant
|
||||
QString layoutCanBeImported(QString oldAppletsPath, QString newName, QString exportDirectory = QString());
|
||||
|
||||
QTemporaryDir m_storageTmpDir;
|
||||
|
||||
Layouts::Manager *m_manager;
|
||||
};
|
||||
|
||||
|
@ -128,21 +128,6 @@ void Manager::load()
|
||||
void Manager::unload()
|
||||
{
|
||||
m_synchronizer->unloadLayouts();
|
||||
|
||||
//! Remove no-needed temp files
|
||||
QString temp1File = QDir::homePath() + "/.config/lattedock.copy1.bak";
|
||||
QString temp2File = QDir::homePath() + "/.config/lattedock.copy2.bak";
|
||||
|
||||
QFile file1(temp1File);
|
||||
QFile file2(temp2File);
|
||||
|
||||
if (file1.exists()) {
|
||||
file1.remove();
|
||||
}
|
||||
|
||||
if (file2.exists()) {
|
||||
file2.remove();
|
||||
}
|
||||
}
|
||||
|
||||
Latte::Corona *Manager::corona()
|
||||
|
Loading…
x
Reference in New Issue
Block a user