From fee7761d853e2e5d167ed78d809aefd706022f4a Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Tue, 4 Jul 2017 21:57:10 +0300 Subject: [PATCH] update correctly the importing procedure --there were some issues with the use of LayoutSettings in places that we shouldnt use it. LayoutSettings now is used to load only layouts with version>=2 --- app/importer.cpp | 10 ++++++---- app/layoutsettings.cpp | 9 +++++---- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/app/importer.cpp b/app/importer.cpp index 6548e02dc..9813e58e3 100644 --- a/app/importer.cpp +++ b/app/importer.cpp @@ -194,10 +194,12 @@ QString Importer::layoutCanBeImported(QString oldAppletsPath, QString newName) return QString(); } - LayoutSettings oldLSettings(this, oldAppletsPath); + KSharedConfigPtr lConfig = KSharedConfig::openConfig(oldAppletsPath); + KConfigGroup m_layoutGroup = KConfigGroup(lConfig, "LayoutSettings"); + int layoutVersion = m_layoutGroup.readEntry("version", 1); //! old file layout appears to not be old as its version is >=2 - if (oldLSettings.version() >= 2) { + if (layoutVersion >= 2) { return QString(); } @@ -219,8 +221,8 @@ QString Importer::layoutCanBeImported(QString oldAppletsPath, QString newName) } } - QFile newLayoutFile(layoutDir.absolutePath() + "/" + newName + ".layout.latte"); - QString newLayoutPath = newLayoutFile.fileName(); + QString newLayoutPath = layoutDir.absolutePath() + "/" + newName + ".layout.latte"; + QFile newLayoutFile(newLayoutPath); QStringList filter; filter.append(QString(newName + "*.layout.latte")); diff --git a/app/layoutsettings.cpp b/app/layoutsettings.cpp index 202a0311b..bfd9ffbfe 100644 --- a/app/layoutsettings.cpp +++ b/app/layoutsettings.cpp @@ -28,15 +28,16 @@ namespace Latte { LayoutSettings::LayoutSettings(QObject *parent, QString layoutFile, QString layoutName) : QObject(parent) { - qDebug() << "Layout file to create object: " << layoutFile; + qDebug() << "Layout file to create object: " << layoutFile << " with name: " << layoutName; if (QFile(layoutFile).exists()) { if (layoutName.isEmpty()) { int lastSlash = layoutFile.lastIndexOf("/"); - layoutName = layoutFile.remove(0, lastSlash + 1); + QString tempLayoutFile = layoutFile; + layoutName = tempLayoutFile.remove(0, lastSlash + 1); - int ext = layoutName.lastIndexOf(".latterc"); - layoutName = layoutName.remove(ext, 8); + int ext = layoutName.lastIndexOf(".layout.latte"); + layoutName = layoutName.remove(ext, 13); } KSharedConfigPtr lConfig = KSharedConfig::openConfig(layoutFile);